Commit c319b58b authored by Vlad Apostolov's avatar Vlad Apostolov Committed by Lachlan McIlroy

[XFS] Make xfs_bulkstat() to report unlinked but referenced inodes

We need xfs_bulkstat() to report inode stat for inodes with link count
zero but reference count non zero.

The fix here:

http://oss.sgi.com/archives/xfs/2007-09/msg00266.html

changed this behavior and made xfs_bulkstat() to filter all unlinked
inodes including those that are not destroyed yet but held by reference.

The attached patch returns back to the original behavior by marking the
on-disk inode buffer "dirty" when di_mode is cleared (at that time both
inode link and reference counter are zero).

SGI-PV: 972004
SGI-Modid: xfs-linux-melb:xfs-kern:29914a
Signed-off-by: default avatarVlad Apostolov <vapo@sgi.com>
Signed-off-by: default avatarDavid Chinner <dgc@sgi.com>
Signed-off-by: default avatarLachlan McIlroy <lachlan@sgi.com>
parent 98ce2b5b
...@@ -1953,24 +1953,6 @@ xfs_iunlink( ...@@ -1953,24 +1953,6 @@ xfs_iunlink(
ASSERT(agi->agi_unlinked[bucket_index]); ASSERT(agi->agi_unlinked[bucket_index]);
ASSERT(be32_to_cpu(agi->agi_unlinked[bucket_index]) != agino); ASSERT(be32_to_cpu(agi->agi_unlinked[bucket_index]) != agino);
error = xfs_itobp(mp, tp, ip, &dip, &ibp, 0, 0);
if (error)
return error;
/*
* Clear the on-disk di_nlink. This is to prevent xfs_bulkstat
* from picking up this inode when it is reclaimed (its incore state
* initialzed but not flushed to disk yet). The in-core di_nlink is
* already cleared in xfs_droplink() and a corresponding transaction
* logged. The hack here just synchronizes the in-core to on-disk
* di_nlink value in advance before the actual inode sync to disk.
* This is OK because the inode is already unlinked and would never
* change its di_nlink again for this inode generation.
* This is a temporary hack that would require a proper fix
* in the future.
*/
dip->di_core.di_nlink = 0;
if (be32_to_cpu(agi->agi_unlinked[bucket_index]) != NULLAGINO) { if (be32_to_cpu(agi->agi_unlinked[bucket_index]) != NULLAGINO) {
/* /*
* There is already another inode in the bucket we need * There is already another inode in the bucket we need
...@@ -1978,6 +1960,10 @@ xfs_iunlink( ...@@ -1978,6 +1960,10 @@ xfs_iunlink(
* Here we put the head pointer into our next pointer, * Here we put the head pointer into our next pointer,
* and then we fall through to point the head at us. * and then we fall through to point the head at us.
*/ */
error = xfs_itobp(mp, tp, ip, &dip, &ibp, 0, 0);
if (error)
return error;
ASSERT(be32_to_cpu(dip->di_next_unlinked) == NULLAGINO); ASSERT(be32_to_cpu(dip->di_next_unlinked) == NULLAGINO);
/* both on-disk, don't endian flip twice */ /* both on-disk, don't endian flip twice */
dip->di_next_unlinked = agi->agi_unlinked[bucket_index]; dip->di_next_unlinked = agi->agi_unlinked[bucket_index];
...@@ -2367,6 +2353,8 @@ xfs_ifree( ...@@ -2367,6 +2353,8 @@ xfs_ifree(
int error; int error;
int delete; int delete;
xfs_ino_t first_ino; xfs_ino_t first_ino;
xfs_dinode_t *dip;
xfs_buf_t *ibp;
ASSERT(ismrlocked(&ip->i_lock, MR_UPDATE)); ASSERT(ismrlocked(&ip->i_lock, MR_UPDATE));
ASSERT(ip->i_transp == tp); ASSERT(ip->i_transp == tp);
...@@ -2402,8 +2390,27 @@ xfs_ifree( ...@@ -2402,8 +2390,27 @@ xfs_ifree(
* by reincarnations of this inode. * by reincarnations of this inode.
*/ */
ip->i_d.di_gen++; ip->i_d.di_gen++;
xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
error = xfs_itobp(ip->i_mount, tp, ip, &dip, &ibp, 0, 0);
if (error)
return error;
/*
* Clear the on-disk di_mode. This is to prevent xfs_bulkstat
* from picking up this inode when it is reclaimed (its incore state
* initialzed but not flushed to disk yet). The in-core di_mode is
* already cleared and a corresponding transaction logged.
* The hack here just synchronizes the in-core to on-disk
* di_mode value in advance before the actual inode sync to disk.
* This is OK because the inode is already unlinked and would never
* change its di_mode again for this inode generation.
* This is a temporary hack that would require a proper fix
* in the future.
*/
dip->di_core.di_mode = 0;
if (delete) { if (delete) {
xfs_ifree_cluster(ip, tp, first_ino); xfs_ifree_cluster(ip, tp, first_ino);
} }
......
...@@ -291,7 +291,7 @@ xfs_bulkstat_use_dinode( ...@@ -291,7 +291,7 @@ xfs_bulkstat_use_dinode(
dip = (xfs_dinode_t *) dip = (xfs_dinode_t *)
xfs_buf_offset(bp, clustidx << mp->m_sb.sb_inodelog); xfs_buf_offset(bp, clustidx << mp->m_sb.sb_inodelog);
/* /*
* Check the buffer containing the on-disk inode for di_nlink == 0. * Check the buffer containing the on-disk inode for di_mode == 0.
* This is to prevent xfs_bulkstat from picking up just reclaimed * This is to prevent xfs_bulkstat from picking up just reclaimed
* inodes that have their in-core state initialized but not flushed * inodes that have their in-core state initialized but not flushed
* to disk yet. This is a temporary hack that would require a proper * to disk yet. This is a temporary hack that would require a proper
...@@ -299,7 +299,7 @@ xfs_bulkstat_use_dinode( ...@@ -299,7 +299,7 @@ xfs_bulkstat_use_dinode(
*/ */
if (be16_to_cpu(dip->di_core.di_magic) != XFS_DINODE_MAGIC || if (be16_to_cpu(dip->di_core.di_magic) != XFS_DINODE_MAGIC ||
!XFS_DINODE_GOOD_VERSION(dip->di_core.di_version) || !XFS_DINODE_GOOD_VERSION(dip->di_core.di_version) ||
!dip->di_core.di_nlink) !dip->di_core.di_mode)
return 0; return 0;
if (flags & BULKSTAT_FG_QUICK) { if (flags & BULKSTAT_FG_QUICK) {
*dipp = dip; *dipp = dip;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment