Whamcloud - gitweb
LU-16480 lov: fiemap improperly handles fm_extent_count=0 45/49645/5
authorAndrew Perepechko <andrew.perepechko@hpe.com>
Mon, 16 Jan 2023 13:13:34 +0000 (08:13 -0500)
committerOleg Drokin <green@whamcloud.com>
Fri, 27 Jan 2023 00:31:54 +0000 (00:31 +0000)
FIEMAP calls with fm_extent_count=0 are supposed only to
return the number of extents.

lov_object_fiemap() attempts to initialize stripe_last
based on fiemap->fm_extents[0] which is not initialized
in userspace and not even allocated in kernelspace.

Eventually, the call exits with -EINVAL and "FIEMAP does
not init start entry" kernel log message.

Fixes: 409719608c ("LU-11848 lov: FIEMAP support for PFL and FLR file")
Signed-off-by: Andrew Perepechko <andrew.perepechko@hpe.com>
Change-Id: I65e706b5dd5c8a6db90a539c2602af839b4da823
HPE-bug-id: LUS-11443
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/49645
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Alexander Boyko <alexander.boyko@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/lov/lov_object.c

index 8051878..db6a7f3 100644 (file)
@@ -1901,7 +1901,7 @@ static int lov_object_fiemap(const struct lu_env *env, struct cl_object *obj,
        struct fiemap_state fs = { 0 };
        struct lu_extent range;
        int cur_ext;
-       int stripe_last;
+       int stripe_last = 0;
        int start_stripe = 0;
        bool resume = false;
        ENTRY;
@@ -1989,9 +1989,10 @@ static int lov_object_fiemap(const struct lu_env *env, struct cl_object *obj,
         * the high 16bits of fe_device remember which stripe the last
         * call has been arrived, we'd continue from there in this call.
         */
-       if (fiemap->fm_extent_count && fiemap->fm_extents[0].fe_logical)
+       if (fiemap->fm_extent_count && fiemap->fm_extents[0].fe_logical) {
                resume = true;
-       stripe_last = get_fe_stripenr(&fiemap->fm_extents[0]);
+               stripe_last = get_fe_stripenr(&fiemap->fm_extents[0]);
+       }
        /**
         * stripe_last records stripe number we've been processed in the last
         * call