From 59522b2279559720e606c3ee24f4e729166e1c5f Mon Sep 17 00:00:00 2001 From: Mikhail Pershin Date: Wed, 16 Jan 2019 16:24:58 +0300 Subject: [PATCH] LU-11835 mdt: return DOM size on open resend DOM size is returned along with DOM lock always, but it is not true with open resend. Patch fixes that issue and adds test case. Lustre-change: https://review.whamcloud.com/34044 Lustre-commit: bc3ef43d36b51d346f22a4c32214c2945c04dbe5 Signed-off-by: Mikhail Pershin Change-Id: I73d43933f781f192e9aa8c6ee388a043dab5bde9 Reviewed-on: https://review.whamcloud.com/40223 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Lai Siyao Reviewed-by: Oleg Drokin --- lustre/mdc/mdc_locks.c | 2 +- lustre/mdt/mdt_open.c | 46 ++++++++++++++++++------------------------ lustre/tests/recovery-small.sh | 15 ++++++++++++++ 3 files changed, 36 insertions(+), 27 deletions(-) diff --git a/lustre/mdc/mdc_locks.c b/lustre/mdc/mdc_locks.c index f57d229..1c1e54b 100644 --- a/lustre/mdc/mdc_locks.c +++ b/lustre/mdc/mdc_locks.c @@ -834,7 +834,7 @@ static int mdc_finish_enqueue(struct obd_export *exp, body = req_capsule_server_get(pill, &RMF_MDT_BODY); if (!(body->mbo_valid & OBD_MD_DOM_SIZE)) { - LDLM_ERROR(lock, "%s: DoM lock without size.\n", + LDLM_ERROR(lock, "%s: DoM lock without size.", exp->exp_obd->obd_name); GOTO(out_lock, rc = -EPROTO); } diff --git a/lustre/mdt/mdt_open.c b/lustre/mdt/mdt_open.c index 41e2120..3ef8da4 100644 --- a/lustre/mdt/mdt_open.c +++ b/lustre/mdt/mdt_open.c @@ -705,41 +705,35 @@ void mdt_reconstruct_open(struct mdt_thread_info *info, } if (unlikely(mdt_object_remote(child))) { + mdt_object_put(env, parent); + mdt_object_put(env, child); /* the child object was created on remote server */ - if (!mdt_is_dne_client(exp)) { + if (!mdt_is_dne_client(exp)) /* Return -EIO for old client */ - mdt_object_put(env, parent); - mdt_object_put(env, child); GOTO(out, rc = -EIO); - } repbody->mbo_fid1 = *rr->rr_fid2; repbody->mbo_valid |= (OBD_MD_FLID | OBD_MD_MDS); - rc = 0; - } else { - if (mdt_object_exists(child)) { - mdt_prep_ma_buf_from_rep(info, child, ma); - rc = mdt_attr_get_complex(info, child, ma); - if (rc == 0) - rc = mdt_finish_open(info, parent, - child, open_flags, - 1, ldlm_rep); - } else { - /* the child does not exist, we should do - * regular open */ - mdt_object_put(env, parent); - mdt_object_put(env, child); - GOTO(regular_open, 0); - } + GOTO(out, rc = 0); } + if (mdt_object_exists(child)) { + mdt_prep_ma_buf_from_rep(info, child, ma); + rc = mdt_attr_get_complex(info, child, ma); + if (!rc) + rc = mdt_finish_open(info, parent, child, + open_flags, 1, ldlm_rep); + mdt_object_put(env, parent); + mdt_object_put(env, child); + if (!rc) + mdt_pack_size2body(info, rr->rr_fid2, + &lhc->mlh_reg_lh); + GOTO(out, rc); + } + /* the child does not exist, we should do regular open */ mdt_object_put(env, parent); mdt_object_put(env, child); - GOTO(out, rc); - } else { -regular_open: - /* We did not try to create, so we are a pure open */ - rc = mdt_reint_open(info, lhc); } - + /* We did not try to create, so we are a pure open */ + rc = mdt_reint_open(info, lhc); EXIT; out: req->rq_status = rc; diff --git a/lustre/tests/recovery-small.sh b/lustre/tests/recovery-small.sh index 74e354c..ebbf8e2 100755 --- a/lustre/tests/recovery-small.sh +++ b/lustre/tests/recovery-small.sh @@ -2761,6 +2761,21 @@ test_134() { } run_test 134 "race between failover and search for reply data free slot" +test_135() { + [[ $MDS1_VERSION -ge $(version_code 2.12.5) ]] || + skip "Need MDS version at least 2.12.5" + + mkdir -p $DIR/$tdir + $LFS setstripe -E 1M -L mdt $DIR/$tdir + # to have parent dir write lock before open/resend + touch $DIR/$tdir/$tfile + #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157 + do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param fail_loc=0x80000157 + openfile -f O_RDWR:O_CREAT -m 0755 $DIR/$tdir/$tfile || + error "Failed to open DOM file" +} +run_test 135 "DOM: open/create resend to return size" + test_136() { remote_mds_nodsh && skip "remote MDS with nodsh" && return [[ $MDS1_VERSION -ge $(version_code 2.12.52) ]] || -- 1.8.3.1