diff options
author | George Melikov <[email protected]> | 2017-01-28 23:11:09 +0300 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2017-01-28 12:11:09 -0800 |
commit | 721ed0ee86463cb3e4a562d86783fd1372182367 (patch) | |
tree | 43ed94a78c0fd358cb48f2129e528162f109ccb1 /module/zfs/dbuf.c | |
parent | 160af771081bc21313ad0c111d66b348932fe5d2 (diff) |
OpenZFS 7580 - ztest failure in dbuf_read_impl
Authored by: George Wilson <[email protected]>
Reviewed by: Pavel Zakharov <[email protected]>
Reviewed by: Steve Gonczi <[email protected]>
Reviewed by: Matthew Ahrens <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Ported-by: George Melikov <[email protected]>
OpenZFS-issue: https://www.illumos.org/issues/7580
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/3105d95
Closes #5678
Diffstat (limited to 'module/zfs/dbuf.c')
-rw-r--r-- | module/zfs/dbuf.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/module/zfs/dbuf.c b/module/zfs/dbuf.c index 01a761091..d2e65dd9c 100644 --- a/module/zfs/dbuf.c +++ b/module/zfs/dbuf.c @@ -3537,13 +3537,13 @@ dbuf_write_children_ready(zio_t *zio, arc_buf_t *buf, void *vdb) dmu_buf_impl_t *db = vdb; dnode_t *dn; blkptr_t *bp; - uint64_t i; - int epbs; + unsigned int epbs, i; ASSERT3U(db->db_level, >, 0); DB_DNODE_ENTER(db); dn = DB_DNODE(db); epbs = dn->dn_phys->dn_indblkshift - SPA_BLKPTRSHIFT; + ASSERT3U(epbs, <, 31); /* Determine if all our children are holes */ for (i = 0, bp = db->db.db_data; i < 1ULL << epbs; i++, bp++) { @@ -3556,8 +3556,14 @@ dbuf_write_children_ready(zio_t *zio, arc_buf_t *buf, void *vdb) * we may get compressed away. */ if (i == 1ULL << epbs) { - /* didn't find any non-holes */ + /* + * We only found holes. Grab the rwlock to prevent + * anybody from reading the blocks we're about to + * zero out. + */ + rw_enter(&dn->dn_struct_rwlock, RW_WRITER); bzero(db->db.db_data, db->db.db_size); + rw_exit(&dn->dn_struct_rwlock); } DB_DNODE_EXIT(db); } |