From d4c190375625bc94a9548c7088bd4d8eef8d87b2 Mon Sep 17 00:00:00 2001 From: Bob Peterson Date: Apr 18 2017 13:07:45 +0000 Subject: fsck.gfs2: Make pass2 go by directory rbtree for performance This patch speeds up pass2 of fsck.gfs2 for large file systems. Before, pass2 was checking the bitmap for every block in the file system. If the file system is 15TB, that means looping 15 trillion times. With this patch, it merely traverses the inode tree, since it needs that information anyway, and already ignores any blocks that don't have it. Traversing an empty 15TB file system goes from 13.5 minutes to 0.00 seconds for pass2. Signed-off-by: Bob Peterson --- diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c index 808cf21..abc2b96 100644 --- a/gfs2/fsck/pass2.c +++ b/gfs2/fsck/pass2.c @@ -2203,8 +2203,11 @@ static int pass2_check_dir(struct gfs2_sbd *sdp, struct gfs2_inode *ip) */ int pass2(struct gfs2_sbd *sdp) { + struct osi_node *tmp, *next = NULL; + struct gfs2_inode *ip; + struct dir_info *dt; uint64_t dirblk; - int q; + int error; /* Check all the system directory inodes. */ if (!sdp->gfs1 && @@ -2236,11 +2239,11 @@ int pass2(struct gfs2_sbd *sdp) return FSCK_OK; log_info( _("Checking directory inodes.\n")); /* Grab each directory inode, and run checks on it */ - for (dirblk = 0; dirblk < last_fs_block; dirblk++) { - struct gfs2_inode *ip; - struct dir_info *dt; - int error; + for (tmp = osi_first(&dirtree); tmp; tmp = next) { + next = osi_next(tmp); + dt = (struct dir_info *)tmp; + dirblk = dt->dinode.no_addr; warm_fuzzy_stuff(dirblk); if (skip_this_pass || fsck_abort) /* if asked to skip the rest */ return FSCK_OK; @@ -2249,14 +2252,6 @@ int pass2(struct gfs2_sbd *sdp) if (is_system_dir(sdp, dirblk)) continue; - q = bitmap_type(sdp, dirblk); - if (q != GFS2_BLKST_DINODE) - continue; - - dt = dirtree_find(dirblk); - if (dt == NULL) - continue; - /* If we created lost+found, its links should have been properly adjusted, so don't check it. */ if (lf_was_created &&