}
#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;
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)
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);
"relative-paths",
"xattrs",
"xattr-ref",
- "pools",
+ "lov-ost-indexes",
+ "lov-pools",
"print-json",
"print-file-fid",
"print-self-fid",
#include <linux/lustre/lustre_fid.h>
#include <linux/lustre/lustre_idl.h>
#include <linux/lustre/lustre_ioctl.h>
+#include <lustre/lustreapi.h>
#include "list.h"
#include "ls3_debug.h"
#include "ls3_scan.h"
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)
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,
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 */
struct ls3_object_attrs *loa)
{
struct lov_user_md *lum = loa->loa_lum;
- struct llapi_layout *layout = NULL;
int size;
int rc;
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;
loa->loa_attr_bits |= LS3_OBJECT_ATTR_LOV;
out:
- llapi_layout_free(layout);
-
return rc;
}
file-fid
self-fid
links
- pools
+ lov-pools
+ lov-ost-indexes
xattrs
absolute-paths
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"
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
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
}
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