Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
[powerpc.git] / fs / xfs / xfs_itable.c
index efeeafe..9972992 100644 (file)
@@ -290,8 +290,16 @@ xfs_bulkstat_use_dinode(
                return 1;
        dip = (xfs_dinode_t *)
                        xfs_buf_offset(bp, clustidx << mp->m_sb.sb_inodelog);
+       /*
+        * Check the buffer containing the on-disk inode for di_nlink == 0.
+        * This is to prevent xfs_bulkstat from picking up just reclaimed
+        * inodes that have their in-core state initialized but not flushed
+        * to disk yet. This is a temporary hack that would require a proper
+        * fix in the future.
+        */
        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)
                return 0;
        if (flags & BULKSTAT_FG_QUICK) {
                *dipp = dip;
@@ -611,21 +619,25 @@ xfs_bulkstat(
                                                }
                                        }
                                }
+                               ino = XFS_AGINO_TO_INO(mp, agno, agino);
+                               bno = XFS_AGB_TO_DADDR(mp, agno, agbno);
                                /*
                                 * Skip if this inode is free.
                                 */
-                               if (XFS_INOBT_MASK(chunkidx) & irbp->ir_free)
+                               if (XFS_INOBT_MASK(chunkidx) & irbp->ir_free) {
+                                       lastino = ino;
                                        continue;
+                               }
                                /*
                                 * Count used inodes as free so we can tell
                                 * when the chunk is used up.
                                 */
                                irbp->ir_freecount++;
-                               ino = XFS_AGINO_TO_INO(mp, agno, agino);
-                               bno = XFS_AGB_TO_DADDR(mp, agno, agbno);
                                if (!xfs_bulkstat_use_dinode(mp, flags, bp,
-                                                            clustidx, &dip))
+                                                            clustidx, &dip)) {
+                                       lastino = ino;
                                        continue;
+                               }
                                /*
                                 * If we need to do an iget, cannot hold bp.
                                 * Drop it, until starting the next cluster.
@@ -686,8 +698,7 @@ xfs_bulkstat(
                        if (end_of_ag) {
                                agno++;
                                agino = 0;
-                       } else
-                               agino = XFS_INO_TO_AGINO(mp, lastino);
+                       }
                } else
                        break;
        }