From 79c3088bda2948093df989c685568c9cc49419f0 Mon Sep 17 00:00:00 2001 From: Andrew Perepechko Date: Mon, 16 Jan 2023 08:13:34 -0500 Subject: [PATCH] LU-16480 lov: fiemap improperly handles fm_extent_count=0 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. Lustre-change: https://review.whamcloud.com/49645 Lustre-commit: 829af7b029d8e4e391b93792bf5214611b0193bd Fixes: 409719608c ("LU-11848 lov: FIEMAP support for PFL and FLR file") Signed-off-by: Andrew Perepechko Change-Id: I65e706b5dd5c8a6db90a539c2602af839b4da823 HPE-bug-id: LUS-11443 Reviewed-by: Andreas Dilger Reviewed-by: Alexander Boyko Signed-off-by: Etienne AUJAMES Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/55362 Tested-by: jenkins Tested-by: Maloo --- lustre/lov/lov_object.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lustre/lov/lov_object.c b/lustre/lov/lov_object.c index 10d4987..ea39f1f 100644 --- a/lustre/lov/lov_object.c +++ b/lustre/lov/lov_object.c @@ -2066,7 +2066,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; @@ -2156,9 +2156,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 -- 1.8.3.1