diff mbox series

[20/24] lustre: flr: allow layout version update from client/MDS

Message ID 1663478534-19917-21-git-send-email-jsimmons@infradead.org (mailing list archive)
State New, archived
Headers show
Series lustre: update to 2.15.52 | expand

Commit Message

James Simmons Sept. 18, 2022, 5:22 a.m. UTC
From: Bobi Jam <bobijam@whamcloud.com>

Client write request always carries its layout version so
that OFD can reject the request if the carried layout version
is a stale one.

This patch makes OFD allow layout version change request from
client as well as MDS. And during resync write, all OST objects
will get layout version updated.

WC-bug-id: https://jira.whamcloud.com/browse/LU-14642
Lustre-commit: fa6574150b6f745a66 ("LU-14642 flr: allow layout version update from client/MDS")
Signed-off-by: Bobi Jam <bobijam@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/45443
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 fs/lustre/include/obd_support.h         |  2 +-
 fs/lustre/llite/file.c                  | 30 +++++++++++-------------------
 include/uapi/linux/lustre/lustre_user.h | 15 ++++++++++-----
 3 files changed, 22 insertions(+), 25 deletions(-)
diff mbox series

Patch

diff --git a/fs/lustre/include/obd_support.h b/fs/lustre/include/obd_support.h
index 0909351..c98c8a4 100644
--- a/fs/lustre/include/obd_support.h
+++ b/fs/lustre/include/obd_support.h
@@ -517,7 +517,7 @@ 
 
 /* FLR */
 #define OBD_FAIL_FLR_LV_DELAY				0x1A01
-#define OBD_FAIL_FLR_LV_INC				0x1A02
+#define OBD_FAIL_FLR_LV_INC				0x1A02 /* unused since 2.15 */
 #define OBD_FAIL_FLR_RANDOM_PICK_MIRROR			0x1A03
 
 /* LNet is allocated failure locations 0xe000 to 0xffff */
diff --git a/fs/lustre/llite/file.c b/fs/lustre/llite/file.c
index 5394cce..e75f482 100644
--- a/fs/lustre/llite/file.c
+++ b/fs/lustre/llite/file.c
@@ -3553,6 +3553,7 @@  static long ll_file_unlock_lease(struct file *file, struct ll_ioc_lease *ioc,
 	bool lease_broken = false;
 	fmode_t fmode = 0;
 	enum mds_op_bias bias = 0;
+	int fdv;
 	struct file *layout_file = NULL;
 	void *data = NULL;
 	size_t data_size = 0;
@@ -3592,21 +3593,19 @@  static long ll_file_unlock_lease(struct file *file, struct ll_ioc_lease *ioc,
 
 		bias = MDS_CLOSE_RESYNC_DONE;
 		break;
-	case LL_LEASE_LAYOUT_MERGE: {
-		int fd;
-
+	case LL_LEASE_LAYOUT_MERGE:
 		if (ioc->lil_count != 1) {
 			rc = -EINVAL;
 			goto out_lease_close;
 		}
 
 		arg += sizeof(*ioc);
-		if (copy_from_user(&fd, (void __user *)arg, sizeof(u32))) {
+		if (copy_from_user(&fdv, (void __user *)arg, sizeof(u32))) {
 			rc = -EFAULT;
 			goto out_lease_close;
 		}
 
-		layout_file = fget(fd);
+		layout_file = fget(fdv);
 		if (!layout_file) {
 			rc = -EBADF;
 			goto out_lease_close;
@@ -3621,9 +3620,7 @@  static long ll_file_unlock_lease(struct file *file, struct ll_ioc_lease *ioc,
 		data = file_inode(layout_file);
 		bias = MDS_CLOSE_LAYOUT_MERGE;
 		break;
-	}
 	case LL_LEASE_LAYOUT_SPLIT: {
-		int fdv;
 		int mirror_id;
 
 		if (ioc->lil_count != 2) {
@@ -3700,29 +3697,24 @@  static long ll_file_unlock_lease(struct file *file, struct ll_ioc_lease *ioc,
 
 	if (lease_broken)
 		fmode = 0;
-
 out:
-	switch (ioc->lil_flags) {
-	case LL_LEASE_RESYNC_DONE:
+	if (ioc->lil_flags == LL_LEASE_RESYNC_DONE && data)
 		kfree(data);
-		break;
-	case LL_LEASE_LAYOUT_MERGE:
-	case LL_LEASE_LAYOUT_SPLIT:
-		if (layout_file)
-			fput(layout_file);
 
-		ll_layout_refresh(inode, &fd->fd_layout_version);
-		break;
-	case LL_LEASE_PCC_ATTACH:
+	if (layout_file)
+		fput(layout_file);
+
+	if (ioc->lil_flags == LL_LEASE_PCC_ATTACH) {
 		if (!rc)
 			rc = rc2;
 		rc = pcc_readwrite_attach_fini(file, inode,
 					       param.pa_layout_gen,
 					       lease_broken, rc,
 					       attached);
-		break;
 	}
 
+	ll_layout_refresh(inode, &fd->fd_layout_version);
+
 	if (!rc)
 		rc = ll_lease_type_from_fmode(fmode);
 	return rc;
diff --git a/include/uapi/linux/lustre/lustre_user.h b/include/uapi/linux/lustre/lustre_user.h
index 8cfee7f..6577202 100644
--- a/include/uapi/linux/lustre/lustre_user.h
+++ b/include/uapi/linux/lustre/lustre_user.h
@@ -578,11 +578,6 @@  enum lov_comp_md_entry_flags {
 /* The mirror flags sent by client */
 #define LCME_MIRROR_FLAGS	(LCME_FL_NOSYNC)
 
-/* the highest bit in obdo::o_layout_version is used to mark if the file is
- * being resynced.
- */
-#define LU_LAYOUT_RESYNC	LCME_FL_NEG
-
 /* lcme_id can be specified as certain flags, and the first
  * bit of lcme_id is used to indicate that the ID is representing
  * certain LCME_FL_* but not a real ID. Which implies we can have
@@ -595,6 +590,16 @@  enum lcme_id {
 	LCME_ID_NOT_ID	= LCME_FL_NEG
 };
 
+/* layout version equals to lcme_id, except some bits have special meanings */
+enum layout_version_flags {
+	/* layout version reaches the high water mark to be increased to
+	 * circularly reuse the smallest value
+	 */
+	LU_LAYOUT_HIGEN		= 0x40000000,
+	/* the highest bit is used to mark if the file is being resynced */
+	LU_LAYOUT_RESYNC	= 0x80000000,
+};
+
 struct lov_comp_md_entry_v1 {
 	__u32			lcme_id;	/* unique id of component */
 	__u32			lcme_flags;	/* LCME_FL_XXX */