]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
repair: properly mark lost+found inode as used
authorCarlos Maiolino <cmaiolino@redhat.com>
Wed, 9 Nov 2011 16:54:07 +0000 (14:54 -0200)
committerChristoph Hellwig <hch@lst.de>
Thu, 10 Nov 2011 11:09:07 +0000 (11:09 +0000)
This patch makes mk_orphanage() to properly set the inode link count of
the recently allocated inode in the AVL tree, avoiding the lost+found
directory to be bypass the link count check in phase7 and possibly leaving
lost+found directory with a wrong link count.

Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
repair/phase6.c

index 1c82cb1914c6f920c98de9c9121defb0ee65faad..5b27cb4511648964b543ff2d2a35fb9cb553dff7 100644 (file)
@@ -823,6 +823,8 @@ mk_orphanage(xfs_mount_t *mp)
        xfs_inode_t     *ip;
        xfs_inode_t     *pip;
        xfs_fsblock_t   first;
+       ino_tree_node_t *irec;
+       int             ino_offset = 0;
        int             i;
        int             committed;
        int             error;
@@ -875,6 +877,19 @@ mk_orphanage(xfs_mount_t *mp)
                        ORPHANAGE, error);
        }
        ip->i_d.di_nlink++;             /* account for . */
+       ino = ip->i_ino;
+
+       irec = find_inode_rec(mp,
+                       XFS_INO_TO_AGNO(mp, ino),
+                       XFS_INO_TO_AGINO(mp, ino));
+       ino_offset = get_inode_offset(mp, ino, irec);
+
+       /*
+        * Mark the inode allocated to lost+found as used in the AVL tree
+        * so it is not skipped in phase 7
+        */
+       set_inode_used(irec, ino_offset);
+       add_inode_ref(irec, ino_offset);
 
        /*
         * now that we know the transaction will stay around,
@@ -902,6 +917,7 @@ mk_orphanage(xfs_mount_t *mp)
                                XFS_INO_TO_AGINO(mp, mp->m_sb.sb_rootino)), 0);
 
 
+
        libxfs_trans_log_inode(tp, pip, XFS_ILOG_CORE);
        libxfs_dir_init(tp, ip, pip);
        libxfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
@@ -912,9 +928,9 @@ mk_orphanage(xfs_mount_t *mp)
                        ORPHANAGE, error);
        }
 
-       ino = ip->i_ino;
 
        libxfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES|XFS_TRANS_SYNC);
+       add_inode_reached(irec,ino_offset);
 
        return(ino);
 }