From 3a0a50f44f68066642a23365fa4a6f1924dd1108 Mon Sep 17 00:00:00 2001 From: Lai Siyao Date: Thu, 4 Jan 2018 09:38:43 +0800 Subject: [PATCH] LU-10155 recovery: support setstripe replay Regular file open will always reserve space for LOV ea, which is used to store user specified lov_user_md, or lov_mds_md for replay, but if this open is the first open in 'lfs setstripe', it doesn't have lov_user_md specified, or lov_mds_md for replay because O_LOV_DELAY_CREATE is set, but MDT will treat the EA field in the request as valid one, so fails in magic check in this open replay. This patch fixes this issues on both sides: 1. client doesn't reserve space for LOV ea in open(O_LOV_DELAY_CREATE), this change is not necessary, but to make clean of the code. 2. server doesn't create OST objects for open(O_LOV_DELAY_CREATE) replay. Add setstripe/setdirstripe replay test in replay-single.sh, which are 2c, 2d. Signed-off-by: Lai Siyao Change-Id: Ia7971523710822308328239f36f7d690314e0e45 Reviewed-on: https://review.whamcloud.com/30704 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Mike Pershin Reviewed-by: Jinshan Xiong Reviewed-by: Oleg Drokin --- lustre/mdc/mdc_locks.c | 8 +++++++- lustre/mdd/mdd_dir.c | 2 +- lustre/tests/replay-single.sh | 18 ++++++++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/lustre/mdc/mdc_locks.c b/lustre/mdc/mdc_locks.c index 546b7f5..d5f054c 100644 --- a/lustre/mdc/mdc_locks.c +++ b/lustre/mdc/mdc_locks.c @@ -300,8 +300,14 @@ mdc_intent_open_pack(struct obd_export *exp, struct lookup_intent *it, req_capsule_set_size(&req->rq_pill, &RMF_NAME, RCL_CLIENT, op_data->op_namelen + 1); - req_capsule_set_size(&req->rq_pill, &RMF_EADATA, RCL_CLIENT, + if (cl_is_lov_delay_create(it->it_flags)) { + /* open(O_LOV_DELAY_CREATE) won't pack lmm */ + LASSERT(lmmsize == 0); + req_capsule_set_size(&req->rq_pill, &RMF_EADATA, RCL_CLIENT, 0); + } else { + req_capsule_set_size(&req->rq_pill, &RMF_EADATA, RCL_CLIENT, max(lmmsize, obddev->u.cli.cl_default_mds_easize)); + } req_capsule_set_size(&req->rq_pill, &RMF_FILE_SECCTX_NAME, RCL_CLIENT, op_data->op_file_secctx_name != NULL ? diff --git a/lustre/mdd/mdd_dir.c b/lustre/mdd/mdd_dir.c index e421b08..af74cfe 100644 --- a/lustre/mdd/mdd_dir.c +++ b/lustre/mdd/mdd_dir.c @@ -2249,7 +2249,7 @@ static int mdd_declare_create_object(const struct lu_env *env, GOTO(out, rc); /* replay case, create LOV EA from client data */ - if (spec->no_create || + if ((!(spec->sp_cr_flags & MDS_OPEN_DELAY_CREATE) && spec->no_create) || (spec->sp_cr_flags & MDS_OPEN_HAS_EA && S_ISREG(attr->la_mode))) { buf = mdd_buf_get_const(env, spec->u.sp_ea.eadata, spec->u.sp_ea.eadatalen); diff --git a/lustre/tests/replay-single.sh b/lustre/tests/replay-single.sh index 3327962..0d0954a 100755 --- a/lustre/tests/replay-single.sh +++ b/lustre/tests/replay-single.sh @@ -119,6 +119,24 @@ test_2b() { } run_test 2b "touch" +test_2c() { + replay_barrier $SINGLEMDS + $LFS setstripe -c $OSTCOUNT $DIR/$tfile + fail $SINGLEMDS + $CHECKSTAT -t file $DIR/$tfile || + error "$CHECKSTAT $DIR/$tfile check failed" +} +run_test 2c "setstripe replay" + +test_2d() { + replay_barrier $SINGLEMDS + $LFS setdirstripe -i 0 -c $MDSCOUNT $DIR/$tdir + fail $SINGLEMDS + $CHECKSTAT -t dir $DIR/$tdir || + error "$CHECKSTAT $DIR/$tdir check failed" +} +run_test 2d "setdirstripe replay" + test_3a() { local file=$DIR/$tfile replay_barrier $SINGLEMDS -- 1.8.3.1