Skip to contentSkip to conversation

Lustre fixes

PATCH New Oleg Drokin 1 participant 6 messages Feb 9, 2014 Staging

lore
Share & tools
lore
#0 lore raw

cover Lustre fixes

This is a set of patches that eliminates rest of crashes and most leaks hit during standard lustre regression testing for me.

This serie + O_LOV_DELAY_CREATE patch from Andreas (that was submitted separately and needs separate approval:
http://www.spinics.net/lists/linux-fsdevel/msg72386.html ) makes most of the sanity testing to also pass.

Andrew Perepechko (1):
lustre/xattr: separate ACL and XATTR caches

Bobi Jam (1):
lustre/lov: avoid subobj's coh_parent race

John L. Hammond (1):
lustre: don't leak llog handle in llog_cat_process_cb()

Swapnil Pimpale (1):
lustre: Unsafe error handling around ll_splice_alias

yang sheng (1):
lustre: instantiate negative dentry

 .../lustre/lustre/include/lustre/lustre_idl.h      |   1 -
 drivers/staging/lustre/lustre/ldlm/ldlm_lock.c     |   2 -
 .../staging/lustre/lustre/llite/llite_internal.h   |   7 --
 drivers/staging/lustre/lustre/llite/namei.c        |  15 ++-
 drivers/staging/lustre/lustre/llite/statahead.c    |   9 +-
 drivers/staging/lustre/lustre/llite/xattr.c        |  29 +++--
 drivers/staging/lustre/lustre/llite/xattr_cache.c  | 117 ++++-----------------
 drivers/staging/lustre/lustre/lov/lov_object.c     |  10 +-
 drivers/staging/lustre/lustre/lov/lovsub_dev.c     |   4 +
 drivers/staging/lustre/lustre/mdc/mdc_internal.h   |   2 +-
 drivers/staging/lustre/lustre/mdc/mdc_locks.c      |   9 +-
 drivers/staging/lustre/lustre/mdc/mdc_reint.c      |   2 +-
 drivers/staging/lustre/lustre/mdc/mdc_request.c    |  30 +++++-
 drivers/staging/lustre/lustre/obdclass/llog_cat.c  |   6 +-
 drivers/staging/lustre/lustre/ptlrpc/layout.c      |   3 +-
 15 files changed, 100 insertions(+), 146 deletions(-)
Signature · 1 line
1.8.5.3
#1 lore raw

PATCH 1/5 lustre/lov: avoid subobj's coh_parent race

From: Bobi Jam <[email protected]>

* during a file lov object initialization, we need protect the access and change of its subobj->coh_parent, since it could be another layout change race there, which makes an unreferenced lovsub obj in the site object hash table.

* dump lovsub objects in the site if the lovsub device reference > 0 during its finalization phase.

Reviewed-on: http://review.whamcloud.com/6105
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-1480

---
 drivers/staging/lustre/lustre/lov/lov_object.c | 10 +++++++---
 drivers/staging/lustre/lustre/lov/lovsub_dev.c |  4 ++++
 2 files changed, 11 insertions(+), 3 deletions(-)
drivers/staging/lustre/lustre/lov/lov_object.c +7 -3
index df8b5b5..fe0b70a 100644
@@ -122,8 +122,8 @@ static struct cl_object *lov_sub_find(const struct lu_env *env,
 }
 
 static int lov_init_sub(const struct lu_env *env, struct lov_object *lov,
-			struct cl_object *stripe,
-			struct lov_layout_raid0 *r0, int idx)
+			struct cl_object *stripe, struct lov_layout_raid0 *r0,
+			int idx)
 {
 	struct cl_object_header *hdr;
 	struct cl_object_header *subhdr;
@@ -144,7 +144,6 @@ static int lov_init_sub(const struct lu_env *env, struct lov_object *lov,
 
 	hdr    = cl_object_header(lov2cl(lov));
 	subhdr = cl_object_header(stripe);
-	parent = subhdr->coh_parent;
 
 	oinfo = lov->lo_lsm->lsm_oinfo[idx];
 	CDEBUG(D_INODE, DFID"@%p[%d] -> "DFID"@%p: ostid: "DOSTID
@@ -153,8 +152,12 @@ static int lov_init_sub(const struct lu_env *env, struct lov_object *lov,
 	       PFID(&hdr->coh_lu.loh_fid), hdr, POSTID(&oinfo->loi_oi),
 	       oinfo->loi_ost_idx, oinfo->loi_ost_gen);
 
+	/* reuse ->coh_attr_guard to protect coh_parent change */
+	spin_lock(&subhdr->coh_attr_guard);
+	parent = subhdr->coh_parent;
 	if (parent == NULL) {
 		subhdr->coh_parent = hdr;
+		spin_unlock(&subhdr->coh_attr_guard);
 		subhdr->coh_nesting = hdr->coh_nesting + 1;
 		lu_object_ref_add(&stripe->co_lu, "lov-parent", lov);
 		r0->lo_sub[idx] = cl2lovsub(stripe);
@@ -166,6 +169,7 @@ static int lov_init_sub(const struct lu_env *env, struct lov_object *lov,
 		struct lov_object *old_lov;
 		unsigned int mask = D_INODE;
 
+		spin_unlock(&subhdr->coh_attr_guard);
 		old_obj = lu_object_locate(&parent->coh_lu, &lov_device_type);
 		LASSERT(old_obj != NULL);
 		old_lov = cl2lov(lu2cl(old_obj));
drivers/staging/lustre/lustre/lov/lovsub_dev.c +4 -0
index 998ea1c..926c35a 100644
@@ -131,6 +131,10 @@ static struct lu_device *lovsub_device_free(const struct lu_env *env,
 	struct lovsub_device *lsd  = lu2lovsub_dev(d);
 	struct lu_device     *next = cl2lu_dev(lsd->acid_next);
 
+	if (atomic_read(&d->ld_ref) && d->ld_site) {
+		LIBCFS_DEBUG_MSG_DATA_DECL(msgdata, D_ERROR, NULL);
+		lu_site_print(env, d->ld_site, &msgdata, lu_cdebug_printer);
+	}
 	cl_device_fini(lu2cl_dev(d));
 	OBD_FREE_PTR(lsd);
 	return next;
Signature · 1 line
1.8.5.3
#2 lore raw

PATCH 2/5 lustre: Unsafe error handling around ll_splice_alias

In reply to Oleg Drokin

From: Swapnil Pimpale <[email protected]>

Callers of ll_splice_alias() should not assign the returned pointer to the dentry since it can be an err pointer. Fixed the above bug using a temporary dentry pointer. This temporary pointer is assigned to dentry only if ll_splice_alias has not returned an err pointer.

Reviewed-on: http://review.whamcloud.com/7460
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3807

---
 drivers/staging/lustre/lustre/llite/namei.c     | 9 ++++++---
 drivers/staging/lustre/lustre/llite/statahead.c | 9 ++++++---
 2 files changed, 12 insertions(+), 6 deletions(-)
drivers/staging/lustre/lustre/llite/namei.c +6 -3
index 1d03a6f..8938d37 100644
@@ -462,9 +462,12 @@ int ll_lookup_it_finish(struct ptlrpc_request *request,
 	 * Atoimc_open may passin hashed dentries for open.
 	 */
 	if (d_unhashed(*de)) {
-		*de = ll_splice_alias(inode, *de);
-		if (IS_ERR(*de))
-			return PTR_ERR(*de);
+		struct dentry *alias;
+
+		alias = ll_splice_alias(inode, *de);
+		if (IS_ERR(alias))
+			return PTR_ERR(alias);
+		*de = alias;
 	}
 
 	if (!it_disposition(it, DISP_LOOKUP_NEG)) {
drivers/staging/lustre/lustre/llite/statahead.c +6 -3
index 183b415..ad61ad4 100644
@@ -1585,12 +1585,15 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp,
 						ll_inode2fid(inode), &bits);
 			if (rc == 1) {
 				if ((*dentryp)->d_inode == NULL) {
-					*dentryp = ll_splice_alias(inode,
+					struct dentry *alias;
+
+					alias = ll_splice_alias(inode,
 								   *dentryp);
-					if (IS_ERR(*dentryp)) {
+					if (IS_ERR(alias)) {
 						ll_sai_unplug(sai, entry);
-						return PTR_ERR(*dentryp);
+						return PTR_ERR(alias);
 					}
+					*dentryp = alias;
 				} else if ((*dentryp)->d_inode != inode) {
 					/* revalidate, but inode is recreated */
 					CDEBUG(D_READA,
Signature · 1 line
1.8.5.3
#3 lore raw

PATCH 3/5 lustre: instantiate negative dentry

In reply to Oleg Drokin

From: yang sheng <[email protected]>

In the atomic_open callback. We should instantiate negative dentry. Else will got sanity:183 failed.

Reviewed-on: http://review.whamcloud.com/8110
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3228

---
 drivers/staging/lustre/lustre/llite/namei.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/staging/lustre/lustre/llite/namei.c +6 -0
index 8938d37..93c3744 100644
@@ -468,6 +468,12 @@ int ll_lookup_it_finish(struct ptlrpc_request *request,
 		if (IS_ERR(alias))
 			return PTR_ERR(alias);
 		*de = alias;
+	} else if (!it_disposition(it, DISP_LOOKUP_NEG)  &&
+		   !it_disposition(it, DISP_OPEN_CREATE)) {
+		/* With DISP_OPEN_CREATE dentry will
+		   instantiated in ll_create_it. */
+		LASSERT((*de)->d_inode == NULL);
+		d_instantiate(*de, inode);
 	}
 
 	if (!it_disposition(it, DISP_LOOKUP_NEG)) {
Signature · 1 line
1.8.5.3
#4 lore raw

PATCH 4/5 lustre/xattr: separate ACL and XATTR caches

In reply to Oleg Drokin

From: Andrew Perepechko <[email protected]>

This patch separates ACL and XATTR caches, so that when updating an ACL only LOOKUP lock is needed and when updating another XATTR only XATTR lock is needed.

This patch also reverts XATTR cache support for setxattr because client performing REINT under even PR lock will deadlock if an active server operation (like unlink) attempts to cancel all locks, and setxattr has to wait for it (MDC max-in-flight is 1).

This patch disables the r/o cache if the data is unreasonably large (larger than maximum single EA size).

Reviewed-on: http://review.whamcloud.com/7208
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3669

---
 .../lustre/lustre/include/lustre/lustre_idl.h      |   1 -
 drivers/staging/lustre/lustre/ldlm/ldlm_lock.c     |   2 -
 .../staging/lustre/lustre/llite/llite_internal.h   |   7 --
 drivers/staging/lustre/lustre/llite/xattr.c        |  29 +++--
 drivers/staging/lustre/lustre/llite/xattr_cache.c  | 117 ++++-----------------
 drivers/staging/lustre/lustre/mdc/mdc_internal.h   |   2 +-
 drivers/staging/lustre/lustre/mdc/mdc_locks.c      |   9 +-
 drivers/staging/lustre/lustre/mdc/mdc_reint.c      |   2 +-
 drivers/staging/lustre/lustre/mdc/mdc_request.c    |  30 +++++-
 drivers/staging/lustre/lustre/ptlrpc/layout.c      |   3 +-
 10 files changed, 68 insertions(+), 134 deletions(-)
drivers/staging/lustre/lustre/include/lustre/lustre_idl.h +0 -1
index 05c77c0..4183a35 100644
@@ -1747,7 +1747,6 @@ static inline __u32 lov_mds_md_size(__u16 stripes, __u32 lmm_magic)
 			  OBD_MD_FLGID   | OBD_MD_FLFLAGS | OBD_MD_FLNLINK | \
 			  OBD_MD_FLGENER | OBD_MD_FLRDEV  | OBD_MD_FLGROUP)
 
-#define OBD_MD_FLXATTRLOCKED OBD_MD_FLGETATTRLOCK
 #define OBD_MD_FLXATTRALL (OBD_MD_FLXATTR | OBD_MD_FLXATTRLS)
 
 /* don't forget obdo_fid which is way down at the bottom so it can
drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +0 -2
index 692623b..0548aca 100644
@@ -145,8 +145,6 @@ char *ldlm_it2str(int it)
 		return "getxattr";
 	case IT_LAYOUT:
 		return "layout";
-	case IT_SETXATTR:
-		return "setxattr";
 	default:
 		CERROR("Unknown intent %d\n", it);
 		return "UNKNOWN";
drivers/staging/lustre/lustre/llite/llite_internal.h +0 -7
index 28669ea..bc17c29 100644
@@ -296,13 +296,6 @@ int ll_xattr_cache_get(struct inode *inode,
 			size_t size,
 			__u64 valid);
 
-int ll_xattr_cache_update(struct inode *inode,
-			const char *name,
-			const char *newval,
-			size_t size,
-			__u64 valid,
-			int flags);
-
 /*
  * Locking to guarantee consistency of non-atomic updates to long long i_size,
  * consistency between file size and KMS.
drivers/staging/lustre/lustre/llite/xattr.c +19 -10
index af83580..b1ed4d9 100644
@@ -183,17 +183,11 @@ int ll_setxattr_common(struct inode *inode, const char *name,
 		valid |= rce_ops2valid(rce->rce_ops);
 	}
 #endif
-	if (sbi->ll_xattr_cache_enabled &&
-	    (rce == NULL || rce->rce_ops == RMT_LSETFACL)) {
-		rc = ll_xattr_cache_update(inode, name, pv, size, valid, flags);
-	} else {
 		oc = ll_mdscapa_get(inode);
 		rc = md_setxattr(sbi->ll_md_exp, ll_inode2fid(inode), oc,
 				valid, name, pv, size, 0, flags,
 				ll_i2suppgid(inode), &req);
 		capa_put(oc);
-	}
-
 #ifdef CONFIG_FS_POSIX_ACL
 	if (new_value != NULL)
 		lustre_posix_acl_xattr_free(new_value, size);
@@ -292,6 +286,7 @@ int ll_getxattr_common(struct inode *inode, const char *name,
 	void *xdata;
 	struct obd_capa *oc;
 	struct rmtacl_ctl_entry *rce = NULL;
+	struct ll_inode_info *lli = ll_i2info(inode);
 
 	CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n",
 	       inode->i_ino, inode->i_generation, inode);
@@ -339,7 +334,7 @@ int ll_getxattr_common(struct inode *inode, const char *name,
 	 */
 	if (xattr_type == XATTR_ACL_ACCESS_T &&
 	    !(sbi->ll_flags & LL_SBI_RMT_CLIENT)) {
-		struct ll_inode_info *lli = ll_i2info(inode);
+
 		struct posix_acl *acl;
 
 		spin_lock(&lli->lli_lock);
@@ -358,13 +353,27 @@ int ll_getxattr_common(struct inode *inode, const char *name,
 #endif
 
 do_getxattr:
-	if (sbi->ll_xattr_cache_enabled && (rce == NULL ||
-					    rce->rce_ops == RMT_LGETFACL ||
-					    rce->rce_ops == RMT_LSETFACL)) {
+	if (sbi->ll_xattr_cache_enabled && xattr_type != XATTR_ACL_ACCESS_T) {
 		rc = ll_xattr_cache_get(inode, name, buffer, size, valid);
+		if (rc == -EAGAIN)
+			goto getxattr_nocache;
 		if (rc < 0)
 			GOTO(out_xattr, rc);
+
+		/* Add "system.posix_acl_access" to the list */
+		if (lli->lli_posix_acl != NULL && valid & OBD_MD_FLXATTRLS) {
+			if (size == 0) {
+				rc += sizeof(XATTR_NAME_ACL_ACCESS);
+			} else if (size - rc >= sizeof(XATTR_NAME_ACL_ACCESS)) {
+				memcpy(buffer + rc, XATTR_NAME_ACL_ACCESS,
+				       sizeof(XATTR_NAME_ACL_ACCESS));
+				rc += sizeof(XATTR_NAME_ACL_ACCESS);
+			} else {
+				GOTO(out_xattr, rc = -ERANGE);
+			}
+		}
 	} else {
+getxattr_nocache:
 		oc = ll_mdscapa_get(inode);
 		rc = md_getxattr(sbi->ll_md_exp, ll_inode2fid(inode), oc,
 				valid | (rce ? rce_ops2valid(rce->rce_ops) : 0),
drivers/staging/lustre/lustre/llite/xattr_cache.c +18 -99

173 lines not on this page · raw message

drivers/staging/lustre/lustre/mdc/mdc_internal.h +1 -1
index 5069829..fc21777 100644
@@ -101,7 +101,7 @@ int mdc_enqueue(struct obd_export *exp, struct ldlm_enqueue_info *einfo,
 		struct lustre_handle *lockh, void *lmm, int lmmsize,
 		struct ptlrpc_request **req, __u64 extra_lock_flags);
 
-int mdc_resource_get_unused(struct obd_export *exp, struct lu_fid *fid,
+int mdc_resource_get_unused(struct obd_export *exp, const struct lu_fid *fid,
 			    struct list_head *cancels, ldlm_mode_t mode,
 			    __u64 bits);
 /* mdc/mdc_request.c */
drivers/staging/lustre/lustre/mdc/mdc_locks.c +1 -8
index 8aa7c80..288a41e 100644
@@ -378,13 +378,6 @@ mdc_intent_getxattr_pack(struct obd_export *exp,
 
 	mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1);
 
-	if (it->it_op == IT_SETXATTR)
-		/* If we want to upgrade to LCK_PW, let's cancel LCK_PR
-		 * locks now. This avoids unnecessary ASTs. */
-		count = mdc_resource_get_unused(exp, &op_data->op_fid1,
-						&cancels, LCK_PW,
-						MDS_INODELOCK_XATTR);
-
 	rc = ldlm_prep_enqueue_req(exp, req, &cancels, count);
 	if (rc) {
 		ptlrpc_request_free(req);
@@ -842,7 +835,7 @@ resend:
 			return -EOPNOTSUPP;
 		req = mdc_intent_layout_pack(exp, it, op_data);
 		lvb_type = LVB_T_LAYOUT;
-	} else if (it->it_op & (IT_GETXATTR | IT_SETXATTR)) {
+	} else if (it->it_op & IT_GETXATTR) {
 		req = mdc_intent_getxattr_pack(exp, it, op_data);
 	} else {
 		LBUG();
drivers/staging/lustre/lustre/mdc/mdc_reint.c +1 -1
index 9f3a345..1aea154 100644
@@ -66,7 +66,7 @@ static int mdc_reint(struct ptlrpc_request *request,
 /* Find and cancel locally locks matched by inode @bits & @mode in the resource
  * found by @fid. Found locks are added into @cancel list. Returns the amount of
  * locks added to @cancels list. */
-int mdc_resource_get_unused(struct obd_export *exp, struct lu_fid *fid,
+int mdc_resource_get_unused(struct obd_export *exp, const struct lu_fid *fid,
 			    struct list_head *cancels, ldlm_mode_t mode,
 			    __u64 bits)
 {
drivers/staging/lustre/lustre/mdc/mdc_request.c +26 -4
index 8301392..17c8e14 100644
@@ -355,10 +355,32 @@ static int mdc_xattr_common(struct obd_export *exp,const struct req_format *fmt,
 				     input_size);
 	}
 
-	rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, opcode);
-	if (rc) {
-		ptlrpc_request_free(req);
-		return rc;
+	/* Flush local XATTR locks to get rid of a possible cancel RPC */
+	if (opcode == MDS_REINT && fid_is_sane(fid) &&
+	    exp->exp_connect_data.ocd_ibits_known & MDS_INODELOCK_XATTR) {
+		LIST_HEAD(cancels);
+		int count;
+
+		/* Without that packing would fail */
+		if (input_size == 0)
+			req_capsule_set_size(&req->rq_pill, &RMF_EADATA,
+					     RCL_CLIENT, 0);
+
+		count = mdc_resource_get_unused(exp, fid,
+						&cancels, LCK_EX,
+						MDS_INODELOCK_XATTR);
+
+		rc = mdc_prep_elc_req(exp, req, MDS_REINT, &cancels, count);
+		if (rc) {
+			ptlrpc_request_free(req);
+			return rc;
+		}
+	} else {
+		rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, opcode);
+		if (rc) {
+			ptlrpc_request_free(req);
+			return rc;
+		}
 	}
 
 	if (opcode == MDS_REINT) {
drivers/staging/lustre/lustre/ptlrpc/layout.c +2 -1
index 9b8f691..41c12e0 100644
@@ -295,7 +295,8 @@ static const struct req_msg_field *mds_reint_setxattr_client[] = {
 	&RMF_REC_REINT,
 	&RMF_CAPA1,
 	&RMF_NAME,
-	&RMF_EADATA
+	&RMF_EADATA,
+	&RMF_DLM_REQ
 };
 
 static const struct req_msg_field *mdt_swap_layouts[] = {
Signature · 1 line
1.8.5.3
#5 lore raw

PATCH 5/5 lustre: don't leak llog handle in llog_cat_process_cb()

In reply to Oleg Drokin

From: "John L. Hammond" <[email protected]>

An early return from llog_cat_process_cb() was leaking the llog handle. Fix this by not doing that.

Reviewed-on: http://review.whamcloud.com/7847
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4054

---
 drivers/staging/lustre/lustre/obdclass/llog_cat.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/lustre/lustre/obdclass/llog_cat.c +3 -3
index c0f3af7..1d999310 100644
@@ -551,9 +551,8 @@ int llog_cat_process_cb(const struct lu_env *env, struct llog_handle *cat_llh,
 
 	if (rec->lrh_index < d->lpd_startcat)
 		/* Skip processing of the logs until startcat */
-		return 0;
-
-	if (d->lpd_startidx > 0) {
+		rc = 0;
+	else if (d->lpd_startidx > 0) {
 		struct llog_process_cat_data cd;
 
 		cd.lpcd_first_idx = d->lpd_startidx;
@@ -566,6 +565,7 @@ int llog_cat_process_cb(const struct lu_env *env, struct llog_handle *cat_llh,
 		rc = llog_process_or_fork(env, llh, d->lpd_cb, d->lpd_data,
 					  NULL, false);
 	}
+
 	llog_handle_put(llh);
 
 	return rc;
Signature · 1 line
1.8.5.3