usr/src/cmd/zdb/zdb.c
changeset 13743 95aba6e49b9f
parent 13700 2889e2596bd6
child 13764 38b4aca480b3
equal deleted inserted replaced
13742:b6bbdd77139c 13743:95aba6e49b9f
    55 #include <sys/zio_compress.h>
    55 #include <sys/zio_compress.h>
    56 #include <sys/zfs_fuid.h>
    56 #include <sys/zfs_fuid.h>
    57 #include <sys/arc.h>
    57 #include <sys/arc.h>
    58 #include <sys/ddt.h>
    58 #include <sys/ddt.h>
    59 #include <sys/zfeature.h>
    59 #include <sys/zfeature.h>
       
    60 #include <zfs_comutil.h>
    60 #undef ZFS_MAXNAMELEN
    61 #undef ZFS_MAXNAMELEN
    61 #undef verify
    62 #undef verify
    62 #include <libzfs.h>
    63 #include <libzfs.h>
    63 
    64 
    64 #define	ZDB_COMPRESS_NAME(idx) ((idx) < ZIO_COMPRESS_FUNCTIONS ? \
    65 #define	ZDB_COMPRESS_NAME(idx) ((idx) < ZIO_COMPRESS_FUNCTIONS ? \
   202 	dump_nvlist(nv, 8);
   203 	dump_nvlist(nv, 8);
   203 
   204 
   204 	nvlist_free(nv);
   205 	nvlist_free(nv);
   205 }
   206 }
   206 
   207 
       
   208 /* ARGSUSED */
       
   209 static void
       
   210 dump_history_offsets(objset_t *os, uint64_t object, void *data, size_t size)
       
   211 {
       
   212 	spa_history_phys_t *shp = data;
       
   213 
       
   214 	if (shp == NULL)
       
   215 		return;
       
   216 
       
   217 	(void) printf("\t\tpool_create_len = %llu\n",
       
   218 	    (u_longlong_t)shp->sh_pool_create_len);
       
   219 	(void) printf("\t\tphys_max_off = %llu\n",
       
   220 	    (u_longlong_t)shp->sh_phys_max_off);
       
   221 	(void) printf("\t\tbof = %llu\n",
       
   222 	    (u_longlong_t)shp->sh_bof);
       
   223 	(void) printf("\t\teof = %llu\n",
       
   224 	    (u_longlong_t)shp->sh_eof);
       
   225 	(void) printf("\t\trecords_lost = %llu\n",
       
   226 	    (u_longlong_t)shp->sh_records_lost);
       
   227 }
       
   228 
   207 static void
   229 static void
   208 zdb_nicenum(uint64_t num, char *buf)
   230 zdb_nicenum(uint64_t num, char *buf)
   209 {
   231 {
   210 	if (dump_opt['P'])
   232 	if (dump_opt['P'])
   211 		(void) sprintf(buf, "%llu", (longlong_t)num);
   233 		(void) sprintf(buf, "%llu", (longlong_t)num);
   851 
   873 
   852 	(void) printf("\nHistory:\n");
   874 	(void) printf("\nHistory:\n");
   853 	for (int i = 0; i < num; i++) {
   875 	for (int i = 0; i < num; i++) {
   854 		uint64_t time, txg, ievent;
   876 		uint64_t time, txg, ievent;
   855 		char *cmd, *intstr;
   877 		char *cmd, *intstr;
       
   878 		boolean_t printed = B_FALSE;
   856 
   879 
   857 		if (nvlist_lookup_uint64(events[i], ZPOOL_HIST_TIME,
   880 		if (nvlist_lookup_uint64(events[i], ZPOOL_HIST_TIME,
   858 		    &time) != 0)
   881 		    &time) != 0)
   859 			continue;
   882 			goto next;
   860 		if (nvlist_lookup_string(events[i], ZPOOL_HIST_CMD,
   883 		if (nvlist_lookup_string(events[i], ZPOOL_HIST_CMD,
   861 		    &cmd) != 0) {
   884 		    &cmd) != 0) {
   862 			if (nvlist_lookup_uint64(events[i],
   885 			if (nvlist_lookup_uint64(events[i],
   863 			    ZPOOL_HIST_INT_EVENT, &ievent) != 0)
   886 			    ZPOOL_HIST_INT_EVENT, &ievent) != 0)
   864 				continue;
   887 				goto next;
   865 			verify(nvlist_lookup_uint64(events[i],
   888 			verify(nvlist_lookup_uint64(events[i],
   866 			    ZPOOL_HIST_TXG, &txg) == 0);
   889 			    ZPOOL_HIST_TXG, &txg) == 0);
   867 			verify(nvlist_lookup_string(events[i],
   890 			verify(nvlist_lookup_string(events[i],
   868 			    ZPOOL_HIST_INT_STR, &intstr) == 0);
   891 			    ZPOOL_HIST_INT_STR, &intstr) == 0);
   869 			if (ievent >= LOG_END)
   892 			if (ievent >= ZFS_NUM_LEGACY_HISTORY_EVENTS)
   870 				continue;
   893 				goto next;
   871 
   894 
   872 			(void) snprintf(internalstr,
   895 			(void) snprintf(internalstr,
   873 			    sizeof (internalstr),
   896 			    sizeof (internalstr),
   874 			    "[internal %s txg:%lld] %s",
   897 			    "[internal %s txg:%lld] %s",
   875 			    zfs_history_event_names[ievent], txg,
   898 			    zfs_history_event_names[ievent], txg,
   878 		}
   901 		}
   879 		tsec = time;
   902 		tsec = time;
   880 		(void) localtime_r(&tsec, &t);
   903 		(void) localtime_r(&tsec, &t);
   881 		(void) strftime(tbuf, sizeof (tbuf), "%F.%T", &t);
   904 		(void) strftime(tbuf, sizeof (tbuf), "%F.%T", &t);
   882 		(void) printf("%s %s\n", tbuf, cmd);
   905 		(void) printf("%s %s\n", tbuf, cmd);
       
   906 		printed = B_TRUE;
       
   907 
       
   908 next:
       
   909 		if (dump_opt['h'] > 1) {
       
   910 			if (!printed)
       
   911 				(void) printf("unrecognized record:\n");
       
   912 			dump_nvlist(events[i], 2);
       
   913 		}
   883 	}
   914 	}
   884 }
   915 }
   885 
   916 
   886 /*ARGSUSED*/
   917 /*ARGSUSED*/
   887 static void
   918 static void
  1454 	dump_uint8,		/* other uint8[]		*/
  1485 	dump_uint8,		/* other uint8[]		*/
  1455 	dump_uint64,		/* other uint64[]		*/
  1486 	dump_uint64,		/* other uint64[]		*/
  1456 	dump_zap,		/* other ZAP			*/
  1487 	dump_zap,		/* other ZAP			*/
  1457 	dump_zap,		/* persistent error log		*/
  1488 	dump_zap,		/* persistent error log		*/
  1458 	dump_uint8,		/* SPA history			*/
  1489 	dump_uint8,		/* SPA history			*/
  1459 	dump_uint64,		/* SPA history offsets		*/
  1490 	dump_history_offsets,	/* SPA history offsets		*/
  1460 	dump_zap,		/* Pool properties		*/
  1491 	dump_zap,		/* Pool properties		*/
  1461 	dump_zap,		/* DSL permissions		*/
  1492 	dump_zap,		/* DSL permissions		*/
  1462 	dump_acl,		/* ZFS ACL			*/
  1493 	dump_acl,		/* ZFS ACL			*/
  1463 	dump_uint8,		/* ZFS SYSACL			*/
  1494 	dump_uint8,		/* ZFS SYSACL			*/
  1464 	dump_none,		/* FUID nvlist			*/
  1495 	dump_none,		/* FUID nvlist			*/