Whamcloud - gitweb
LU-10405 lov: fill no-extent fiemap on object with no stripe. 91/30591/6
authorDominique Martinet <dominique.martinet@cea.fr>
Tue, 19 Dec 2017 09:00:04 +0000 (10:00 +0100)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 25 Jan 2018 04:47:44 +0000 (04:47 +0000)
This is useful for cp of large sparse files with no stripe info,
as cp relies on fiemap to detect what to read.

Add test 130f: fiemap for unstriped file

Change-Id: I12802c5b1cdec6baf5ee3cec6c706d92d9be4f63
Signed-off-by: Dominique Martinet <dominique.martinet@cea.fr>
Reviewed-on: https://review.whamcloud.com/30591
Tested-by: Jenkins
Reviewed-by: Quentin Bouget <quentin.bouget@cea.fr>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
lustre/lov/lov_object.c
lustre/tests/sanity.sh

index 9b56d84..3628b7a 100644 (file)
@@ -1805,8 +1805,11 @@ static int lov_object_fiemap(const struct lu_env *env, struct cl_object *obj,
        ENTRY;
 
        lsm = lov_lsm_addref(cl2lov(obj));
-       if (lsm == NULL)
-               RETURN(-ENODATA);
+       if (lsm == NULL) {
+               /* no extent: there is no object for mapping */
+               fiemap->fm_mapped_extents = 0;
+               return 0;
+       }
 
        if (!(fiemap->fm_flags & FIEMAP_FLAG_DEVICE_ORDER)) {
                /**
index 4d1f590..c04480b 100755 (executable)
@@ -10039,6 +10039,27 @@ test_130e() {
 }
 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
 
+test_130f() {
+       filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
+       [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
+               return
+
+       local fm_file=$DIR/$tfile
+       $MULTIOP $fm_file oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T33554432c ||
+               error "multiop create with lov_delay_create on $fm_file"
+
+       filefrag -ves $fm_file || error "filefrag $fm_file failed"
+       filefrag_extents=$(filefrag -vek $fm_file |
+                          awk '/extents? found/ { print $2 }')
+       if [[ "$filefrag_extents" != "0" ]]; then
+               error "FIEMAP on $fm_file failed; " \
+                     "returned $filefrag_extents expected 0"
+       fi
+
+       rm -f $fm_file
+}
+run_test 130f "FIEMAP (unstriped file)"
+
 # Test for writev/readv
 test_131a() {
        rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 ||