Whamcloud - gitweb
LU-11642 lmv: allocate fid on parent MDT in migrate 41/33641/3
authorLai Siyao <lai.siyao@intel.com>
Sun, 21 Oct 2018 22:48:17 +0000 (06:48 +0800)
committerOleg Drokin <green@whamcloud.com>
Wed, 21 Nov 2018 04:05:56 +0000 (04:05 +0000)
During directory migration, if the migrated file is not directory,
the target should be allocated on its parent MDT, not user specified
MDT. Because if it's parent is striped, this file should be migrated
to the MDT by its name hash, not the starting MDT of its parent.

Add sanity 230k to check file data not changed after migration.

Signed-off-by: Lai Siyao <lai.siyao@whamcloud.com>
Change-Id: Ic7d3de8ea982b7cf4da758e4d3ab8d8ee15ecfdb
Reviewed-on: https://review.whamcloud.com/33641
Tested-by: Jenkins
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Mike Pershin <mpershin@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/lmv/lmv_obd.c
lustre/tests/sanity.sh

index 090f3b1..329965e 100644 (file)
@@ -2006,7 +2006,10 @@ static int lmv_migrate(struct obd_export *exp, struct md_op_data *op_data,
        if (IS_ERR(child_tgt))
                RETURN(PTR_ERR(child_tgt));
 
-       rc = lmv_fid_alloc(NULL, exp, &target_fid, op_data);
+       if (!S_ISDIR(op_data->op_mode) && tp_tgt)
+               rc = __lmv_fid_alloc(lmv, &target_fid, tp_tgt->ltd_idx);
+       else
+               rc = lmv_fid_alloc(NULL, exp, &target_fid, op_data);
        if (rc)
                RETURN(rc);
 
index 18ad4eb..7e9c572 100755 (executable)
@@ -15468,6 +15468,56 @@ test_230j() {
 }
 run_test 230j "DoM file data not changed after dir migration"
 
+test_230k() {
+       [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs"
+       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.56) ] &&
+               skip "Need MDS version at least 2.11.56"
+
+       local total=20
+       local files_on_starting_mdt=0
+
+       $LFS mkdir -i -1 -c 2 $DIR/$tdir || error "mkdir failed"
+       $LFS getdirstripe $DIR/$tdir
+       for i in $(seq $total); do
+               echo $((i*i - i)) > $DIR/$tdir/$tfile.$i || error "write failed"
+               [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
+                       files_on_starting_mdt=$((files_on_starting_mdt + 1))
+       done
+
+       echo "$files_on_starting_mdt files on MDT0"
+
+       $LFS migrate -m 1,3 $DIR/$tdir || error "migrate -m 1,3 failed"
+       $LFS getdirstripe $DIR/$tdir
+
+       files_on_starting_mdt=0
+       for i in $(seq $total); do
+               $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
+                       error "file $tfile.$i mismatch after migration"
+               [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 1 ]] &&
+                       files_on_starting_mdt=$((files_on_starting_mdt + 1))
+       done
+
+       echo "$files_on_starting_mdt files on MDT1 after migration"
+       [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT1"
+
+       $LFS migrate -m 0 -c 2 $DIR/$tdir || error "migrate -m 0 -c 2 failed"
+       $LFS getdirstripe $DIR/$tdir
+
+       files_on_starting_mdt=0
+       for i in $(seq $total); do
+               $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
+                       error "file $tfile.$i mismatch after 2nd migration"
+               [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
+                       files_on_starting_mdt=$((files_on_starting_mdt + 1))
+       done
+
+       echo "$files_on_starting_mdt files on MDT0 after 2nd migration"
+       [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT0"
+
+       true
+}
+run_test 230k "file data not changed after dir migration"
+
 test_231a()
 {
        # For simplicity this test assumes that max_pages_per_rpc