public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] Fix i_state of inode is changed after the inode is freed [try #2]
@ 2006-08-23 11:14 Masayuki Saito
  2006-08-24  7:16 ` Nathan Scott
  0 siblings, 1 reply; 6+ messages in thread
From: Masayuki Saito @ 2006-08-23 11:14 UTC (permalink / raw)
  To: Nathan Scott, David Chinner; +Cc: xfs, linux-kernel

Fix i_state of the inode is changed after the inode is freed.

Signed-off-by: Masayuki Saito <m-saito@tnes.nec.co.jp>
Signed-off-by: ASANO Masahiro <masano@tnes.nec.co.jp>
---

--- linux-2.6.17.7/fs/xfs/xfs_inode.c.orig	2006-08-21 20:15:58.385211286 +0900
+++ linux-2.6.17.7/fs/xfs/xfs_inode.c	2006-08-21 21:21:22.277033371 +0900
@@ -2751,18 +2751,30 @@ xfs_iunpin(
 		 * call as the inode reclaim may be blocked waiting for
 		 * the inode to become unpinned.
 		 */
+		int need_iput = 0;
+		struct inode *inode;
+		spin_lock(&ip->i_flags_lock);
 		if (!(ip->i_flags & (XFS_IRECLAIM|XFS_IRECLAIMABLE))) {
 			vnode_t	*vp = XFS_ITOV_NULL(ip);
 
 			/* make sync come back and flush this inode */
 			if (vp) {
-				struct inode	*inode = vn_to_inode(vp);
+				inode = vn_to_inode(vp);
 
-				if (!(inode->i_state & I_NEW))
-					mark_inode_dirty_sync(inode);
+				if (!(inode->i_state &
+						(I_NEW|I_FREEING|I_CLEAR))) {
+					inode = igrab(inode);
+					if (inode) {
+						need_iput = 1;
+						mark_inode_dirty_sync(inode);
+					}
+				}
 			}
 		}
+		spin_unlock(&ip->i_flags_lock);
 		wake_up(&ip->i_ipin_wait);
+		if (need_iput)
+			iput(inode);
 	}
 }

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] Fix i_state of inode is changed after the inode is freed [try #2]
  2006-08-23 11:14 [PATCH 2/2] Fix i_state of inode is changed after the inode is freed [try #2] Masayuki Saito
@ 2006-08-24  7:16 ` Nathan Scott
  2006-08-24 10:13   ` Masayuki Saito
  2006-08-31  2:44   ` Masayuki Saito
  0 siblings, 2 replies; 6+ messages in thread
From: Nathan Scott @ 2006-08-24  7:16 UTC (permalink / raw)
  To: Masayuki Saito, David Chinner; +Cc: xfs, linux-kernel

On Wed, Aug 23, 2006 at 08:14:45PM +0900, Masayuki Saito wrote:
> Fix i_state of the inode is changed after the inode is freed.
> 
> Signed-off-by: Masayuki Saito <m-saito@tnes.nec.co.jp>
> Signed-off-by: ASANO Masahiro <masano@tnes.nec.co.jp>

This version is producing a gcc warning...

fs/xfs/xfs_inode.c: In function 'xfs_iunpin':
fs/xfs/xfs_inode.c:2765: warning: 'inode' may be used uninitialized in this function

Which doesn't look correct due to your need_iput guard, but perhaps
we should do this instead...

cheers.

-- 
Nathan


Fix i_state of the inode is changed after the inode is freed.

Signed-off-by: Masayuki Saito <m-saito@tnes.nec.co.jp>
Signed-off-by: ASANO Masahiro <masano@tnes.nec.co.jp>
---

Index: xfs-linux/xfs_inode.c
===================================================================
--- xfs-linux.orig/xfs_inode.c	2006-08-24 17:02:36.896740000 +1000
+++ xfs-linux/xfs_inode.c	2006-08-24 17:09:29.430521750 +1000
@@ -2761,19 +2761,29 @@ xfs_iunpin(
 		 * call as the inode reclaim may be blocked waiting for
 		 * the inode to become unpinned.
 		 */
+		struct inode *inode = NULL;
+
+		spin_lock(&ip->i_flags_lock);
 		if (!(ip->i_flags & (XFS_IRECLAIM|XFS_IRECLAIMABLE))) {
 			bhv_vnode_t	*vp = XFS_ITOV_NULL(ip);
 
 			/* make sync come back and flush this inode */
 			if (vp) {
-				struct inode	*inode = vn_to_inode(vp);
+				inode = vn_to_inode(vp);
 
 				if (!(inode->i_state &
-						(I_NEW|I_FREEING|I_CLEAR)))
-					mark_inode_dirty_sync(inode);
+						(I_NEW|I_FREEING|I_CLEAR))) {
+					inode = igrab(inode);
+					if (inode)
+						mark_inode_dirty_sync(inode);
+				} else
+					inode = NULL;
 			}
 		}
+		spin_unlock(&ip->i_flags_lock);
 		wake_up(&ip->i_ipin_wait);
