From: Fan Yong Date: Sat, 23 May 2015 14:38:02 +0000 (+0800) Subject: LU-6380 scrub: handle update_log during initial scrub X-Git-Tag: 2.7.56~3 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=342149e654cdde71b34ad0148749adc7cf9f7cfe LU-6380 scrub: handle update_log during initial scrub The normal OI scrub will not run until recovery finished. But the update logs (update_log, and sub-items under update_log_dir) will be accessed during the recovery. So if the the OI mapping for the update log cannot be handled before the recovery, then the normal OI scrub cannot be started/resumed. To resolve above dependency, the initial OI scrub (that will be triggered by the mount process with sync mode before the recovery) will handle the update logs' OI mappings in advance. In DNE2, each MDT will have a special FID for update log, during recovery, the failover MDT can retrieve update logs on remote MDT by this FID, that said the FID is special and it also has to be located globally (not local FID). So the MDT index is packed into the FID (as f_oid), then FLD can locate the special FID. To handle such special FIDs, OI scrub needs to know the target index. Signed-off-by: Fan Yong Change-Id: Iac71c20c1f1631efbe19a03e380822cead6c00d1 Reviewed-on: http://review.whamcloud.com/15192 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: wangdi Reviewed-by: Oleg Drokin --- diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c index 508ec87..1e5f472 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -5842,7 +5842,9 @@ static int osd_device_init0(const struct lu_env *env, GOTO(out, rc); } - if (server_name_is_ost(o->od_svname)) + o->od_index = -1; /* -1 means index is invalid */ + rc = server_name2index(o->od_svname, &o->od_index, NULL); + if (rc == LDD_F_SV_TYPE_OST) o->od_is_ost = 1; o->od_full_scrub_ratio = OFSR_DEFAULT; diff --git a/lustre/osd-ldiskfs/osd_internal.h b/lustre/osd-ldiskfs/osd_internal.h index 885ab3b..0caaf0d 100644 --- a/lustre/osd-ldiskfs/osd_internal.h +++ b/lustre/osd-ldiskfs/osd_internal.h @@ -240,6 +240,7 @@ struct osd_device { od_index_in_idif:1; __u32 od_dirent_journal; + int od_index; struct proc_dir_entry *od_proc_entry; struct lprocfs_stats *od_stats; diff --git a/lustre/osd-ldiskfs/osd_scrub.c b/lustre/osd-ldiskfs/osd_scrub.c index 909967a..56a4a94 100644 --- a/lustre/osd-ldiskfs/osd_scrub.c +++ b/lustre/osd-ldiskfs/osd_scrub.c @@ -1526,6 +1526,8 @@ static int osd_ios_lf_fill(void *buf, const char *name, int namelen, loff_t offset, __u64 ino, unsigned d_type); static int osd_ios_dl_fill(void *buf, const char *name, int namelen, loff_t offset, __u64 ino, unsigned d_type); +static int osd_ios_uld_fill(void *buf, const char *name, int namelen, + loff_t offset, __u64 ino, unsigned d_type); static int osd_ios_general_scan(struct osd_thread_info *info, struct osd_device *dev, @@ -1543,6 +1545,7 @@ enum osd_lf_flags { OLF_HIDE_FID = 0x0002, OLF_SHOW_NAME = 0x0004, OLF_NO_OI = 0x0008, + OLF_IDX_IN_FID = 0x0010, }; struct osd_lf_map { @@ -1662,6 +1665,21 @@ static const struct osd_lf_map osd_lf_maps[] = { { "BATCHID", { FID_SEQ_LOCAL_FILE, BATCHID_COMMITTED_OID, 0 }, OLF_SHOW_NAME, sizeof("BATCHID") - 1, NULL, NULL }, + /* OSP update logs update_log{_dir} use f_seq = FID_SEQ_UPDATE_LOG{_DIR} + * and f_oid = index for their log files. See lu_update_log{_dir}_fid() + * for more details. */ + + /* update_log */ + { "update_log", { FID_SEQ_UPDATE_LOG, 0, 0 }, + OLF_SHOW_NAME | OLF_IDX_IN_FID, sizeof("update_log") - 1, + NULL, NULL }, + + /* update_log_dir */ + { "update_log_dir", { FID_SEQ_UPDATE_LOG_DIR, 0, 0 }, + OLF_SHOW_NAME | OLF_SCAN_SUBITEMS | OLF_IDX_IN_FID, + sizeof("update_log_dir") - 1, + osd_ios_general_scan, osd_ios_uld_fill }, + /* lost+found */ { "lost+found", { FID_SEQ_LOCAL_FILE, OSD_LPF_OID, 0 }, OLF_SCAN_SUBITEMS, sizeof("lost+found") - 1, @@ -1764,10 +1782,16 @@ osd_ios_scan_one(struct osd_thread_info *info, struct osd_device *dev, osd_id_gen(id, inode->i_ino, inode->i_generation); if (rc == -ENODATA) { - if (fid == NULL || fid_is_zero(fid) || flags & OLF_HIDE_FID) + if (fid == NULL || fid_is_zero(fid) || flags & OLF_HIDE_FID) { lu_igif_build(&tfid, inode->i_ino, inode->i_generation); - else + } else { tfid = *fid; + if (flags & OLF_IDX_IN_FID) { + LASSERT(dev->od_index >= 0); + + tfid.f_oid = dev->od_index; + } + } rc = osd_ea_fid_set(info, inode, &tfid, 0, 0); if (rc != 0) { CDEBUG(D_LFSCK, "%s: fail to set LMA for init OI " @@ -1950,6 +1974,35 @@ static int osd_ios_dl_fill(void *buf, const char *name, int namelen, RETURN(rc); } +static int osd_ios_uld_fill(void *buf, const char *name, int namelen, + loff_t offset, __u64 ino, unsigned d_type) +{ + struct osd_ios_filldir_buf *fill_buf = buf; + struct dentry *child; + struct lu_fid tfid; + int rc = 0; + ENTRY; + + /* skip any non-DFID format name */ + if (name[0] != '[') + RETURN(0); + + child = osd_ios_lookup_one_len(name, fill_buf->oifb_dentry, namelen); + if (IS_ERR(child)) + RETURN(PTR_ERR(child)); + + /* skip the start '[' */ + sscanf(&name[1], SFID, RFID(&tfid)); + if (fid_is_sane(&tfid)) + rc = osd_ios_scan_one(fill_buf->oifb_info, fill_buf->oifb_dev, + child->d_inode, &tfid, 0); + else + rc = -EIO; + dput(child); + + RETURN(rc); +} + static int osd_ios_root_fill(void *buf, const char *name, int namelen, loff_t offset, __u64 ino, unsigned d_type) { diff --git a/lustre/tests/sanity-lfsck.sh b/lustre/tests/sanity-lfsck.sh index 14b8c14..646a1f6 100644 --- a/lustre/tests/sanity-lfsck.sh +++ b/lustre/tests/sanity-lfsck.sh @@ -8,8 +8,8 @@ set -e ONLY=${ONLY:-"$*"} -#Bug number for excepting test 6380 -ALWAYS_EXCEPT="$SANITY_LFSCK_EXCEPT 4 5 " +#Bug number for excepting test +ALWAYS_EXCEPT="$SANITY_LFSCK_EXCEPT" [ "$SLOW" = "no" ] && EXCEPT_SLOW="" # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT! diff --git a/lustre/tests/sanity-scrub.sh b/lustre/tests/sanity-scrub.sh index 4124c2b..efb9a64 100644 --- a/lustre/tests/sanity-scrub.sh +++ b/lustre/tests/sanity-scrub.sh @@ -7,8 +7,8 @@ set -e ONLY=${ONLY:-"$*"} -#Bug number for excepting test 6380 -ALWAYS_EXCEPT="$SANITY_SCRUB_EXCEPT 1b 1c 2 3 4a 4b 4c 5 6 7 8 9 10 15" +#Bug number for excepting test 6705 +ALWAYS_EXCEPT="$SANITY_SCRUB_EXCEPT 1c 5 10" [ "$SLOW" = "no" ] && EXCEPT_SLOW="" # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT! @@ -578,7 +578,7 @@ test_5() { scrub_prep 1000 scrub_backup_restore 1 - echo "starting MDTs with OI scrub disabled" + echo "starting MDTs with OI scrub disabled (1)" scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB" scrub_check_status 3 init scrub_check_flags 4 inconsistent @@ -603,7 +603,7 @@ test_5() { do_nodes $(comma_list $(mdts_nodes)) \ $LCTL set_param fail_loc=0 fail_val=0 - echo "starting MDTs with OI scrub disabled" + echo "starting MDTs with OI scrub disabled (2)" scrub_start_mds 10 "$MOUNT_OPTS_NOSCRUB" scrub_check_status 11 crashed scrub_stop_mds 12 @@ -863,7 +863,7 @@ run_test 9 "OI scrub speed control" test_10a() { scrub_prep 0 scrub_backup_restore 1 - echo "starting mds$n with OI scrub disabled" + echo "starting mds$n with OI scrub disabled (1)" scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB" scrub_check_flags 4 inconsistent mount_client $MOUNT || error "(5) Fail to start client!" @@ -878,7 +878,7 @@ test_10a() { scrub_check_status 7 scanning umount_client $MOUNT || error "(8) Fail to stop client!" scrub_stop_mds 9 - echo "starting MDTs with OI scrub disabled" + echo "starting MDTs with OI scrub disabled (2)" scrub_start_mds 10 "$MOUNT_OPTS_NOSCRUB" scrub_check_status 11 paused scrub_stop_mds 12