lustre-devel-lustre.org archive mirror
 help / color / mirror / Atom feed
From: James Simmons <jsimmons@infradead.org>
To: Andreas Dilger <adilger@whamcloud.com>,
	Oleg Drokin <green@whamcloud.com>, NeilBrown <neilb@suse.de>
Cc: Lustre Development List <lustre-devel@lists.lustre.org>
Subject: [lustre-devel] [PATCH 20/24] lustre: flr: allow layout version update from client/MDS
Date: Sun, 18 Sep 2022 01:22:10 -0400	[thread overview]
Message-ID: <1663478534-19917-21-git-send-email-jsimmons@infradead.org> (raw)
In-Reply-To: <1663478534-19917-1-git-send-email-jsimmons@infradead.org>

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 --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 */
-- 
1.8.3.1

_______________________________________________
lustre-devel mailing list
lustre-devel@lists.lustre.org
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org

  parent reply	other threads:[~2022-09-18  5:23 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-18  5:21 [lustre-devel] [PATCH 00/24] lustre: update to 2.15.52 James Simmons
2022-09-18  5:21 ` [lustre-devel] [PATCH 01/24] lustre: dne: add crush2 hash type James Simmons
2022-09-18  5:21 ` [lustre-devel] [PATCH 02/24] lustre: ptlrpc: change rq_self to struct lnet_nid James Simmons
2022-09-18  5:21 ` [lustre-devel] [PATCH 03/24] lustre: ptlrpc: pass net num to ptlrpc_uuid_to_connection James Simmons
2022-09-18  5:21 ` [lustre-devel] [PATCH 04/24] lustre: ptlrpc: change rq_peer to struct lnet_nid James Simmons
2022-09-18  5:21 ` [lustre-devel] [PATCH 05/24] lustre: ptlrpc: change rq_source " James Simmons
2022-09-18  5:21 ` [lustre-devel] [PATCH 06/24] lustre: ptlrpc: change bd_sender in ptlrpc_bulk_frag_ops James Simmons
2022-09-18  5:21 ` [lustre-devel] [PATCH 07/24] lustre: ptlrpc: pass lnet_nid for self to ptl_send_buf() James Simmons
2022-09-18  5:21 ` [lustre-devel] [PATCH 08/24] lustre: llite: don't use a kms if it invalid James Simmons
2022-09-18  5:21 ` [lustre-devel] [PATCH 09/24] lustre: mdc: check/grab import before access James Simmons
2022-09-18  5:22 ` [lustre-devel] [PATCH 10/24] lustre: llog: handle -EBADR for catalog processing James Simmons
2022-09-18  5:22 ` [lustre-devel] [PATCH 11/24] lnet: Always use ping reply to set route lr_alive James Simmons
2022-09-18  5:22 ` [lustre-devel] [PATCH 12/24] lustre: clio: remove vvp_page_print() James Simmons
2022-09-18  5:22 ` [lustre-devel] [PATCH 13/24] lustre: clio: remove cpo_prep and cpo_make_ready James Simmons
2022-09-18  5:22 ` [lustre-devel] [PATCH 14/24] lustre: clio: remove struct vvp_page James Simmons
2022-09-18  5:22 ` [lustre-devel] [PATCH 15/24] lustre: clio: remove unused convenience functions James Simmons
2022-09-18  5:22 ` [lustre-devel] [PATCH 16/24] lustre: clio: remove cpl_obj James Simmons
2022-09-18  5:22 ` [lustre-devel] [PATCH 17/24] lustre: osc: remove oap_cli James Simmons
2022-09-18  5:22 ` [lustre-devel] [PATCH 18/24] lustre: osc: Remove submit time James Simmons
2022-09-18  5:22 ` [lustre-devel] [PATCH 19/24] lnet: selftest: revert "LU-16011 lnet: use preallocate bulk for server" James Simmons
2022-09-18  5:22 ` James Simmons [this message]
2022-09-18  5:22 ` [lustre-devel] [PATCH 21/24] lustre: ptlrpc: adds configurable ping interval James Simmons
2022-09-18  5:22 ` [lustre-devel] [PATCH 22/24] lnet: allow direct messages regardless of peer NI status James Simmons
2022-09-18  5:22 ` [lustre-devel] [PATCH 23/24] lnet: Honor peer timeout of zero James Simmons
2022-09-18  5:22 ` [lustre-devel] [PATCH 24/24] lustre: update version to 2.15.52 James Simmons

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1663478534-19917-21-git-send-email-jsimmons@infradead.org \
    --to=jsimmons@infradead.org \
    --cc=adilger@whamcloud.com \
    --cc=green@whamcloud.com \
    --cc=lustre-devel@lists.lustre.org \
    --cc=neilb@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).