Skip to content

Commit d1fada1

Browse files
ahrensbehlendorf
authored andcommitted
Illumos #3603, #3604: bobj improvements
3603 panic from bpobj_enqueue_subobj() 3604 zdb should print bpobjs more verbosely 3871 GCC 4.5.3 does not like issue 3604 patch Reviewed by: Henrik Mattson <henrik.mattson@delphix.com> Reviewed by: Adam Leventhal <ahl@delphix.com> Reviewed by: Christopher Siden <christopher.siden@delphix.com> Reviewed by: George Wilson <george.wilson@delphix.com> Reviewed by: Garrett D'Amore <garrett@damore.org> Approved by: Dan McDonald <danmcd@nexenta.com> References: https://www.illumos.org/issues/3603 https://www.illumos.org/issues/3604 https://www.illumos.org/issues/3871 illumos/illumos-gate@d047563 Ported-by: Richard Yao <ryao@gentoo.org> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Issue #1775 Note that the patch from Illumos issue 3871 is not accepted into Illumos at the time of this writing. It is something that I wrote when porting this. Documentation is in the Illumos issue.
1 parent 24a6465 commit d1fada1

File tree

3 files changed

+62
-19
lines changed

3 files changed

+62
-19
lines changed

cmd/zdb/zdb.c

Lines changed: 54 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,41 +1233,67 @@ dump_bpobj_cb(void *arg, const blkptr_t *bp, dmu_tx_t *tx)
12331233
}
12341234

