Whamcloud - gitweb
LU-3864 lov: return minimal FIEMAP for released files
[fs/lustre-release.git] / lustre / tests / sanity-hsm.sh
index ea4c4c3..8687a61 100644 (file)
@@ -2946,6 +2946,41 @@ test_227() {
 }
 run_test 227 "changelog when explicit setting of HSM flags"
 
+test_228() {
+       # test needs a running copytool
+       copytool_setup
+
+       dd if=/dev/urandom of=$DIR/$tfile bs=1M count=1 conv=sync ||
+               error "creating $DIR/$tfile"
+       $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $DIR/$tfile
+       wait_request_state $(path2fid $DIR/$tfile) ARCHIVE SUCCEED
+
+       $LFS hsm_release $DIR/$tfile
+       check_hsm_flags $DIR/$tfile "0x0000000d"
+
+       filefrag $DIR/$tfile | grep " 1 extent found" ||
+               error "filefrag on released file must return only one extent"
+
+       # only newer versions of cp detect sparse files by stat/FIEMAP
+       # (LU-2580)
+       cp --sparse=auto $DIR/$tfile $DIR/$tfile.2 ||
+               error "copying $DIR/$tfile"
+       cmp $DIR/$tfile $DIR/$tfile.2 || error "comparing copied $DIR/$tfile"
+
+       $LFS hsm_release $DIR/$tfile
+       check_hsm_flags $DIR/$tfile "0x0000000d"
+
+       mkdir $DIR/$tdir
+
+       tar cf - --sparse $DIR/$tfile | tar xvf - -C $DIR/$tdir ||
+               error "tar failed"
+       cmp $DIR/$tfile $DIR/$tdir/$DIR/$tfile ||
+               error "comparing untarred $DIR/$tfile"
+
+       copytool_cleanup
+}
+run_test 228 "On released file, return extend to FIEMAP. For [cp,tar] --sparse"
+
 test_250() {
        # test needs a running copytool
        copytool_setup