]> granicus.if.org Git - zfs/commitdiff
OpenZFS 7900 - zdb shouldn't print the path of a znode at verbosity < 5
authorAlan Somers <asomers@gmail.com>
Thu, 13 Apr 2017 21:22:32 +0000 (14:22 -0700)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Fri, 14 Apr 2017 18:11:28 +0000 (11:11 -0700)
Authored by: Alan Somers <asomers@gmail.com>
Approved by: Dan McDonald <danmcd@omniti.com>
Reviewed by: Paul Dagnelie <pcd@delphix.com>
Reviewed by: Matt Ahrens <mahrens@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Ported-by: Giuseppe Di Natale <dinatale2@llnl.gov>
There are two reasons:
1) Finding a znode's path is slower than printing any other znode
   information at verbosity < 5.
2) On a corrupted pool like the one mentioned below, zdb will crash when it
   tries to determine the znode's path. But with this patch, zdb can still
   extract useful information from such pools.

OpenZFS-issue: https://www.illumos.org/issues/7900
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/2b0dee1
Closes #6016

cmd/zdb/zdb.c

index 13d0bcf0e5f1eeb90fd27cdbef36b54fac82b198..e8672c8367d24da87c70a695bff59e83282e912c 100644 (file)
@@ -1824,23 +1824,19 @@ dump_znode(objset_t *os, uint64_t object, void *data, size_t size)
                return;
        }
 
-       error = zfs_obj_to_path(os, object, path, sizeof (path));
-       if (error != 0) {
-               (void) snprintf(path, sizeof (path), "\?\?\?<object#%llu>",
-                   (u_longlong_t)object);
-       }
-       if (dump_opt['d'] < 3) {
-               (void) printf("\t%s\n", path);
-               (void) sa_handle_destroy(hdl);
-               return;
-       }
-
        z_crtime = (time_t)crtm[0];
        z_atime = (time_t)acctm[0];
        z_mtime = (time_t)modtm[0];
        z_ctime = (time_t)chgtm[0];
 
-       (void) printf("\tpath   %s\n", path);
+       if (dump_opt['d'] > 4) {
+               error = zfs_obj_to_path(os, object, path, sizeof (path));
+               if (error != 0) {
+                       (void) snprintf(path, sizeof (path),
+                           "\?\?\?<object#%llu>", (u_longlong_t)object);
+               }
+               (void) printf("\tpath   %s\n", path);
+       }
        dump_uidgid(os, uid, gid);
        (void) printf("\tatime  %s", ctime(&z_atime));
        (void) printf("\tmtime  %s", ctime(&z_mtime));