"usage: getstripe [--ost|-O <uuid>] [--quiet|-q] [--verbose|-v]\n"
" [--stripe-count|-c] [--stripe-index|-i]\n"
" [--pool|-p] [--stripe-size|-S] [--directory|-d]\n"
- " [--mdt|-m] [--recursive|-r] [--raw|-R]\n"
+ " [--mdt|-m] [--recursive|-r] [--raw|-R] [--yaml|-y]\n"
" [--layout|-L] [--fid|-F] [--generation|-g]\n"
" [--component-id|-I [comp_id]]\n"
" [--component-flags [comp_flags]]\n"
"To list the striping info for a given directory\n"
"or recursively for all directories in a directory tree.\n"
"usage: getdirstripe [--obd|-O <uuid>] [--mdt-count|-c]\n"
- " [--mdt-index|-i] [--mdt-hash|-H]\n"
- " [--recursive|-r] [--default|-D] <dir> ..."},
+ " [--mdt-index|-i] [--mdt-hash|-t]\n"
+ " [--recursive|-r] [--yaml|-y]\n"
+ " [--default|-D] <dir> ..."},
{"mkdir", lfs_setdirstripe, 0,
"To create a striped directory on a specified MDT. This can only\n"
"be done on MDT0 with the right of administrator.\n"
{"stripe_size", no_argument, 0, 'S'},
/* dirstripe {"mdt-count", required_argument, 0, 'T'}, */
{"verbose", no_argument, 0, 'v'},
+ {"yaml", no_argument, 0, 'y'},
{0, 0, 0, 0}
};
int c, rc;
char *end, *tmp;
- while ((c = getopt_long(argc, argv, "cdDE:FghiI:LmMoO:pqrRsSv",
+ while ((c = getopt_long(argc, argv, "cdDE:FghiI:LmMoO:pqrRsSvy",
long_opts, NULL)) != -1) {
switch (c) {
case 'c':
case 'v':
param->fp_verbose = VERBOSE_DEFAULT | VERBOSE_DETAIL;
break;
+ case 'y':
+ param->fp_yaml = 1;
+ break;
default:
return CMD_HELP;
}
{"default", no_argument, 0, 'D'},
{"obd", required_argument, 0, 'O'},
{"mdt-count", no_argument, 0, 'T'},
+ {"yaml", no_argument, 0, 'y'},
{0, 0, 0, 0}
};
int c, rc;
param.fp_get_lmv = 1;
while ((c = getopt_long(argc, argv,
- "cDHiO:rtT", long_opts, NULL)) != -1)
+ "cDHiO:rtTy", long_opts, NULL)) != -1)
{
switch (c) {
case 'O':
case 'r':
param.fp_recursive = 1;
break;
+ case 'y':
+ param.fp_yaml = 1;
+ break;
default:
return CMD_HELP;
}
LDF_IS_RAW = 0x0002,
LDF_INDENT = 0x0004,
LDF_SKIP_OBJS = 0x0008,
+ LDF_YAML = 0x0010,
};
static void lov_dump_user_lmm_header(struct lov_user_md *lum, char *path,
bool is_dir = flags & LDF_IS_DIR;
bool is_raw = flags & LDF_IS_RAW;
bool indent = flags & LDF_INDENT;
+ bool yaml = flags & LDF_YAML;
bool skip_objs = flags & LDF_SKIP_OBJS;
char *prefix = is_dir ? "" : "lmm_";
char *separator = "";
llapi_printf(LLAPI_MSG_NORMAL, "%s(Default) ", space);
}
- if (!indent && depth && path && ((verbose != VERBOSE_OBJID) || !is_dir))
+ if (!yaml && !indent && depth && path &&
+ ((verbose != VERBOSE_OBJID) || !is_dir))
llapi_printf(LLAPI_MSG_NORMAL, "%s\n", path);
if ((verbose & VERBOSE_DETAIL) && !is_dir) {
(uintmax_t)lmm_oi_id(&lum->lmm_oi));
}
if ((verbose & (VERBOSE_DETAIL | VERBOSE_DFID)) && !is_dir) {
+ __u64 seq;
+ __u32 oid;
+ __u32 ver;
+
if (verbose & ~VERBOSE_DFID)
llapi_printf(LLAPI_MSG_NORMAL, "%slmm_fid: ",
space);
* separate lmm_oi_seq() and lmm_oi_id() routines for this.
*
* For newer layout types hopefully this will be a real FID. */
- llapi_printf(LLAPI_MSG_NORMAL, DFID"\n",
- lmm_oi_seq(&lum->lmm_oi) == 0 ?
- lmm_oi_id(&lum->lmm_oi) :
- lmm_oi_seq(&lum->lmm_oi),
- lmm_oi_seq(&lum->lmm_oi) == 0 ?
- 0 : (__u32)lmm_oi_id(&lum->lmm_oi),
- (__u32)(lmm_oi_id(&lum->lmm_oi) >> 32));
+ seq = lmm_oi_seq(&lum->lmm_oi) == 0 ?
+ lmm_oi_id(&lum->lmm_oi) : lmm_oi_seq(&lum->lmm_oi);
+ oid = lmm_oi_seq(&lum->lmm_oi) == 0 ?
+ 0 : (__u32)lmm_oi_id(&lum->lmm_oi);
+ ver = (__u32)(lmm_oi_id(&lum->lmm_oi) >> 32);
+ if (yaml)
+ llapi_printf(LLAPI_MSG_NORMAL, DFID_NOBRACE"\n",
+ seq, oid, ver);
+ else
+ llapi_printf(LLAPI_MSG_NORMAL, DFID"\n",
+ seq, oid, ver);
}
if (verbose & VERBOSE_COUNT) {
llapi_printf(LLAPI_MSG_NORMAL, "%hd",
(__s16)lum->lmm_stripe_count);
}
- separator = is_dir ? " " : "\n";
+ if (!yaml && is_dir)
+ separator = " ";
+ else
+ separator = "\n";
}
if (verbose & VERBOSE_SIZE) {
llapi_printf(LLAPI_MSG_NORMAL, "%u",
lum->lmm_stripe_size);
}
- separator = is_dir ? " " : "\n";
+ if (!yaml && is_dir)
+ separator = " ";
+ else
+ separator = "\n";
}
if ((verbose & VERBOSE_LAYOUT) && !is_dir) {
else
llapi_printf(LLAPI_MSG_NORMAL, "%u",
objects[0].l_ost_idx);
- separator = is_dir ? " " : "\n";
+ if (!yaml && is_dir)
+ separator = " ";
+ else
+ separator = "\n";
}
if ((verbose & VERBOSE_POOL) && pool_name && (pool_name[0] != '\0')) {
llapi_printf(LLAPI_MSG_NORMAL, "%s%spool: ",
space, prefix);
llapi_printf(LLAPI_MSG_NORMAL, "%s", pool_name);
- separator = is_dir ? " " : "\n";
+ if (!yaml && is_dir)
+ separator = " ";
+ else
+ separator = "\n";
}
if (strlen(separator) != 0)
bool is_dir = flags & LDF_IS_DIR;
bool indent = flags & LDF_INDENT;
bool skip_objs = flags & LDF_SKIP_OBJS;
+ bool yaml = flags & LDF_YAML;
int i, obdstripe = (obdindex != OBD_NOT_FOUND) ? 0 : 1;
if (!obdstripe) {
if (indent)
llapi_printf(LLAPI_MSG_NORMAL,
"%6slmm_objects:\n", " ");
+ else if (yaml)
+ llapi_printf(LLAPI_MSG_NORMAL, "lmm_objects:\n");
else
llapi_printf(LLAPI_MSG_NORMAL,
"\tobdidx\t\t objid\t\t objid\t\t group\n");
if (obdindex != OBD_NOT_FOUND && obdindex != idx)
continue;
- if (indent) {
+ if (yaml) {
+ struct lu_fid fid = { 0 };
+
+ ostid_to_fid(&fid, &objects[i].l_ost_oi, idx);
+ llapi_printf(LLAPI_MSG_NORMAL,
+ "%sl_ost_idx: %d\n", space, idx);
+ llapi_printf(LLAPI_MSG_NORMAL,
+ "%8sl_fid: "DFID_NOBRACE"\n",
+ " ", PFID(&fid));
+ } else if (indent) {
struct lu_fid fid = { 0 };
ostid_to_fid(&fid, &objects[i].l_ost_oi, idx);
}
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, int verbose,
+ enum lov_dump_flags flags)
{
struct lmv_user_mds_data *objects = lum->lum_objects;
char *prefix = lum->lum_magic == LMV_USER_MAGIC ? "(Default)" : "";
int i, obdstripe = 0;
char *separator = "";
+ bool yaml = flags & LDF_YAML;
if (obdindex != OBD_NOT_FOUND) {
if (lum->lum_stripe_count == 0) {
llapi_printf(LLAPI_MSG_NORMAL, "lmv_stripe_count: ");
llapi_printf(LLAPI_MSG_NORMAL, "%u",
(int)lum->lum_stripe_count);
- if (verbose & VERBOSE_OFFSET)
+ if ((verbose & VERBOSE_OFFSET) && !yaml)
separator = " ";
else
separator = "\n";
llapi_printf(LLAPI_MSG_NORMAL, "lmv_stripe_offset: ");
llapi_printf(LLAPI_MSG_NORMAL, "%d",
(int)lum->lum_stripe_offset);
- if (verbose & VERBOSE_HASH_TYPE)
+ if (verbose & VERBOSE_HASH_TYPE && !yaml)
separator = " ";
else
separator = "\n";
struct lov_comp_md_v1 *comp_v1 = (void *)¶m->fp_lmd->lmd_lmm;
int depth = param->fp_max_depth;
int verbose = param->fp_verbose;
+ bool yaml = flags & LDF_YAML;
if (depth && path && ((verbose != VERBOSE_OBJID) ||
- !(flags & LDF_IS_DIR)))
+ !(flags & LDF_IS_DIR)) && !yaml)
llapi_printf(LLAPI_MSG_NORMAL, "%s\n", path);
if (verbose & VERBOSE_DETAIL) {
comp_v1->lcm_entry_count);
}
- if (verbose & VERBOSE_DETAIL)
+ if (verbose & VERBOSE_DETAIL && !yaml)
llapi_printf(LLAPI_MSG_NORMAL, "components:\n");
}
struct lov_comp_md_entry_v1 *entry;
char *separator = "";
int verbose = param->fp_verbose;
+ bool yaml = flags & LDF_YAML;
entry = &comp_v1->lcm_entries[index];
+ if (yaml)
+ llapi_printf(LLAPI_MSG_NORMAL, "%2scomponent%d:\n", " ", index);
+
if (verbose & VERBOSE_COMP_ID) {
- if (verbose & VERBOSE_DETAIL)
+ if (verbose & VERBOSE_DETAIL && !yaml)
llapi_printf(LLAPI_MSG_NORMAL,
"%slcme_id: ", " - ");
else if (verbose & ~VERBOSE_COMP_ID)
separator = "\n";
}
- if (verbose & VERBOSE_DETAIL) {
+ if (yaml) {
+ llapi_printf(LLAPI_MSG_NORMAL, "%s", separator);
+ llapi_printf(LLAPI_MSG_NORMAL, "%4ssub_layout:\n", " ");
+ } else if (verbose & VERBOSE_DETAIL) {
llapi_printf(LLAPI_MSG_NORMAL, "%s", separator);
llapi_printf(LLAPI_MSG_NORMAL, "%4slcme_offset: %u\n",
" ", entry->lcme_offset);
if (param->fp_raw)
flags |= LDF_IS_RAW;
+ if (param->fp_yaml)
+ flags |= LDF_YAML;
switch (magic) {
case LOV_USER_MAGIC_V1:
lum = (struct lmv_user_md *)param->fp_lmv_md;
strlcpy(pool_name, lum->lum_pool_name, sizeof(pool_name));
lmv_dump_user_lmm(lum, pool_name, path, param->fp_obd_index,
- param->fp_max_depth, param->fp_verbose);
+ param->fp_max_depth, param->fp_verbose,
+ flags);
break;
}
case LOV_USER_MAGIC_COMP_V1: