[SSI] openssi/kernel/cluster/ssi/cfs cfs_server.c,1.19,1.20

Roger Tsang <[email protected]> Tue, 05 Jul 2011 22:01:23 +0000
Newsgroups gmane.linux.cluster.ssic.cvs
Message-ID <[email protected]>
Update of /cvsroot/ssic-linux/openssi/kernel/cluster/ssi/cfs
In directory vz-cvs-3.sog:/tmp/cvs-serv3562/ssi/cfs

Modified Files:
      Tag: OPENSSI-FC
	cfs_server.c 
Log Message:
cfs_rb_delayedunlinks: fix droot->i_sem deadlock in error path.


Index: cfs_server.c
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/kernel/cluster/ssi/cfs/cfs_server.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- cfs_server.c	17 Jan 2011 06:51:54 -0000	1.19
+++ cfs_server.c	5 Jul 2011 22:01:21 -0000	1.20
@@ -716,8 +716,6 @@
 
 	droot = sbtocmi(sb)->mi_pfs_sb->s_root;
 
-	down(&(droot->d_inode->i_sem));
-
 	/*
 	 * If .cfs_unlink directory exists, then read the directory and set
 	 * the delayed unlink bit if the file is still in use, otherwise
@@ -725,14 +723,15 @@
 	 * unlinks were done in the file system and there is nothing to
 	 * clean up so return.
 	 */
+	down(&droot->d_inode->i_sem);
 	ddir = lookup_one_len(CFS_UNLINKDIR, droot, strlen(CFS_UNLINKDIR));
-	if (IS_ERR(ddir)) {
+	if (unlikely(IS_ERR(ddir))) {
+		up(&droot->d_inode->i_sem);
 		error = PTR_ERR(ddir);
 		ddir = NULL;
 		goto done;
 	}
-
-	up(&(droot->d_inode->i_sem));
+	up(&droot->d_inode->i_sem);
 
 	dir = ddir->d_inode;
 
@@ -824,7 +823,7 @@
 			down(&dir->i_sem);
 
 			pdp = lookup_one_len(dp->d_name, ddir, strlen(dp->d_name));
-			if (IS_ERR(pdp)) {
+			if (unlikely(IS_ERR(pdp))) {
 				up(&dir->i_sem);
 				error = PTR_ERR((void *)pdp);
 				break;
@@ -883,7 +882,7 @@
 			} else if (S_ISDIR(pdp->d_inode->i_mode)) {
 				error = vfs_rmdir(dir, pdp);
 				up(&dir->i_sem);
-				if (error) {
+				if (unlikely(error)) {
 					printk(KERN_WARNING
 					  "cfs_rb_delayedunlinks: rmdir %s  "
 				 	  "returned %d \n", dp->d_name,error);
@@ -891,7 +890,7 @@
 			} else {
 				error = vfs_unlink(dir, pdp);
 				up(&dir->i_sem);
-				if (error) {
+				if (unlikely(error)) {
 					printk(KERN_WARNING
 					  "cfs_rb_delayedunlinks: remove %s  "
 				 	  "returned %d \n", dp->d_name,error);


------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security 
threats, fraudulent activity, and more. Splunk takes this data and makes 
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2