Skip to contentSkip to conversation

xfs: properly account for reclaimed inodes

PATCH In review Johannes Weiner 5 participants 9 messages Oct 1, 2010 – Oct 7, 2010 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: properly account for reclaimed inodes

When marking an inode reclaimable, a per-AG counter is increased, the inode is tagged reclaimable in its per-AG tree, and, when this is the first reclaimable inode in the AG, the AG entry in the per-mount tree is also tagged.

When an inode is finally reclaimed, however, it is only deleted from the per-AG tree. Neither the counter is decreased, nor is the parent tree's AG entry untagged properly.

Since the tags in the per-mount tree are not cleared, the inode shrinker iterates over all AGs that have had reclaimable inodes at one point in time.

The counters on the other hand signal an increasing amount of slab objects to reclaim. Since "70e60ce xfs: convert inode shrinker to per-filesystem context" this is not a real issue anymore because the shrinker bails out after one iteration.

But the problem was observable on a machine running v2.6.34, where the reclaimable work increased and each process going into direct reclaim eventually got stuck on the xfs inode shrinking path, trying to scan several million objects.

Fix this by properly unwinding the reclaimable-state tracking of an inode when it is reclaimed.

---
 fs/xfs/linux-2.6/xfs_sync.c |   19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)
fs/xfs/linux-2.6/xfs_sync.c +14 -5
index d59c4a6..81976ff 100644
@@ -668,14 +668,11 @@ xfs_inode_set_reclaim_tag(
 	xfs_perag_put(pag);
 }
 
