Whamcloud - gitweb
LU-6460 llite: clear LLIF_FILE_RESTORING when done 09/14609/7
authorBruno Faccini <bruno.faccini@intel.com>
Mon, 27 Apr 2015 09:08:34 +0000 (11:08 +0200)
committerOleg Drokin <oleg.drokin@intel.com>
Fri, 31 Jul 2015 01:33:00 +0000 (01:33 +0000)
Clear LLIF_FILE_RESTORING if restore done to ensure to start again
to glimpse new attrs.

Signed-off-by: Bruno Faccini <bruno.faccini@intel.com>
Change-Id: I0f2f9532e06965273efa10e3f69e26d00676b8a6
Reviewed-on: http://review.whamcloud.com/14609
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Jinshan Xiong <jinshan.xiong@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/llite/llite_lib.c
lustre/mdt/mdt_handler.c
lustre/tests/cfg/local.sh
lustre/tests/sanity-hsm.sh

index d45e644..10a9928 100644 (file)
@@ -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;
index 48d916b..3789fb4 100644 (file)
@@ -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);
index d3d5236..cd3647e 100644 (file)
@@ -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"
index 3f9d37b..4051de9 100755 (executable)
@@ -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