From: Andriy Skulysh Date: Wed, 30 Jan 2019 09:33:49 +0000 (+0200) Subject: LU-11925 hsm: attributes aren't updated after RESTORE X-Git-Tag: 2.12.53~16 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=63493381b3a1a1ebd5293df69403ee2ff8b0440e LU-11925 hsm: attributes aren't updated after RESTORE MDS returns file size to a client with UPDATE lock while file is RELEASED. It isn't cancelled after RESTORE and the client has old file size after appending data. Flush update lock after RESTORE completed. Change-Id: Ib956dbd075691ce5fac1ce552df9519f9fa768e4 Cray-bug-id: LUS-6945 Signed-off-by: Andriy Skulysh Reviewed-on: https://review.whamcloud.com/34180 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Ben Evans Reviewed-by: Sergey Cheremencev Reviewed-by: Oleg Drokin --- diff --git a/lustre/mdt/mdt_coordinator.c b/lustre/mdt/mdt_coordinator.c index 51708d1..a23e536 100644 --- a/lustre/mdt/mdt_coordinator.c +++ b/lustre/mdt/mdt_coordinator.c @@ -1551,6 +1551,8 @@ static int hsm_cdt_request_completed(struct mdt_thread_info *mti, * if no retry will be attempted and if object is still alive, * in other cases we just unlock the object */ if (car->car_hai->hai_action == HSMA_RESTORE) { + struct mdt_lock_handle *lh; + /* restore in data FID done, we swap the layouts * only if restore is successful */ if (pgs->hpk_errval == 0 && !IS_ERR(obj)) { @@ -1574,6 +1576,13 @@ static int hsm_cdt_request_completed(struct mdt_thread_info *mti, need_changelog = false; cdt_restore_handle_del(mti, cdt, &car->car_hai->hai_fid); + if (!IS_ERR_OR_NULL(obj)) { + /* flush UPDATE lock so attributes are upadated */ + lh = &mti->mti_lh[MDT_LH_OLD]; + mdt_lock_reg_init(lh, LCK_EX); + mdt_object_lock(mti, obj, lh, MDS_INODELOCK_UPDATE); + mdt_object_unlock(mti, obj, lh, 1); + } } GOTO(out, rc); diff --git a/lustre/tests/sanity-hsm.sh b/lustre/tests/sanity-hsm.sh index d67e960..97a5129 100755 --- a/lustre/tests/sanity-hsm.sh +++ b/lustre/tests/sanity-hsm.sh @@ -3944,6 +3944,42 @@ test_112() { } run_test 112 "State of recorded request" +test_113() { + local file1=$DIR/$tdir/$tfile + local file2=$DIR2/$tdir/$tfile + + local fid=$(create_small_sync_file $file1) + + stack_trap "zconf_umount \"$(facet_host $SINGLEAGT)\" \"$MOUNT3\"" EXIT + zconf_mount "$(facet_host $SINGLEAGT)" "$MOUNT3" || + error "cannot mount '$MOUNT3' on '$SINGLEAGT'" + + copytool setup -m "$MOUNT3" + + do_nodes $(comma_list $(nodes_list)) $LCTL clear + + $LFS hsm_archive $file1 || error "Fail to archive $file1" + wait_request_state $fid ARCHIVE SUCCEED + + $LFS hsm_release $file1 + echo "Verifying released state: " + check_hsm_flags $file1 "0x0000000d" + + multiop_bg_pause $file1 oO_WRONLY:O_APPEND:_w4c || error "multiop failed" + MULTIPID=$! + stat $file2 & + kill -USR1 $MULTIPID + + wait + sync + + local size1=$(stat -c "%s" $file1) + local size2=$(stat -c "%s" $file2) + + [ $size1 -eq $size2 ] || error "sizes are different $size1 $size2" +} +run_test 113 "wrong stat after restore" + test_200() { local f=$DIR/$tdir/$tfile local fid=$(create_empty_file "$f")