Skip to contentSkip to conversation

Few lustre fixes and cleanups.

PATCH New [email protected] 1 participant 5 messages May 16, 2015 Staging

lore
Share & tools
lore
#0 lore raw

cover Few lustre fixes and cleanups.

From: Oleg Drokin <[email protected]>

This set fixes a couple of style issues, and a couple of bugs.

Please consider

Oleg Drokin (4):
staging/lustre: Only set INTERRUPTIBLE state before calling schedule staging/lustre/ptlrpc: Fix wrong indenting in plain_authorize() staging/lustre/ptlrpc: Fix potential NULL pointer dereference staging/lustre/llite: Fix wrong identing in ll_setxattr_common

 drivers/staging/lustre/lustre/include/lustre_lib.h | 15 +++++----------
 drivers/staging/lustre/lustre/llite/xattr.c        | 10 +++++-----
 drivers/staging/lustre/lustre/lov/lov_pack.c       |  3 ++-
 drivers/staging/lustre/lustre/ptlrpc/sec_plain.c   |  2 +-
 4 files changed, 13 insertions(+), 17 deletions(-)
Signature · 1 line
2.1.0
#1 lore raw

PATCH 1/4 staging/lustre: Only set INTERRUPTIBLE state before calling schedule

From: Oleg Drokin <[email protected]>

In __l_wait_event the condition could be a complicated function that does allocations and other potentialy blocking activities, so it sohuld not be called in a task state other than RUNNABLE

---
 drivers/staging/lustre/lustre/include/lustre_lib.h | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)
drivers/staging/lustre/lustre/include/lustre_lib.h +5 -10
index bf13563..43ee9f0 100644
@@ -549,19 +549,13 @@ do {									   \
 		__blocked = cfs_block_sigsinv(0);			      \
 									       \
 	for (;;) {							     \
-		unsigned       __wstate;				       \
-									       \
-		__wstate = info->lwi_on_signal != NULL &&		      \
-			   (__timeout == 0 || __allow_intr) ?		  \
-			TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE;	       \
-									       \
-		set_current_state(TASK_INTERRUPTIBLE);		 \
-									       \
 		if (condition)						 \
 			break;						 \
 									       \
+		set_current_state(TASK_INTERRUPTIBLE);			       \
+									       \
 		if (__timeout == 0) {					  \
-			schedule();						\
+			schedule();					       \
 		} else {						       \
 			long interval = info->lwi_interval?	  \
 					     min_t(long,	     \
@@ -582,6 +576,8 @@ do {									   \
 			}						      \
 		}							      \
 									       \
+		set_current_state(TASK_RUNNING);			       \
+									       \
 		if (condition)						 \
 			break;						 \
 		if (cfs_signal_pending()) {				    \
@@ -605,7 +601,6 @@ do {									   \
 									       \
 	cfs_restore_sigs(__blocked);					   \
 									       \
-	set_current_state(TASK_RUNNING);			       \
 	remove_wait_queue(&wq, &__wait);					   \
 } while (0)
 
Signature · 1 line
2.1.0
#2 lore raw

PATCH 2/4 staging/lustre/ptlrpc: Fix wrong indenting in plain_authorize()

In reply to [email protected]

From: Oleg Drokin <[email protected]>

smatch highlighted a wrongly indented bit of code that almost hides the extra assignment.

---
 drivers/staging/lustre/lustre/ptlrpc/sec_plain.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lustre/ptlrpc/sec_plain.c +1 -1
index 989cdcd..65f3ab4 100644
@@ -870,7 +870,7 @@ int plain_authorize(struct ptlrpc_request *req)
 			lustre_msg_buf(msg, PLAIN_PACK_MSG_OFF, 0),
 			lustre_msg_buflen(msg, PLAIN_PACK_MSG_OFF),
 			NULL, 0, (unsigned char *)&msg->lm_cksum, &hsize);
-			req->rq_reply_off = 0;
+		req->rq_reply_off = 0;
 	}
 
 	return 0;
Signature · 1 line
2.1.0
#3 lore raw

PATCH 3/4 staging/lustre/ptlrpc: Fix potential NULL pointer dereference

In reply to [email protected]

From: Oleg Drokin <[email protected]>

In lov_unpackmd() there's this strange bit of code where we first try to look inside of lmm striping pattern for it's type, and then we check if the pattern is NULL which cannot be right. Move the check under if (lmm) branch so that it's safe.

Found by Coverity version 6.6.1

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

Signed-off: Oleg Drokin <[email protected]>

---
 drivers/staging/lustre/lustre/lov/lov_pack.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/staging/lustre/lustre/lov/lov_pack.c +2 -1
index 5356d53..92b9ffe 100644
@@ -367,9 +367,11 @@ int lov_unpackmd(struct obd_export *exp,  struct lov_stripe_md **lsmp,
 		if (rc)
 			return rc;
 		magic = le32_to_cpu(lmm->lmm_magic);
+		pattern = le32_to_cpu(lmm->lmm_pattern);
 	} else {
 		magic = LOV_MAGIC;
 		stripe_count = lov_get_stripecnt(lov, magic, 0);
+		pattern = LOV_PATTERN_RAID0;
 	}
 
 	/* If we aren't passed an lsmp struct, we just want the size */
@@ -384,7 +386,6 @@ int lov_unpackmd(struct obd_export *exp,  struct lov_stripe_md **lsmp,
 		return 0;
 	}
 
-	pattern = le32_to_cpu(lmm->lmm_pattern);
 	lsm_size = lov_alloc_memmd(lsmp, stripe_count, pattern, magic);
 	if (lsm_size < 0)
 		return lsm_size;
Signature · 1 line
2.1.0
#4 lore raw

PATCH 4/4 staging/lustre/llite: Fix wrong identing in ll_setxattr_common

In reply to [email protected]

From: Oleg Drokin <[email protected]>

smatch has highlighted wrong indenting that results from commit 7fc1f831d83f ("staging/lustre/llite: extended attribute cache")

---
 drivers/staging/lustre/lustre/llite/xattr.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/staging/lustre/lustre/llite/xattr.c +5 -5
index e0fcbe1..362a87d 100644
@@ -188,11 +188,11 @@ int ll_setxattr_common(struct inode *inode, const char *name,
 		valid |= rce_ops2valid(rce->rce_ops);
 	}
 #endif
-		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);
+	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);
Signature · 1 line
2.1.0