From c81288a1e2a9a6b26176f9167ad39482189abecd Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Thu, 17 Feb 2022 13:51:32 -0600 Subject: [PATCH] EX-4015 lipe: cache layout in loa In ldiskfs_read_attr_lov(), cache the decoded llapi_layout() in the current object attrs. Then resue this layout in lov-pools. Add lov-ost-indexes to return a list of all object OST indexes for the current file. Test-Parameters: trivial testlist=sanity-lipe-scan3 facet=mds1 Signed-off-by: John L. Hammond Change-Id: I3451857fc25f1f9507b6e185bad39fcb3f0e6f22 Reviewed-on: https://review.whamcloud.com/46546 Tested-by: jenkins Tested-by: Maloo --- lipe/src/lipe_scan3/ls3_main.c | 66 ++++++++++++++++++++++++++++------ lipe/src/lipe_scan3/ls3_object_attrs.c | 4 +++ lipe/src/lipe_scan3/ls3_object_attrs.h | 1 + lipe/src/lipe_scan3/ls3_scan.c | 7 ++-- lipe/src/lipe_scan3/tests/lipe.scm | 3 +- lustre/tests/sanity-lipe-scan3.sh | 20 +++++++---- 6 files changed, 78 insertions(+), 23 deletions(-) diff --git a/lipe/src/lipe_scan3/ls3_main.c b/lipe/src/lipe_scan3/ls3_main.c index 32ebfd2..e5fa5b3 100644 --- a/lipe/src/lipe_scan3/ls3_main.c +++ b/lipe/src/lipe_scan3/ls3_main.c @@ -656,8 +656,8 @@ out: } #undef FUNC_NAME -SCM_DEFINE(ls3_scm_pools_list, "pools", 0, 0, 0, - (), "return pools of current file") +SCM_DEFINE(ls3_scm_lov_pools_list, "lov-pools", 0, 0, 0, + (), "return all pools from LOV of current file") { struct ls3_object_attrs *loa = ls3_attrs_try(LS3_OBJECT_ATTR_LOV); struct llapi_layout *ll = NULL; @@ -670,12 +670,8 @@ SCM_DEFINE(ls3_scm_pools_list, "pools", 0, 0, 0, return SCM_EOL; /* XXX llapi_layout_*() functions return -1 on error and set errno. */ - errno = 0; - ll = llapi_layout_get_by_xattr(loa->loa_lum, loa->loa_lum_size, 0); - if (ll == NULL) { - rc = -1; - goto out; - } + assert(loa->loa_layout != NULL); + ll = loa->loa_layout; rc = llapi_layout_comp_use(ll, LLAPI_LAYOUT_COMP_USE_LAST); if (rc < 0) @@ -696,8 +692,57 @@ SCM_DEFINE(ls3_scm_pools_list, "pools", 0, 0, 0, goto out; } out: - llapi_layout_free(ll); + if (rc < 0) + ls3_throw_read_attr_error(LS3_OBJECT_ATTR_LOV, + errno != 0 ? errno : EINVAL); + + return lis; +} + +SCM_DEFINE(ls3_scm_lov_ost_indexes_list, "lov-ost-indexes", 0, 0, 0, + (), "return all object OST indexes for current file") +{ + struct ls3_object_attrs *loa = ls3_attrs_try(LS3_OBJECT_ATTR_LOV); + struct llapi_layout *ll = NULL; + SCM lis = SCM_EOL; + int rc; + + /* TODO Distinguish between missing xattr and other error. */ + if (!(loa->loa_attr_bits & LS3_OBJECT_ATTR_LOV)) + return SCM_EOL; + + /* XXX llapi_layout_*() functions return -1 on error and set errno. */ + assert(loa->loa_layout != NULL); + ll = loa->loa_layout; + rc = llapi_layout_comp_use(ll, LLAPI_LAYOUT_COMP_USE_LAST); + if (rc < 0) + goto out; + + while (rc == 0) { + uint64_t stripe_count; + uint64_t i; + + rc = llapi_layout_stripe_count_get(ll, &stripe_count); + if (rc < 0) + goto out; + + /* XXX We build the list in reverse order. */ + for (i = stripe_count; i != 0; i--) { + uint64_t ost_index = -1; + + rc = llapi_layout_ost_index_get(ll, i - 1, &ost_index); + if (rc < 0) + goto out; + + lis = scm_cons(scm_from_uint64(ost_index), lis); + } + + rc = llapi_layout_comp_use(ll, LLAPI_LAYOUT_COMP_USE_PREV); + if (rc < 0) + goto out; + } +out: if (rc < 0) ls3_throw_read_attr_error(LS3_OBJECT_ATTR_LOV, errno != 0 ? errno : EINVAL); @@ -1055,7 +1100,8 @@ static void ls3_scm_init(void *unused) "relative-paths", "xattrs", "xattr-ref", - "pools", + "lov-ost-indexes", + "lov-pools", "print-json", "print-file-fid", "print-self-fid", diff --git a/lipe/src/lipe_scan3/ls3_object_attrs.c b/lipe/src/lipe_scan3/ls3_object_attrs.c index 872fbfb..76dc162 100644 --- a/lipe/src/lipe_scan3/ls3_object_attrs.c +++ b/lipe/src/lipe_scan3/ls3_object_attrs.c @@ -12,6 +12,7 @@ #include #include #include +#include #include "list.h" #include "ls3_debug.h" #include "ls3_scan.h" @@ -404,6 +405,8 @@ void lipe_object_attrs_reset(struct ls3_object_attrs *loa) lipe_object_attrs_links_fini(loa); lipe_object_attrs_paths_fini(loa); lipe_object_attrs_xattrs_fini(loa); + llapi_layout_free(loa->loa_layout); + loa->loa_layout = NULL; } int lipe_object_attrs_init(struct ls3_object_attrs *loa) @@ -434,6 +437,7 @@ void lipe_object_attrs_fini(struct ls3_object_attrs *loa) free(loa->loa_lum); free(loa->loa_link_buf); free(loa->loa_lmv_buf); + llapi_layout_free(loa->loa_layout); } static int lipe_object_attrs_add_link(struct ls3_object_attrs *attrs, diff --git a/lipe/src/lipe_scan3/ls3_object_attrs.h b/lipe/src/lipe_scan3/ls3_object_attrs.h index 73bea61..76a0feb 100644 --- a/lipe/src/lipe_scan3/ls3_object_attrs.h +++ b/lipe/src/lipe_scan3/ls3_object_attrs.h @@ -169,6 +169,7 @@ struct ls3_object_attrs { size_t loa_lmv_buf_size; struct lov_user_md *loa_lum; int loa_lum_size; + struct llapi_layout *loa_layout; /* LS3_OBJECT_ATTR_LOV */ struct hsm_user_state loa_hsm_state; struct lustre_som_attrs loa_som; /* The entry number. If inode is not directory, value is zero */ diff --git a/lipe/src/lipe_scan3/ls3_scan.c b/lipe/src/lipe_scan3/ls3_scan.c index dfa3abb..808fabc1 100644 --- a/lipe/src/lipe_scan3/ls3_scan.c +++ b/lipe/src/lipe_scan3/ls3_scan.c @@ -376,7 +376,6 @@ static int ldiskfs_read_attr_lov(struct ls3_instance *li, struct ls3_object_attrs *loa) { struct lov_user_md *lum = loa->loa_lum; - struct llapi_layout *layout = NULL; int size; int rc; @@ -387,8 +386,8 @@ static int ldiskfs_read_attr_lov(struct ls3_instance *li, if (rc < 0) goto out; - layout = llapi_layout_get_by_xattr(lum, size, 0); - if (layout == NULL) { + loa->loa_layout = llapi_layout_get_by_xattr(lum, size, 0); + if (loa->loa_layout == NULL) { LS3_ERROR_OBJ(lo, "cannot decode '%s' xattr: rc = %d\n", XATTR_NAME_LOV, rc); rc = -errno; @@ -397,8 +396,6 @@ static int ldiskfs_read_attr_lov(struct ls3_instance *li, loa->loa_attr_bits |= LS3_OBJECT_ATTR_LOV; out: - llapi_layout_free(layout); - return rc; } diff --git a/lipe/src/lipe_scan3/tests/lipe.scm b/lipe/src/lipe_scan3/tests/lipe.scm index 78f1bb6..4316c77 100644 --- a/lipe/src/lipe_scan3/tests/lipe.scm +++ b/lipe/src/lipe_scan3/tests/lipe.scm @@ -46,7 +46,8 @@ file-fid self-fid links - pools + lov-pools + lov-ost-indexes xattrs absolute-paths diff --git a/lustre/tests/sanity-lipe-scan3.sh b/lustre/tests/sanity-lipe-scan3.sh index 86fddbc..5d5bada 100644 --- a/lustre/tests/sanity-lipe-scan3.sh +++ b/lustre/tests/sanity-lipe-scan3.sh @@ -16,8 +16,8 @@ FAIL_ON_ERROR=false declare -r ROOT_FID="[0x200000007:0x1:0x0]" -# bug number for skipped test: -ALWAYS_EXCEPT="$SANITY_LIPE_SCAN3_EXCEPT" +# bug number for skipped test: DCO-8906 +ALWAYS_EXCEPT="$SANITY_LIPE_SCAN3_EXCEPT 130" # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT! (( OSTCOUNT >= 2 )) || skip_env "need at least 2 OSTs" @@ -34,6 +34,9 @@ for t in lipe_scan3; do done which jq || skip_env "jq is not installed" +which yq || skip_env "yq is not installed" +jq --version +yq --version build_test_filter check_and_setup_lustre @@ -320,7 +323,7 @@ test_100() { expect_print lipe_scan3_format "$device" "($proc)" done - for proc in absolute-paths relative-paths links pools xattrs; do + for proc in absolute-paths relative-paths links lov-pools lov-ost-indexes xattrs; do expect_print lipe_scan3_format "$device" "($proc)" done } @@ -641,14 +644,17 @@ test_130() { local facet=mds1 local device="$(facet_device $facet)" local file=$MOUNT/$tfile - local fd + local -a ost_indexes - init_lipe_scan3_env_file "$file" + init_lipe_scan3_env + $LFS setstripe -c -1 "$file" echo XXX > "$file" + ost_indexes=($($LFS getstripe --yaml "$file" | yq '.lmm_objects[] | .l_ost_idx')) - expect_expr "$device" '(pools)' '()' + expect_expr "$device" '(lov-pools)' '()' + expect_expr "$device" '(lov-ost-indexes)' "(${ost_indexes[*]})" } -run_test 130 "lipe_scan3 pools does the right thing" +run_test 130 "lipe_scan3 lov-pools and lov-ost-indexes do the right thing" test_200() { local facet=mds1 -- 1.8.3.1