12351235
static void
1236-
dump_bpobj(bpobj_t *bpo, char *name)
1236+
dump_bpobj(bpobj_t *bpo, char *name, int indent)
12371237
{
12381238
char bytes[32];
12391239
char comp[32];
12401240
char uncomp[32];
1241+
uint64_t i;
12411242

12421243
if (dump_opt['d'] < 3)
12431244
return;
12441245

12451246
zdb_nicenum(bpo->bpo_phys->bpo_bytes, bytes);
1246-
if (bpo->bpo_havesubobj) {
1247+
if (bpo->bpo_havesubobj && bpo->bpo_phys->bpo_subobjs != 0) {
12471248
zdb_nicenum(bpo->bpo_phys->bpo_comp, comp);
12481249
zdb_nicenum(bpo->bpo_phys->bpo_uncomp, uncomp);
1249-
(void) printf("\n %s: %llu local blkptrs, %llu subobjs, "
1250-
"%s (%s/%s comp)\n",
1251-
name, (u_longlong_t)bpo->bpo_phys->bpo_num_blkptrs,
1250+
(void) printf(" %*s: object %llu, %llu local blkptrs, "
1251+
"%llu subobjs, %s (%s/%s comp)\n",
1252+
indent * 8, name,
1253+
(u_longlong_t)bpo->bpo_object,
1254+
(u_longlong_t)bpo->bpo_phys->bpo_num_blkptrs,
12521255
(u_longlong_t)bpo->bpo_phys->bpo_num_subobjs,
12531256
bytes, comp, uncomp);
1257+
1258+
for (i = 0; i < bpo->bpo_phys->bpo_num_subobjs; i++) {
1259+
uint64_t subobj;
1260+
bpobj_t subbpo;
1261+
int error;
1262+
VERIFY0(dmu_read(bpo->bpo_os,
1263+
bpo->bpo_phys->bpo_subobjs,
1264+
i * sizeof (subobj), sizeof (subobj), &subobj, 0));
1265+
error = bpobj_open(&subbpo, bpo->bpo_os, subobj);
1266+
if (error != 0) {
1267+
(void) printf("ERROR %u while trying to open "
1268+
"subobj id %llu\n",
1269+
error, (u_longlong_t)subobj);
1270+
continue;
1271+
}
1272+
dump_bpobj(&subbpo, "subobj", indent + 1);
1273+
}
12541274
} else {
1255-
(void) printf("\n %s: %llu blkptrs, %s\n",
1256-
name, (u_longlong_t)bpo->bpo_phys->bpo_num_blkptrs, bytes);
1275+
(void) printf(" %*s: object %llu, %llu blkptrs, %s\n",
1276+
indent * 8, name,
1277+
(u_longlong_t)bpo->bpo_object,
1278+
(u_longlong_t)bpo->bpo_phys->bpo_num_blkptrs,
1279+
bytes);
12571280
}
12581281

12591282
if (dump_opt['d'] < 5)
12601283
return;
12611284

1262-
(void) printf("\n");
12631285

1264-
(void) bpobj_iterate_nofree(bpo, dump_bpobj_cb, NULL, NULL);
1286+
if (indent == 0) {
1287+
(void) bpobj_iterate_nofree(bpo, dump_bpobj_cb, NULL, NULL);
1288+
(void) printf("\n");
1289+
}
12651290
}
12661291

12671292
static void
12681293
dump_deadlist(dsl_deadlist_t *dl)
12691294
{
12701295
dsl_deadlist_entry_t *dle;
1296+
uint64_t unused;
12711297
char bytes[32];
12721298
char comp[32];
12731299
char uncomp[32];
@@ -1286,14 +1312,24 @@ dump_deadlist(dsl_deadlist_t *dl)
12861312

12871313
(void) printf("\n");
12881314

1315+
/* force the tree to be loaded */
1316+
dsl_deadlist_space_range(dl, 0, UINT64_MAX, &unused, &unused, &unused);
1317+
12891318
for (dle = avl_first(&dl->dl_tree); dle;
12901319
dle = AVL_NEXT(&dl->dl_tree, dle)) {
1291-
(void) printf(" mintxg %llu -> obj %llu\n",
1292-
(longlong_t)dle->dle_mintxg,
1293-
(longlong_t)dle->dle_bpobj.bpo_object);
1320+
if (dump_opt['d'] >= 5) {
1321+
char buf[128];
1322+
(void) snprintf(buf, sizeof (buf), "mintxg %llu -> obj %llu",
1323+
(longlong_t)dle->dle_mintxg,
1324+
(longlong_t)dle->dle_bpobj.bpo_object);
12941325

1295-
if (dump_opt['d'] >= 5)
1296-
dump_bpobj(&dle->dle_bpobj, "");
1326+
dump_bpobj(&dle->dle_bpobj, buf, 0);
1327+
} else {
1328+
(void) printf("mintxg %llu -> obj %llu\n",
1329+
(longlong_t)dle->dle_mintxg,
1330+
(longlong_t)dle->dle_bpobj.bpo_object);
1331+
1332+
}
12971333
}
12981334
}
12991335

@@ -1316,7 +1352,7 @@ fuid_table_destroy(void)
13161352
* print uid or gid information.
13171353
* For normal POSIX id just the id is printed in decimal format.
13181354
* For CIFS files with FUID the fuid is printed in hex followed by
1319-
* the doman-rid string.
1355+
* the domain-rid string.
13201356
*/
13211357
static void
13221358
print_idstr(uint64_t id, const char *id_type)
@@ -2669,10 +2705,11 @@ dump_zpool(spa_t *spa)
26692705
if (dump_opt['d'] || dump_opt['i']) {
26702706
dump_dir(dp->dp_meta_objset);
26712707
if (dump_opt['d'] >= 3) {
2672-
dump_bpobj(&spa->spa_deferred_bpobj, "Deferred frees");
2708+
dump_bpobj(&spa->spa_deferred_bpobj,
2709+
"Deferred frees", 0);
26732710
if (spa_version(spa) >= SPA_VERSION_DEADLISTS) {
26742711
dump_bpobj(&spa->spa_dsl_pool->dp_free_bpobj,
2675-
"Pool snapshot frees");
2712+
"Pool snapshot frees", 0);
26762713
}
26772714

26782715
if (spa_feature_is_active(spa,

module/zfs/bpobj.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*/
2121
/*
2222
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23-
* Copyright (c) 2012 by Delphix. All rights reserved.
23+
* Copyright (c) 2013 by Delphix. All rights reserved.
2424
*/
2525

2626
#include <sys/bpobj.h>
@@ -418,6 +418,12 @@ bpobj_enqueue_subobj(bpobj_t *bpo, uint64_t subobj, dmu_tx_t *tx)
418418

419419
VERIFY3U(0, ==, dmu_buf_hold(bpo->bpo_os, subsubobjs,
420420
0, FTAG, &subdb, 0));
421+
/*
422+
* Make sure that we are not asking dmu_write()
423+
* to write more data than we have in our buffer.
424+
*/
425+
VERIFY3U(subdb->db_size, >=,
426+
numsubsub * sizeof (subobj));
421427
dmu_write(bpo->bpo_os, bpo->bpo_phys->bpo_subobjs,
422428
bpo->bpo_phys->bpo_num_subobjs * sizeof (subobj),
423429
numsubsub * sizeof (subobj), subdb->db_data, tx);

module/zfs/dmu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1829,7 +1829,7 @@ __dmu_object_info_from_dnode(dnode_t *dn, dmu_object_info_t *doi)
18291829
doi->doi_checksum = dn->dn_checksum;
18301830
doi->doi_compress = dn->dn_compress;
18311831
doi->doi_physical_blocks_512 = (DN_USED_BYTES(dnp) + 256) >> 9;
1832-
doi->doi_max_offset = (dnp->dn_maxblkid + 1) * dn->dn_datablksz;
1832+
doi->doi_max_offset = (dn->dn_maxblkid + 1) * dn->dn_datablksz;
18331833
doi->doi_fill_count = 0;
18341834
for (i = 0; i < dnp->dn_nblkptr; i++)
18351835
doi->doi_fill_count += dnp->dn_blkptr[i].blk_fill;

0 commit comments

Comments
 (0)