[SSI] openssi/kernel/cluster/ssi/cfs inode.c,1.72,1.73

Roger Tsang <[email protected]> Wed, 18 Dec 2013 08:04:56 +0000
Newsgroups gmane.linux.cluster.ssic.cvs
Message-ID <[email protected]>
Update of /cvsroot/ssic-linux/openssi/kernel/cluster/ssi/cfs
In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv11048/cluster/ssi/cfs

Modified Files:
      Tag: OPENSSI-FC
	inode.c 
Log Message:
cfs_getattr: acquire CFS_ATTR token. fix possible stale attribute cache at remote cluster nodes. regression introduced in CVS tag OPENSSI-FC-1-9-6-PRE63


Index: inode.c
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/kernel/cluster/ssi/cfs/inode.c,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -d -r1.72 -r1.73
--- inode.c	16 Nov 2011 07:49:37 -0000	1.72
+++ inode.c	18 Dec 2013 08:04:54 -0000	1.73
@@ -901,9 +901,6 @@
 	int error, result;
 #ifdef CFS_FILE_WRITE_LIVELOCK_FIX
 	int rwlocked; /* non-zero: i_alloc_sem held */
-
-	/* Linux: called from notify_change() with down_write on i_alloc_sem */
-	rwlocked = (attr->ia_valid & ATTR_SIZE);
 #endif
 #ifdef CFS_SETATTR_LAZY
 	if (attr->ia_valid & ATTR_SIZE) {
@@ -927,6 +924,14 @@
 	 *                      (notify_change)
 	 *     ->CFSTOK_ATTR    (cfs_setattr)
 	 */
+	/* Hold ATTR token non-blocking */
+	result = cfstok_req(inode, CFSTOK_ATTR, CFSTOK_EXCL,
+				CFSTOK_HOLD, NON_RANGE, NULL);
+	if (result == CFSTOK_HELD) {
+		rwlocked = 0;
+		goto cfstok_held; /* avoid Linux i_sem dance */
+	}
+	rwlocked = (attr->ia_valid & ATTR_SIZE);
 	if (rwlocked)
 		up_write(&inode->i_alloc_sem);
 #endif
@@ -942,22 +947,20 @@
 				CFSTOK_BLOCK|CFSTOK_HOLD, NON_RANGE, NULL);
 	down(&inode->i_sem);
 #ifdef CFSTOK_INTR
-	if (result == CFSTOK_INTERRUPTED) {
+	if (unlikely(result == CFSTOK_INTERRUPTED)) {
 #ifdef DEBUG
 		printk(KERN_DEBUG "%s: Interrupted\n", __FUNCTION__);
 #endif
-#ifdef CFS_FILE_WRITE_LIVELOCK_FIX
-		if (rwlocked)
-			down_write(&inode->i_alloc_sem);
-#endif
-		return -ERESTARTSYS;
+		error = -ERESTARTSYS;
+		goto out_intr;
 	}
 #endif /* CFSTOK_INTR */
 	SSI_ASSERT(result == CFSTOK_HELD);
+#ifdef CFS_FILE_WRITE_LIVELOCK_FIX
+cfstok_held:
+#endif
 
 	cfs_begin_data_update(inode);
-#ifdef CFS_SKIP
-	/* SSI: No need to flush. Got token */
 #ifdef CFS_SETATTR_LAZY_FLUSH
         /* Write all dirty data if we're changing file permissions or size */
         if ((attr->ia_valid & (ATTR_MODE|ATTR_UID|ATTR_GID|ATTR_SIZE)) != 0) {
@@ -970,7 +973,6 @@
 	if (error)
 		goto out;
 #endif
-#endif /* CFS_SKIP */
 
 	/* CFS can verify operation here, because we are holding tokens
 	 * and the inode is up to date.
@@ -1023,6 +1025,9 @@
 	cfs_end_data_update(inode);
 	/* Release token */
 	cfstok_relse(inode, CFSTOK_ATTR, CFSTOK_EXCL, NON_RANGE);
+#ifdef CFSTOK_INTR
+out_intr:
+#endif
 #ifdef CFS_FILE_WRITE_LIVELOCK_FIX
 	if (rwlocked)
 		down_write(&inode->i_alloc_sem);
@@ -1321,7 +1326,7 @@
 {
 	struct inode *inode = dentry->d_inode;
 	int	status;
-#ifdef CFS_ZAP_CACHES
+#ifdef CFS_FILE_RW_NOLOCK
 	int need_atime;
 #endif
 
@@ -1333,10 +1338,24 @@
  		goto out_nowait;
 	}
 
+#ifndef CFS_FILE_RW_NOLOCK
+	/* Hold ATTR token */
+	status = cfstok_req(inode, CFSTOK_ATTR, CFSTOK_SR,
+				CFSTOK_BLOCK|CFSTOK_HOLD, NON_RANGE, NULL);
+#ifdef CFSTOK_INTR
+	if (status == CFSTOK_INTERRUPTED) {
+#ifdef DEBUG
+		printk(KERN_DEBUG "%s: Interrupted\n", __FUNCTION__);
+#endif
+		return -ERESTARTSYS;
+	}
+#endif /* CFSTOK_INTR */
+	SSI_ASSERT(status == CFSTOK_HELD);
+	status = 0; /* attributes received with token */
+#else /* CFS_FILE_RW_NOLOCK */
 	/* SSI: no longer acquire CFSTOK_ATTR token in SR mode.
 	 * Linux VFS intends to grab attributes in real-time.
 	 */
-#ifdef CFS_ZAP_CACHES
 	need_atime = 1;
 	if (IS_NOATIME(inode))
 		need_atime = 0;
@@ -1352,9 +1371,13 @@
 	} else
 		status = cfs_revalidate_inode(inode);
 	if (!status)
-#endif /* CFS_ZAP_CACHES */
+#endif /* CFS_FILE_RW_NOLOCK */
 	generic_fillattr(inode, stat);
 
+#ifndef CFS_FILE_RW_NOLOCK
+	/* Release token */
+	cfstok_relse(inode, CFSTOK_ATTR, CFSTOK_SR, NON_RANGE);
+#endif /* !CFS_FILE_RW_NOLOCK */
 out_nowait:
 	dfprintk(PAGECACHE, "CFS: (%x/%ld) revalidation complete\n",
 		inode->i_sb->s_dev, inode->i_ino);


------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk