public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [REVIEW 4 of 4] Fix race in xfs_iunpin
@ 2006-10-24  7:22 David Chinner
  0 siblings, 0 replies; only message in thread
From: David Chinner @ 2006-10-24  7:22 UTC (permalink / raw)
  To: xfs; +Cc: t-nagano, xfs-dev


-- 
Dave Chinner
Principal Engineer
SGI Australian Software Group


Close a race condition in xfs_iunpin() -  we need to guarantee the
atomicity of the last unpin and the checking of the XFS_IRECLAIM*
flags otherwise pre-emption or interrupt can cause us to race with
xfs_iget_core() which would now see the inode as unpinned and hence
clear the XFS_IRECLAIMABLE flag.

---
 fs/xfs/xfs_inode.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Index: 2.6.x-xfs-new/fs/xfs/xfs_inode.c
===================================================================
--- 2.6.x-xfs-new.orig/fs/xfs/xfs_inode.c	2006-10-19 10:26:01.983441994 +1000
+++ 2.6.x-xfs-new/fs/xfs/xfs_inode.c	2006-10-19 10:29:31.008384156 +1000
@@ -2741,7 +2741,7 @@ xfs_iunpin(
 {
 	ASSERT(atomic_read(&ip->i_pincount) > 0);
 
-	if (atomic_dec_and_test(&ip->i_pincount)) {
+	if (atomic_dec_and_lock(&ip->i_pincount, &ip->i_flags_lock)) {
 
 		/*
 		 * If the inode is currently being reclaimed, the link between
@@ -2760,7 +2760,6 @@ xfs_iunpin(
 		 * unpinned.
 		 */
 
-		spin_lock(&ip->i_flags_lock);
 		if (!__xfs_iflags_test(ip, XFS_IRECLAIM|XFS_IRECLAIMABLE)) {
 			bhv_vnode_t	*vp = XFS_ITOV_NULL(ip);
 			struct inode *inode = NULL;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-10-24  7:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-24  7:22 [REVIEW 4 of 4] Fix race in xfs_iunpin David Chinner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox