Whamcloud - gitweb
EX-9585 lipe: add lipe_find3 pool option
authorVitaliy Kuznetsov <vkuznetsov@ddn.com>
Tue, 21 May 2024 19:05:16 +0000 (21:05 +0200)
committerAndreas Dilger <adilger@whamcloud.com>
Thu, 30 May 2024 00:41:09 +0000 (00:41 +0000)
Add an option to print the OST pool for a file with the
"-printf" argument, both as long option %{pool} as well as
short option and "%Lp" that is compatible with "lfs find".
The long %{pools} option prints *all* pools in the layout.

Update the lipe-find3.1 man page and add test cases for both.

Test-Parameters: trivial testlist=sanity-lipe-find3,sanity-lipe-scan3
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Vitaliy Kuznetsov <vkuznetsov@ddn.com>
Change-Id: I18d2d3cc161c8aa92eb27c33b06214b6f53ebbe5
Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/54785
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Alexandre Ioffe <aioffe@ddn.com>
lipe/man/lipe_find3.1
lipe/src/lipe_find3/lf3_parse_format.c
lipe/src/lipe_scan3/lipe-scan3-notes.txt
lipe/src/lipe_scan3/ls3_main.c
lipe/src/lipe_scan3/tests/lipe.scm
lustre/tests/sanity-lipe-find3.sh
lustre/tests/sanity-lipe-scan3.sh

index 6ab7fc4..1959b75 100644 (file)
@@ -303,6 +303,8 @@ stripe count of last instantiated component
 file FID
 .IP %{mirror-count},%LN
 FLR mirror count
+.IP %{pool},%Lp
+OST pool name of last instantiated component
 .IP %{projid},%LP
 numerical project ID
 .IP %{stripe-size},%LS
index b8725eb..9732631 100644 (file)
@@ -254,6 +254,9 @@ width:
                case 'N':
                        LF3_EMIT_N('d', "(lov-mirror-count)");
                        break;
+               case 'p':
+                       LF3_EMIT_S('a', "(lov-pool)");
+                       break;
                case 'P':
                        LF3_EMIT_N('d', "(projid)");
                        break;
@@ -324,6 +327,10 @@ width:
                        LF3_EMIT_S('a', "(file-fid)");
                else if (strcmp(ext, "mirror-count") == 0)
                        LF3_EMIT_N('d', "(lov-mirror-count)", ext);
+               else if (strcmp(ext, "pool") == 0)
+                       LF3_EMIT_S('a', "(lov-pool)", ext);
+               else if (strcmp(ext, "pools") == 0)
+                       LF3_EMIT_S('a', "(lov-pools)", ext);
                else if (strcmp(ext, "projid") == 0)
                        LF3_EMIT_N('d', "(projid)", ext);
                else if (strcmp(ext, "stripe-count") == 0)
index ef464e4..29b5f7b 100644 (file)
@@ -109,8 +109,8 @@ analagous to the implicit "this" pointer in C++ member functions.
   (flags) inode flags (I)
   (nlink) inode link count (I)
   (mode) inode type and access mode flags (I,C)
-  (size) ... (I)
-  (blocks) ... (I)
+  (size) file size in bytes (I)
+  (blocks) file allocated blocks in 512-byte sectors (I)
   (self-fid) self_fid from lma xattr of inode (F)
   (file-fid) self_fid for MDT inode, FID of corresponding file for OST object (ff_parent)
   (links) list of pairs of parent-fid, name (list (cons F, S) ...)
@@ -118,6 +118,7 @@ analagous to the implicit "this" pointer in C++ member functions.
   (relative-paths) list of all paths to file relative to client mount (list S ...)
   (xattr-ref name) xattr value as bytevector
   (xattrs) list of name, xattr value pairs
+  (pool) name of last initialized pool (S)
   (pools) list of pool names (list S ...)
 
 As much as possible, attribute values are evaluated on demand and
index d45b8ad..524d76e 100644 (file)
@@ -914,6 +914,51 @@ out:
        return scm_from_uint64(stripe_size);
 }
 
