From b78e84580a2d46ce674d48cb01774d95a5cc5464 Mon Sep 17 00:00:00 2001 From: Artem Blagodarenko Date: Tue, 14 May 2024 08:25:19 -0400 Subject: [PATCH] LU-10026 csdc: reserve OBD_BRW_SPECULATIVE_COMPR flag DIO does not set KMS like buffered IO, and the KMS it sets is not safe. So this requires special handling for last chunk compression. Since we can't know when we're doing the last chunk with DIO, the solution is as follows: If a DIO write is chunk aligned at the start but not a full chunk, we compress it but mark it 'speculative'. Then the server double checks that the write is beyond current file size, and if it's not, it will ask the client to do a resend, and the client will send the data back uncompressed. This makes it reasonable to fully enable DIO to compressed files - previously we converted unaligned DIO to buffered IO. This patch reserves OBD_BRW_SPECULATIVE_COMPR flag. Signed-off-by: Patrick Farrell Signed-off-by: Artem Blagodarenko Change-Id: I679bc103bd2862115d94286e7c2ed43e1580b29e Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/55104 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Reviewed-by: Patrick Farrell --- lustre/include/uapi/linux/lustre/lustre_idl.h | 2 ++ lustre/ptlrpc/wiretest.c | 2 ++ lustre/utils/wirecheck.c | 1 + lustre/utils/wiretest.c | 2 ++ 4 files changed, 7 insertions(+) diff --git a/lustre/include/uapi/linux/lustre/lustre_idl.h b/lustre/include/uapi/linux/lustre/lustre_idl.h index 2a26077..f051c19 100644 --- a/lustre/include/uapi/linux/lustre/lustre_idl.h +++ b/lustre/include/uapi/linux/lustre/lustre_idl.h @@ -1450,6 +1450,8 @@ struct hsm_state_set { #define OBD_BRW_RDMA_ONLY 0x20000 /* RPC contains RDMA-only pages*/ #define OBD_BRW_SYS_RESOURCE 0x40000 /* page has CAP_SYS_RESOURCE */ #define OBD_BRW_COMPRESSED 0x80000 /* data compressed on client */ +/* client compressed data optimistically but server must check file size */ +#define OBD_BRW_SPECULATIVE_COMPR 0x100000 #define OBD_BRW_OVER_ALLQUOTA (OBD_BRW_OVER_USRQUOTA | \ OBD_BRW_OVER_GRPQUOTA | \ diff --git a/lustre/ptlrpc/wiretest.c b/lustre/ptlrpc/wiretest.c index 7ac85f3..91a3861 100644 --- a/lustre/ptlrpc/wiretest.c +++ b/lustre/ptlrpc/wiretest.c @@ -2508,6 +2508,8 @@ void lustre_assert_wire_constants(void) OBD_BRW_SYS_RESOURCE); LASSERTF(OBD_BRW_COMPRESSED == 0x80000, "found 0x%.8x\n", OBD_BRW_COMPRESSED); + LASSERTF(OBD_BRW_SPECULATIVE_COMPR == 0x100000, "found 0x%.8x\n", + OBD_BRW_SPECULATIVE_COMPR); /* Checks for struct ost_body */ LASSERTF((int)sizeof(struct ost_body) == 208, "found %lld\n", diff --git a/lustre/utils/wirecheck.c b/lustre/utils/wirecheck.c index 4c970b8..1529b80 100644 --- a/lustre/utils/wirecheck.c +++ b/lustre/utils/wirecheck.c @@ -1188,6 +1188,7 @@ check_niobuf_remote(void) CHECK_DEFINE_X(OBD_BRW_RDMA_ONLY); CHECK_DEFINE_X(OBD_BRW_SYS_RESOURCE); CHECK_DEFINE_X(OBD_BRW_COMPRESSED); + CHECK_DEFINE_X(OBD_BRW_SPECULATIVE_COMPR); } static void diff --git a/lustre/utils/wiretest.c b/lustre/utils/wiretest.c index 5a8bd5f..e4e5427 100644 --- a/lustre/utils/wiretest.c +++ b/lustre/utils/wiretest.c @@ -2533,6 +2533,8 @@ void lustre_assert_wire_constants(void) OBD_BRW_SYS_RESOURCE); LASSERTF(OBD_BRW_COMPRESSED == 0x80000, "found 0x%.8x\n", OBD_BRW_COMPRESSED); + LASSERTF(OBD_BRW_SPECULATIVE_COMPR == 0x100000, "found 0x%.8x\n", + OBD_BRW_SPECULATIVE_COMPR); /* Checks for struct ost_body */ LASSERTF((int)sizeof(struct ost_body) == 208, "found %lld\n", -- 1.8.3.1