+		if (inode)
+			iput(inode);
 	}
 }
 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] Fix i_state of inode is changed after the inode is freed [try #2]
  2006-08-24  7:16 ` Nathan Scott
@ 2006-08-24 10:13   ` Masayuki Saito
  2006-08-31  2:44   ` Masayuki Saito
  1 sibling, 0 replies; 6+ messages in thread
From: Masayuki Saito @ 2006-08-24 10:13 UTC (permalink / raw)
  To: Nathan Scott; +Cc: David Chinner, xfs, linux-kernel

Hi, Nathan

>Which doesn't look correct due to your need_iput guard, but perhaps
>we should do this instead...

I think that your fix is simpler, so I agree it.


Masayuki

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] Fix i_state of inode is changed after the inode is freed [try #2]
  2006-08-24  7:16 ` Nathan Scott
  2006-08-24 10:13   ` Masayuki Saito
@ 2006-08-31  2:44   ` Masayuki Saito
  2006-08-31  3:19     ` Nathan Scott
  1 sibling, 1 reply; 6+ messages in thread
From: Masayuki Saito @ 2006-08-31  2:44 UTC (permalink / raw)
  To: Nathan Scott; +Cc: David Chinner, xfs, linux-kernel

Hi, Nathan


>Fix i_state of the inode is changed after the inode is freed.
>
>Signed-off-by: Masayuki Saito <m-saito@tnes.nec.co.jp>
>Signed-off-by: ASANO Masahiro <masano@tnes.nec.co.jp>
>---
>
>Index: xfs-linux/xfs_inode.c
>===================================================================
>--- xfs-linux.orig/xfs_inode.c	2006-08-24 17:02:36.896740000 +1000
>+++ xfs-linux/xfs_inode.c	2006-08-24 17:09:29.430521750 +1000
>@@ -2761,19 +2761,29 @@ xfs_iunpin(
> 		 * call as the inode reclaim may be blocked waiting for
> 		 * the inode to become unpinned.
> 		 */
>+		struct inode *inode = NULL;
>+
>+		spin_lock(&ip->i_flags_lock);
> 		if (!(ip->i_flags & (XFS_IRECLAIM|XFS_IRECLAIMABLE))) {
> 			bhv_vnode_t	*vp = XFS_ITOV_NULL(ip);
> 
> 			/* make sync come back and flush this inode */
> 			if (vp) {
>-				struct inode	*inode = vn_to_inode(vp);
>+				inode = vn_to_inode(vp);
> 
> 				if (!(inode->i_state &
>-						(I_NEW|I_FREEING|I_CLEAR)))
>-					mark_inode_dirty_sync(inode);
>+						(I_NEW|I_FREEING|I_CLEAR))) {
>+					inode = igrab(inode);
>+					if (inode)
>+						mark_inode_dirty_sync(inode);
>+				} else
>+					inode = NULL;
> 			}
> 		}
>+		spin_unlock(&ip->i_flags_lock);
> 		wake_up(&ip->i_ipin_wait);
>+		if (inode)
>+			iput(inode);
> 	}
> }

Are the patches going to be merged?

Masayuki

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] Fix i_state of inode is changed after the inode is freed [try #2]
  2006-08-31  2:44   ` Masayuki Saito
@ 2006-08-31  3:19     ` Nathan Scott
  2006-08-31  5:06       ` Masayuki Saito
  0 siblings, 1 reply; 6+ messages in thread
From: Nathan Scott @ 2006-08-31  3:19 UTC (permalink / raw)
  To: Masayuki Saito; +Cc: David Chinner, xfs, linux-kernel

On Thu, Aug 31, 2006 at 11:44:23AM +0900, Masayuki Saito wrote:
> Hi, Nathan
> 
> Are the patches going to be merged?

Yep, they're queued up for 2.6.19.  Since it was a race found
only on testing with a ramdisk (iirc) it didn't really seem to
me like they needed to be rushed through for a 2.6.18-rc.  The
race has also been there for the entire lifetime of the Linux
XFS port... so, not urgent (and not risk free either).

cheers.

-- 
Nathan

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] Fix i_state of inode is changed after the inode is freed [try #2]
  2006-08-31  3:19     ` Nathan Scott
@ 2006-08-31  5:06       ` Masayuki Saito
  0 siblings, 0 replies; 6+ messages in thread
From: Masayuki Saito @ 2006-08-31  5:06 UTC (permalink / raw)
  To: Nathan Scott; +Cc: David Chinner, xfs, linux-kernel

>> Are the patches going to be merged?
>
>Yep, they're queued up for 2.6.19.  Since it was a race found
>only on testing with a ramdisk (iirc) it didn't really seem to
>me like they needed to be rushed through for a 2.6.18-rc.  The
>race has also been there for the entire lifetime of the Linux
>XFS port... so, not urgent (and not risk free either).

Thanks, I agree it.  I'm looking forward to receiving the TAKE.
So far thank you, Nathan.  I wish to be glorious in your future.

cheers.

--
Masayuki

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-08-31  5:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-23 11:14 [PATCH 2/2] Fix i_state of inode is changed after the inode is freed [try #2] Masayuki Saito
2006-08-24  7:16 ` Nathan Scott
2006-08-24 10:13   ` Masayuki Saito
2006-08-31  2:44   ` Masayuki Saito
2006-08-31  3:19     ` Nathan Scott
2006-08-31  5:06       ` Masayuki Saito

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