[lustre-devel] [PATCH 26/32] lustre: mdc: pack default LMV in open reply

James Simmons jsimmons at infradead.org
Wed Aug 3 18:38:11 PDT 2022


From: Lai Siyao <lai.siyao at whamcloud.com>

Add flag MDS_OPEN_DEFAULT_LMV to indicate that default LMV should be
packed in open reply, otherwise if open fetches LOOKUP lock, client
won't know directory has default LMV, and in subdir creation default
LMV won't take effect.

WC-bug-id: https://jira.whamcloud.com/browse/LU-15850
Lustre-commit: f6e4272fb0be5b798 ("LU-15850 mdt: pack default LMV in open reply")
Signed-off-by: Lai Siyao <lai.siyao at whamcloud.com>
Reviewed-on: https://review.whamcloud.com/47576
Reviewed-by: Andreas Dilger <adilger at whamcloud.com>
Reviewed-by: Hongchao Zhang <hongchao at whamcloud.com>
Reviewed-by: Oleg Drokin <green at whamcloud.com>
Signed-off-by: James Simmons <jsimmons at infradead.org>
---
 fs/lustre/mdc/mdc_lib.c                 | 1 +
 fs/lustre/mdc/mdc_locks.c               | 2 ++
 fs/lustre/ptlrpc/layout.c               | 1 +
 fs/lustre/ptlrpc/wiretest.c             | 2 ++
 include/uapi/linux/lustre/lustre_user.h | 5 ++++-
 5 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/fs/lustre/mdc/mdc_lib.c b/fs/lustre/mdc/mdc_lib.c
index 51080a1..077639d 100644
--- a/fs/lustre/mdc/mdc_lib.c
+++ b/fs/lustre/mdc/mdc_lib.c
@@ -329,6 +329,7 @@ void mdc_open_pack(struct req_capsule *pill, struct md_op_data *op_data,
 			rec->cr_archive_id = op_data->op_archive_id;
 		}
 	}
+	cr_flags |= MDS_OPEN_DEFAULT_LMV;
 	set_mrc_cr_flags(rec, cr_flags);
 }
 
diff --git a/fs/lustre/mdc/mdc_locks.c b/fs/lustre/mdc/mdc_locks.c
index b86d1b9..2a9b9a8 100644
--- a/fs/lustre/mdc/mdc_locks.c
+++ b/fs/lustre/mdc/mdc_locks.c
@@ -393,6 +393,8 @@ static int mdc_save_lovea(struct ptlrpc_request *req, void *data, u32 size)
 	 */
 	req_capsule_set_size(&req->rq_pill, &RMF_NIOBUF_INLINE, RCL_SERVER,
 			     sizeof(struct niobuf_remote));
+	req_capsule_set_size(&req->rq_pill, &RMF_DEFAULT_MDT_MD, RCL_SERVER,
+			     sizeof(struct lmv_user_md));
 	ptlrpc_request_set_replen(req);
 
 	/* Get real repbuf allocated size as rounded up power of 2 */
diff --git a/fs/lustre/ptlrpc/layout.c b/fs/lustre/ptlrpc/layout.c
index 8725edd..82ec899 100644
--- a/fs/lustre/ptlrpc/layout.c
+++ b/fs/lustre/ptlrpc/layout.c
@@ -447,6 +447,7 @@
 	&RMF_NIOBUF_INLINE,
 	&RMF_FILE_SECCTX,
 	&RMF_FILE_ENCCTX,
+	&RMF_DEFAULT_MDT_MD,
 };
 
 static const struct req_msg_field *ldlm_intent_getattr_client[] = {
diff --git a/fs/lustre/ptlrpc/wiretest.c b/fs/lustre/ptlrpc/wiretest.c
index 81e0485..60a7fd0 100644
--- a/fs/lustre/ptlrpc/wiretest.c
+++ b/fs/lustre/ptlrpc/wiretest.c
@@ -2326,6 +2326,8 @@ void lustre_assert_wire_constants(void)
 		 (long long)MDS_OPEN_RESYNC);
 	LASSERTF(MDS_OPEN_PCC == 00000000010000000000000ULL, "found 0%.22lloULL\n",
 		 (long long)MDS_OPEN_PCC);
+	LASSERTF(MDS_OPEN_DEFAULT_LMV == 00000000040000000000000ULL, "found 0%.22lloULL\n",
+		 (long long)MDS_OPEN_DEFAULT_LMV);
 	LASSERTF(LUSTRE_SYNC_FL == 0x00000008, "found 0x%.8x\n",
 		 LUSTRE_SYNC_FL);
 	LASSERTF(LUSTRE_IMMUTABLE_FL == 0x00000010, "found 0x%.8x\n",
diff --git a/include/uapi/linux/lustre/lustre_user.h b/include/uapi/linux/lustre/lustre_user.h
index c57929b..7b79604 100644
--- a/include/uapi/linux/lustre/lustre_user.h
+++ b/include/uapi/linux/lustre/lustre_user.h
@@ -1246,12 +1246,15 @@ enum la_valid {
 					      * for newly created file
 					      */
 #define MDS_OP_WITH_FID	  020000000000000ULL /* operation carried out by FID */
+#define MDS_OPEN_DEFAULT_LMV  040000000000000ULL /* open fetches default LMV */
 
+/* lustre internal open flags, which should not be set from user space */
 #define MDS_OPEN_FL_INTERNAL (MDS_OPEN_HAS_EA | MDS_OPEN_HAS_OBJS |	\
 			      MDS_OPEN_OWNEROVERRIDE | MDS_OPEN_LOCK |	\
 			      MDS_OPEN_BY_FID | MDS_OPEN_LEASE |	\
 			      MDS_OPEN_RELEASE | MDS_OPEN_RESYNC |	\
-			      MDS_OPEN_PCC | MDS_OP_WITH_FID)
+			      MDS_OPEN_PCC | MDS_OP_WITH_FID |		\
+			      MDS_OPEN_DEFAULT_LMV)
 
 /********* Changelogs **********/
 /** Changelog record types */
-- 
1.8.3.1



More information about the lustre-devel mailing list