void llapi_set_command_name(const char *cmd);
void llapi_clear_command_name(void);
-#define VERBOSE_COUNT 0x1
-#define VERBOSE_SIZE 0x2
-#define VERBOSE_OFFSET 0x4
-#define VERBOSE_POOL 0x8
-#define VERBOSE_DETAIL 0x10
-#define VERBOSE_OBJID 0x20
-#define VERBOSE_GENERATION 0x40
-#define VERBOSE_MDTINDEX 0x80
-#define VERBOSE_LAYOUT 0x100
-#define VERBOSE_COMP_COUNT 0x200
-#define VERBOSE_COMP_FLAGS 0x400
-#define VERBOSE_COMP_START 0x800
-#define VERBOSE_COMP_END 0x1000
-#define VERBOSE_COMP_ID 0x2000
-#define VERBOSE_DFID 0x4000
-#define VERBOSE_HASH_TYPE 0x8000
-#define VERBOSE_MIRROR_COUNT 0x10000
-#define VERBOSE_MIRROR_ID 0x20000
-#define VERBOSE_DEFAULT (VERBOSE_COUNT | VERBOSE_SIZE | \
- VERBOSE_OFFSET | VERBOSE_POOL | \
- VERBOSE_OBJID | VERBOSE_GENERATION | \
- VERBOSE_LAYOUT | VERBOSE_HASH_TYPE | \
- VERBOSE_COMP_COUNT | VERBOSE_COMP_FLAGS | \
- VERBOSE_COMP_START | VERBOSE_COMP_END | \
- VERBOSE_COMP_ID | VERBOSE_MIRROR_COUNT| \
- VERBOSE_MIRROR_ID)
+enum llapi_layout_verbose {
+ VERBOSE_STRIPE_COUNT = 0x1,
+ VERBOSE_STRIPE_SIZE = 0x2,
+ VERBOSE_STRIPE_OFFSET = 0x4,
+ VERBOSE_POOL = 0x8,
+ VERBOSE_DETAIL = 0x10,
+ VERBOSE_OBJID = 0x20,
+ VERBOSE_GENERATION = 0x40,
+ VERBOSE_MDTINDEX = 0x80,
+ VERBOSE_PATTERN = 0x100,
+ VERBOSE_COMP_COUNT = 0x200,
+ VERBOSE_COMP_FLAGS = 0x400,
+ VERBOSE_COMP_START = 0x800,
+ VERBOSE_COMP_END = 0x1000,
+ VERBOSE_COMP_ID = 0x2000,
+ VERBOSE_DFID = 0x4000,
+ VERBOSE_HASH_TYPE = 0x8000,
+ VERBOSE_MIRROR_COUNT = 0x10000,
+ VERBOSE_MIRROR_ID = 0x20000,
+ VERBOSE_DEFAULT = VERBOSE_STRIPE_COUNT | VERBOSE_STRIPE_SIZE |
+ VERBOSE_STRIPE_OFFSET | VERBOSE_POOL |
+ VERBOSE_OBJID | VERBOSE_GENERATION |
+ VERBOSE_PATTERN | VERBOSE_HASH_TYPE |
+ VERBOSE_COMP_COUNT | VERBOSE_COMP_FLAGS |
+ VERBOSE_COMP_START | VERBOSE_COMP_END |
+ VERBOSE_COMP_ID | VERBOSE_MIRROR_COUNT |
+ VERBOSE_MIRROR_ID
+};
+/* Compatibility with original names */
+#define VERBOSE_SIZE VERBOSE_STRIPE_SIZE
+#define VERBOSE_COUNT VERBOSE_STRIPE_COUNT
+#define VERBOSE_OFFSET VERBOSE_STRIPE_OFFSET
+#define VERBOSE_LAYOUT VERBOSE_PATTERN
struct find_param {
unsigned int fp_max_depth;
fp_check_blocks:1,
fp_exclude_blocks:1;
- int fp_verbose;
+ enum llapi_layout_verbose fp_verbose;
int fp_quiet;
/* regular expression */
verify_mirror_count() {
local tf=$1
local expected=$2
- local mirror_count=$(get_mirror_ids $tf)
+ local mirror_count=$($LFS getstripe -N $tf)
[[ $mirror_count = $expected ]] || {
$LFS getstripe -v $tf
error "extending mirrored file $DIR/$tfile failed"
# make sure the mirrored file was created successfully
- [ $(get_mirror_ids $DIR/$tfile) -eq 2 ] ||
+ [ $($LFS getstripe -N $DIR/$tfile) -eq 2 ] ||
{ $LFS getstripe $DIR/$tfile; error "expected 2 mirrors"; }
drop_client_cache
"without verification failed"
# make sure that $tfile has two mirrors and $tfile-2 does not exist
- [ $(get_mirror_ids $DIR/$tfile) -eq 2 ] ||
+ [ $($LFS getstripe -N $DIR/$tfile) -eq 2 ] ||
{ $LFS getstripe $DIR/$tfile; error "expected count 2"; }
[[ ! -e $DIR/$tfile-2 ]] || error "$DIR/$tfile-2 was not unlinked"
create_file_36 $tf $tf-2 $tf-3
- [ $(get_mirror_ids $tf) -gt 1 ] || error "wrong mirror count"
+ [ $($LFS getstripe -N $tf) -gt 1 ] || error "wrong mirror count"
# test case 1 - check file write and verify layout version
$MULTIOP $tf oO_WRONLY:c ||
verify_ost_layout_version $tf
# test case 2
- local mds_idx=mds$(($($LFS getstripe -m $tf-2) + 1))
+ local mds_facet=mds$(($($LFS getstripe -m $tf-2) + 1))
local delay_sec=10
- do_facet $mds_idx $LCTL set_param fail_val=$delay_sec
+ do_facet $mds_facet $LCTL set_param fail_val=$delay_sec
#define OBD_FAIL_FLR_LV_DELAY 0x1A01
- do_facet $mds_idx $LCTL set_param fail_loc=0x1A01
+ do_facet $mds_facet $LCTL set_param fail_loc=0x1A01
# write should take at least $fail_loc seconds and succeed
local st=$(date +%s)
# verify OST layout version
verify_ost_layout_version $tf
- do_facet $mds_idx $LCTL set_param fail_loc=0
+ do_facet $mds_facet $LCTL set_param fail_loc=0
# test case 3
mds_idx=mds$(($($LFS getstripe -m $tf-3) + 1))
#define OBD_FAIL_FLR_LV_INC 0x1A02
- do_facet $mds_idx $LCTL set_param fail_loc=0x1A02
+ do_facet $mds_facet $LCTL set_param fail_loc=0x1A02
# write open file should return error
$MULTIOP $tf-3 oO_WRONLY:O_SYNC:w1024c &&
error "write a mirrored file succeeded" || true
- do_facet $mds_idx $LCTL set_param fail_loc=0
+ do_facet $mds_facet $LCTL set_param fail_loc=0
}
run_test 36 "write to mirrored files"
}
run_test 35 "LFSCK can rebuild the lost agent entry"
-# It will be replaced by "lfs getstripe -N" via LU-11124.
-get_mirrors_count() {
- local mirrors=$($LFS getstripe $1 |
- awk '/lcm_mirror_count/ { print $2 }')
- echo $mirrors
-}
-
test_36a() {
[ $OSTCOUNT -lt 3 ] && skip "needs >= 3 OSTs" && return
local mirrors
- mirrors=$(get_mirrors_count $DIR/$tdir/f0)
+ mirrors=$($LFS getstripe -N $DIR/$tdir/f0)
[ $mirrors -eq 2 ] || error "(18) $DIR/$tdir/f0 has $mirrors mirrors"
- mirrors=$(get_mirrors_count $DIR/$tdir/f1)
+ mirrors=$($LFS getstripe -N $DIR/$tdir/f1)
[ $mirrors -eq 2 ] || error "(19) $DIR/$tdir/f1 has $mirrors mirrors"
- mirrors=$(get_mirrors_count $DIR/$tdir/f2)
+ mirrors=$($LFS getstripe -N $DIR/$tdir/f2)
[ $mirrors -eq 2 ] || error "(20) $DIR/$tdir/f2 has $mirrors mirrors"
echo "Trigger layout LFSCK on all devices to find out orphan OST-object"
[ $repaired -eq 9 ] ||
error "(24) Expect 9 fixed on mds1, but got: $repaired"
- mirrors=$(get_mirrors_count $DIR/$tdir/f0)
+ mirrors=$($LFS getstripe -N $DIR/$tdir/f0)
[ $mirrors -eq 3 ] || error "(25) $DIR/$tdir/f0 has $mirrors mirrors"
- mirrors=$(get_mirrors_count $DIR/$tdir/f1)
+ mirrors=$($LFS getstripe -N $DIR/$tdir/f1)
[ $mirrors -eq 3 ] || error "(26) $DIR/$tdir/f1 has $mirrors mirrors"
- mirrors=$(get_mirrors_count $DIR/$tdir/f2)
+ mirrors=$($LFS getstripe -N $DIR/$tdir/f2)
[ $mirrors -eq 3 ] || error "(27) $DIR/$tdir/f2 has $mirrors mirrors"
$LFS getstripe $DIR/$tdir/f0 | grep "lcme_mirror_id:.*1" || {
[ $count -eq 9 ] || error "(8) Expect 9 fixed on mds1, but got: $count"
local name=$MOUNT/.lustre/lost+found/MDT0000/${fid}-R-0
- count=$($LFS getstripe $name | awk '/lcm_mirror_count/ { print $2 }')
+ count=$($LFS getstripe --mirror-count $name)
[ $count -eq 3 ] || error "(9) $DIR/$tdir/f0 has $count mirrors"
- count=$($LFS getstripe $name | awk '/lcm_entry_count/ { print $2 }')
- [ $count -eq 6 ] || error "(10) $DIR/$tdir/f0 has $count entries"
+ count=$($LFS getstripe --component-count $name)
+ [ $count -eq 6 ] || error "(10) $DIR/$tdir/f0 has $count components"
$LFS getstripe $name | grep "lcme_mirror_id:.*1" || {
$LFS getstripe $name
[ $count -eq 6 ] || error "(7) Expect 9 fixed on mds1, but got: $count"
local name=$MOUNT/.lustre/lost+found/MDT0000/${fid}-R-0
- count=$($LFS getstripe $name | awk '/lcm_mirror_count/ { print $2 }')
+ count=$($LFS getstripe --mirror-count $name)
[ $count -eq 2 ] || error "(8) $DIR/$tdir/f0 has $count mirrors"
- count=$($LFS getstripe $name | awk '/lcm_entry_count/ { print $2 }')
- [ $count -eq 4 ] || error "(9) $DIR/$tdir/f0 has $count entries"
+ count=$($LFS getstripe --component-count $name)
+ [ $count -eq 4 ] || error "(9) $DIR/$tdir/f0 has $count components"
local flags=$($LFS getstripe $name | head -n 10 |
awk '/lcme_flags/ { print $2 }')
{ .val = 'm', .name = "mdt_index", .has_arg = no_argument },
/* find { .val = 'M', .name = "mtime", .has_arg = required_argument }*/
/* find { .val = 'n', .name = "name", .has_arg = required_argument }*/
+ { .val = 'N', .name = "mirror-count", .has_arg = no_argument },
{ .val = 'O', .name = "obd", .has_arg = required_argument },
{ .val = 'O', .name = "ost", .has_arg = required_argument },
{ .val = 'p', .name = "pool", .has_arg = no_argument },
char *end, *tmp;
while ((c = getopt_long(argc, argv,
- "-cdDE::FghiI::LmMoO:pqrRsSvy",
+ "-cdDE::FghiI::LmMNoO:pqrRsSvy",
long_opts, NULL)) != -1) {
if (neg_opt)
--neg_opt;
break;
case 'i':
if (!(param->fp_verbose & VERBOSE_DETAIL)) {
- param->fp_verbose |= VERBOSE_OFFSET;
+ param->fp_verbose |= VERBOSE_STRIPE_OFFSET;
param->fp_max_depth = 0;
}
break;
break;
case 'L':
if (!(param->fp_verbose & VERBOSE_DETAIL)) {
- param->fp_verbose |= VERBOSE_LAYOUT;
+ param->fp_verbose |= VERBOSE_PATTERN;
param->fp_max_depth = 0;
}
break;
param->fp_max_depth = 0;
param->fp_verbose |= VERBOSE_MDTINDEX;
break;
+ case 'N':
+ if (!(param->fp_verbose & VERBOSE_DETAIL)) {
+ param->fp_verbose |= VERBOSE_MIRROR_COUNT;
+ param->fp_max_depth = 0;
+ }
+ break;
case 'O':
if (param->fp_obd_uuid) {
fprintf(stderr,
break;
case 'S':
if (!(param->fp_verbose & VERBOSE_DETAIL)) {
- param->fp_verbose |= VERBOSE_SIZE;
+ param->fp_verbose |= VERBOSE_STRIPE_SIZE;
param->fp_max_depth = 0;
}
break;
break;
case 'i':
case 'm':
- param.fp_verbose |= VERBOSE_OFFSET;
+ param.fp_verbose |= VERBOSE_STRIPE_OFFSET;
break;
#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(3, 0, 53, 0)
case 't':
static void lov_dump_user_lmm_header(struct lov_user_md *lum, char *path,
struct lov_user_ost_data_v1 *objects,
- int verbose, int depth, char *pool_name,
+ enum llapi_layout_verbose verbose,
+ int depth, char *pool_name,
enum lov_dump_flags flags)
{
bool is_dir = flags & LDF_IS_DIR;
seq, oid, ver);
}
- if (verbose & VERBOSE_COUNT) {
- if (verbose & ~VERBOSE_COUNT)
+ if (verbose & VERBOSE_STRIPE_COUNT) {
+ if (verbose & ~VERBOSE_STRIPE_COUNT)
llapi_printf(LLAPI_MSG_NORMAL, "%s%sstripe_count: ",
space, prefix);
if (is_dir) {
separator = "\n";
}
- if (verbose & VERBOSE_SIZE) {
+ if (verbose & VERBOSE_STRIPE_SIZE) {
llapi_printf(LLAPI_MSG_NORMAL, "%s", separator);
- if (verbose & ~VERBOSE_SIZE)
+ if (verbose & ~VERBOSE_STRIPE_SIZE)
llapi_printf(LLAPI_MSG_NORMAL, "%s%sstripe_size: ",
space, prefix);
if (is_dir && !is_raw && lum->lmm_stripe_size == 0) {
separator = "\n";
}
- if ((verbose & VERBOSE_LAYOUT)) {
+ if ((verbose & VERBOSE_PATTERN)) {
llapi_printf(LLAPI_MSG_NORMAL, "%s", separator);
- if (verbose & ~VERBOSE_LAYOUT)
+ if (verbose & ~VERBOSE_PATTERN)
llapi_printf(LLAPI_MSG_NORMAL, "%s%spattern: ",
space, prefix);
if (lov_pattern_supported(lum->lmm_pattern))
separator = "\n";
}
- if (verbose & VERBOSE_OFFSET) {
+ if (verbose & VERBOSE_STRIPE_OFFSET) {
llapi_printf(LLAPI_MSG_NORMAL, "%s", separator);
- if (verbose & ~VERBOSE_OFFSET)
+ if (verbose & ~VERBOSE_STRIPE_OFFSET)
llapi_printf(LLAPI_MSG_NORMAL, "%s%sstripe_offset: ",
space, prefix);
if (is_dir || skip_objs)
void lov_dump_user_lmm_v1v3(struct lov_user_md *lum, char *pool_name,
struct lov_user_ost_data_v1 *objects,
char *path, int obdindex, int depth,
- int header, enum lov_dump_flags flags)
+ enum llapi_layout_verbose verbose,
+ enum lov_dump_flags flags)
{
bool is_dir = flags & LDF_IS_DIR;
bool indent = flags & LDF_INDENT;
if (!obdstripe)
return;
- lov_dump_user_lmm_header(lum, path, objects, header, depth, pool_name,
+ lov_dump_user_lmm_header(lum, path, objects, verbose, depth, pool_name,
flags);
- if (!is_dir && !skip_objs && (header & VERBOSE_OBJID) &&
+ if (!is_dir && !skip_objs && (verbose & VERBOSE_OBJID) &&
!(lum->lmm_pattern & LOV_PATTERN_F_RELEASED ||
lov_pattern(lum->lmm_pattern) == LOV_PATTERN_MDT)) {
char *space = " - ";
}
void lmv_dump_user_lmm(struct lmv_user_md *lum, char *pool_name,
- char *path, int obdindex, int depth, int verbose,
+ char *path, int obdindex, int depth,
+ enum llapi_layout_verbose verbose,
enum lov_dump_flags flags)
{
struct lmv_user_mds_data *objects = lum->lum_objects;
/* show all information default */
if (!verbose) {
if (lum->lum_magic == LMV_USER_MAGIC)
- verbose = VERBOSE_POOL | VERBOSE_COUNT |
- VERBOSE_OFFSET | VERBOSE_HASH_TYPE;
+ verbose = VERBOSE_POOL | VERBOSE_STRIPE_COUNT |
+ VERBOSE_STRIPE_OFFSET | VERBOSE_HASH_TYPE;
else
verbose = VERBOSE_OBJID;
}
if (depth && path && ((verbose != VERBOSE_OBJID)))
llapi_printf(LLAPI_MSG_NORMAL, "%s%s\n", prefix, path);
- if (verbose & VERBOSE_COUNT) {
+ if (verbose & VERBOSE_STRIPE_COUNT) {
llapi_printf(LLAPI_MSG_NORMAL, "%s", separator);
- if (verbose & ~VERBOSE_COUNT)
+ if (verbose & ~VERBOSE_STRIPE_COUNT)
llapi_printf(LLAPI_MSG_NORMAL, "lmv_stripe_count: ");
llapi_printf(LLAPI_MSG_NORMAL, "%u",
(int)lum->lum_stripe_count);
- if ((verbose & VERBOSE_OFFSET) && !yaml)
+ if ((verbose & VERBOSE_STRIPE_OFFSET) && !yaml)
separator = " ";
else
separator = "\n";
}
- if (verbose & VERBOSE_OFFSET) {
+ if (verbose & VERBOSE_STRIPE_OFFSET) {
llapi_printf(LLAPI_MSG_NORMAL, "%s", separator);
- if (verbose & ~VERBOSE_OFFSET)
+ if (verbose & ~VERBOSE_STRIPE_OFFSET)
llapi_printf(LLAPI_MSG_NORMAL, "lmv_stripe_offset: ");
llapi_printf(LLAPI_MSG_NORMAL, "%d",
(int)lum->lum_stripe_offset);
{
struct lov_comp_md_v1 *comp_v1 = (void *)¶m->fp_lmd->lmd_lmm;
int depth = param->fp_max_depth;
- int verbose = param->fp_verbose;
+ enum llapi_layout_verbose verbose = param->fp_verbose;
bool yaml = flags & LDF_YAML;
if (depth && path && ((verbose != VERBOSE_OBJID) ||
struct lov_comp_md_v1 *comp_v1 = (void *)¶m->fp_lmd->lmd_lmm;
struct lov_comp_md_entry_v1 *entry;
char *separator = "";
- int verbose = param->fp_verbose;
+ enum llapi_layout_verbose verbose = param->fp_verbose;
bool yaml = flags & LDF_YAML;
entry = &comp_v1->lcm_entries[index];
static inline bool has_any_comp_options(struct find_param *param)
{
- int verbose = param->fp_verbose;
+ enum llapi_layout_verbose verbose = param->fp_verbose;
if (param->fp_check_comp_id || param->fp_check_comp_count ||
param->fp_check_comp_start || param->fp_check_comp_end ||