aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_inode.c
diff options
context:
space:
mode:
authorVlad Apostolov <vapo@sgi.com>2007-11-23 00:27:51 -0500
committerLachlan McIlroy <lachlan@redback.melbourne.sgi.com>2008-02-07 02:13:37 -0500
commitc319b58b13bb22f9a2478825b06c641c825f51ec (patch)
tree92d259656210a8bd698e02aac28b37c32d6a9e3e /fs/xfs/xfs_inode.c
parent98ce2b5b1bd6db9f8d510b4333757fa6b1efe131 (diff)
[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: Vlad Apostolov <vapo@sgi.com> Signed-off-by: David Chinner <dgc@sgi.com> Signed-off-by: Lachlan McIlroy <lachlan@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_inode.c')
-rw-r--r--fs/xfs/xfs_inode.c43
1 files changed, 25 insertions, 18 deletions
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 6d5641ff08f6..597e0ed4d2b6 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -1953,24 +1953,6 @@ xfs_iunlink(
1953 ASSERT(agi->agi_unlinked[bucket_index]); 1953 ASSERT(agi->agi_unlinked[bucket_index]);
1954 ASSERT(be32_to_cpu(agi->agi_unlinked[bucket_index]) != agino); 1954 ASSERT(be32_to_cpu(agi->agi_unlinked[bucket_index]) != agino);
1955 1955
1956 error = xfs_itobp(mp, tp, ip, &dip, &ibp, 0, 0);
1957 if (error)
1958 return error;
1959
1960 /*
1961 * Clear the on-disk di_nlink. This is to prevent xfs_bulkstat
1962 * from picking up this inode when it is reclaimed (its incore state
1963 * initialzed but not flushed to disk yet). The in-core di_nlink is
1964 * already cleared in xfs_droplink() and a corresponding transaction
1965 * logged. The hack here just synchronizes the in-core to on-disk
1966 * di_nlink value in advance before the actual inode sync to disk.
1967 * This is OK because the inode is already unlinked and would never
1968 * change its di_nlink again for this inode generation.
1969 * This is a temporary hack that would require a proper fix
1970 * in the future.
1971 */
1972 dip->di_core.di_nlink = 0;
1973
1974 if (be32_to_cpu(agi->agi_unlinked[bucket_index]) != NULLAGINO) { 1956 if (be32_to_cpu(agi->agi_unlinked[bucket_index]) != NULLAGINO) {
1975 /* 1957 /*
1976 * There is already another inode in the bucket we need 1958 * There is already another inode in the bucket we need
@@ -1978,6 +1960,10 @@ xfs_iunlink(
1978 * Here we put the head pointer into our next pointer, 1960 * Here we put the head pointer into our next pointer,
1979 * and then we fall through to point the head at us. 1961 * and then we fall through to point the head at us.
1980 */ 1962 */
1963 error = xfs_itobp(mp, tp, ip, &dip, &ibp, 0, 0);
1964 if (error)
1965 return error;
1966
1981 ASSERT(be32_to_cpu(dip->di_next_unlinked) == NULLAGINO); 1967 ASSERT(be32_to_cpu(dip->di_next_unlinked) == NULLAGINO);
1982 /* both on-disk, don't endian flip twice */ 1968 /* both on-disk, don't endian flip twice */
1983 dip->di_next_unlinked = agi->agi_unlinked[bucket_index]; 1969 dip->di_next_unlinked = agi->agi_unlinked[bucket_index];
@@ -2367,6 +2353,8 @@ xfs_ifree(
2367 int error; 2353 int error;
2368 int delete; 2354 int delete;
2369 xfs_ino_t first_ino; 2355 xfs_ino_t first_ino;
2356 xfs_dinode_t *dip;
2357 xfs_buf_t *ibp;
2370 2358
2371 ASSERT(ismrlocked(&ip->i_lock, MR_UPDATE)); 2359 ASSERT(ismrlocked(&ip->i_lock, MR_UPDATE));
2372 ASSERT(ip->i_transp == tp); 2360 ASSERT(ip->i_transp == tp);
@@ -2402,8 +2390,27 @@ xfs_ifree(
2402 * by reincarnations of this inode. 2390 * by reincarnations of this inode.
2403 */ 2391 */
2404 ip->i_d.di_gen++; 2392 ip->i_d.di_gen++;
2393
2405 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); 2394 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
2406 2395
2396 error = xfs_itobp(ip->i_mount, tp, ip, &dip, &ibp, 0, 0);
2397 if (error)
2398 return error;
2399
2400 /*
2401 * Clear the on-disk di_mode. This is to prevent xfs_bulkstat
2402 * from picking up this inode when it is reclaimed (its incore state
2403 * initialzed but not flushed to disk yet). The in-core di_mode is
2404 * already cleared and a corresponding transaction logged.
2405 * The hack here just synchronizes the in-core to on-disk
2406 * di_mode value in advance before the actual inode sync to disk.
2407 * This is OK because the inode is already unlinked and would never
2408 * change its di_mode again for this inode generation.
2409 * This is a temporary hack that would require a proper fix
2410 * in the future.
2411 */
2412 dip->di_core.di_mode = 0;
2413
2407 if (delete) { 2414 if (delete) {
2408 xfs_ifree_cluster(ip, tp, first_ino); 2415 xfs_ifree_cluster(ip, tp, first_ino);
2409 } 2416 }