Whamcloud - gitweb
LU-3888 utils: print lmm_fid as part of getstripe 65/10465/33
authorAndreas Dilger <andreas.dilger@intel.com>
Sat, 24 Sep 2016 05:32:39 +0000 (11:02 +0530)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 29 Sep 2016 14:59:57 +0000 (14:59 +0000)
Print the lmm_fid in the standard DFID format in addition to the older
lmm_object_id and lmm_seq fields when using "lfs getstripe -v".  This
is still a bit of a hack, since lmm_mds_md_{v1,v3} do not store a
proper FID in the header, so the fields need to be parsed separately
instead of using lmm_oi_seq() and lmm_oi_id(), but at least userspace
can start using this output in scripts instead of needing to call
path2fid separately.

In the future, new layout formats should use proper FIDs instead of
ost_id fields.

Add "lfs getstripe -F" to print the lmm_fid of a file.  This should
match the inode FID from "lfs fid2path" for 2.x-created files.

Document "lfs getstripe -g" option in lfs.1 and usage message.

Fix lfs_fid2path() to not complain on the MDS if an invalid FID is
requested, since an error is returned to the application anyway.
Don't print errors in llapi_fid2path(), there is already one being
printed in lfs_fid2path().

Rename VERBOSE_ALL to VERBOSE_DEFAULT to make it more clear what this
is for, since it didn't actually print all of the components.

Add PFL VERBOSE_COMP_* flags to lustreapi.h to avoid future conflicts.

Test-Parameters: trivial
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Signed-off-by: Lokesh Nagappa Jaliminche <lokesh.jaliminche@seagate.com>
Change-Id: I4e27797ec3905327ea0a88911b1c75193d500c1e
Reviewed-on: http://review.whamcloud.com/10465
Reviewed-by: Fan Yong <fan.yong@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
lustre/doc/lfs.1
lustre/include/lustre/lustre_user.h
lustre/include/lustre/lustreapi.h
lustre/mdt/mdt_handler.c
lustre/tests/sanity.sh
lustre/utils/lfs.c
lustre/utils/liblustreapi.c

index 522c38a..a9eb54e 100644 (file)
@@ -32,9 +32,8 @@ lfs \- Lustre utility to create a file with specific striping pattern, find the
 .B lfs getname [-h]|[path ...]
 .br
 .B lfs getstripe [--obd|-O <uuid>] [--quiet|-q] [--verbose|-v]
-        \fB[--stripe-count|-c ] [--stripe-index|-i] [--mdt-index|-M]
-        \fB[--stripe-size|-S] [--directory|-d]
-        \fB[--layout|-L]
+        \fB[--stripe-count|-c ] [--stripe-index|-i] [--mdt-index|-M] [--fid|-F]
+        \fB[--stripe-size|-S] [--directory|-d] [--layout|-L] [--generation|-g]
         \fB[--pool|-p] [--recursive|-r] [--raw|-R] <dirname|filename> ...\fR
 .br
 .B lfs migrate \fB-m <mdt_index>\fR
@@ -156,7 +155,7 @@ to that filesystem are displayed.
 .B getstripe [--obd|-O <uuid>] [--quiet|-q] [--verbose|-v]
         \fB[--count | -c ] [--index | -i | --offset | -o  ]
         \fB[--pool | -p ] [--size | -s ] [--directory | -d ]
-        \fB[--layout | -L]
+        \fB[--layout | -L ] [--fid | -F ] [--generation | -g ]
         \fB[--recursive | -r ] [--raw | -R ] <dirname|filename>\fR
 .br
 List the striping information for a given filename or directory tree.
@@ -167,6 +166,8 @@ only want specific striping information then the options of
 .BR --index ,
 .BR --offset ,
 .BR --layout ,
+.BR --fid ,
+.BR --generation ,
 or
 .B --pool
 can be used to return only the specific fields.
@@ -195,6 +196,11 @@ can be used to limit the information, like
 .RB ' "ls -d" ').
 You can limit the returned files to those with objects on a specific OST with
 .BR --obd .
