Whamcloud - gitweb
LU-8367 osp: wait for precreate on reformatted OST 51/49151/6
authorLi Dongyang <dongyangli@ddn.com>
Mon, 14 Nov 2022 13:28:37 +0000 (00:28 +1100)
committerOleg Drokin <green@whamcloud.com>
Tue, 3 Jan 2023 21:34:32 +0000 (21:34 +0000)
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 <dongyangli@ddn.com>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/49151
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Alexander Boyko <alexander.boyko@hpe.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/ofd/ofd_dev.c
lustre/osp/osp_precreate.c
lustre/tests/conf-sanity.sh

index fdc110d..5848454 100644 (file)
@@ -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) ||
index 8dcf73d..5ea92e4 100644 (file)
@@ -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;
index 3e7be0f..680033c 100644 (file)
@@ -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)