From 09b457fffc8ae1f4f0944b2580955f5caca86aba Mon Sep 17 00:00:00 2001 From: Alexander Boyko Date: Thu, 23 Nov 2017 04:51:02 -0500 Subject: [PATCH] LU-10271 hsm: don't release with wrong size MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Change-Id: I94df1889265e5b6d03b16745de93e52af95d5b7c Reviewed-on: https://review.whamcloud.com/30240 Reviewed-by: Henri Doreau Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Sergey Cheremencev Reviewed-by: Quentin Bouget Reviewed-by: John L. Hammond Reviewed-by: Oleg Drokin --- lustre/include/obd_support.h | 1 + lustre/llite/file.c | 13 +++++++++++-- lustre/tests/sanity-hsm.sh | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 2 deletions(-) diff --git a/lustre/include/obd_support.h b/lustre/include/obd_support.h index e82f36d..85910ce 100644 --- a/lustre/include/obd_support.h +++ b/lustre/include/obd_support.h @@ -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_MERGE 0x807 #define OBD_FAIL_MGS 0x900 #define OBD_FAIL_MGS_ALL_REQUEST_NET 0x901 diff --git a/lustre/llite/file.c b/lustre/llite/file.c index d640b0d..c52a1f1 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -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); - 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) @@ -2169,9 +2172,15 @@ int ll_hsm_release(struct inode *inode) 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); + /* 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. */ diff --git a/lustre/tests/sanity-hsm.sh b/lustre/tests/sanity-hsm.sh index 0afa7e1..5ddc833d 100755 --- a/lustre/tests/sanity-hsm.sh +++ b/lustre/tests/sanity-hsm.sh @@ -4863,6 +4863,41 @@ test_252() { } 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" -- 1.8.3.1