xfs
[Top] [All Lists]

[PATCH 3/3 RESEND] xfs_repair: handle fragmented multiblock dir2 in proc

To: Eric Sandeen <sandeen@xxxxxxxxxx>
Subject: [PATCH 3/3 RESEND] xfs_repair: handle fragmented multiblock dir2 in process_leaf_node_dir2()
From: Eric Sandeen <sandeen@xxxxxxxxxxx>
Date: Tue, 22 May 2012 08:42:38 -0500
Cc: xfs-oss <xfs@xxxxxxxxxxx>
In-reply-to: <4FBABCAB.20300@xxxxxxxxxx>
References: <4FBABCAB.20300@xxxxxxxxxx>
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:12.0) Gecko/20120428 Thunderbird/12.0.1
process_leaf_node_dir2() had the following loop:

        while ((dbno = blkmap_next_off(blkmap, ndbno, &t)) < mp->m_dirleafblk) {
                ...
                ndbno = dbno + mp->m_dirblkfsbs - 1;
                ...
        }

which does not account for fragmented multiblock dir2.

ndbno was blindly being advanced by m_dirblkfsbs, but then
blkmap_next_off() would return the logical block of the next
mapped extent in blkmap, which may be within the current
(fragmented) dir2 multi-block, not the next multi-block,
because the extent index t hadn't been advanced.

Fix this by calling blkmap_next_off() until ndbno has advanced
into the next multiblock dir2 block, thereby keeping
the extent index t straight while properly advancing
ndbno.

Signed-off-by: Eric Sandeen <sandeen@xxxxxxxxxx>
---

Resending, first one didn't make it through the mailing list gauntlet

diff --git a/repair/dir2.c b/repair/dir2.c
index f9562d7..7a614a8 100644
--- a/repair/dir2.c
+++ b/repair/dir2.c
@@ -2003,7 +2003,11 @@ process_leaf_node_dir2(
        ndbno = NULLDFILOFF;
        while ((dbno = blkmap_next_off(blkmap, ndbno, &t)) < mp->m_dirleafblk) {
                nex = blkmap_getn(blkmap, dbno, mp->m_dirblkfsbs, &bmp, &lbmp);
-               ndbno = dbno + mp->m_dirblkfsbs - 1;
+               /* Advance through map to last dfs block in this dir block */
+               ndbno = dbno;
+               while (ndbno < dbno + mp->m_dirblkfsbs - 1) {
+                       ndbno = blkmap_next_off(blkmap, ndbno, &t);
+               }
                if (nex == 0) {
                        do_warn(
 _("block %" PRIu64 " for directory inode %" PRIu64 " is missing\n"),




<Prev in Thread] Current Thread [Next in Thread>