usr/src/cmd/zdb/zdb.c
changeset 14005 55fc53126003
parent 13991 53e4f9da98a1
equal deleted inserted replaced
14004:dd91fed709a7 14005:55fc53126003
  1995 typedef struct zdb_blkstats {
  1995 typedef struct zdb_blkstats {
  1996 	uint64_t zb_asize;
  1996 	uint64_t zb_asize;
  1997 	uint64_t zb_lsize;
  1997 	uint64_t zb_lsize;
  1998 	uint64_t zb_psize;
  1998 	uint64_t zb_psize;
  1999 	uint64_t zb_count;
  1999 	uint64_t zb_count;
       
  2000 	uint64_t zb_gangs;
       
  2001 	uint64_t zb_ditto_samevdev;
  2000 	uint64_t zb_psize_histogram[PSIZE_HISTO_SIZE];
  2002 	uint64_t zb_psize_histogram[PSIZE_HISTO_SIZE];
  2001 } zdb_blkstats_t;
  2003 } zdb_blkstats_t;
  2002 
  2004 
  2003 /*
  2005 /*
  2004  * Extended object types to report deferred frees and dedup auto-ditto blocks.
  2006  * Extended object types to report deferred frees and dedup auto-ditto blocks.
  2042 		return;
  2044 		return;
  2043 
  2045 
  2044 	for (int i = 0; i < 4; i++) {
  2046 	for (int i = 0; i < 4; i++) {
  2045 		int l = (i < 2) ? BP_GET_LEVEL(bp) : ZB_TOTAL;
  2047 		int l = (i < 2) ? BP_GET_LEVEL(bp) : ZB_TOTAL;
  2046 		int t = (i & 1) ? type : ZDB_OT_TOTAL;
  2048 		int t = (i & 1) ? type : ZDB_OT_TOTAL;
       
  2049 		int equal;
  2047 		zdb_blkstats_t *zb = &zcb->zcb_type[l][t];
  2050 		zdb_blkstats_t *zb = &zcb->zcb_type[l][t];
  2048 
  2051 
  2049 		zb->zb_asize += BP_GET_ASIZE(bp);
  2052 		zb->zb_asize += BP_GET_ASIZE(bp);
  2050 		zb->zb_lsize += BP_GET_LSIZE(bp);
  2053 		zb->zb_lsize += BP_GET_LSIZE(bp);
  2051 		zb->zb_psize += BP_GET_PSIZE(bp);
  2054 		zb->zb_psize += BP_GET_PSIZE(bp);
  2052 		zb->zb_count++;
  2055 		zb->zb_count++;
  2053 		zb->zb_psize_histogram[BP_GET_PSIZE(bp) >> SPA_MINBLOCKSHIFT]++;
  2056 		zb->zb_psize_histogram[BP_GET_PSIZE(bp) >> SPA_MINBLOCKSHIFT]++;
       
  2057 
       
  2058 		zb->zb_gangs += BP_COUNT_GANG(bp);
       
  2059 
       
  2060 		switch (BP_GET_NDVAS(bp)) {
       
  2061 		case 2:
       
  2062 			if (DVA_GET_VDEV(&bp->blk_dva[0]) ==
       
  2063 			    DVA_GET_VDEV(&bp->blk_dva[1]))
       
  2064 				zb->zb_ditto_samevdev++;
       
  2065 			break;
       
  2066 		case 3:
       
  2067 			equal = (DVA_GET_VDEV(&bp->blk_dva[0]) ==
       
  2068 			    DVA_GET_VDEV(&bp->blk_dva[1])) +
       
  2069 			    (DVA_GET_VDEV(&bp->blk_dva[0]) ==
       
  2070 			    DVA_GET_VDEV(&bp->blk_dva[2])) +
       
  2071 			    (DVA_GET_VDEV(&bp->blk_dva[1]) ==
       
  2072 			    DVA_GET_VDEV(&bp->blk_dva[2]));
       
  2073 			if (equal != 0)
       
  2074 				zb->zb_ditto_samevdev++;
       
  2075 			break;
       
  2076 		}
       
  2077 
  2054 	}
  2078 	}
  2055 
  2079 
  2056 	if (dump_opt['L'])
  2080 	if (dump_opt['L'])
  2057 		return;
  2081 		return;
  2058 
  2082 
  2437 		return (2);
  2461 		return (2);
  2438 
  2462 
  2439 	(void) printf("\n");
  2463 	(void) printf("\n");
  2440 	(void) printf("\tbp count:      %10llu\n",
  2464 	(void) printf("\tbp count:      %10llu\n",
  2441 	    (u_longlong_t)tzb->zb_count);
  2465 	    (u_longlong_t)tzb->zb_count);
       
  2466 	(void) printf("\tganged count:  %10llu\n",
       
  2467 	    (longlong_t)tzb->zb_gangs);
  2442 	(void) printf("\tbp logical:    %10llu      avg: %6llu\n",
  2468 	(void) printf("\tbp logical:    %10llu      avg: %6llu\n",
  2443 	    (u_longlong_t)tzb->zb_lsize,
  2469 	    (u_longlong_t)tzb->zb_lsize,
  2444 	    (u_longlong_t)(tzb->zb_lsize / tzb->zb_count));
  2470 	    (u_longlong_t)(tzb->zb_lsize / tzb->zb_count));
  2445 	(void) printf("\tbp physical:   %10llu      avg:"
  2471 	(void) printf("\tbp physical:   %10llu      avg:"
  2446 	    " %6llu     compression: %6.2f\n",
  2472 	    " %6llu     compression: %6.2f\n",
  2458 	    (u_longlong_t)zcb.zcb_dedup_blocks,
  2484 	    (u_longlong_t)zcb.zcb_dedup_blocks,
  2459 	    (double)zcb.zcb_dedup_asize / tzb->zb_asize + 1.0);
  2485 	    (double)zcb.zcb_dedup_asize / tzb->zb_asize + 1.0);
  2460 	(void) printf("\tSPA allocated: %10llu     used: %5.2f%%\n",
  2486 	(void) printf("\tSPA allocated: %10llu     used: %5.2f%%\n",
  2461 	    (u_longlong_t)norm_alloc, 100.0 * norm_alloc / norm_space);
  2487 	    (u_longlong_t)norm_alloc, 100.0 * norm_alloc / norm_space);
  2462 
  2488 
       
  2489 	if (tzb->zb_ditto_samevdev != 0) {
       
  2490 		(void) printf("\tDittoed blocks on same vdev: %llu\n",
       
  2491 		    (longlong_t)tzb->zb_ditto_samevdev);
       
  2492 	}
       
  2493 
  2463 	if (dump_opt['b'] >= 2) {
  2494 	if (dump_opt['b'] >= 2) {
  2464 		int l, t, level;
  2495 		int l, t, level;
  2465 		(void) printf("\nBlocks\tLSIZE\tPSIZE\tASIZE"
  2496 		(void) printf("\nBlocks\tLSIZE\tPSIZE\tASIZE"
  2466 		    "\t  avg\t comp\t%%Total\tType\n");
  2497 		    "\t  avg\t comp\t%%Total\tType\n");
  2467 
  2498 
  2468 		for (t = 0; t <= ZDB_OT_TOTAL; t++) {
  2499 		for (t = 0; t <= ZDB_OT_TOTAL; t++) {
  2469 			char csize[32], lsize[32], psize[32], asize[32];
  2500 			char csize[32], lsize[32], psize[32], asize[32];
  2470 			char avg[32];
  2501 			char avg[32], gang[32];
  2471 			char *typename;
  2502 			char *typename;
  2472 
  2503 
  2473 			if (t < DMU_OT_NUMTYPES)
  2504 			if (t < DMU_OT_NUMTYPES)
  2474 				typename = dmu_ot[t].ot_name;
  2505 				typename = dmu_ot[t].ot_name;
  2475 			else
  2506 			else
  2506 				zdb_nicenum(zb->zb_count, csize);
  2537 				zdb_nicenum(zb->zb_count, csize);
  2507 				zdb_nicenum(zb->zb_lsize, lsize);
  2538 				zdb_nicenum(zb->zb_lsize, lsize);
  2508 				zdb_nicenum(zb->zb_psize, psize);
  2539 				zdb_nicenum(zb->zb_psize, psize);
  2509 				zdb_nicenum(zb->zb_asize, asize);
  2540 				zdb_nicenum(zb->zb_asize, asize);
  2510 				zdb_nicenum(zb->zb_asize / zb->zb_count, avg);
  2541 				zdb_nicenum(zb->zb_asize / zb->zb_count, avg);
       
  2542 				zdb_nicenum(zb->zb_gangs, gang);
  2511 
  2543 
  2512 				(void) printf("%6s\t%5s\t%5s\t%5s\t%5s"
  2544 				(void) printf("%6s\t%5s\t%5s\t%5s\t%5s"
  2513 				    "\t%5.2f\t%6.2f\t",
  2545 				    "\t%5.2f\t%6.2f\t",
  2514 				    csize, lsize, psize, asize, avg,
  2546 				    csize, lsize, psize, asize, avg,
  2515 				    (double)zb->zb_lsize / zb->zb_psize,
  2547 				    (double)zb->zb_lsize / zb->zb_psize,
  2518 				if (level == ZB_TOTAL)
  2550 				if (level == ZB_TOTAL)
  2519 					(void) printf("%s\n", typename);
  2551 					(void) printf("%s\n", typename);
  2520 				else
  2552 				else
  2521 					(void) printf("    L%d %s\n",
  2553 					(void) printf("    L%d %s\n",
  2522 					    level, typename);
  2554 					    level, typename);
       
  2555 
       
  2556 				if (dump_opt['b'] >= 3 && zb->zb_gangs > 0) {
       
  2557 					(void) printf("\t number of ganged "
       
  2558 					    "blocks: %s\n", gang);
       
  2559 				}
  2523 
  2560 
  2524 				if (dump_opt['b'] >= 4) {
  2561 				if (dump_opt['b'] >= 4) {
  2525 					(void) printf("psize "
  2562 					(void) printf("psize "
  2526 					    "(in 512-byte sectors): "
  2563 					    "(in 512-byte sectors): "
  2527 					    "number of blocks\n");
  2564 					    "number of blocks\n");