Whamcloud - gitweb
LU-11925 hsm: attributes aren't updated after RESTORE 82/35082/2
authorAndriy Skulysh <c17819@cray.com>
Wed, 30 Jan 2019 09:33:49 +0000 (11:33 +0200)
committerOleg Drokin <green@whamcloud.com>
Thu, 20 Jun 2019 03:56:20 +0000 (03:56 +0000)
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.

Lustre-change: https://review.whamcloud.com/34180
Lustre-commit: 63493381b3a1a1ebd5293df69403ee2ff8b0440e

Change-Id: Ib956dbd075691ce5fac1ce552df9519f9fa768e4
Cray-bug-id: LUS-6945
Signed-off-by: Andriy Skulysh <c17819@cray.com>
Reviewed-by: Ben Evans <bevans@cray.com>
Reviewed-by: Sergey Cheremencev <c17829@cray.com>
Signed-off-by: Minh Diep <mdiep@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/35082
Tested-by: Jenkins
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Patrick Farrell <pfarrell@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/mdt/mdt_coordinator.c
lustre/tests/sanity-hsm.sh

index 6795c7d..7548598 100644 (file)
@@ -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);
index 4a035e5..05b48ec 100755 (executable)
@@ -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")