From f671890c1c6ef021581f6de6b9047a9b4d988d25 Mon Sep 17 00:00:00 2001 From: Bruno Faccini Date: Mon, 14 Oct 2013 11:27:37 +0200 Subject: [PATCH] LU-3616 mdt: deny write on executed file during restore After commit c42b426c87c3d3b1dc9eda612cc831293dc80d68, from Gerrit patch/Change-Id Ic8f82ddc9a56206307c2e5be2523fb7ce42b8638 (at http://review.whamcloud.com/3035) for LU-1338 (now HSM-5), it is allowed to write in a file being executed during it is restored. This patch revert to expected behavior (ETXTBSY). Also added test_30c in sanity-hsm to verify this behavior. Signed-off-by: Bruno Faccini Change-Id: Id1e2f624dd02c2bec18ffe6cb1ae9198c1cfd23a Reviewed-on: http://review.whamcloud.com/7636 Tested-by: Hudson Tested-by: Maloo Reviewed-by: John L. Hammond Reviewed-by: jacques-Charles Lafoucriere Reviewed-by: Oleg Drokin --- lustre/mdt/mdt_open.c | 14 ++------------ lustre/tests/sanity-hsm.sh | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/lustre/mdt/mdt_open.c b/lustre/mdt/mdt_open.c index dcd18c5..d3c3081 100644 --- a/lustre/mdt/mdt_open.c +++ b/lustre/mdt/mdt_open.c @@ -713,13 +713,7 @@ static int mdt_mfd_open(struct mdt_thread_info *info, struct mdt_object *p, repbody->ioepoch = o->mot_ioepoch; } } else if (flags & MDS_FMODE_EXEC) { - /* if file is released, we can't deny write because we must - * restore (write) it to access it.*/ - if ((ma->ma_valid & MA_HSM) && - (ma->ma_hsm.mh_flags & HS_RELEASED)) - rc = 0; - else - rc = mdt_write_deny(o); + rc = mdt_write_deny(o); } if (rc) RETURN(rc); @@ -1221,11 +1215,7 @@ static int mdt_object_open_lock(struct mdt_thread_info *info, if (open_flags & MDS_OPEN_LOCK) { if (open_flags & FMODE_WRITE) lm = LCK_CW; - /* if file is released, we can't deny write because we must - * restore (write) it to access it. */ - else if ((open_flags & MDS_FMODE_EXEC) && - !((ma->ma_valid & MA_HSM) && - (ma->ma_hsm.mh_flags & HS_RELEASED))) + else if (open_flags & MDS_FMODE_EXEC) lm = LCK_PR; else lm = LCK_CR; diff --git a/lustre/tests/sanity-hsm.sh b/lustre/tests/sanity-hsm.sh index d3c9e89..20675d7 100644 --- a/lustre/tests/sanity-hsm.sh +++ b/lustre/tests/sanity-hsm.sh @@ -1824,6 +1824,41 @@ test_30b() { } run_test 30b "Restore at exec (release case)" +test_30c() { + needclients 2 || return 0 + + # test needs a running copytool + copytool_setup + + mkdir -p $DIR/$tdir + local f=$DIR/$tdir/SLEEP + local fid=$(copy_file /bin/sleep $f) + chmod 755 $f + $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f + wait_request_state $fid ARCHIVE SUCCEED + $LFS hsm_release $f + check_hsm_flags $f "0x0000000d" + # set no retry action mode + cdt_set_no_retry + do_node $CLIENT2 "$f 10" & + local pid=$! + sleep 3 + echo 'Hi!' > $f + [[ $? == 0 ]] && error "Update during exec of released file must fail" + wait $pid + [[ $? == 0 ]] || error "Execution failed during run" + cmp /bin/sleep $f + [[ $? == 0 ]] || error "Binary overwritten during exec" + + # cleanup + # remove no try action mode + cdt_clear_no_retry + check_hsm_flags $f "0x00000009" + + copytool_cleanup +} +run_test 30c "Update during exec of released file must fail" + restore_and_check_size() { local f=$1 local fid=$2 -- 1.8.3.1