From a2c4b0583a84165b867b18e1446c187d18335879 Mon Sep 17 00:00:00 2001 From: Bruno Faccini Date: Mon, 27 Apr 2015 11:08:34 +0200 Subject: [PATCH 1/1] LU-6460 llite: clear LLIF_FILE_RESTORING when done Clear LLIF_FILE_RESTORING if restore done to ensure to start again to glimpse new attrs. Signed-off-by: Bruno Faccini Change-Id: I0f2f9532e06965273efa10e3f69e26d00676b8a6 Reviewed-on: http://review.whamcloud.com/14609 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: John L. Hammond Reviewed-by: Jinshan Xiong Reviewed-by: Oleg Drokin --- lustre/llite/llite_lib.c | 6 ++++ lustre/mdt/mdt_handler.c | 7 +++-- lustre/tests/cfg/local.sh | 2 ++ lustre/tests/sanity-hsm.sh | 70 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 82 insertions(+), 3 deletions(-) diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index d45e644..10a9928 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -1911,8 +1911,14 @@ int ll_update_inode(struct inode *inode, struct lustre_md *md) } if (body->mbo_valid & OBD_MD_TSTATE) { + /* Set LLIF_FILE_RESTORING if restore ongoing and + * clear it when done to ensure to start again + * glimpsing updated attrs + */ if (body->mbo_t_state & MS_RESTORE) ll_file_set_flag(lli, LLIF_FILE_RESTORING); + else + ll_file_clear_flag(lli, LLIF_FILE_RESTORING); } return 0; diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 48d916b..3789fb4 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -897,10 +897,11 @@ static int mdt_getattr_internal(struct mdt_thread_info *info, } /* if file is released, check if a restore is running */ - if ((ma->ma_valid & MA_HSM) && (ma->ma_hsm.mh_flags & HS_RELEASED) && - mdt_hsm_restore_is_running(info, mdt_object_fid(o))) { - repbody->mbo_t_state = MS_RESTORE; + if (ma->ma_valid & MA_HSM) { repbody->mbo_valid |= OBD_MD_TSTATE; + if ((ma->ma_hsm.mh_flags & HS_RELEASED) && + mdt_hsm_restore_is_running(info, mdt_object_fid(o))) + repbody->mbo_t_state = MS_RESTORE; } is_root = lu_fid_eq(mdt_object_fid(o), &info->mti_mdt->mdt_md_root_fid); diff --git a/lustre/tests/cfg/local.sh b/lustre/tests/cfg/local.sh index d3d5236..cd3647e 100644 --- a/lustre/tests/cfg/local.sh +++ b/lustre/tests/cfg/local.sh @@ -112,6 +112,7 @@ LQUOTAOPTS=${LQUOTAOPTS:-"hash_lqs_cur_bits=3"} MOUNT=${MOUNT:-/mnt/${FSNAME}} MOUNT1=${MOUNT1:-$MOUNT} MOUNT2=${MOUNT2:-${MOUNT}2} +MOUNT3=${MOUNT3:-${MOUNT}3} # Comma-separated option list used as "mount [...] -o $MOUNT_OPTS [...]" MOUNT_OPTS=${MOUNT_OPTS:-"user_xattr,flock"} # Mount flags (e.g. "-n") used as "mount [...] $MOUNT_FLAGS [...]" @@ -119,6 +120,7 @@ MOUNT_FLAGS=${MOUNT_FLAGS:-""} DIR=${DIR:-$MOUNT} DIR1=${DIR:-$MOUNT1} DIR2=${DIR2:-$MOUNT2} +DIR3=${DIR3:-$MOUNT3} if [ $UID -ne 0 ]; then log "running as non-root uid $UID" diff --git a/lustre/tests/sanity-hsm.sh b/lustre/tests/sanity-hsm.sh index 3f9d37b..4051de9 100755 --- a/lustre/tests/sanity-hsm.sh +++ b/lustre/tests/sanity-hsm.sh @@ -1417,6 +1417,76 @@ test_12p() { } run_test 12p "implicit restore of a file on copytool mount point" +cleanup_test_12q() { + trap 0 + zconf_umount $(facet_host $SINGLEAGT) $MOUNT3 || + error "cannot umount $MOUNT3 on $SINGLEAGT" +} + +test_12q() { + + zconf_mount $(facet_host $SINGLEAGT) $MOUNT3 || + error "cannot mount $MOUNT3 on $SINGLEAGT" + + trap cleanup_test_12q EXIT + + # test needs a running copytool + copytool_setup $SINGLEAGT $MOUNT3 + + mkdir $DIR/$tdir + local f=$DIR/$tdir/$tfile + local f2=$DIR2/$tdir/$tfile + local fid=$(make_small $f) + local orig_size=$(stat -c "%s" $f) + + $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $f + wait_request_state $fid ARCHIVE SUCCEED + + $LFS hsm_release $f || error "could not release file" + check_hsm_flags $f "0x0000000d" + + search_and_kill_copytool + sleep 5 + search_copytools && error "Copytool should have stopped" + + cat $f > /dev/null & + + # wait a bit to allow implicit restore request to be handled. + # if not, next stat would also block on layout-lock. + sleep 5 + + local size=$(stat -c "%s" $f2) + [ $size -eq $orig_size ] || + error "$f2: wrong size after archive: $size != $orig_size" + + HSM_ARCHIVE_PURGE=false copytool_setup $SINGLEAGT /mnt/lustre3 + + wait + + size=$(stat -c "%s" $f) + [ $size -eq $orig_size ] || + error "$f: wrong size after restore: $size != $orig_size" + + size=$(stat -c "%s" $f2) + [ $size -eq $orig_size ] || + error "$f2: wrong size after restore: $size != $orig_size" + + :>$f + + size=$(stat -c "%s" $f) + [ $size -eq 0 ] || + error "$f: wrong size after overwrite: $size != 0" + + size=$(stat -c "%s" $f2) + [ $size -eq 0 ] || + error "$f2: wrong size after overwrite: $size != 0" + + copytool_cleanup + zconf_umount $(facet_host $SINGLEAGT) $MOUNT3 || + error "cannot umount $MOUNT3 on $SINGLEAGT" +} +run_test 12q "file attributes are refreshed after restore" + test_13() { # test needs a running copytool copytool_setup -- 1.8.3.1