Whamcloud - gitweb
LU-12361 lov: fix wrong calculated length for fiemap 83/35083/3
authorWang Shilong <wshilong@ddn.com>
Thu, 30 May 2019 14:46:09 +0000 (22:46 +0800)
committerOleg Drokin <green@whamcloud.com>
Thu, 20 Jun 2019 03:56:33 +0000 (03:56 +0000)
lov_stripe_intersects() will return a closed interval
[@obd_start, @obd_end], so to calcuate length of interval we need

 @obd_end - @obd_start + 1

rather than

 @obd_end - @obd_start

Wrong extent length will make us return wrong fiemap information.

Lustre-change: https://review.whamcloud.com/34998
Lustre-commit: 225e7b8c70fb68bc3aa3a6d88c5e9bda322c9cc9

Change-Id: I30deb17cf5fa80a6d3046098fbac0d3faa01ad1c
Signed-off-by: Wang Shilong <wshilong@ddn.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Gu Zheng <gzheng@ddn.com>
Signed-off-by: Minh Diep <mdiep@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/35083
Tested-by: Jenkins
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/lov/lov_object.c
lustre/lov/lov_offset.c
lustre/tests/sanity.sh

index 200f943..b0568d7 100644 (file)
@@ -1646,7 +1646,7 @@ int fiemap_for_stripe(const struct lu_env *env, struct cl_object *obj,
        if (lun_start == lun_end)
                return 0;
 
-       req_fm_len = obd_object_end - lun_start;
+       req_fm_len = obd_object_end - lun_start + 1;
        fs->fs_fm->fm_length = 0;
        len_mapped_single_call = 0;
 
@@ -1689,7 +1689,7 @@ int fiemap_for_stripe(const struct lu_env *env, struct cl_object *obj,
                        fs->fs_fm->fm_mapped_extents = 1;
 
                        fm_ext[0].fe_logical = lun_start;
-                       fm_ext[0].fe_length = obd_object_end - lun_start;
+                       fm_ext[0].fe_length = obd_object_end - lun_start + 1;
                        fm_ext[0].fe_flags |= FIEMAP_EXTENT_UNKNOWN;
 
                        goto inactive_tgt;
index 6ed52e2..0c9d668 100644 (file)
@@ -237,6 +237,8 @@ loff_t lov_size_to_stripe(struct lov_stripe_md *lsm, int index, u64 file_size,
  * given an extent in an lov and a stripe, calculate the extent of the stripe
  * that is contained within the lov extent.  this returns true if the given
  * stripe does intersect with the lov extent.
+ *
+ * Closed interval [@obd_start, @obd_end] will be returned.
  */
 int lov_stripe_intersects(struct lov_stripe_md *lsm, int index, int stripeno,
                          struct lu_extent *ext, u64 *obd_start, u64 *obd_end)
index afd1a18..76c3758 100755 (executable)
@@ -20297,6 +20297,15 @@ test_812() {
 }
 run_test 812 "do not drop reqs generated when imp is going to idle (LU-11951)"
 
+test_814()
+{
+       dd of=$DIR/$tfile seek=128 bs=1k < /dev/null
+       echo -n y >> $DIR/$tfile
+       cp --sparse=always $DIR/$tfile $DIR/${tfile}.cp || error "copy failed"
+       diff $DIR/$tfile $DIR/${tfile}.cp || error "files should be same"
+}
+run_test 814 "sparse cp works as expected (LU-12361)"
+
 #
 # tests that do cleanup/setup should be run at the end
 #