[Cluster-devel] [gfs2-utils PATCH 7/7] fsck.gfs2: Make pass2 go by directory rbtree for performance

Bob Peterson rpeterso at redhat.com
Wed Jun 22 19:26:52 UTC 2016


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 <rpeterso at redhat.com>
---
 gfs2/fsck/pass2.c | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c
index f808cea..bc6828a 100644
--- a/gfs2/fsck/pass2.c
+++ b/gfs2/fsck/pass2.c
@@ -2088,8 +2088,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 &&
@@ -2121,11 +2124,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;
@@ -2134,14 +2137,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 &&
-- 
2.5.5




More information about the Cluster-devel mailing list