From e06b2ed956f45feffa3adc7e2e7399ab737b37be Mon Sep 17 00:00:00 2001 From: Li Dongyang Date: Tue, 15 Nov 2022 00:28:37 +1100 Subject: [PATCH] LU-8367 osp: wait for precreate on reformatted OST We should wait for precreate rpc to finish when we see a just reformatted/replaced OST, otherwise the client could try to access the object on OST before it's created. Do not use sync_trans when recreating the objects on the reformatted/replaced OST. Fix detecting reformatted OST for FID_SEQ_NORMAL, for such seqs the oid will be initialized as LUSTRE_FID_INIT_OID, which is 1. Change-Id: I4aebb9d573aa352dd7897e5f1129dc2117a084bb Fixes: 63e17799a3 ("LU-8367 osp: enable replay for precreation request") Signed-off-by: Li Dongyang Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/49151 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Alexander Boyko Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- lustre/ofd/ofd_dev.c | 2 ++ lustre/osp/osp_precreate.c | 22 ++++++++++++++-------- lustre/tests/conf-sanity.sh | 1 - 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/lustre/ofd/ofd_dev.c b/lustre/ofd/ofd_dev.c index fdc110d..5848454 100644 --- a/lustre/ofd/ofd_dev.c +++ b/lustre/ofd/ofd_dev.c @@ -1681,6 +1681,8 @@ static int ofd_create_hdl(struct tgt_session_info *tsi) /* From last created */ diff = OST_MAX_PRECREATE; ofd_seq_last_oid_set(oseq, ostid_id(&oa->o_oi) - diff); + /* no sync_trans when recreating last batch */ + sync_trans = 0; } if (!(oa->o_valid & OBD_MD_FLFLAGS) || diff --git a/lustre/osp/osp_precreate.c b/lustre/osp/osp_precreate.c index 8dcf73d..5ea92e4 100644 --- a/lustre/osp/osp_precreate.c +++ b/lustre/osp/osp_precreate.c @@ -815,12 +815,17 @@ static int osp_get_lastfid_from_ost(const struct lu_env *env, if (fid_oid(last_fid) > 0 && update) d->opd_last_used_fid = *last_fid; - if (fid_oid(last_fid) == 0 && - fid_seq(last_fid) == fid_seq(&d->opd_last_used_fid)) { - /* reformatted OST, it requires creation request - * to recreate objects - */ - d->opd_force_creation = true; + if (fid_seq(last_fid) == fid_seq(&d->opd_last_used_fid)) { + if (fid_oid(last_fid) == 0 || + (fid_seq_is_norm(fid_seq(last_fid)) && + fid_oid(last_fid) == LUSTRE_FID_INIT_OID)) { + /* reformatted OST, it requires creation request + * to recreate objects + */ + spin_lock(&d->opd_pre_lock); + d->opd_force_creation = true; + spin_unlock(&d->opd_pre_lock); + } } CDEBUG(D_HA, "%s: Got last_fid "DFID"\n", d->opd_obd->obd_name, PFID(last_fid)); @@ -1418,7 +1423,7 @@ static int osp_precreate_ready_condition(const struct lu_env *env, return 1; } - if (d->opd_pre_recovering) + if (d->opd_pre_recovering || d->opd_force_creation) return 0; /* ready if got enough precreated objects */ @@ -1501,7 +1506,8 @@ int osp_precreate_reserve(const struct lu_env *env, struct osp_device *d, spin_lock(&d->opd_pre_lock); precreated = osp_objs_precreated(env, d); if (precreated > d->opd_pre_reserved && - !d->opd_pre_recovering) { + !d->opd_pre_recovering && + !d->opd_force_creation) { d->opd_pre_reserved++; spin_unlock(&d->opd_pre_lock); rc = 0; diff --git a/lustre/tests/conf-sanity.sh b/lustre/tests/conf-sanity.sh index 3e7be0f..680033c 100644 --- a/lustre/tests/conf-sanity.sh +++ b/lustre/tests/conf-sanity.sh @@ -5585,7 +5585,6 @@ test_69() { start_ost || error "OST0 restart failure" wait_osc_import_state mds ost FULL - sleep $((TIMEOUT/2)) #object recreation requires some time mount_client $MOUNT || error "mount client failed" touch $DIR/$tdir/$tfile-last || error "create file after reformat" local idx=$($LFS getstripe -i $DIR/$tdir/$tfile-last) -- 1.8.3.1