Skip to contentSkip to conversation

xfs: active inodes stat is broken

PATCH Superseded Dave Chinner 2 participants 5 messages Dec 1, 2014 – Dec 2, 2014 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: active inodes stat is broken

From: Dave Chinner <[email protected]>

vn_active only ever gets decremented, so it has a very large negative number. Make it track the inode count we currently have allocated properly so we can easily track the size of the inode cache via tools like PCP.

---
 fs/xfs/xfs_icache.c | 3 +++
 fs/xfs/xfs_super.c  | 1 -
 2 files changed, 3 insertions(+), 1 deletion(-)
fs/xfs/xfs_icache.c +3 -0
index 92ca910..8bc3d78 100644
@@ -128,6 +128,7 @@ xfs_inode_free(
 	/* asserts to verify all state is correct here */
 	ASSERT(atomic_read(&ip->i_pincount) == 0);
 	ASSERT(!xfs_isiflocked(ip));
+	XFS_STATS_DEC(vn_active);
 
 	call_rcu(&VFS_I(ip)->i_rcu, xfs_inode_free_callback);
 }
@@ -287,6 +288,8 @@ xfs_iget_cache_miss(
 	if (!ip)
 		return -ENOMEM;
 
+	XFS_STATS_INC(vn_active);
+
 	error = xfs_iread(mp, tp, ip, flags);
 	if (error)
 		goto out_destroy;
fs/xfs/xfs_super.c +0 -1
index fee11c8..6b95851 100644
@@ -1005,7 +1005,6 @@ xfs_fs_evict_inode(
 	clear_inode(inode);
 	XFS_STATS_INC(vn_rele);
 	XFS_STATS_INC(vn_remove);
-	XFS_STATS_DEC(vn_active);
 
 	xfs_inactive(ip);
 }
Signature · 6 lines
2.0.0

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#1 lore raw
Quoted 18 lines · Dave Chinner

From: Dave Chinner<[email protected]>

vn_active only ever gets decremented, so it has a very large negative number. Make it track the inode count we currently have allocated properly so we can easily track the size of the inode cache via tools like PCP.

---
  fs/xfs/xfs_icache.c | 3 +++
  fs/xfs/xfs_super.c  | 1 -
  2 files changed, 3 insertions(+), 1 deletion(-)
fs/xfs/xfs_icache.c +0 -0
index 92ca910..8bc3d78 100644

fs/xfs/xfs_icache.c xfs_inode_free( · line 134

Quoted 7 lines
fs/xfs/xfs_icache.c +1 -0
@@ -128,6 +128,7 @@ xfs_inode_free(
  	/* asserts to verify all state is correct here */
  	ASSERT(atomic_read(&ip->i_pincount) == 0);
  	ASSERT(!xfs_isiflocked(ip));
+	XFS_STATS_DEC(vn_active);
 
  	call_rcu(&VFS_I(ip)->i_rcu, xfs_inode_free_callback);
  }

Would the inode allocated and freed in xfs_recover_inode_owner_change() cause this the count to go negative?

--Mark.

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

#2 lore raw
Quoted 24 lines · Mark Tinguely
Quoted 23 lines · Dave Chinner

From: Dave Chinner<[email protected]>

vn_active only ever gets decremented, so it has a very large negative number. Make it track the inode count we currently have allocated properly so we can easily track the size of the inode cache via tools like PCP.

---
 fs/xfs/xfs_icache.c | 3 +++
 fs/xfs/xfs_super.c  | 1 -
 2 files changed, 3 insertions(+), 1 deletion(-)
fs/xfs/xfs_icache.c +1 -0
index 92ca910..8bc3d78 100644
@@ -128,6 +128,7 @@ xfs_inode_free(
 	/* asserts to verify all state is correct here */
 	ASSERT(atomic_read(&ip->i_pincount) == 0);
 	ASSERT(!xfs_isiflocked(ip));
+	XFS_STATS_DEC(vn_active);
 
Quoted 5 lines

fs/xfs/xfs_icache.c xfs_inode_free( · line 134

Quoted 2 lines
fs/xfs/xfs_icache.c +0 -0
 	call_rcu(&VFS_I(ip)->i_rcu, xfs_inode_free_callback);
 }

Would the inode allocated and freed in xfs_recover_inode_owner_change() cause this the count to go negative?

Good catch - it will. Recovering swap extent operations is pretty rare, so I wouldn't have noticed an off-by-one-or-two on a normal system where there are several thousand allocated and cached inodes even at idle. I'll fix it.

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

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

PATCH v2 1/1 xfs: active inodes stat is broken

From: Dave Chinner <[email protected]>

vn_active only ever gets decremented, so it has a very large negative number. Make it track the inode count we currently have allocated properly so we can easily track the size of the inode cache via tools like PCP.

---
Version 2:
- move stat increment to inode allocation code rather than cache miss code so that inc/dec are evenly balanced no matter who calls them.

 fs/xfs/xfs_icache.c | 2 ++
 fs/xfs/xfs_super.c  | 1 -
 2 files changed, 2 insertions(+), 1 deletion(-)
fs/xfs/xfs_icache.c +2 -0
index 92ca910..9771b7e 100644
@@ -63,6 +63,7 @@ xfs_inode_alloc(
 		return NULL;
 	}
 
+	XFS_STATS_INC(vn_active);
 	ASSERT(atomic_read(&ip->i_pincount) == 0);
 	ASSERT(!spin_is_locked(&ip->i_flags_lock));
 	ASSERT(!xfs_isiflocked(ip));
@@ -128,6 +129,7 @@ xfs_inode_free(
 	/* asserts to verify all state is correct here */
 	ASSERT(atomic_read(&ip->i_pincount) == 0);
 	ASSERT(!xfs_isiflocked(ip));
+	XFS_STATS_DEC(vn_active);
 
 	call_rcu(&VFS_I(ip)->i_rcu, xfs_inode_free_callback);
 }
fs/xfs/xfs_super.c +0 -1
index fee11c8..6b95851 100644
@@ -1005,7 +1005,6 @@ xfs_fs_evict_inode(
 	clear_inode(inode);
 	XFS_STATS_INC(vn_rele);
 	XFS_STATS_INC(vn_remove);
-	XFS_STATS_DEC(vn_active);
 
 	xfs_inactive(ip);
 }

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

Reviewed-by on v2 1/1
#4 lore raw
Quoted 10 lines · Dave Chinner

From: Dave Chinner <[email protected]>

vn_active only ever gets decremented, so it has a very large negative number. Make it track the inode count we currently have allocated properly so we can easily track the size of the inode cache via tools like PCP.

---

Nice to have that working.

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