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: Lai Siyao <lai.siyao@whamcloud.com>,
	Lustre Development List <lustre-devel@lists.lustre.org>
Subject: [lustre-devel] [PATCH 24/40] lustre: llite: match lock in corresponding namespace
Date: Sun,  9 Apr 2023 08:13:04 -0400	[thread overview]
Message-ID: <1681042400-15491-25-git-send-email-jsimmons@infradead.org> (raw)
In-Reply-To: <1681042400-15491-1-git-send-email-jsimmons@infradead.org>

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

For remote object, LOOKUP lock is on parent MDT, so lmv_lock_match()
iterates all MDT namespaces to match locks. This is needed in places
where only LOOKUP ibit is matched, and the lock namespace is unknown.

WC-bug-id: https://jira.whamcloud.com/browse/LU-15971
Lustre-commit: 64264dc424ca13d90 ("LU-15971 llite: match lock in corresponding namespace")
Signed-off-by: Lai Siyao <lai.siyao@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/47843
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Qian Yingjin <qian@ddn.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 fs/lustre/llite/dir.c            |  3 ++-
 fs/lustre/llite/file.c           |  6 ++---
 fs/lustre/llite/llite_internal.h |  4 ++--
 fs/lustre/llite/namei.c          |  7 +++---
 fs/lustre/lmv/lmv_obd.c          | 52 ++++++++++++++++++++++++----------------
 5 files changed, 42 insertions(+), 30 deletions(-)

diff --git a/fs/lustre/llite/dir.c b/fs/lustre/llite/dir.c
index 1298bd6..0422701 100644
--- a/fs/lustre/llite/dir.c
+++ b/fs/lustre/llite/dir.c
@@ -347,7 +347,8 @@ static int ll_readdir(struct file *filp, struct dir_context *ctx)
 			struct inode *parent;
 
 			parent = file_dentry(filp)->d_parent->d_inode;
-			if (ll_have_md_lock(parent, &ibits, LCK_MINMODE))
+			if (ll_have_md_lock(ll_i2mdexp(parent), parent, &ibits,
+					    LCK_MINMODE))
 				pfid = *ll_inode2fid(parent);
 		}
 
