Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1519215

[PATCH 10/35] staging: lustre: lmv: revalidate the dentry for striped dir

From James Simmons <jsimmons@infradead.org>
Newsgroups linux.kernel
Subject [PATCH 10/35] staging: lustre: lmv: revalidate the dentry for striped dir
Date 2016-11-10 18:40 +0100
Message-ID <sC1ur-MX-87@gated-at.bofh.it> (permalink)
References <sC1up-MX-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: wang di <di.wang@intel.com>

If there are bad stripe during striped dir revalidation,
most likely due the race between close(unlink) and
getattr, then let's revalidate the dentry, instead of
return error, like normal directory.

Signed-off-by: wang di <di.wang@intel.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6831
Reviewed-on: http://review.whamcloud.com/15720
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7078
Reviewed-on: http://review.whamcloud.com/16382
Reviewed-by: Alex Zhuravlev <alexey.zhuravlev@intel.com>
Reviewed-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 drivers/staging/lustre/lustre/llite/file.c      |    7 +++++
 drivers/staging/lustre/lustre/llite/llite_lib.c |   30 ++++++++++++++++++++++-
 drivers/staging/lustre/lustre/lmv/lmv_intent.c  |   11 +++++++-
 3 files changed, 45 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c
index 7adbf31..28c2501 100644
--- a/drivers/staging/lustre/lustre/llite/file.c
+++ b/drivers/staging/lustre/lustre/llite/file.c
@@ -2732,6 +2732,13 @@ static int ll_inode_revalidate_fini(struct inode *inode, int rc)
 	/* Already unlinked. Just update nlink and return success */
 	if (rc == -ENOENT) {
 		clear_nlink(inode);
+		/* If it is striped directory, and there is bad stripe
+		 * Let's revalidate the dentry again, instead of returning
+		 * error
+		 */
+		if (S_ISDIR(inode->i_mode) && ll_i2info(inode)->lli_lsm_md)
+			return 0;
+
 		/* This path cannot be hit for regular files unless in
 		 * case of obscure races, so no need to validate size.
 		 */
diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c
index c1b646c..4a4741b 100644
--- a/drivers/staging/lustre/lustre/llite/llite_lib.c
+++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
@@ -1194,16 +1194,44 @@ static int ll_update_lsm_md(struct inode *inode, struct lustre_md *md)
 
 	/* set the directory layout */
 	if (!lli->lli_lsm_md) {
+		struct cl_attr *attr;
+
 		rc = ll_init_lsm_md(inode, md);
 		if (rc)
 			return rc;
 
-		lli->lli_lsm_md = lsm;
 		/*
 		 * set lsm_md to NULL, so the following free lustre_md
 		 * will not free this lsm
 		 */
 		md->lmv = NULL;
+		lli->lli_lsm_md = lsm;
+
+		attr = kzalloc(sizeof(*attr), GFP_NOFS);
+		if (!attr)
+			return -ENOMEM;
+
+		/* validate the lsm */
+		rc = md_merge_attr(ll_i2mdexp(inode), lsm, attr,
+				   ll_md_blocking_ast);
+		if (rc) {
+			kfree(attr);
+			return rc;
+		}
+
+		if (md->body->mbo_valid & OBD_MD_FLNLINK)
+			md->body->mbo_nlink = attr->cat_nlink;
+		if (md->body->mbo_valid & OBD_MD_FLSIZE)
+			md->body->mbo_size = attr->cat_size;
+		if (md->body->mbo_valid & OBD_MD_FLATIME)
+			md->body->mbo_atime = attr->cat_atime;
+		if (md->body->mbo_valid & OBD_MD_FLCTIME)
+			md->body->mbo_ctime = attr->cat_ctime;
+		if (md->body->mbo_valid & OBD_MD_FLMTIME)
+			md->body->mbo_mtime = attr->cat_mtime;
+
+		kfree(attr);
+
 		CDEBUG(D_INODE, "Set lsm %p magic %x to "DFID"\n", lsm,
 		       lsm->lsm_md_magic, PFID(ll_inode2fid(inode)));
 		return 0;
diff --git a/drivers/staging/lustre/lustre/lmv/lmv_intent.c b/drivers/staging/lustre/lustre/lmv/lmv_intent.c
index 9f4e826..b1071cf 100644
--- a/drivers/staging/lustre/lustre/lmv/lmv_intent.c
+++ b/drivers/staging/lustre/lustre/lmv/lmv_intent.c
@@ -223,7 +223,14 @@ int lmv_revalidate_slaves(struct obd_export *exp,
 			LASSERT(body);
 
 			if (unlikely(body->mbo_nlink < 2)) {
-				CERROR("%s: nlink %d < 2 corrupt stripe %d "DFID":" DFID"\n",
+				/*
+				 * If this is bad stripe, most likely due
+				 * to the race between close(unlink) and
+				 * getattr, let's return -EONENT, so llite
+				 * will revalidate the dentry see
+				 * ll_inode_revalidate_fini()
+				 */
+				CDEBUG(D_INODE, "%s: nlink %d < 2 corrupt stripe %d "DFID":" DFID"\n",
 				       obd->obd_name, body->mbo_nlink, i,
 				       PFID(&lsm->lsm_md_oinfo[i].lmo_fid),
 				       PFID(&lsm->lsm_md_oinfo[0].lmo_fid));
@@ -233,7 +240,7 @@ int lmv_revalidate_slaves(struct obd_export *exp,
 					it.it_lock_mode = 0;
 				}
 
-				rc = -EIO;
+				rc = -ENOENT;
 				goto cleanup;
 			}
 
-- 
1.7.1

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 00/35] second batch of missing lustre 2.8 patches James Simmons <jsimmons@infradead.org> - 2016-11-10 18:40 +0100
  [PATCH 04/35] staging: lustre: lov: init LOV stripe type beforehand James Simmons <jsimmons@infradead.org> - 2016-11-10 18:40 +0100
  [PATCH 31/35] staging: lustre: obdclass: add export for lprocfs_stats_alloc_one() James Simmons <jsimmons@infradead.org> - 2016-11-10 18:40 +0100
  [PATCH 30/35] staging: lustre: llite: ll_write_begin/end not passing on errors James Simmons <jsimmons@infradead.org> - 2016-11-10 18:40 +0100
  [PATCH 14/35] staging: lustre: nrs: serialize executions of nrs_policy_stop James Simmons <jsimmons@infradead.org> - 2016-11-10 18:40 +0100
  [PATCH 19/35] staging: lustre: obdclass: remove structure holes to reduce memory James Simmons <jsimmons@infradead.org> - 2016-11-10 18:40 +0100
  [PATCH 15/35] staging: lustre: llite: tar restore fails for HSM released files. James Simmons <jsimmons@infradead.org> - 2016-11-10 18:40 +0100
  [PATCH 20/35] staging: lustre: ptlrpc: Move IT_* definitions to lustre_idl.h James Simmons <jsimmons@infradead.org> - 2016-11-10 18:40 +0100
  [PATCH 26/35] staging: lustre: mdc: remove console spew from mdc_ioc_fid2path James Simmons <jsimmons@infradead.org> - 2016-11-10 18:40 +0100
  [PATCH 35/35] staging: lustre: idl: clean up file attribute flags James Simmons <jsimmons@infradead.org> - 2016-11-10 18:40 +0100
  [PATCH 22/35] staging: lustre: llite: clear dir stripe md in ll_iget James Simmons <jsimmons@infradead.org> - 2016-11-10 18:40 +0100
  [PATCH 01/35] staging: lustre: hsm: Use file lease to implement migration James Simmons <jsimmons@infradead.org> - 2016-11-10 18:40 +0100
  [PATCH 10/35] staging: lustre: lmv: revalidate the dentry for striped dir James Simmons <jsimmons@infradead.org> - 2016-11-10 18:40 +0100
  [PATCH 28/35] staging: lustre: osc: Remove remains of osc_ast_guard James Simmons <jsimmons@infradead.org> - 2016-11-10 18:40 +0100
  [PATCH 03/35] staging: lustre: ptlrpc: mbits is sent within ptlrpc_body James Simmons <jsimmons@infradead.org> - 2016-11-10 18:40 +0100
  [PATCH 27/35] staging: lustre: ptlrpc: reset imp_replay_cursor James Simmons <jsimmons@infradead.org> - 2016-11-10 18:40 +0100
  [PATCH 25/35] staging: lustre: osc: Do not merge extents with partial pages James Simmons <jsimmons@infradead.org> - 2016-11-10 18:40 +0100
  [PATCH 16/35] staging: lustre: llite: support SELinux context labelling James Simmons <jsimmons@infradead.org> - 2016-11-10 18:50 +0100
  [PATCH 11/35] staging: lustre: ptlrpc: race at req processing James Simmons <jsimmons@infradead.org> - 2016-11-10 18:50 +0100
  [PATCH 06/35] staging: lustre: osc: Performance tune for LRU James Simmons <jsimmons@infradead.org> - 2016-11-10 18:50 +0100
  [PATCH 17/35] staging: lustre: obd: Remove dead code in precleanup James Simmons <jsimmons@infradead.org> - 2016-11-10 18:50 +0100
  [PATCH 13/35] staging: lustre: llite: lookup master inode by ilookup5_nowait James Simmons <jsimmons@infradead.org> - 2016-11-10 18:50 +0100
  [PATCH 18/35] staging: lustre: osc: fix max_dirty_mb tunable setting limit James Simmons <jsimmons@infradead.org> - 2016-11-10 18:50 +0100
  [PATCH 24/35] staging: lustre: osc: osc_extent should hold refcount to osc_object James Simmons <jsimmons@infradead.org> - 2016-11-10 18:50 +0100
  [PATCH 23/35] staging: lustre: ldlm: improve lock timeout messages James Simmons <jsimmons@infradead.org> - 2016-11-10 18:50 +0100
  [PATCH 05/35] staging: lustre: llog: fix wrong offset in llog_process_thread() James Simmons <jsimmons@infradead.org> - 2016-11-10 18:50 +0100
  [PATCH 02/35] staging: lustre: obd: rename obd_unpackmd() to md_unpackmd() James Simmons <jsimmons@infradead.org> - 2016-11-10 19:10 +0100
  [PATCH 07/35] staging: lustre: lov: avoid infinite loop in lsm_alloc_plain() James Simmons <jsimmons@infradead.org> - 2016-11-10 19:10 +0100
  [PATCH 09/35] staging: lustre: mgc: IR log failure should not stop mount James Simmons <jsimmons@infradead.org> - 2016-11-10 19:10 +0100

csiph-web