Whamcloud - gitweb
LU-10271 hsm: don't release with wrong size 40/30240/2
authorAlexander Boyko <c17825@cray.com>
Thu, 23 Nov 2017 09:51:02 +0000 (04:51 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Fri, 1 Dec 2017 05:15:20 +0000 (05:15 +0000)
The result of ll_merge_attr operation was ignored during
ll_hsm_release. For this case the released file could have
the wrong size on MDS, like
File: ‘released.file’
Size: 0  Blocks: 0  IO Block: 4194304 regular empty file

Patch adds test_253 sanity-hsm, to check hsm release
operation when cl_object_attr_get failed. It produces
the wrong size-on-mds for a released file.

Signed-off-by: Alexander Boyko <c17825@cray.com>
Change-Id: I94df1889265e5b6d03b16745de93e52af95d5b7c
Reviewed-on: https://review.whamcloud.com/30240
Reviewed-by: Henri Doreau <henri.doreau@cea.fr>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Sergey Cheremencev <c17829@cray.com>
Reviewed-by: Quentin Bouget <quentin.bouget@cea.fr>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/include/obd_support.h
lustre/llite/file.c
lustre/tests/sanity-hsm.sh

index e82f36d..85910ce 100644 (file)
@@ -467,6 +467,7 @@ extern char obd_jobid_var[];
 #define OBD_FAIL_MDC_RPCS_SEM           0x804
 #define OBD_FAIL_MDC_LIGHTWEIGHT        0x805
 #define OBD_FAIL_MDC_CLOSE              0x806
 #define OBD_FAIL_MDC_RPCS_SEM           0x804
 #define OBD_FAIL_MDC_LIGHTWEIGHT        0x805
 #define OBD_FAIL_MDC_CLOSE              0x806
+#define OBD_FAIL_MDC_MERGE              0x807
 
 #define OBD_FAIL_MGS                     0x900
 #define OBD_FAIL_MGS_ALL_REQUEST_NET     0x901
 
 #define OBD_FAIL_MGS                     0x900
 #define OBD_FAIL_MGS_ALL_REQUEST_NET     0x901
index d640b0d..c52a1f1 100644 (file)
@@ -1020,7 +1020,10 @@ int ll_merge_attr(const struct lu_env *env, struct inode *inode)
        ctime = LTIME_S(inode->i_ctime);
 
        cl_object_attr_lock(obj);
        ctime = LTIME_S(inode->i_ctime);
 
        cl_object_attr_lock(obj);
-       rc = cl_object_attr_get(env, obj, attr);
+       if (OBD_FAIL_CHECK(OBD_FAIL_MDC_MERGE))
+               rc = -EINVAL;
+       else
+               rc = cl_object_attr_get(env, obj, attr);
        cl_object_attr_unlock(obj);
 
        if (rc != 0)
        cl_object_attr_unlock(obj);
 
        if (rc != 0)
@@ -2169,9 +2172,15 @@ int ll_hsm_release(struct inode *inode)
        if (IS_ERR(env))
                GOTO(out, rc = PTR_ERR(env));
 
        if (IS_ERR(env))
                GOTO(out, rc = PTR_ERR(env));
 
-       ll_merge_attr(env, inode);
+       rc = ll_merge_attr(env, inode);
        cl_env_put(env, &refcheck);
 
        cl_env_put(env, &refcheck);
 
+       /* If error happen, we have the wrong size for a file.
+        * Don't release it.
+        */
+       if (rc != 0)
+               GOTO(out, rc);
+
        /* Release the file.
         * NB: lease lock handle is released in mdc_hsm_release_pack() because
         * we still need it to pack l_remote_handle to MDT. */
        /* Release the file.
         * NB: lease lock handle is released in mdc_hsm_release_pack() because
         * we still need it to pack l_remote_handle to MDT. */
index 0afa7e1..5ddc833 100755 (executable)
@@ -4863,6 +4863,41 @@ test_252() {
 }
 run_test 252 "Timeout'ed running archive of a removed file should be canceled"
 
 }
 run_test 252 "Timeout'ed running archive of a removed file should be canceled"
 
+test_253() {
+       local rc
+       # test needs a running copytool
+       copytool_setup
+
+       mkdir -p $DIR/$tdir
+       local f=$DIR/$tdir/$tfile
+
+       dd if=/dev/zero of=$f bs=1MB count=10
+       local fid=$(path2fid $f)
+
+       $LFS hsm_archive $f || error "could not archive file"
+       wait_request_state $fid ARCHIVE SUCCEED
+
+       # clear locks to discard inode data
+       cancel_lru_locks osc
+
+       #define OBD_FAIL_MDC_MERGE              0x807
+       $LCTL set_param fail_loc=0x807
+
+       #expect error here, instead of release with wrong size
+       $LFS hsm_release $f
+       rc=$?
+       if ((rc == 0)); then
+               file_size=$(stat -c '%s' $f)
+               if ((file_size != 10485760)); then
+                       error "Wrong file size after hsm_release"
+               fi
+       else
+               echo "could not release file"
+       fi
+       copytool_cleanup
+}
+run_test 253 "Check for wrong file size after release"
+
 test_300() {
        # the only way to test ondisk conf is to restart MDS ...
        echo "Stop coordinator and remove coordinator state at mount"
 test_300() {
        # the only way to test ondisk conf is to restart MDS ...
        echo "Stop coordinator and remove coordinator state at mount"