From 113fa79b7dc9b598c615d4cbfa6e3513d2c6d35b Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Tue, 19 Dec 2017 10:00:04 +0100 Subject: [PATCH] LU-10405 lov: fill no-extent fiemap on object with no stripe. 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 Reviewed-on: https://review.whamcloud.com/30591 Tested-by: Jenkins Reviewed-by: Quentin Bouget Reviewed-by: Andreas Dilger Tested-by: Maloo --- lustre/lov/lov_object.c | 7 +++++-- lustre/tests/sanity.sh | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/lustre/lov/lov_object.c b/lustre/lov/lov_object.c index 9b56d84..3628b7a 100644 --- a/lustre/lov/lov_object.c +++ b/lustre/lov/lov_object.c @@ -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)) { /** diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 4d1f590..c04480b 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -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 || -- 1.8.3.1