From 544d46eb8f13b9ba9f33d0af796665c11ea45163 Mon Sep 17 00:00:00 2001 From: Di Wang Date: Thu, 5 Nov 2015 02:25:52 -0800 Subject: [PATCH] LU-7396 llite: check request != NULL in ll_migrate Check if the request is NULL, before retrieve reply body from the request. Signed-off-by: Di Wang Change-Id: Ifec9caf270b938b7583de0315610f930fa52649d Reviewed-on: http://review.whamcloud.com/17079 Tested-by: Jenkins Reviewed-by: John L. Hammond Tested-by: Maloo Reviewed-by: Andreas Dilger --- lustre/llite/file.c | 36 ++++++++++++++++++++++-------------- lustre/tests/sanity.sh | 12 ++++++++++++ 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/lustre/llite/file.c b/lustre/llite/file.c index 1b368b8..9b75dc2 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -3061,24 +3061,32 @@ again: if (rc == 0) ll_update_times(request, parent); - body = req_capsule_server_get(&request->rq_pill, &RMF_MDT_BODY); - if (body == NULL) - GOTO(out_free, rc = -EPROTO); - - /* If the server does release layout lock, then we cleanup - * the client och here, otherwise release it in out_free: */ - if (och != NULL && body->mbo_valid & OBD_MD_CLOSE_INTENT_EXECED) { - obd_mod_put(och->och_mod); - md_clear_open_replay_data(ll_i2sbi(parent)->ll_md_exp, och); - och->och_fh.cookie = DEAD_HANDLE_MAGIC; - OBD_FREE_PTR(och); - och = NULL; + if (request != NULL) { + body = req_capsule_server_get(&request->rq_pill, &RMF_MDT_BODY); + if (body == NULL) { + ptlrpc_req_finished(request); + GOTO(out_free, rc = -EPROTO); + } + + /* If the server does release layout lock, then we cleanup + * the client och here, otherwise release it in out_free: */ + if (och != NULL && + body->mbo_valid & OBD_MD_CLOSE_INTENT_EXECED) { + obd_mod_put(och->och_mod); + md_clear_open_replay_data(ll_i2sbi(parent)->ll_md_exp, + och); + och->och_fh.cookie = DEAD_HANDLE_MAGIC; + OBD_FREE_PTR(och); + och = NULL; + } + ptlrpc_req_finished(request); } - ptlrpc_req_finished(request); /* Try again if the file layout has changed. */ - if (rc == -EAGAIN && S_ISREG(child_inode->i_mode)) + if (rc == -EAGAIN && S_ISREG(child_inode->i_mode)) { + request = NULL; goto again; + } out_free: if (child_inode != NULL) { if (och != NULL) /* close the file */ diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index fae421c..a73ace6 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -13053,6 +13053,18 @@ test_230f() { } run_test 230f "migrate mulitple remote link files" +test_230g() { + [ $PARALLEL == "yes" ] && skip "skip parallel run" && return + [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return + + mkdir -p $DIR/$tdir/migrate_dir + + $LFS migrate -m 1000 $DIR/$tdir/migrate_dir && + error "migrating dir to non-exist MDT succeeds" + true +} +run_test 230g "migrate dir to non-exist MDT" + test_231a() { # For simplicity this test assumes that max_pages_per_rpc -- 1.8.3.1