From: Fan Yong Date: Thu, 11 Sep 2014 23:55:43 +0000 (+0800) Subject: LU-1452 scrub: OI scrub skips uninitialized groups X-Git-Tag: 2.6.91~40 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=9ce1fdd9b79bca5cd4dbeb4740fbc889c573d5fc LU-1452 scrub: OI scrub skips uninitialized groups If the ldiskfs group descriptor is marked as LDISKFS_BG_INODE_UNINIT, then means that the inodes in such group have never been initialized, so the otable based iterator can skip this group directly to speed up the scanning. If the iteration position reaches the unused inodes area in the group descriptor (indicated by bg_itable_unused), then skip the rest inodes in this group to reduce the scanning time. Signed-off-by: Fan Yong Change-Id: Ie8a2eb1269d288865ce51d40e211e3db54d062af Reviewed-on: http://review.whamcloud.com/12737 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Lai Siyao --- diff --git a/lustre/osd-ldiskfs/osd_scrub.c b/lustre/osd-ldiskfs/osd_scrub.c index 547bb11..709d6505 100644 --- a/lustre/osd-ldiskfs/osd_scrub.c +++ b/lustre/osd-ldiskfs/osd_scrub.c @@ -1164,8 +1164,22 @@ static int osd_inode_iteration(struct osd_thread_info *info, while (*pos <= limit && *count < max) { struct osd_idmap_cache *oic = NULL; + struct ldiskfs_group_desc *desc; param.bg = (*pos - 1) / LDISKFS_INODES_PER_GROUP(param.sb); + desc = ldiskfs_get_group_desc(param.sb, param.bg, NULL); + if (desc == NULL) + RETURN(-EIO); + + ldiskfs_lock_group(param.sb, param.bg); + if (desc->bg_flags & cpu_to_le16(LDISKFS_BG_INODE_UNINIT)) { + ldiskfs_unlock_group(param.sb, param.bg); + *pos = 1 + (param.bg + 1) * + LDISKFS_INODES_PER_GROUP(param.sb); + continue; + } + ldiskfs_unlock_group(param.sb, param.bg); + param.offset = (*pos - 1) % LDISKFS_INODES_PER_GROUP(param.sb); param.gbase = 1 + param.bg * LDISKFS_INODES_PER_GROUP(param.sb); param.bitmap = ldiskfs_read_inode_bitmap(param.sb, param.bg); @@ -1179,6 +1193,11 @@ static int osd_inode_iteration(struct osd_thread_info *info, while (param.offset < LDISKFS_INODES_PER_GROUP(param.sb) && *count < max) { + if (param.offset + + ldiskfs_itable_unused_count(param.sb, desc) > + LDISKFS_INODES_PER_GROUP(param.sb)) + goto next_group; + rc = next(info, dev, ¶m, &oic, noslot); switch (rc) { case SCRUB_NEXT_BREAK: diff --git a/lustre/tests/sanity-scrub.sh b/lustre/tests/sanity-scrub.sh index c19e59e..c612cdb 100644 --- a/lustre/tests/sanity-scrub.sh +++ b/lustre/tests/sanity-scrub.sh @@ -24,7 +24,8 @@ SAVED_OSTSIZE=${OSTSIZE} SAVED_OSTCOUNT=${OSTCOUNT} # use small MDS + OST size to speed formatting time # do not use too small MDSSIZE/OSTSIZE, which affect the default journal size -MDSSIZE=100000 +# 200M MDT device can guarantee uninitialized groups during the OI scrub +MDSSIZE=200000 OSTSIZE=100000 # no need too much OSTs, to reduce the format/start/stop overhead [ $OSTCOUNT -gt 4 ] && OSTCOUNT=4