-void
-__xfs_inode_clear_reclaim_tag(
-	xfs_mount_t	*mp,
+STATIC void
+__xfs_inode_clear_reclaim(
 	xfs_perag_t	*pag,
 	xfs_inode_t	*ip)
 {
-	radix_tree_tag_clear(&pag->pag_ici_root,
-			XFS_INO_TO_AGINO(mp, ip->i_ino), XFS_ICI_RECLAIM_TAG);
 	pag->pag_ici_reclaimable--;
 	if (!pag->pag_ici_reclaimable) {
 		/* clear the reclaim tag from the perag radix tree */
@@ -689,6 +686,17 @@ __xfs_inode_clear_reclaim_tag(
 	}
 }
 
+void
+__xfs_inode_clear_reclaim_tag(
+	xfs_mount_t	*mp,
+	xfs_perag_t	*pag,
+	xfs_inode_t	*ip)
+{
+	radix_tree_tag_clear(&pag->pag_ici_root,
+			XFS_INO_TO_AGINO(mp, ip->i_ino), XFS_ICI_RECLAIM_TAG);
+	__xfs_inode_clear_reclaim(pag, ip);
+}
+
 /*
  * Inodes in different states need to be treated differently, and the return
  * value of xfs_iflush is not sufficient to get this right. The following table
@@ -838,6 +846,7 @@ reclaim:
 	if (!radix_tree_delete(&pag->pag_ici_root,
 				XFS_INO_TO_AGINO(ip->i_mount, ip->i_ino)))
 		ASSERT(0);
+	__xfs_inode_clear_reclaim(pag, ip);
 	write_unlock(&pag->pag_ici_lock);
 
 	/*
Signature · 6 lines
1.7.2.3

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Reviewed-by on v1 1/1
#1 lore raw
Quoted 23 lines · Johannes Weiner

When marking an inode reclaimable, a per-AG counter is increased, the inode is tagged reclaimable in its per-AG tree, and, when this is the first reclaimable inode in the AG, the AG entry in the per-mount tree is also tagged.

When an inode is finally reclaimed, however, it is only deleted from the per-AG tree. Neither the counter is decreased, nor is the parent tree's AG entry untagged properly.

Since the tags in the per-mount tree are not cleared, the inode shrinker iterates over all AGs that have had reclaimable inodes at one point in time.

The counters on the other hand signal an increasing amount of slab objects to reclaim. Since "70e60ce xfs: convert inode shrinker to per-filesystem context" this is not a real issue anymore because the shrinker bails out after one iteration.

But the problem was observable on a machine running v2.6.34, where the reclaimable work increased and each process going into direct reclaim eventually got stuck on the xfs inode shrinking path, trying to scan several million objects.

Quoted 5 lines

Fix this by properly unwinding the reclaimable-state tracking of an inode when it is reclaimed.

Looks OK to me, and has run through a few hours of testing without problems.

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Reviewed-by on v1 1/1
#2 lore raw
In reply to Johannes Weiner
Quoted 23 lines · Johannes Weiner

When marking an inode reclaimable, a per-AG counter is increased, the inode is tagged reclaimable in its per-AG tree, and, when this is the first reclaimable inode in the AG, the AG entry in the per-mount tree is also tagged.

When an inode is finally reclaimed, however, it is only deleted from the per-AG tree. Neither the counter is decreased, nor is the parent tree's AG entry untagged properly.

Since the tags in the per-mount tree are not cleared, the inode shrinker iterates over all AGs that have had reclaimable inodes at one point in time.

The counters on the other hand signal an increasing amount of slab objects to reclaim. Since "70e60ce xfs: convert inode shrinker to per-filesystem context" this is not a real issue anymore because the shrinker bails out after one iteration.

But the problem was observable on a machine running v2.6.34, where the reclaimable work increased and each process going into direct reclaim eventually got stuck on the xfs inode shrinking path, trying to scan several million objects.

Quoted 5 lines

Fix this by properly unwinding the reclaimable-state tracking of an inode when it is reclaimed.

Yes, this looks right to me. The state was correctly adjusted in xfs_iget_cache_hit() when a RECLAIMABLE inode is found in the cache, but it was not done when reclaim completes.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#3 lore raw
Quoted 30 lines · Alex Elder
Quoted 23 lines · Johannes Weiner

When marking an inode reclaimable, a per-AG counter is increased, the inode is tagged reclaimable in its per-AG tree, and, when this is the first reclaimable inode in the AG, the AG entry in the per-mount tree is also tagged.

When an inode is finally reclaimed, however, it is only deleted from the per-AG tree. Neither the counter is decreased, nor is the parent tree's AG entry untagged properly.

Since the tags in the per-mount tree are not cleared, the inode shrinker iterates over all AGs that have had reclaimable inodes at one point in time.

The counters on the other hand signal an increasing amount of slab objects to reclaim. Since "70e60ce xfs: convert inode shrinker to per-filesystem context" this is not a real issue anymore because the shrinker bails out after one iteration.

But the problem was observable on a machine running v2.6.34, where the reclaimable work increased and each process going into direct reclaim eventually got stuck on the xfs inode shrinking path, trying to scan several million objects.

Quoted 5 lines

Fix this by properly unwinding the reclaimable-state tracking of an inode when it is reclaimed.

Quoted 6 lines

Yes, this looks right to me. The state was correctly adjusted in xfs_iget_cache_hit() when a RECLAIMABLE inode is found in the cache, but it was not done when reclaim completes.

Alex, can you push this to Linus ASAP? This needs to go back to stable kernels as well..

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#4 lore raw

Hi,

Quoted 36 lines · Dave Chinner
Quoted 35 lines · Alex Elder
Quoted 23 lines · Johannes Weiner

When marking an inode reclaimable, a per-AG counter is increased, the inode is tagged reclaimable in its per-AG tree, and, when this is the first reclaimable inode in the AG, the AG entry in the per-mount tree is also tagged.

When an inode is finally reclaimed, however, it is only deleted from the per-AG tree. Neither the counter is decreased, nor is the parent tree's AG entry untagged properly.

Since the tags in the per-mount tree are not cleared, the inode shrinker iterates over all AGs that have had reclaimable inodes at one point in time.

The counters on the other hand signal an increasing amount of slab objects to reclaim. Since "70e60ce xfs: convert inode shrinker to per-filesystem context" this is not a real issue anymore because the shrinker bails out after one iteration.

But the problem was observable on a machine running v2.6.34, where the reclaimable work increased and each process going into direct reclaim eventually got stuck on the xfs inode shrinking path, trying to scan several million objects.

Quoted 5 lines

Fix this by properly unwinding the reclaimable-state tracking of an inode when it is reclaimed.

Yes, this looks right to me. The state was correctly adjusted in xfs_iget_cache_hit() when a RECLAIMABLE inode is found in the cache, but it was not done when reclaim completes.

Quoted 4 lines
Quoted 1 line

Alex, can you push this to Linus ASAP? This needs to go back to stable kernels as well..

Here is my suggestion of a backport to .34. Dave, Alex, do you approve?

Hannes

fs/xfs/xfs_iget.c +1 -0
index 6845db9..3314f2a 100644
@@ -499,6 +499,7 @@ xfs_ireclaim(
 	write_lock(&pag->pag_ici_lock);
 	if (!radix_tree_delete(&pag->pag_ici_root, agino))
 		ASSERT(0);
+	pag->pag_ici_reclaimable--;
 	write_unlock(&pag->pag_ici_lock);
 	xfs_perag_put(pag);
 

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#5 lore raw
Quoted 55 lines · On Monday 04 October 2010, 12:22:13 Johannes Weiner wrote:

Hi,

Quoted 36 lines · Dave Chinner
Quoted 35 lines · Alex Elder
Quoted 23 lines · Johannes Weiner

When marking an inode reclaimable, a per-AG counter is increased, the inode is tagged reclaimable in its per-AG tree, and, when this is the first reclaimable inode in the AG, the AG entry in the per-mount tree is also tagged.

When an inode is finally reclaimed, however, it is only deleted from the per-AG tree. Neither the counter is decreased, nor is the parent tree's AG entry untagged properly.

Since the tags in the per-mount tree are not cleared, the inode shrinker iterates over all AGs that have had reclaimable inodes at one point in time.

The counters on the other hand signal an increasing amount of slab objects to reclaim. Since "70e60ce xfs: convert inode shrinker to per-filesystem context" this is not a real issue anymore because the shrinker bails out after one iteration.

But the problem was observable on a machine running v2.6.34, where the reclaimable work increased and each process going into direct reclaim eventually got stuck on the xfs inode shrinking path, trying to scan several million objects.

Quoted 5 lines

Fix this by properly unwinding the reclaimable-state tracking of an inode when it is reclaimed.

Yes, this looks right to me. The state was correctly adjusted in xfs_iget_cache_hit() when a RECLAIMABLE inode is found in the cache, but it was not done when reclaim completes.

Quoted 4 lines
Quoted 1 line

Alex, can you push this to Linus ASAP? This needs to go back to stable kernels as well..

Here is my suggestion of a backport to .34. Dave, Alex, do you approve?

Hannes

fs/xfs/xfs_iget.c +0 -0
index 6845db9..3314f2a 100644

fs/xfs/xfs_iget.c xfs_ireclaim( · line 505

Quoted 7 lines
fs/xfs/xfs_iget.c +1 -0
@@ -499,6 +499,7 @@ xfs_ireclaim(
 	write_lock(&pag->pag_ici_lock);
 	if (!radix_tree_delete(&pag->pag_ici_root, agino))
 		ASSERT(0);
+	pag->pag_ici_reclaimable--;
 	write_unlock(&pag->pag_ici_lock);
 	xfs_perag_put(pag);
 

Ping?

Masters of xfs, please raise your voices!

Pete

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

Reviewed-by
#6 lore raw
Quoted 66 lines · Hans-Peter Jansen
Quoted 55 lines · On Monday 04 October 2010, 12:22:13 Johannes Weiner wrote:

Hi,

Quoted 36 lines · Dave Chinner
Quoted 35 lines · Alex Elder
Quoted 23 lines · Johannes Weiner

When marking an inode reclaimable, a per-AG counter is increased, the inode is tagged reclaimable in its per-AG tree, and, when this is the first reclaimable inode in the AG, the AG entry in the per-mount tree is also tagged.

When an inode is finally reclaimed, however, it is only deleted from the per-AG tree. Neither the counter is decreased, nor is the parent tree's AG entry untagged properly.

Since the tags in the per-mount tree are not cleared, the inode shrinker iterates over all AGs that have had reclaimable inodes at one point in time.

The counters on the other hand signal an increasing amount of slab objects to reclaim. Since "70e60ce xfs: convert inode shrinker to per-filesystem context" this is not a real issue anymore because the shrinker bails out after one iteration.

But the problem was observable on a machine running v2.6.34, where the reclaimable work increased and each process going into direct reclaim eventually got stuck on the xfs inode shrinking path, trying to scan several million objects.

Quoted 5 lines

Fix this by properly unwinding the reclaimable-state tracking of an inode when it is reclaimed.

Yes, this looks right to me. The state was correctly adjusted in xfs_iget_cache_hit() when a RECLAIMABLE inode is found in the cache, but it was not done when reclaim completes.

Quoted 4 lines
Quoted 1 line

Alex, can you push this to Linus ASAP? This needs to go back to stable kernels as well..

Here is my suggestion of a backport to .34. Dave, Alex, do you approve?

Hannes

fs/xfs/xfs_iget.c +0 -0
index 6845db9..3314f2a 100644

fs/xfs/xfs_iget.c xfs_ireclaim( · line 505

Quoted 7 lines
fs/xfs/xfs_iget.c +1 -0
@@ -499,6 +499,7 @@ xfs_ireclaim(
 	write_lock(&pag->pag_ici_lock);
 	if (!radix_tree_delete(&pag->pag_ici_root, agino))
 		ASSERT(0);
+	pag->pag_ici_reclaimable--;
 	write_unlock(&pag->pag_ici_lock);
 	xfs_perag_put(pag);
 

Ping?

Quoted 3 lines

Masters of xfs, please raise your voices!

Pete

I know I'm a little late to the game in saying so, but I do agree this looks like the right fix for the .34 stable branch.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

Reviewed-by
#7 lore raw
In reply to Johannes Weiner
Quoted 54 lines · Johannes Weiner

Hi,

Quoted 36 lines · Dave Chinner
Quoted 35 lines · Alex Elder
Quoted 23 lines · Johannes Weiner

When marking an inode reclaimable, a per-AG counter is increased, the inode is tagged reclaimable in its per-AG tree, and, when this is the first reclaimable inode in the AG, the AG entry in the per-mount tree is also tagged.

When an inode is finally reclaimed, however, it is only deleted from the per-AG tree. Neither the counter is decreased, nor is the parent tree's AG entry untagged properly.

Since the tags in the per-mount tree are not cleared, the inode shrinker iterates over all AGs that have had reclaimable inodes at one point in time.

The counters on the other hand signal an increasing amount of slab objects to reclaim. Since "70e60ce xfs: convert inode shrinker to per-filesystem context" this is not a real issue anymore because the shrinker bails out after one iteration.

But the problem was observable on a machine running v2.6.34, where the reclaimable work increased and each process going into direct reclaim eventually got stuck on the xfs inode shrinking path, trying to scan several million objects.

Quoted 5 lines

Fix this by properly unwinding the reclaimable-state tracking of an inode when it is reclaimed.

Yes, this looks right to me. The state was correctly adjusted in xfs_iget_cache_hit() when a RECLAIMABLE inode is found in the cache, but it was not done when reclaim completes.

Quoted 4 lines
Quoted 1 line

Alex, can you push this to Linus ASAP? This needs to go back to stable kernels as well..

Here is my suggestion of a backport to .34. Dave, Alex, do you approve?

Hannes

fs/xfs/xfs_iget.c +0 -0
index 6845db9..3314f2a 100644

fs/xfs/xfs_iget.c xfs_ireclaim( · line 504

Quoted 6 lines
fs/xfs/xfs_iget.c +1 -0
@@ -499,6 +499,7 @@ xfs_ireclaim(
 	write_lock(&pag->pag_ici_lock);
 	if (!radix_tree_delete(&pag->pag_ici_root, agino))
 		ASSERT(0);
+	pag->pag_ici_reclaimable--;
 	write_unlock(&pag->pag_ici_lock);
 	xfs_perag_put(pag);

Looks good to me.

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Tested-by
#8 lore raw
Quoted 64 lines · Dave Chinner
Quoted 54 lines · Johannes Weiner

Hi,

Quoted 36 lines · Dave Chinner
Quoted 35 lines · Alex Elder
Quoted 23 lines · Johannes Weiner

When marking an inode reclaimable, a per-AG counter is increased, the inode is tagged reclaimable in its per-AG tree, and, when this is the first reclaimable inode in the AG, the AG entry in the per-mount tree is also tagged.

When an inode is finally reclaimed, however, it is only deleted from the per-AG tree. Neither the counter is decreased, nor is the parent tree's AG entry untagged properly.

Since the tags in the per-mount tree are not cleared, the inode shrinker iterates over all AGs that have had reclaimable inodes at one point in time.

The counters on the other hand signal an increasing amount of slab objects to reclaim. Since "70e60ce xfs: convert inode shrinker to per-filesystem context" this is not a real issue anymore because the shrinker bails out after one iteration.

But the problem was observable on a machine running v2.6.34, where the reclaimable work increased and each process going into direct reclaim eventually got stuck on the xfs inode shrinking path, trying to scan several million objects.

Quoted 5 lines

Fix this by properly unwinding the reclaimable-state tracking of an inode when it is reclaimed.

Yes, this looks right to me. The state was correctly adjusted in xfs_iget_cache_hit() when a RECLAIMABLE inode is found in the cache, but it was not done when reclaim completes.

Quoted 4 lines
Quoted 1 line

Alex, can you push this to Linus ASAP? This needs to go back to stable kernels as well..

Here is my suggestion of a backport to .34. Dave, Alex, do you approve?

Hannes

fs/xfs/xfs_iget.c +0 -0
index 6845db9..3314f2a 100644

fs/xfs/xfs_iget.c xfs_ireclaim( · line 504

Quoted 6 lines
fs/xfs/xfs_iget.c +1 -0
@@ -499,6 +499,7 @@ xfs_ireclaim(
 	write_lock(&pag->pag_ici_lock);
 	if (!radix_tree_delete(&pag->pag_ici_root, agino))
 		ASSERT(0);
+	pag->pag_ici_reclaimable--;
 	write_unlock(&pag->pag_ici_lock);
 	xfs_perag_put(pag);

Looks good to me.

Quoted 1 line

i've got this in production and things seem to be acting a lot more like I would expect.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs