public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfs: check for not fully initialized inodes in xfs_ireclaim
@ 2009-11-12 19:06 Christoph Hellwig
  2009-11-30 20:07 ` Alex Elder
  2009-12-01 18:12 ` [PATCH V2] " Christoph Hellwig
  0 siblings, 2 replies; 5+ messages in thread
From: Christoph Hellwig @ 2009-11-12 19:06 UTC (permalink / raw)
  To: xfs

Add an assert for inodes not added to the inode cache in xfs_ireclaim, to make
sure we're not going to introduce something like the famous nfsd inode cache
bug again.

Signed-off-by: Christoph Hellwig <hch@lst.de>

Index: xfs/fs/xfs/xfs_iget.c
===================================================================
--- xfs.orig/fs/xfs/xfs_iget.c	2009-11-12 17:10:20.216276486 +0100
+++ xfs/fs/xfs/xfs_iget.c	2009-11-12 17:13:27.565003964 +0100
@@ -514,17 +514,21 @@ xfs_ireclaim(
 {
 	struct xfs_mount	*mp = ip->i_mount;
 	struct xfs_perag	*pag;
+	xfs_agino_t		agino = XFS_INO_TO_AGINO(mp, ip->i_ino);
 
 	XFS_STATS_INC(xs_ig_reclaims);
 
 	/*
-	 * Remove the inode from the per-AG radix tree.  It doesn't matter
-	 * if it was never added to it because radix_tree_delete can deal
-	 * with that case just fine.
+	 * Remove the inode from the per-AG radix tree.
+	 *
+	 * Because radix_tree_delete won't complain even if the item was never
+	 * added to the tree assert that it's been there before to catch
+	 * problems with the inode life time early on.
 	 */
 	pag = xfs_get_perag(mp, ip->i_ino);
 	write_lock(&pag->pag_ici_lock);
-	radix_tree_delete(&pag->pag_ici_root, XFS_INO_TO_AGINO(mp, ip->i_ino));
+	ASSERT(radix_tree_lookup(&pag->pag_ici_root, agino));
+	radix_tree_delete(&pag->pag_ici_root, agino);
 	write_unlock(&pag->pag_ici_lock);
 	xfs_put_perag(mp, pag);
 

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* RE: [PATCH] xfs: check for not fully initialized inodes in xfs_ireclaim
  2009-11-12 19:06 [PATCH] xfs: check for not fully initialized inodes in xfs_ireclaim Christoph Hellwig
@ 2009-11-30 20:07 ` Alex Elder
  2009-11-30 20:33   ` Christoph Hellwig
  2009-12-01 18:12 ` [PATCH V2] " Christoph Hellwig
  1 sibling, 1 reply; 5+ messages in thread
From: Alex Elder @ 2009-11-30 20:07 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: xfs

Christoph Hellwig wrote:
> Add an assert for inodes not added to the inode cache in xfs_ireclaim, to make
> sure we're not going to introduce something like the famous nfsd inode cache
> bug again.

I confess I have not looked at the radix tree
code in detail yet, but radix_tree_delete()
returns a value that is ignored here.  It reportedly
will return a null pointer if the index has no
corresponding item in the tree, so this could be
used in the assertion rather than doing a separate
lookup.

I think the change is fine, but would rather see
it done without the extra lookup (though there may
be a good reason for doing it anyway).

					-Alex

> Signed-off-by: Christoph Hellwig <hch@lst.de>
> 
> Index: xfs/fs/xfs/xfs_iget.c
> ===================================================================
> --- xfs.orig/fs/xfs/xfs_iget.c	2009-11-12 17:10:20.216276486 +0100
> +++ xfs/fs/xfs/xfs_iget.c	2009-11-12 17:13:27.565003964 +0100
> @@ -514,17 +514,21 @@ xfs_ireclaim(
>  {
>  	struct xfs_mount	*mp = ip->i_mount;
>  	struct xfs_perag	*pag;
> +	xfs_agino_t		agino = XFS_INO_TO_AGINO(mp, ip->i_ino);
> 
>  	XFS_STATS_INC(xs_ig_reclaims);
> 
>  	/*
> -	 * Remove the inode from the per-AG radix tree.  It doesn't matter
> -	 * if it was never added to it because radix_tree_delete can deal
> -	 * with that case just fine.
> +	 * Remove the inode from the per-AG radix tree.
> +	 *
> +	 * Because radix_tree_delete won't complain even if the item was never
> +	 * added to the tree assert that it's been there before to catch
> +	 * problems with the inode life time early on.
>  	 */
>  	pag = xfs_get_perag(mp, ip->i_ino);
>  	write_lock(&pag->pag_ici_lock);
> -	radix_tree_delete(&pag->pag_ici_root, XFS_INO_TO_AGINO(mp, ip->i_ino));
> +	ASSERT(radix_tree_lookup(&pag->pag_ici_root, agino));
> +	radix_tree_delete(&pag->pag_ici_root, agino);
>  	write_unlock(&pag->pag_ici_lock);
>  	xfs_put_perag(mp, pag);
> 
> 
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* Re: [PATCH] xfs: check for not fully initialized inodes in xfs_ireclaim
  2009-11-30 20:07 ` Alex Elder
@ 2009-11-30 20:33   ` Christoph Hellwig
  0 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2009-11-30 20:33 UTC (permalink / raw)
  To: Alex Elder; +Cc: Christoph Hellwig, xfs

On Mon, Nov 30, 2009 at 02:07:40PM -0600, Alex Elder wrote:
> Christoph Hellwig wrote:
> > Add an assert for inodes not added to the inode cache in xfs_ireclaim, to make
> > sure we're not going to introduce something like the famous nfsd inode cache
> > bug again.
> 
> I confess I have not looked at the radix tree
> code in detail yet, but radix_tree_delete()
> returns a value that is ignored here.  It reportedly
> will return a null pointer if the index has no
> corresponding item in the tree, so this could be
> used in the assertion rather than doing a separate
> lookup.
> 
> I think the change is fine, but would rather see
> it done without the extra lookup (though there may
> be a good reason for doing it anyway).

Sounds good, I'll redo it.

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* [PATCH V2] xfs: check for not fully initialized inodes in xfs_ireclaim
  2009-11-12 19:06 [PATCH] xfs: check for not fully initialized inodes in xfs_ireclaim Christoph Hellwig
  2009-11-30 20:07 ` Alex Elder
@ 2009-12-01 18:12 ` Christoph Hellwig
  2009-12-15 20:05   ` Alex Elder
  1 sibling, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2009-12-01 18:12 UTC (permalink / raw)
  To: xfs

Add an assert for inodes not added to the inode cache in xfs_ireclaim, to make
sure we're not going to introduce something like the famous nfsd inode cache
bug again.

Signed-off-by: Christoph Hellwig <hch@lst.de>

Index: xfs/fs/xfs/xfs_iget.c
===================================================================
--- xfs.orig/fs/xfs/xfs_iget.c	2009-11-26 19:10:47.206253628 +0100
+++ xfs/fs/xfs/xfs_iget.c	2009-12-01 19:09:43.310004091 +0100
@@ -514,17 +514,21 @@ xfs_ireclaim(
 {
 	struct xfs_mount	*mp = ip->i_mount;
 	struct xfs_perag	*pag;
+	xfs_agino_t		agino = XFS_INO_TO_AGINO(mp, ip->i_ino);
 
 	XFS_STATS_INC(xs_ig_reclaims);
 
 	/*
-	 * Remove the inode from the per-AG radix tree.  It doesn't matter
-	 * if it was never added to it because radix_tree_delete can deal
-	 * with that case just fine.
+	 * Remove the inode from the per-AG radix tree.
+	 *
+	 * Because radix_tree_delete won't complain even if the item was never
+	 * added to the tree assert that it's been there before to catch
+	 * problems with the inode life time early on.
 	 */
 	pag = xfs_get_perag(mp, ip->i_ino);
 	write_lock(&pag->pag_ici_lock);
-	radix_tree_delete(&pag->pag_ici_root, XFS_INO_TO_AGINO(mp, ip->i_ino));
+	if (!radix_tree_delete(&pag->pag_ici_root, agino))
+		ASSERT(0);
 	write_unlock(&pag->pag_ici_lock);
 	xfs_put_perag(mp, pag);
 

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* RE: [PATCH V2] xfs: check for not fully initialized inodes in xfs_ireclaim
  2009-12-01 18:12 ` [PATCH V2] " Christoph Hellwig
@ 2009-12-15 20:05   ` Alex Elder
  0 siblings, 0 replies; 5+ messages in thread
From: Alex Elder @ 2009-12-15 20:05 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: xfs

Christoph Hellwig wrote:
> Add an assert for inodes not added to the inode cache in xfs_ireclaim, to make
> sure we're not going to introduce something like the famous nfsd inode cache
> bug again.

It's a shame we can't do more than an ASSERT() here
(for non-debug builds).

Looks good though.

> Signed-off-by: Christoph Hellwig <hch@lst.de>

Reviewed-by: Alex Elder <aelder@sgi.com>

> Index: xfs/fs/xfs/xfs_iget.c
> ===================================================================
> --- xfs.orig/fs/xfs/xfs_iget.c	2009-11-26 19:10:47.206253628 +0100
> +++ xfs/fs/xfs/xfs_iget.c	2009-12-01 19:09:43.310004091 +0100
> @@ -514,17 +514,21 @@ xfs_ireclaim(
>  {
>  	struct xfs_mount	*mp = ip->i_mount;
>  	struct xfs_perag	*pag;
> +	xfs_agino_t		agino = XFS_INO_TO_AGINO(mp, ip->i_ino);
> 
>  	XFS_STATS_INC(xs_ig_reclaims);
> 
>  	/*
> -	 * Remove the inode from the per-AG radix tree.  It doesn't matter
> -	 * if it was never added to it because radix_tree_delete can deal
> -	 * with that case just fine.
> +	 * Remove the inode from the per-AG radix tree.
> +	 *
> +	 * Because radix_tree_delete won't complain even if the item was never
> +	 * added to the tree assert that it's been there before to catch
> +	 * problems with the inode life time early on.
>  	 */
>  	pag = xfs_get_perag(mp, ip->i_ino);
>  	write_lock(&pag->pag_ici_lock);
> -	radix_tree_delete(&pag->pag_ici_root, XFS_INO_TO_AGINO(mp, ip->i_ino));
> +	if (!radix_tree_delete(&pag->pag_ici_root, agino))
> +		ASSERT(0);
>  	write_unlock(&pag->pag_ici_lock);
>  	xfs_put_perag(mp, pag);
> 
> 
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

end of thread, other threads:[~2009-12-15 20:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-12 19:06 [PATCH] xfs: check for not fully initialized inodes in xfs_ireclaim Christoph Hellwig
2009-11-30 20:07 ` Alex Elder
2009-11-30 20:33   ` Christoph Hellwig
2009-12-01 18:12 ` [PATCH V2] " Christoph Hellwig
2009-12-15 20:05   ` Alex Elder

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