[PATCH 3/5] xfs_repair: fix dir refcount when '.' missing and dir is rebuilt

Eric Sandeen
2014-09-07T16:41:11Z

In phase 6's longform_dir2_entry_check, if we never
find a '.' entry we never add a reference to that entry;
if we subsequently rebuild it, '.' gets added, but
no ref to it is ever made. This leads to Phase 7 doing
i.e.:

Phase 7 - verify and correct link counts...
resetting inode 5184 nlinks from 2 to 1

and the next run will do:

Phase 7 - verify and correct link counts...
resetting inode 5184 nlinks from 1 to 2

So if '.' was never found, but the directory got
rebuilt, manually add the ref for it.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
repair/phase6.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/repair/phase6.c b/repair/phase6.c
index f13069f..cc36a9c 100644
--- a/repair/phase6.c
+++ b/repair/phase6.c
@@ -2288,6 +2288,12 @@ out_fix:
if (bplist[i])
libxfs_putbuf(bplist[i]);
longform_dir2_rebuild(mp, ino, ip, irec, ino_offset, hashtab);
+ /*
+ * If we didn't find a dot, we never added a ref for it;
+ * it's there now after the rebuild, so mark it as reached.
+ */
+ if (*need_dot)
+ add_inode_ref(irec, ino_offset);
*num_illegal = 0;
*need_dot = 0;
} else {
--
1.7.1