+To show only the FID use
+.BR --fid .
+The layout generation can be printed with the
+.B --generation
+option.
 .TP
 .B setstripe [--stripe-count|-c stripe_count] [--stripe-size|-S stripe_size]
         \fB[--stripe-index|-i start_ost_index] [--pool <poolname>]
index c7f80f7..0b7cdb9 100644 (file)
@@ -382,7 +382,7 @@ struct lov_user_ost_data_v1 {     /* per-stripe data structure */
 struct lov_user_md_v1 {           /* LOV EA user data (host-endian) */
        __u32 lmm_magic;          /* magic number = LOV_USER_MAGIC_V1 */
        __u32 lmm_pattern;        /* LOV_PATTERN_RAID0, LOV_PATTERN_RAID1 */
-       struct ost_id lmm_oi;     /* LOV object ID */
+       struct ost_id lmm_oi;     /* MDT parent inode id/seq (id/0 for 1.x) */
        __u32 lmm_stripe_size;    /* size of stripe in bytes */
        __u16 lmm_stripe_count;   /* num stripes in use for this object */
        union {
@@ -397,7 +397,7 @@ struct lov_user_md_v1 {           /* LOV EA user data (host-endian) */
 struct lov_user_md_v3 {           /* LOV EA user data (host-endian) */
        __u32 lmm_magic;          /* magic number = LOV_USER_MAGIC_V3 */
        __u32 lmm_pattern;        /* LOV_PATTERN_RAID0, LOV_PATTERN_RAID1 */
-       struct ost_id lmm_oi;     /* LOV object ID */
+       struct ost_id lmm_oi;     /* MDT parent inode id/seq (id/0 for 1.x) */
        __u32 lmm_stripe_size;    /* size of stripe in bytes */
        __u16 lmm_stripe_count;   /* num stripes in use for this object */
        union {
index a1cc6e5..613795e 100644 (file)
@@ -131,18 +131,24 @@ extern int llapi_file_get_stripe(const char *path, struct lov_user_md *lum);
 #define HAVE_LLAPI_FILE_LOOKUP
 extern int llapi_file_lookup(int dirfd, const char *name);
 
-#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_ALL            (VERBOSE_COUNT | VERBOSE_SIZE | \
+#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_DEFAULT                (VERBOSE_COUNT | VERBOSE_SIZE | \
                                 VERBOSE_OFFSET | VERBOSE_POOL | \
-                                VERBOSE_OBJID | VERBOSE_GENERATION |\
+                                VERBOSE_OBJID | VERBOSE_GENERATION | \
                                 VERBOSE_LAYOUT)
 
 struct find_param {
index 12cc56e..3e44b43 100644 (file)
@@ -5717,9 +5717,9 @@ static int mdt_fid2path(struct mdt_thread_info *info,
                RETURN(-EINVAL);
 
        if (!fid_is_namespace_visible(&fp->gf_fid)) {
-               CWARN("%s: "DFID" is invalid, sequence should be "
-                     ">= %#llx\n", mdt_obd_name(mdt),
-                     PFID(&fp->gf_fid), (__u64)FID_SEQ_NORMAL);
+               CDEBUG(D_INFO, "%s: "DFID" is invalid, f_seq should be >= "LPX64
+                      ", or f_oid != 0, or f_ver == 0\n", mdt_obd_name(mdt),
+                      PFID(&fp->gf_fid), (__u64)FID_SEQ_NORMAL);
                RETURN(-EINVAL);
        }
 
index 1492176..ca79475 100755 (executable)
@@ -4436,30 +4436,47 @@ test_56a() {    # was test_56
                error "$GETSTRIPE $DIR/$tdir: found $FILENUM, not $NUMFILES"
        echo "$GETSTRIPE --recursive passed."
 
-        # test lfs getstripe with file instead of dir
+       # test lfs getstripe with file instead of dir
        FILENUM=$($GETSTRIPE $DIR/$tdir/file1 | grep -c obdidx)
        [[ $FILENUM -eq 1 ]] ||
                error "$GETSTRIPE $DIR/$tdir/file1: found $FILENUM, not 1"
        echo "$GETSTRIPE file1 passed."
 
-        #test lfs getstripe with --verbose
+       #test lfs getstripe with --verbose
        [[ $($GETSTRIPE --verbose $DIR/$tdir |
                grep -c lmm_magic) -eq $NUMFILES ]] ||
                error "$GETSTRIPE --verbose $DIR/$tdir: want $NUMFILES"
        [[ $($GETSTRIPE $DIR/$tdir | grep -c lmm_magic) -eq 0 ]] ||
-               rror "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
+               error "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
+
+       #test lfs getstripe with -v prints lmm_fid
+       [[ $($GETSTRIPE -v $DIR/$tdir | grep -c lmm_fid) -eq $NUMFILES ]] ||
+               error "$GETSTRIPE -v $DIR/$tdir: want $NUMFILES lmm_fid: lines"
+       [[ $($GETSTRIPE $DIR/$tdir | grep -c lmm_fid) -eq 0 ]] ||
+               error "$GETSTRIPE $DIR/$tdir: showed lmm_fid"
        echo "$GETSTRIPE --verbose passed."
 
-        #test lfs getstripe with --obd
-        $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
+       #check for FID information
+       local fid1=$($GETSTRIPE --fid $DIR/$tdir/file1)
+       local fid2=$($GETSTRIPE --verbose $DIR/$tdir/file1 |
+                      awk '/lmm_fid: / { print $2 }')
+       local fid3=$($LFS path2fid $DIR/$tdir/file1)
+       [ "$fid1" != "$fid2" ] &&
+               error "getstripe --fid $fid1 != getstripe --verbose $fid2"
+       [ "$fid1" != "$fid3" ] &&
+               error "getstripe --fid $fid1 != lfs path2fid $fid3"
+       echo "$GETSTRIPE --fid passed."
+
+       #test lfs getstripe with --obd
+       $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
                grep -q "unknown obduuid" ||
                error "$GETSTRIPE --obd wrong_uuid should return error message"
 
        [[ $OSTCOUNT -lt 2 ]] &&
-                skip_env "skipping other $GETSTRIPE --obd test" && return
+               skip_env "skipping other $GETSTRIPE --obd test" && return
 
-        OSTIDX=1
-        OBDUUID=$(ostuuid_from_index $OSTIDX)
+       OSTIDX=1
+       OBDUUID=$(ostuuid_from_index $OSTIDX)
        FILENUM=$($GETSTRIPE -ir $DIR/$tdir | grep "^$OSTIDX\$" | wc -l)
        FOUND=$($GETSTRIPE -r --obd $OBDUUID $DIR/$tdir | grep obdidx | wc -l)
        [[ $FOUND -eq $FILENUM ]] ||
@@ -4805,7 +4822,7 @@ run_test 56s "check lfs find -stripe-count works"
 
 test_56t() { # LU-611
        TDIR=$DIR/${tdir}t
-       setup_56 $NUMFILES $NUMDIRS "-s 512k"
+       setup_56 $NUMFILES $NUMDIRS "--stripe-size 512k"
 
        $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
 
@@ -10157,17 +10174,17 @@ test_154A() {
        [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
                skip "Need MDS version at least 2.4.1" && return
 
-       touch $DIR/$tfile
-       local FID=$($LFS path2fid $DIR/$tfile)
-       [ -z "$FID" ] && error "path2fid unable to get $DIR/$tfile FID"
+       local tf=$DIR/$tfile
+       touch $tf
 
-       # check that we get the same pathname back
-       local FOUND=$($LFS fid2path $MOUNT "$FID")
-       [ -z "$FOUND" ] && error "fid2path unable to get $FID path"
-       [ "$FOUND" != "$DIR/$tfile" ] &&
-               error "fid2path(path2fid($DIR/$tfile)) = $FOUND != $DIR/$tfile"
+       local fid=$($LFS path2fid $tf)
+       [ -z "$fid" ] && error "path2fid unable to get $tf FID"
 
-       rm -rf $DIR/$tfile
+       # check that we get the same pathname back
+       local found=$($LFS fid2path $MOUNT "$fid")
+       [ -z "$found" ] && error "fid2path unable to get '$fid' path"
+       [ "$found" == "$tf" ] ||
+               error "fid2path($fid=path2fid($tf)) = $found != $tf"
 }
 run_test 154A "lfs path2fid and fid2path basic checks"
 
index be62857..7d11175 100644 (file)
@@ -175,11 +175,11 @@ command_t cmdlist[] = {
        {"getstripe", lfs_getstripe, 0,
         "To list the striping info for a given file or files in a\n"
         "directory or recursively for all files in a directory tree.\n"
-        "usage: getstripe [--ost|-O <uuid>] [--quiet | -q] [--verbose | -v]\n"
+        "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-index|-M] [--recursive|-r] [--raw|-R]\n"
-        "                 [--layout|-L]\n"
+        "                 [--layout|-L] [--fid|-F] [--generation|-g]\n"
         "                 <directory|filename> ..."},
        {"setdirstripe", lfs_setdirstripe, 0,
         "To create a striped directory on a specified MDT. This can only\n"
@@ -1738,6 +1738,7 @@ static int lfs_getstripe_internal(int argc, char **argv,
                {"stripe_count",        no_argument,            0, 'c'},
                {"directory",           no_argument,            0, 'd'},
                {"default",             no_argument,            0, 'D'},
+               {"fid",                 no_argument,            0, 'F'},
                {"generation",          no_argument,            0, 'g'},
 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 9, 53, 0)
                /* This formerly implied "stripe-index", but was explicitly
@@ -1775,7 +1776,7 @@ static int lfs_getstripe_internal(int argc, char **argv,
        };
        int c, rc;
 
-       while ((c = getopt_long(argc, argv, "cdDghiLMoO:pqrRsSv",
+       while ((c = getopt_long(argc, argv, "cdDFghiLMoO:pqrRsSv",
                                long_opts, NULL)) != -1) {
                switch (c) {
                case 'O':
@@ -1796,11 +1797,17 @@ static int lfs_getstripe_internal(int argc, char **argv,
                case 'D':
                        param->fp_get_default_lmv = 1;
                        break;
+               case 'F':
+                       if (!(param->fp_verbose & VERBOSE_DETAIL)) {
+                               param->fp_verbose |= VERBOSE_DFID;
+                               param->fp_max_depth = 0;
+                       }
+                       break;
                case 'r':
                        param->fp_recursive = 1;
                        break;
                case 'v':
-                       param->fp_verbose = VERBOSE_ALL | VERBOSE_DETAIL;
+                       param->fp_verbose = VERBOSE_DEFAULT | VERBOSE_DETAIL;
                        break;
                case 'c':
 #if LUSTRE_VERSION_CODE >= OBD_OCD_VERSION(2, 6, 53, 0)
@@ -1880,7 +1887,7 @@ static int lfs_getstripe_internal(int argc, char **argv,
                param->fp_max_depth = -1;
 
        if (!param->fp_verbose)
-               param->fp_verbose = VERBOSE_ALL;
+               param->fp_verbose = VERBOSE_DEFAULT;
        if (param->fp_quiet)
                param->fp_verbose = VERBOSE_OBJID;
 
index e0ed3bb..df4b459 100644 (file)
@@ -2103,13 +2103,13 @@ static int sattr_cache_get_defaults(const char *const fsname,
 }
 
 static void lov_dump_user_lmm_header(struct lov_user_md *lum, char *path,
-                                     struct lov_user_ost_data_v1 *objects,
-                                     int is_dir, int verbose, int depth,
-                                     int raw, char *pool_name)
+                                    struct lov_user_ost_data_v1 *objects,
+                                    int is_dir, int verbose, int depth,
+                                    int raw, char *pool_name)
 {
-        char *prefix = is_dir ? "" : "lmm_";
+       char *prefix = is_dir ? "" : "lmm_";
        char *separator = "";
-        int rc;
+       int rc;
 
        if (is_dir && lmm_oi_seq(&lum->lmm_oi) == FID_SEQ_LOV_DEFAULT) {
                lmm_oi_set_seq(&lum->lmm_oi, 0);
@@ -2117,8 +2117,8 @@ static void lov_dump_user_lmm_header(struct lov_user_md *lum, char *path,
                        llapi_printf(LLAPI_MSG_NORMAL, "(Default) ");
        }
 
-        if (depth && path && ((verbose != VERBOSE_OBJID) || !is_dir))
-                llapi_printf(LLAPI_MSG_NORMAL, "%s\n", path);
+       if (depth && path && ((verbose != VERBOSE_OBJID) || !is_dir))
+               llapi_printf(LLAPI_MSG_NORMAL, "%s\n", path);
 
        if ((verbose & VERBOSE_DETAIL) && !is_dir) {
                llapi_printf(LLAPI_MSG_NORMAL, "lmm_magic:          0x%08X\n",
@@ -2128,58 +2128,86 @@ static void lov_dump_user_lmm_header(struct lov_user_md *lum, char *path,
                llapi_printf(LLAPI_MSG_NORMAL, "lmm_object_id:      %#jx\n",
                             (uintmax_t)lmm_oi_id(&lum->lmm_oi));
        }
+       if ((verbose & (VERBOSE_DETAIL | VERBOSE_DFID)) && !is_dir) {
+               if (verbose & ~VERBOSE_DFID)
+                       llapi_printf(LLAPI_MSG_NORMAL, "lmm_fid:            ");
+               /* This needs a bit of hand-holding since old 1.x lmm_oi
+                * have { oi.oi_id = mds_inum, oi.oi_seq = 0 } and 2.x lmm_oi
+                * have { oi.oi_id = mds_oid, oi.oi_seq = mds_seq } instead of
+                * a real FID.  Ideally the 2.x code would have stored this
+                * like a FID with { oi_id = mds_seq, oi_seq = mds_oid } so the
+                * ostid union lu_fid { f_seq = mds_seq, f_oid = mds_oid }
+                * worked properly (especially since IGIF FIDs use mds_inum as
+                * the FID SEQ), but unfortunately that didn't happen.
+                *
+                * Print it to look like an IGIF FID, even though the fields
+                * are reversed on disk, so that it makes sense to userspace.
+                *
+                * Don't use ostid_id() and ostid_seq(), since they assume the
+                * oi_fid fields are in the right order.  This is why there are
+                * 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));
+       }
 
-        if (verbose & VERBOSE_COUNT) {
-                if (verbose & ~VERBOSE_COUNT)
-                        llapi_printf(LLAPI_MSG_NORMAL, "%sstripe_count:   ",
-                                     prefix);
-                if (is_dir) {
-                        if (!raw && lum->lmm_stripe_count == 0) {
-                                unsigned int scount;
-                                rc = sattr_cache_get_defaults(NULL, path,
-                                                              &scount, NULL,
-                                                              NULL);
-                                if (rc == 0)
+       if (verbose & VERBOSE_COUNT) {
+               if (verbose & ~VERBOSE_COUNT)
+                       llapi_printf(LLAPI_MSG_NORMAL, "%sstripe_count:   ",
+                                    prefix);
+               if (is_dir) {
+                       if (!raw && lum->lmm_stripe_count == 0) {
+                               unsigned int scount;
+                               rc = sattr_cache_get_defaults(NULL, path,
+                                                             &scount, NULL,
+                                                             NULL);
+                               if (rc == 0)
                                        llapi_printf(LLAPI_MSG_NORMAL, "%d",
                                                     scount);
-                                else
-                                        llapi_error(LLAPI_MSG_ERROR, rc,
-                                                    "Cannot determine default"
-                                                    " stripe count.");
-                        } else {
+                               else
+                                       llapi_error(LLAPI_MSG_ERROR, rc,
+                                                   "Cannot determine default"
+                                                   " stripe count.");
+                       } else {
                                llapi_printf(LLAPI_MSG_NORMAL, "%d",
-                                             lum->lmm_stripe_count ==
-                                             (typeof(lum->lmm_stripe_count))(-1)
+                                            lum->lmm_stripe_count ==
+                                            (typeof(lum->lmm_stripe_count))(-1)
                                             ? -1 : lum->lmm_stripe_count);
-                        }
-                } else {
+                       }
+               } else {
                        llapi_printf(LLAPI_MSG_NORMAL, "%hd",
                                     (__s16)lum->lmm_stripe_count);
-                }
+               }
                separator = is_dir ? " " : "\n";
-        }
+       }
 
-        if (verbose & VERBOSE_SIZE) {
+       if (verbose & VERBOSE_SIZE) {
                llapi_printf(LLAPI_MSG_NORMAL, "%s", separator);
-                if (verbose & ~VERBOSE_SIZE)
-                        llapi_printf(LLAPI_MSG_NORMAL, "%sstripe_size:    ",
-                                     prefix);
-                if (is_dir && !raw && lum->lmm_stripe_size == 0) {
-                        unsigned int ssize;
-                        rc = sattr_cache_get_defaults(NULL, path, NULL, &ssize,
-                                                      NULL);
-                        if (rc == 0)
+               if (verbose & ~VERBOSE_SIZE)
+                       llapi_printf(LLAPI_MSG_NORMAL, "%sstripe_size:    ",
+                                    prefix);
+               if (is_dir && !raw && lum->lmm_stripe_size == 0) {
+                       unsigned int ssize;
+                       rc = sattr_cache_get_defaults(NULL, path, NULL, &ssize,
+                                                     NULL);
+                       if (rc == 0)
                                llapi_printf(LLAPI_MSG_NORMAL, "%u", ssize);
-                        else
-                                llapi_error(LLAPI_MSG_ERROR, rc,
-                                            "Cannot determine default"
-                                            " stripe size.");
-                } else {
+                       else
+                               llapi_error(LLAPI_MSG_ERROR, rc,
+                                           "Cannot determine default"
+                                           " stripe size.");
+               } else {
                        llapi_printf(LLAPI_MSG_NORMAL, "%u",
                                     lum->lmm_stripe_size);
-                }
+               }
                separator = is_dir ? " " : "\n";
-        }
+       }
 
        if ((verbose & VERBOSE_LAYOUT) && !is_dir) {
                llapi_printf(LLAPI_MSG_NORMAL, "%s", separator);
@@ -2190,42 +2218,42 @@ static void lov_dump_user_lmm_header(struct lov_user_md *lum, char *path,
                separator = "\n";
        }
 
-        if ((verbose & VERBOSE_GENERATION) && !is_dir) {
+       if ((verbose & VERBOSE_GENERATION) && !is_dir) {
                llapi_printf(LLAPI_MSG_NORMAL, "%s", separator);
-                if (verbose & ~VERBOSE_GENERATION)
-                        llapi_printf(LLAPI_MSG_NORMAL, "%slayout_gen:     ",
-                                     prefix);
+               if (verbose & ~VERBOSE_GENERATION)
+                       llapi_printf(LLAPI_MSG_NORMAL, "%slayout_gen:     ",
+                                    prefix);
                llapi_printf(LLAPI_MSG_NORMAL, "%u",
                             (int)lum->lmm_layout_gen);
                separator = "\n";
-        }
+       }
 
-        if (verbose & VERBOSE_OFFSET) {
+       if (verbose & VERBOSE_OFFSET) {
                llapi_printf(LLAPI_MSG_NORMAL, "%s", separator);
-                if (verbose & ~VERBOSE_OFFSET)
-                        llapi_printf(LLAPI_MSG_NORMAL, "%sstripe_offset:  ",
-                                     prefix);
-                if (is_dir)
+               if (verbose & ~VERBOSE_OFFSET)
+                       llapi_printf(LLAPI_MSG_NORMAL, "%sstripe_offset:  ",
+                                    prefix);
+               if (is_dir)
                        llapi_printf(LLAPI_MSG_NORMAL, "%d",
-                                     lum->lmm_stripe_offset ==
-                                     (typeof(lum->lmm_stripe_offset))(-1) ? -1 :
+                                    lum->lmm_stripe_offset ==
+                                    (typeof(lum->lmm_stripe_offset))(-1) ? -1 :
                                     lum->lmm_stripe_offset);
-                else
+               else
                        llapi_printf(LLAPI_MSG_NORMAL, "%u",
                                     objects[0].l_ost_idx);
                separator = is_dir ? " " : "\n";
-        }
+       }
 
-        if ((verbose & VERBOSE_POOL) && (pool_name != NULL)) {
+       if ((verbose & VERBOSE_POOL) && (pool_name != NULL)) {
                llapi_printf(LLAPI_MSG_NORMAL, "%s", separator);
-                if (verbose & ~VERBOSE_POOL)
-                        llapi_printf(LLAPI_MSG_NORMAL, "%spool:           ",
-                                     prefix);
+               if (verbose & ~VERBOSE_POOL)
+                       llapi_printf(LLAPI_MSG_NORMAL, "%spool:           ",
+                                    prefix);
                llapi_printf(LLAPI_MSG_NORMAL, "%s", pool_name);
-        }
+       }
 
-        if (!is_dir || (is_dir && (verbose != VERBOSE_OBJID)))
-                llapi_printf(LLAPI_MSG_NORMAL, "\n");
+       if (!is_dir || (is_dir && (verbose != VERBOSE_OBJID)))
+               llapi_printf(LLAPI_MSG_NORMAL, "\n");
 }
 
 void lov_dump_user_lmm_v1v3(struct lov_user_md *lum, char *pool_name,
@@ -3804,6 +3832,7 @@ int llapi_changelog_clear(const char *mdtname, const char *idstr,
 int llapi_fid2path(const char *device, const char *fidstr, char *buf,
                   int buflen, long long *recno, int *linkno)
 {
+       const char *fidstr_orig = fidstr;
        struct lu_fid fid;
        struct getinfo_fid2path *gf;
        int rc;
@@ -3814,8 +3843,8 @@ int llapi_fid2path(const char *device, const char *fidstr, char *buf,
        sscanf(fidstr, SFID, RFID(&fid));
        if (!fid_is_sane(&fid)) {
                llapi_err_noerrno(LLAPI_MSG_ERROR,
-                                 "bad FID format [%s], should be [seq:oid:ver]"
-                                 " (e.g. "DFID")\n", fidstr,
+                                 "bad FID format '%s', should be [seq:oid:ver]"
+                                 " (e.g. "DFID")\n", fidstr_orig,
                                  (unsigned long long)FID_SEQ_NORMAL, 2, 0);
                return -EINVAL;
        }
@@ -3823,6 +3852,7 @@ int llapi_fid2path(const char *device, const char *fidstr, char *buf,
        gf = malloc(sizeof(*gf) + buflen);
        if (gf == NULL)
                return -ENOMEM;
+
        gf->gf_fid = fid;
        gf->gf_recno = *recno;
        gf->gf_linkno = *linkno;
@@ -3830,21 +3860,20 @@ int llapi_fid2path(const char *device, const char *fidstr, char *buf,
 
        /* Take path or fsname */
        rc = root_ioctl(device, OBD_IOC_FID2PATH, gf, NULL, 0);
-       if (rc) {
-               if (rc != -ENOENT)
-                       llapi_error(LLAPI_MSG_ERROR, rc, "ioctl err %d", rc);
-       } else {
-               memcpy(buf, gf->gf_u.gf_path, gf->gf_pathlen);
-               if (buf[0] == '\0') { /* ROOT path */
-                       buf[0] = '/';
-                       buf[1] = '\0';
-               }
-               *recno = gf->gf_recno;
-               *linkno = gf->gf_linkno;
-        }
+       if (rc)
+               goto out_free;
 
-        free(gf);
-        return rc;
+       memcpy(buf, gf->gf_u.gf_path, gf->gf_pathlen);
+       if (buf[0] == '\0') { /* ROOT path */
+               buf[0] = '/';
+               buf[1] = '\0';
+       }
+       *recno = gf->gf_recno;
+       *linkno = gf->gf_linkno;
+
+out_free:
+       free(gf);
+       return rc;
 }
 
 static int fid_from_lma(const char *path, const int fd, lustre_fid *fid)