+SCM_DEFINE(ls3_scm_lov_pool, "lov-pool", 0, 0, 0,
+          (), "return pool of last component of current file")
+{
+       struct ls3_object_attrs *loa = ls3_attrs_try(LS3_OBJECT_ATTR_LOV);
+       struct llapi_layout *ll = NULL;
+       char buf[LOV_MAXPOOLNAME + 1];
+       SCM lis = SCM_EOL;
+       uint32_t flags;
+       int rc;
+
+       /* TODO Distinguish between missing xattr and other error. */
+       if (loa->loa_layout == NULL)
+               return SCM_EOL;
+
+       ll = loa->loa_layout;
+
+       /* XXX llapi_layout_*() functions return -1 on error and set errno. */
+       rc = llapi_layout_comp_use(ll, LLAPI_LAYOUT_COMP_USE_LAST);
+       if (rc < 0)
+               goto out;
+
+       buf[0] = '\0';
+
+       rc = llapi_layout_comp_flags_get(ll, &flags);
+       if (!(flags & LCME_FL_INIT)) {
+               rc = llapi_layout_comp_use(ll, LLAPI_LAYOUT_COMP_USE_PREV);
+               if (rc < 0)
+                       goto out;
+       }
+
+       rc = llapi_layout_pool_name_get(ll, buf, sizeof(buf));
+       if (rc < 0)
+               goto out;
+
+       if (buf[0] != '\0')
+               lis = scm_from_latin1_string(buf);
+
+out:
+       if (rc < 0)
+               ls3_throw_read_attr_error(LS3_OBJECT_ATTR_LOV,
+                                         errno != 0 ? errno : EINVAL);
+
+       return lis;
+}
+
 SCM_DEFINE(ls3_scm_lov_pools_list, "lov-pools", 0, 0, 0,
           (), "return all pools from LOV of current file")
 {
@@ -1521,6 +1566,7 @@ static void ls3_module_init(void *unused)
        "lov-stripe-count",
        "lov-stripe-size",
        "lov-ost-indexes",
+       "lov-pool",
        "lov-pools",
        "print-json",
        "print-file-fid",
index 97ca965..6bde9c0 100644 (file)
@@ -55,6 +55,7 @@
           file-fid
           self-fid
           links
+          lov-pool
           lov-pools
           lov-ost-indexes
           xattrs
index e12dec8..63bbab4 100644 (file)
@@ -983,6 +983,10 @@ run_test 115 "lipe_find3 -path and -ipath with UTF-8"
 test_116() {
        local file=$MOUNT/$tfile
        declare -a fid
+       local mb=1
+       local first_pool=tst_pool
+       declare -A fid_s
+       local combined="($first_pool"
        local x
 
        init_lipe_find3_env
@@ -1072,6 +1076,42 @@ test_116() {
                        -name $tfile-4-$x -printf '%LS %{fid}'
        done
 
+       # Test pool and pools options
+       $LFS setstripe -E "$mb"M -c 1 --pool "$first_pool" "$file-pfl-all" ||
+               error "cannot first setstripe pool $x for file $file-pfl-all"
+
+       for x in testpool newpool oldpool; do
+               $LFS setstripe -c 1 --pool "$x" "$file-5-$x" ||
+                       error "cannot setstripe pool "$x" for file $file-5-$x"
+
+               fid_s[${x}]=$($LFS path2fid "$file-5-$x")
+               echo XXX > "$file-5-$x"
+
+               mb=$((mb + 10))
+               $LFS setstripe --comp-add -E "$mb"M -c 1 \
+                                               --pool $x "$file-pfl-all" ||
+                       error "cannot setstripe pool $x for file $file-pfl-all"
+
+               echo XXX >> "$file-pfl-all"
+       done
+       pfid=$($LFS path2fid "$file-pfl-all")
+       sync
+
+       for x in testpool newpool oldpool; do
+               combined+=" $x"
+               expect1 "$x ${fid_s[${x}]}" lipe_find3_facet mds1 \
+                       -name $tfile-5-$x -printf '%{pool} %{fid}'
+               expect1 "$x ${fid_s[${x}]}" lipe_find3_facet mds1 \
+                       -name $tfile-5-$x -printf '%Lp %{fid}'
+       done
+       combined+=")"
+
+       expect1 "$combined $pfid" lipe_find3_facet mds1 \
+               -name $tfile-pfl-all -printf '%{pools} %{fid}'
+
+       expect1 "newpool $pfid" lipe_find3_facet mds1 \
+               -name $tfile-pfl-all -printf '%Lp %{fid}'
+
        init_lipe_find3_env
 }
 run_test 116 "lipe_find3 verify printf formats"
index 50b2f47..2e07085 100644 (file)
@@ -398,7 +398,7 @@ test_100() {
        done
 
        for proc in absolute-paths relative-paths links lov-mirror-count \
-               lov-ost-indexes lov-pools lov-stripe-count xattrs; do
+               lov-ost-indexes lov-pool lov-pools lov-stripe-count xattrs; do
                expect_print lipe_scan3_format $facet "($proc)"
        done
 }
@@ -830,6 +830,7 @@ test_130() {
        ost_indexes=($($LFS getstripe --yaml "$file" | yq '.lmm_objects[] |
                        .l_ost_idx'))
 
+       expect_expr "$facet" '(lov-pool)' '()'
        expect_expr "$facet" '(lov-pools)' '()'
        expect_expr "$facet" '(lov-ost-indexes)' "(${ost_indexes[*]})"
 }