From 57217b7e4e5e8fc63dc948bdbb6b3227997abe5f Mon Sep 17 00:00:00 2001 From: Alexander Boyko Date: Wed, 8 Nov 2023 05:32:55 -0500 Subject: [PATCH] LU-17280 scrub: skip dir stripes with OI After fresh mount and LFSCK start all directory stripes are added to inconsistent list. So scrub for all stripes would print LFSCK message "inconsistent OI FID...fixed. Lets check FID to OI mapping before adding to inconsistent list. Also fixing additional debug for scrub. HPE-bug-id: LUS-11777 Signed-off-by: Alexander Boyko Change-Id: I869f1cf71eb6c10f386a3f388a38032c73d2b41a Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/53078 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Lai Siyao Reviewed-by: Alexander Zarochentsev Reviewed-by: Oleg Drokin --- lustre/lfsck/lfsck_namespace.c | 3 ++- lustre/lfsck/lfsck_striped_dir.c | 2 +- lustre/osd-ldiskfs/osd_handler.c | 5 ++++- lustre/osd-ldiskfs/osd_scrub.c | 19 +++++++++++-------- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/lustre/lfsck/lfsck_namespace.c b/lustre/lfsck/lfsck_namespace.c index 6aef951..82eff71 100644 --- a/lustre/lfsck/lfsck_namespace.c +++ b/lustre/lfsck/lfsck_namespace.c @@ -577,7 +577,8 @@ log: if (th != NULL && !IS_ERR(th)) dt_trans_stop(env, dev, th); - CDEBUG(D_LFSCK, "%s: namespace LFSCK %s flags for "DFID" in the " + CDEBUG(rc ? D_LFSCK : D_INFO, + "%s: namespace LFSCK %s flags for "DFID" in the " "trace file, flags %x, old %x, new %x: rc = %d\n", lfsck_lfsck2name(lfsck), add ? "add" : "del", PFID(fid), (__u32)flags, (__u32)old, (__u32)new, rc); diff --git a/lustre/lfsck/lfsck_striped_dir.c b/lustre/lfsck/lfsck_striped_dir.c index eae958d..6cc6034 100644 --- a/lustre/lfsck/lfsck_striped_dir.c +++ b/lustre/lfsck/lfsck_striped_dir.c @@ -495,7 +495,7 @@ static int lfsck_record_lmv(const struct lu_env *env, int rc = 0; ENTRY; - CDEBUG(D_LFSCK, "%s: record slave LMV EA for the striped directory " + CDEBUG(D_INFO, "%s: record slave LMV EA for the striped directory " DFID": shard = "DFID", index = %u, flags = %u, flags2 = %u, " "depth = %d\n", lfsck_lfsck2name(lfsck), PFID(lfsck_dto2fid(dir)), PFID(fid), diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c index e42fff1..6850059 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -951,6 +951,7 @@ static int osd_stripe_dir_filldir(void *buf, struct osd_thread_info *oti = oclb->oclb_info; struct lu_fid *fid = &oti->oti_fid3; struct osd_inode_id *id = &oti->oti_id3; + struct osd_inode_id id2; struct osd_device *dev = oclb->oclb_dev; struct inode *inode; @@ -974,7 +975,9 @@ static int osd_stripe_dir_filldir(void *buf, iput(inode); osd_add_oi_cache(oti, dev, id, fid); - osd_scrub_oi_insert(dev, fid, id, true); + /* Check shard by scrub only if it has a problem with OI */ + if (osd_oi_lookup(oti, dev, fid, &id2, 0) || !osd_id_eq(id, &id2)) + osd_scrub_oi_insert(dev, fid, id, true); oclb->oclb_found = true; return 1; diff --git a/lustre/osd-ldiskfs/osd_scrub.c b/lustre/osd-ldiskfs/osd_scrub.c index f99798c..9501da1 100644 --- a/lustre/osd-ldiskfs/osd_scrub.c +++ b/lustre/osd-ldiskfs/osd_scrub.c @@ -208,10 +208,10 @@ int osd_scrub_refresh_mapping(struct osd_thread_info *info, osd_dto_credits_noquota[DTO_INDEX_INSERT]); if (IS_ERR(th)) { rc = PTR_ERR(th); - CDEBUG(D_LFSCK, "%s: fail to start trans for scrub op %d " - DFID" => %u/%u: rc = %d\n", osd_name(dev), ops, - PFID(fid), id ? id->oii_ino : -1, id ? id->oii_gen : -1, - rc); + CWARN("%s: fail to start trans for scrub op %d " + DFID" => %u/%u: rc = %d\n", osd_name(dev), ops, + PFID(fid), id ? id->oii_ino : -1, id ? id->oii_gen : -1, + rc); RETURN(rc); } @@ -1235,9 +1235,10 @@ static int osd_scrub_main(void *args) scrub->os_pos_current = ooc->ooc_pos_preload; } - CDEBUG(D_LFSCK, "%s: OI scrub start, flags = 0x%x, pos = %llu\n", + CDEBUG(D_LFSCK, "%s: OI scrub start, flags = 0x%x, pos = %llu%s\n", osd_scrub2name(scrub), scrub->os_start_flags, - scrub->os_pos_current); + scrub->os_pos_current, + scrub->os_file.sf_param & SP_DRYRUN ? " dryrun mode" : ""); rc = osd_inode_iteration(osd_oti_get(&env), dev, ~0U, false); if (unlikely(rc == SCRUB_IT_CRASH)) { @@ -1261,8 +1262,10 @@ post: dev->od_check_ff = 0; } rc = scrub_thread_post(&env, &dev->od_scrub.os_scrub, rc); - CDEBUG(D_LFSCK, "%s: OI scrub: stop, pos = %llu: rc = %d\n", - osd_scrub2name(scrub), scrub->os_pos_current, rc); + CDEBUG(D_LFSCK, "%s: OI scrub: stop, pos = %llu: rc = %d%s\n", + osd_scrub2name(scrub), scrub->os_pos_current, rc, + scrub->os_file.sf_param & SP_DRYRUN ? " dryrun mode" : ""); + out: osd_scrub_ois_fini(scrub, &scrub->os_inconsistent_items); -- 1.8.3.1