Whamcloud - gitweb
LU-1452 scrub: OI scrub skips uninitialized groups 37/12737/5
authorFan Yong <fan.yong@intel.com>
Thu, 11 Sep 2014 23:55:43 +0000 (07:55 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 3 Dec 2014 02:29:07 +0000 (02:29 +0000)
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 <fan.yong@intel.com>
Change-Id: Ie8a2eb1269d288865ce51d40e211e3db54d062af
Reviewed-on: http://review.whamcloud.com/12737
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Lai Siyao <lai.siyao@intel.com>
lustre/osd-ldiskfs/osd_scrub.c
lustre/tests/sanity-scrub.sh

index 547bb11..709d650 100644 (file)
@@ -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, &param, &oic, noslot);
                        switch (rc) {
                        case SCRUB_NEXT_BREAK:
index c19e59e..c612cdb 100644 (file)
@@ -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