Whamcloud - gitweb
LU-3616 mdt: deny write on executed file during restore 36/7636/7
authorBruno Faccini <bruno.faccini@intel.com>
Mon, 14 Oct 2013 09:27:37 +0000 (11:27 +0200)
committerOleg Drokin <oleg.drokin@intel.com>
Fri, 25 Oct 2013 02:22:43 +0000 (02:22 +0000)
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 <bruno.faccini@intel.com>
Change-Id: Id1e2f624dd02c2bec18ffe6cb1ae9198c1cfd23a
Reviewed-on: http://review.whamcloud.com/7636
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: jacques-Charles Lafoucriere <jacques-charles.lafoucriere@cea.fr>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/mdt/mdt_open.c
lustre/tests/sanity-hsm.sh

index dcd18c5..d3c3081 100644 (file)
@@ -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;
index d3c9e89..20675d7 100644 (file)
@@ -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