diff --git a/fs/lustre/llite/file.c b/fs/lustre/llite/file.c
index fb8ede2..746c18f 100644
--- a/fs/lustre/llite/file.c
+++ b/fs/lustre/llite/file.c
@@ -5198,7 +5198,7 @@ int ll_migrate(struct inode *parent, struct file *file, struct lmv_user_md *lum,
  *
  * Returns:		boolean, true iff all bits are found
  */
-int ll_have_md_lock(struct inode *inode, u64 *bits,
+int ll_have_md_lock(struct obd_export *exp, struct inode *inode, u64 *bits,
 		    enum ldlm_mode l_req_mode)
 {
 	struct lustre_handle lockh;
@@ -5222,8 +5222,8 @@ int ll_have_md_lock(struct inode *inode, u64 *bits,
 		if (policy.l_inodebits.bits == 0)
 			continue;
 
-		if (md_lock_match(ll_i2mdexp(inode), flags, fid, LDLM_IBITS,
-				  &policy, mode, &lockh)) {
+		if (md_lock_match(exp, flags, fid, LDLM_IBITS, &policy, mode,
+				  &lockh)) {
 			struct ldlm_lock *lock;
 
 			lock = ldlm_handle2lock(&lockh);
diff --git a/fs/lustre/llite/llite_internal.h b/fs/lustre/llite/llite_internal.h
index cdfc75e..b101a71 100644
--- a/fs/lustre/llite/llite_internal.h
+++ b/fs/lustre/llite/llite_internal.h
@@ -1175,8 +1175,8 @@ static inline void mapping_clear_exiting(struct address_space *mapping)
 /* llite/file.c */
 extern const struct inode_operations ll_file_inode_operations;
 const struct file_operations *ll_select_file_operations(struct ll_sb_info *sbi);
-int ll_have_md_lock(struct inode *inode, u64 *bits,
-		    enum ldlm_mode l_req_mode);
+int ll_have_md_lock(struct obd_export *exp, struct inode *inode,
+		    u64 *bits, enum ldlm_mode l_req_mode);
 enum ldlm_mode ll_take_md_lock(struct inode *inode, u64 bits,
 			       struct lustre_handle *lockh, u64 flags,
 			       enum ldlm_mode mode);
diff --git a/fs/lustre/llite/namei.c b/fs/lustre/llite/namei.c
index ada539e..0c4c8e6 100644
--- a/fs/lustre/llite/namei.c
+++ b/fs/lustre/llite/namei.c
@@ -256,7 +256,8 @@ static void ll_lock_cancel_bits(struct ldlm_lock *lock, u64 to_cancel)
 	 * LCK_CR, LCK_CW, LCK_PR - bug 22891
 	 */
 	if (bits & MDS_INODELOCK_OPEN)
-		ll_have_md_lock(inode, &bits, lock->l_req_mode);
+		ll_have_md_lock(lock->l_conn_export, inode, &bits,
+				lock->l_req_mode);
 
 	if (bits & MDS_INODELOCK_OPEN) {
 		fmode_t fmode;
@@ -284,7 +285,7 @@ static void ll_lock_cancel_bits(struct ldlm_lock *lock, u64 to_cancel)
 	if (bits & (MDS_INODELOCK_LOOKUP | MDS_INODELOCK_UPDATE |
 		    MDS_INODELOCK_LAYOUT | MDS_INODELOCK_PERM |
 		    MDS_INODELOCK_DOM))
-		ll_have_md_lock(inode, &bits, LCK_MINMODE);
+		ll_have_md_lock(lock->l_conn_export, inode, &bits, LCK_MINMODE);
 
 	if (bits & MDS_INODELOCK_DOM) {
 		rc = ll_dom_lock_cancel(inode, lock);
@@ -435,7 +436,7 @@ int ll_md_need_convert(struct ldlm_lock *lock)
 	unlock_res_and_lock(lock);
 
 	inode = ll_inode_from_resource_lock(lock);
-	ll_have_md_lock(inode, &bits, mode);
+	ll_have_md_lock(lock->l_conn_export, inode, &bits, mode);
 	iput(inode);
 	return !!(bits);
 }
diff --git a/fs/lustre/lmv/lmv_obd.c b/fs/lustre/lmv/lmv_obd.c
index 1b6e4aa..1b95d93 100644
--- a/fs/lustre/lmv/lmv_obd.c
+++ b/fs/lustre/lmv/lmv_obd.c
@@ -3558,39 +3558,49 @@ static enum ldlm_mode lmv_lock_match(struct obd_export *exp, u64 flags,
 {
 	struct obd_device *obd = exp->exp_obd;
 	struct lmv_obd *lmv = &obd->u.lmv;
-	enum ldlm_mode rc;
 	struct lu_tgt_desc *tgt;
-	int i;
+	u64 bits = policy->l_inodebits.bits;
+	enum ldlm_mode rc = LCK_MINMODE;
 	int index;
+	int i;
 
 	CDEBUG(D_INODE, "Lock match for " DFID "\n", PFID(fid));
 
-	/*
-	 * With DNE every object can have two locks in different namespaces:
+	/* only one bit is set */
+	LASSERT(bits && !(bits & (bits - 1)));
+	/* With DNE every object can have two locks in different namespaces:
 	 * lookup lock in space of MDT storing direntry and update/open lock in
 	 * space of MDT storing inode.  Try the MDT that the FID maps to first,
 	 * since this can be easily found, and only try others if that fails.
 	 */
-	for (i = 0, index = lmv_fid2tgt_index(lmv, fid);
-	     i < lmv->lmv_mdt_descs.ltd_tgts_size;
-	     i++, index = (index + 1) % lmv->lmv_mdt_descs.ltd_tgts_size) {
-		if (index < 0) {
-			CDEBUG(D_HA, "%s: " DFID " is inaccessible: rc = %d\n",
-			       obd->obd_name, PFID(fid), index);
-			index = 0;
+	if (bits == MDS_INODELOCK_LOOKUP) {
+		for (i = 0, index = lmv_fid2tgt_index(lmv, fid);
+		     i < lmv->lmv_mdt_descs.ltd_tgts_size; i++,
+		     index = (index + 1) % lmv->lmv_mdt_descs.ltd_tgts_size) {
+			if (index < 0) {
+				CDEBUG(D_HA,
+				       "%s: " DFID " is inaccessible: rc = %d\n",
+				       obd->obd_name, PFID(fid), index);
+				index = 0;
+			}
+			tgt = lmv_tgt(lmv, index);
+			if (!tgt || !tgt->ltd_exp || !tgt->ltd_active)
+				continue;
+			rc = md_lock_match(tgt->ltd_exp, flags, fid, type,
+					   policy, mode, lockh);
+			if (rc)
+				break;
 		}
-
-		tgt = lmv_tgt(lmv, index);
-		if (!tgt || !tgt->ltd_exp || !tgt->ltd_active)
-			continue;
-
-		rc = md_lock_match(tgt->ltd_exp, flags, fid, type, policy, mode,
-				   lockh);
-		if (rc)
-			return rc;
+	} else {
+		tgt = lmv_fid2tgt(lmv, fid);
+		if (!IS_ERR(tgt) && tgt->ltd_exp && tgt->ltd_active)
+			rc = md_lock_match(tgt->ltd_exp, flags, fid, type,
+					   policy, mode, lockh);
 	}
 
-	return 0;
+	CDEBUG(D_INODE, "Lock match for "DFID": %d\n", PFID(fid), rc);
+
+	return rc;
 }
 
 static int lmv_get_lustre_md(struct obd_export *exp,
-- 
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:[~2023-04-09 12:34 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-09 12:12 [lustre-devel] [PATCH 00/40] lustre: backport OpenSFS changes from March XX, 2023 James Simmons
2023-04-09 12:12 ` [lustre-devel] [PATCH 01/40] lustre: protocol: basic batching processing framework James Simmons
2023-04-09 12:12 ` [lustre-devel] [PATCH 02/40] lustre: lov: fiemap improperly handles fm_extent_count=0 James Simmons
2023-04-09 12:12 ` [lustre-devel] [PATCH 03/40] lustre: llite: SIGBUS is possible on a race with page reclaim James Simmons
2023-04-09 12:12 ` [lustre-devel] [PATCH 04/40] lustre: osc: page fault in osc_release_bounce_pages() James Simmons
2023-04-09 12:12 ` [lustre-devel] [PATCH 05/40] lustre: readahead: add stats for read-ahead page count James Simmons
2023-04-09 12:12 ` [lustre-devel] [PATCH 06/40] lustre: quota: enforce project quota for root James Simmons
2023-04-09 12:12 ` [lustre-devel] [PATCH 07/40] lustre: ldlm: send the cancel RPC asap James Simmons
2023-04-09 12:12 ` [lustre-devel] [PATCH 08/40] lustre: enc: align Base64 encoding with RFC 4648 base64url James Simmons
2023-04-09 12:12 ` [lustre-devel] [PATCH 09/40] lustre: quota: fix insane grant quota James Simmons
2023-04-09 12:12 ` [lustre-devel] [PATCH 10/40] lustre: llite: check truncated page in ->readpage() James Simmons
2023-04-09 12:12 ` [lustre-devel] [PATCH 11/40] lnet: o2iblnd: Fix key mismatch issue James Simmons
2023-04-09 12:12 ` [lustre-devel] [PATCH 12/40] lustre: sec: fid2path for encrypted files James Simmons
2023-04-09 12:12 ` [lustre-devel] [PATCH 13/40] lustre: sec: Lustre/HSM on enc file with enc key James Simmons
2023-04-09 12:12 ` [lustre-devel] [PATCH 14/40] lustre: llite: check read page past requested James Simmons
2023-04-09 12:12 ` [lustre-devel] [PATCH 15/40] lustre: llite: fix relatime support James Simmons
2023-04-09 12:12 ` [lustre-devel] [PATCH 16/40] lustre: ptlrpc: clarify AT error message James Simmons
2023-04-09 12:12 ` [lustre-devel] [PATCH 17/40] lustre: update version to 2.15.54 James Simmons
2023-04-09 12:12 ` [lustre-devel] [PATCH 18/40] lustre: tgt: skip free inodes in OST weights James Simmons
2023-04-09 12:12 ` [lustre-devel] [PATCH 19/40] lustre: fileset: check fileset for operations by fid James Simmons
2023-04-09 12:13 ` [lustre-devel] [PATCH 20/40] lustre: clio: Remove cl_page_size() James Simmons
2023-04-09 12:13 ` [lustre-devel] [PATCH 21/40] lustre: fid: clean up OBIF_MAX_OID and IDIF_MAX_OID James Simmons
2023-04-09 12:13 ` [lustre-devel] [PATCH 22/40] lustre: llog: fix processing of a wrapped catalog James Simmons
2023-04-09 12:13 ` [lustre-devel] [PATCH 23/40] lustre: llite: replace lld_nfs_dentry flag with opencache handling James Simmons
2023-04-09 12:13 ` James Simmons [this message]
2023-04-09 12:13 ` [lustre-devel] [PATCH 25/40] lnet: libcfs: remove unused hash code James Simmons
2023-04-09 12:13 ` [lustre-devel] [PATCH 26/40] lustre: client: -o network needs add_conn processing James Simmons
2023-04-09 12:13 ` [lustre-devel] [PATCH 27/40] lnet: Lock primary NID logic James Simmons
2023-04-09 12:13 ` [lustre-devel] [PATCH 28/40] lnet: Peers added via kernel API should be permanent James Simmons
2023-04-09 12:13 ` [lustre-devel] [PATCH 29/40] lnet: don't delete peer created by Lustre James Simmons
2023-04-09 12:13 ` [lustre-devel] [PATCH 30/40] lnet: memory leak in copy_ioc_udsp_descr James Simmons
2023-04-09 12:13 ` [lustre-devel] [PATCH 31/40] lnet: remove crash with UDSP James Simmons
2023-04-09 12:13 ` [lustre-devel] [PATCH 32/40] lustre: ptlrpc: fix clang build errors James Simmons
2023-04-09 12:13 ` [lustre-devel] [PATCH 33/40] lustre: ldlm: remove client_import_find_conn() James Simmons
2023-04-09 12:13 ` [lustre-devel] [PATCH 34/40] lnet: add 'force' option to lnetctl peer del James Simmons
2023-04-09 12:13 ` [lustre-devel] [PATCH 35/40] lustre: ldlm: BL_AST lock cancel still can be batched James Simmons
2023-04-09 12:13 ` [lustre-devel] [PATCH 36/40] lnet: lnet_parse_route uses wrong loop var James Simmons
2023-04-09 12:13 ` [lustre-devel] [PATCH 37/40] lustre: tgt: add qos debug James Simmons
2023-04-09 12:13 ` [lustre-devel] [PATCH 38/40] lustre: enc: file names encryption when using secure boot James Simmons
2023-04-09 12:13 ` [lustre-devel] [PATCH 39/40] lustre: uapi: add DMV_IMP_INHERIT connect flag James Simmons
2023-04-09 12:13 ` [lustre-devel] [PATCH 40/40] lustre: llite: dir layout inheritance fixes 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=1681042400-15491-25-git-send-email-jsimmons@infradead.org \
    --to=jsimmons@infradead.org \
    --cc=adilger@whamcloud.com \
    --cc=green@whamcloud.com \
    --cc=lai.siyao@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).