+ if (depth && path && ((verbose != VERBOSE_OBJID) ||
+ !(flags & LDF_IS_DIR)) && !yaml)
+ llapi_printf(LLAPI_MSG_NORMAL, "%s\n", path);
+
+ if (verbose & VERBOSE_DETAIL) {
+ llapi_printf(LLAPI_MSG_NORMAL, "composite_header:\n");
+ llapi_printf(LLAPI_MSG_NORMAL, "%2slcm_magic: 0x%08X\n",
+ " ", comp_v1->lcm_magic);
+ llapi_printf(LLAPI_MSG_NORMAL, "%2slcm_size: %u\n",
+ " ", comp_v1->lcm_size);
+ if (flags & LDF_IS_DIR)
+ llapi_printf(LLAPI_MSG_NORMAL,
+ "%2slcm_flags: %s\n", " ",
+ comp_v1->lcm_mirror_count > 0 ?
+ "mirrored" : "");
+ else
+ llapi_printf(LLAPI_MSG_NORMAL,
+ "%2slcm_flags: %s\n", " ",
+ llapi_layout_flags_string(comp_v1->lcm_flags));
+ }
+
+ if (verbose & VERBOSE_GENERATION) {
+ if (verbose & ~VERBOSE_GENERATION)
+ llapi_printf(LLAPI_MSG_NORMAL, "%2slcm_layout_gen: ",
+ " ");
+ llapi_printf(LLAPI_MSG_NORMAL, "%u\n", comp_v1->lcm_layout_gen);
+ }
+
+ if (verbose & VERBOSE_MIRROR_COUNT) {
+ if (verbose & ~VERBOSE_MIRROR_COUNT)
+ llapi_printf(LLAPI_MSG_NORMAL, "%2slcm_mirror_count: ",
+ " ");
+ llapi_printf(LLAPI_MSG_NORMAL, "%u\n",
+ comp_v1->lcm_magic == LOV_USER_MAGIC_COMP_V1 ?
+ comp_v1->lcm_mirror_count + 1 : 1);
+ }
+
+ if (verbose & VERBOSE_COMP_COUNT) {
+ if (verbose & ~VERBOSE_COMP_COUNT)
+ llapi_printf(LLAPI_MSG_NORMAL, "%2slcm_entry_count: ",
+ " ");
+ llapi_printf(LLAPI_MSG_NORMAL, "%u\n",
+ comp_v1->lcm_magic == LOV_USER_MAGIC_COMP_V1 ?
+ comp_v1->lcm_entry_count : 0);
+ }
+
+ if (verbose & VERBOSE_DETAIL && !yaml)
+ llapi_printf(LLAPI_MSG_NORMAL, "components:\n");
+}
+
+static void lcme_flags2str(__u32 comp_flags)
+{
+ bool found = false;
+ int i = 0;
+
+ if (!comp_flags) {
+ llapi_printf(LLAPI_MSG_NORMAL, "0");
+ return;
+ }
+ for (i = 0; i < ARRAY_SIZE(comp_flags_table); i++) {
+ if (comp_flags & comp_flags_table[i].cfn_flag) {
+ if (found)
+ llapi_printf(LLAPI_MSG_NORMAL, ",");
+ llapi_printf(LLAPI_MSG_NORMAL, "%s",
+ comp_flags_table[i].cfn_name);
+ comp_flags &= ~comp_flags_table[i].cfn_flag;
+ found = true;
+ }
+ }
+ if (comp_flags) {
+ if (found)
+ llapi_printf(LLAPI_MSG_NORMAL, ",");
+ llapi_printf(LLAPI_MSG_NORMAL, "%#x", comp_flags);
+ }
+}
+
+static void lov_dump_comp_v1_entry(struct find_param *param,
+ enum lov_dump_flags flags, int index)
+{
+ 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;
+ 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 && !yaml)
+ llapi_printf(LLAPI_MSG_NORMAL,
+ "%slcme_id: ", " - ");
+ else if (verbose & ~VERBOSE_COMP_ID)
+ llapi_printf(LLAPI_MSG_NORMAL,
+ "%4slcme_id: ", " ");
+ if (entry->lcme_id != LCME_ID_INVAL)
+ llapi_printf(LLAPI_MSG_NORMAL, "%u", entry->lcme_id);
+ else
+ llapi_printf(LLAPI_MSG_NORMAL, "N/A");
+ separator = "\n";
+ }
+
+ if (verbose & VERBOSE_MIRROR_ID) {
+ llapi_printf(LLAPI_MSG_NORMAL, "%s", separator);
+ if (verbose & ~VERBOSE_MIRROR_ID)
+ llapi_printf(LLAPI_MSG_NORMAL,
+ "%4slcme_mirror_id: ", " ");
+ if (entry->lcme_id != LCME_ID_INVAL)
+ llapi_printf(LLAPI_MSG_NORMAL, "%u",
+ mirror_id_of(entry->lcme_id));
+ else
+ llapi_printf(LLAPI_MSG_NORMAL, "N/A");
+ separator = "\n";
+ }
+
+ if (verbose & VERBOSE_COMP_FLAGS) {
+ llapi_printf(LLAPI_MSG_NORMAL, "%s", separator);
+ if (verbose & ~VERBOSE_COMP_FLAGS)
+ llapi_printf(LLAPI_MSG_NORMAL,
+ "%4slcme_flags: ", " ");
+ lcme_flags2str(entry->lcme_flags);
+ separator = "\n";
+ }
+
+ if (verbose & VERBOSE_COMP_START) {
+ llapi_printf(LLAPI_MSG_NORMAL, "%s", separator);
+ if (verbose & ~VERBOSE_COMP_START)
+ llapi_printf(LLAPI_MSG_NORMAL,
+ "%4slcme_extent.e_start: ", " ");
+ llapi_printf(LLAPI_MSG_NORMAL, "%llu",
+ entry->lcme_extent.e_start);
+ separator = "\n";
+ }
+
+ if (verbose & VERBOSE_COMP_END) {
+ llapi_printf(LLAPI_MSG_NORMAL, "%s", separator);
+ if (verbose & ~VERBOSE_COMP_END)
+ llapi_printf(LLAPI_MSG_NORMAL,
+ "%4slcme_extent.e_end: ", " ");
+ if (entry->lcme_extent.e_end == LUSTRE_EOF)
+ llapi_printf(LLAPI_MSG_NORMAL, "%s", "EOF");
+ else
+ llapi_printf(LLAPI_MSG_NORMAL, "%llu",
+ entry->lcme_extent.e_end);
+ separator = "\n";
+ }
+
+ 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);
+ llapi_printf(LLAPI_MSG_NORMAL, "%4slcme_size: %u\n",
+ " ", entry->lcme_size);
+ llapi_printf(LLAPI_MSG_NORMAL, "%4ssub_layout:\n", " ");
+ } else {
+ llapi_printf(LLAPI_MSG_NORMAL, "%s", separator);
+ }
+}
+
+/* Check if the value matches 1 of the given criteria (e.g. --atime +/-N).
+ * @mds indicates if this is MDS timestamps and there are attributes on OSTs.
+ *
+ * The result is -1 if it does not match, 0 if not yet clear, 1 if matches.
+ * The table below gives the answers for the specified parameters (value and
+ * sign), 1st column is the answer for the MDS value, the 2nd is for the OST:
+ * --------------------------------------
+ * 1 | file > limit; sign > 0 | -1 / -1 |
+ * 2 | file = limit; sign > 0 | -1 / -1 |
+ * 3 | file < limit; sign > 0 | ? / 1 |
+ * 4 | file > limit; sign = 0 | -1 / -1 |
+ * 5 | file = limit; sign = 0 | ? / 1 | <- (see the Note below)
+ * 6 | file < limit; sign = 0 | ? / -1 |
+ * 7 | file > limit; sign < 0 | 1 / 1 |
+ * 8 | file = limit; sign < 0 | ? / -1 |
+ * 9 | file < limit; sign < 0 | ? / -1 |
+ * --------------------------------------
+ * Note: 5th actually means that the value is within the interval
+ * (limit - margin, limit]. */
+static int find_value_cmp(unsigned long long file, unsigned long long limit,
+ int sign, int negopt, unsigned long long margin,
+ int mds)
+{
+ int ret = -1;
+
+ if (sign > 0) {
+ /* Drop the fraction of margin (of days). */
+ if (file + margin <= limit)
+ ret = mds ? 0 : 1;
+ } else if (sign == 0) {
+ if (file <= limit && file + margin > limit)
+ ret = mds ? 0 : 1;
+ else if (file + margin <= limit)
+ ret = mds ? 0 : -1;
+ } else if (sign < 0) {
+ if (file > limit)
+ ret = 1;
+ else if (mds)
+ ret = 0;
+ }
+
+ return negopt ? ~ret + 1 : ret;
+}
+
+static inline struct lov_user_md *
+lov_comp_entry(struct lov_comp_md_v1 *comp_v1, int ent_idx)
+{
+ return (struct lov_user_md *)((char *)comp_v1 +
+ comp_v1->lcm_entries[ent_idx].lcme_offset);
+}
+
+static inline struct lov_user_ost_data_v1 *
+lov_v1v3_objects(struct lov_user_md *v1)
+{
+ if (v1->lmm_magic == LOV_USER_MAGIC_V3)
+ return ((struct lov_user_md_v3 *)v1)->lmm_objects;