X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Futils%2Fll_decode_filter_fid.c;h=cc648ffb8cb93d200afb8e635ae40c2149b768fa;hp=36c802251d0b29ebdc356a9e7a5207344089c7e9;hb=381a8cdd527ce4deccfc3f7eb461892f6f2f3fff;hpb=e3a7c58aebafce40323db54bf6056029e5af4a70 diff --git a/lustre/utils/ll_decode_filter_fid.c b/lustre/utils/ll_decode_filter_fid.c index 36c8022..cc648ff 100644 --- a/lustre/utils/ll_decode_filter_fid.c +++ b/lustre/utils/ll_decode_filter_fid.c @@ -15,11 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ @@ -27,7 +23,7 @@ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. * - * Copyright (c) 2011, Whamcloud, Inc. + * Copyright (c) 2011, 2017, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -46,8 +42,42 @@ #include #include #include -#include -#include +#include +#include + +#define PFID_STRIPE_IDX_BITS 16 +#define PFID_STRIPE_COUNT_MASK ((1 << PFID_STRIPE_IDX_BITS) - 1) + +#if __BYTE_ORDER == __BIG_ENDIAN +static void lustre_swab_lu_fid(struct lu_fid *fid) +{ + __swab64s(&fid->f_seq); + __swab32s(&fid->f_oid); + __swab32s(&fid->f_ver); +} + +static void lustre_loa_swab(struct lustre_ost_attrs *loa) +{ + struct lustre_mdt_attrs *lma = &loa->loa_lma; + + __swab32s(&lma->lma_compat); + __swab32s(&lma->lma_incompat); + lustre_swab_lu_fid(&lma->lma_self_fid); + if (lma->lma_compat & LMAC_STRIPE_INFO) { + lustre_swab_lu_fid(&loa->loa_parent_fid); + __swab32s(&loa->loa_stripe_size); + } + if (lma->lma_compat & LMAC_COMP_INFO) { + __swab32s(&loa->loa_comp_id); + __swab64s(&loa->loa_comp_start); + __swab64s(&loa->loa_comp_end); + } +}; +#else +static void lustre_loa_swab(struct lustre_ost_attrs *loa) +{ +} +#endif int main(int argc, char *argv[]) { @@ -57,26 +87,114 @@ int main(int argc, char *argv[]) for (i = 1; i < argc; i++) { char buf[1024]; /* allow xattr that may be larger */ struct filter_fid *ff = (void *)buf; + static int printed; int size; - size = getxattr(argv[i], "trusted.fid", buf, sizeof(buf)); + size = getxattr(argv[i], "trusted.fid", buf, + sizeof(struct filter_fid)); if (size < 0) { + if (errno == ENODATA) { + struct lustre_ost_attrs *loa = (void *)buf; + int rc1; + + rc1 = getxattr(argv[i], "trusted.lma", loa, + sizeof(*loa)); + if (rc1 < sizeof(*loa)) { + fprintf(stderr, + "%s: error reading fid: %s\n", + argv[i], strerror(ENODATA)); + if (!rc) + rc = size; + continue; + } + + lustre_loa_swab(loa); + if (!(loa->loa_lma.lma_compat & + LMAC_STRIPE_INFO)) { + fprintf(stderr, + "%s: not stripe info: %s\n", + argv[i], strerror(ENODATA)); + if (!rc) + rc = size; + continue; + } + + printf("%s: parent="DFID" stripe=%u " + "stripe_size=%u stripe_count=%u", + argv[i], loa->loa_parent_fid.f_seq, + loa->loa_parent_fid.f_oid, 0, /* ver */ + loa->loa_parent_fid.f_stripe_idx & + PFID_STRIPE_COUNT_MASK, + loa->loa_stripe_size, + loa->loa_parent_fid.f_stripe_idx >> + PFID_STRIPE_IDX_BITS); + if (loa->loa_comp_id != 0) + printf(" component_id=%u " + "component_start=%llu " + "component_end=%llu", + loa->loa_comp_id, + loa->loa_comp_start, + loa->loa_comp_end); + printf("\n"); + continue; + } + fprintf(stderr, "%s: error reading fid: %s\n", argv[i], strerror(errno)); - if (rc == 0) + if (!rc) rc = size; - continue; - } - if (size > sizeof(*ff)) - fprintf(stderr, "%s: warning: fid larger than expected " - "(%d bytes), recompile?\n", argv[i], size); - - printf("%s: objid="LPU64" seq="LPU64" parent="DFID"\n", - argv[i], le64_to_cpu(ff->ff_objid), - le64_to_cpu(ff->ff_seq), - le64_to_cpu(ff->ff_parent.f_seq), - le32_to_cpu(ff->ff_parent.f_oid), - le32_to_cpu(ff->ff_parent.f_ver)); + continue; + } + + if (size != sizeof(struct filter_fid) && + size != sizeof(struct filter_fid_18_23) && + size != sizeof(struct filter_fid_24_29) && + size != sizeof(struct filter_fid_210) && !printed) { + fprintf(stderr, + "%s: warning: ffid size is unexpected (%d bytes), recompile?\n", + argv[i], size); + printed = 1; + + if (size < sizeof(struct filter_fid_24_29)) + continue; + } + + printf("%s: ", argv[i]); + if (size == sizeof(struct filter_fid_18_23)) { + struct filter_fid_18_23 *ffo = (void *)buf; + + printf("objid=%llu seq=%llu ", + (unsigned long long)__le64_to_cpu(ffo->ff_objid), + (unsigned long long)__le64_to_cpu(ffo->ff_seq)); + } + + printf("parent="DFID" stripe=%u", + (unsigned long long)__le64_to_cpu(ff->ff_parent.f_seq), + __le32_to_cpu(ff->ff_parent.f_oid), 0, /* ver */ + /* this is stripe_nr actually */ + __le32_to_cpu(ff->ff_parent.f_stripe_idx)); + + if (size >= sizeof(struct filter_fid_210)) { + struct ost_layout *ol = &ff->ff_layout; + + /* new filter_fid, support PFL */ + printf(" stripe_size=%u stripe_count=%u", + __le32_to_cpu(ol->ol_stripe_size), + __le32_to_cpu(ol->ol_stripe_count)); + if (ol->ol_comp_id != 0) + printf(" component_id=%u " + "component_start=%llu " + "component_end=%llu", + __le32_to_cpu(ol->ol_comp_id), + __le64_to_cpu(ol->ol_comp_start), + __le64_to_cpu(ol->ol_comp_end)); + } + if (size >= sizeof(struct filter_fid)) + printf(" layout_version=%u range=%u", + __le32_to_cpu(ff->ff_layout_version), + __le32_to_cpu(ff->ff_range)); + + printf("\n"); } return rc;