diff options
| -rw-r--r-- | sys/contrib/openzfs/include/sys/dbuf.h | 1 | ||||
| -rw-r--r-- | sys/contrib/openzfs/module/zfs/dbuf.c | 28 | ||||
| -rw-r--r-- | sys/contrib/openzfs/module/zfs/dmu_direct.c | 2 |
3 files changed, 22 insertions, 9 deletions
diff --git a/sys/contrib/openzfs/include/sys/dbuf.h b/sys/contrib/openzfs/include/sys/dbuf.h index 0b379ee79caa..a583cbb4d95c 100644 --- a/sys/contrib/openzfs/include/sys/dbuf.h +++ b/sys/contrib/openzfs/include/sys/dbuf.h @@ -389,6 +389,7 @@ dbuf_dirty_record_t *dbuf_dirty(dmu_buf_impl_t *db, dmu_tx_t *tx); dbuf_dirty_record_t *dbuf_dirty_lightweight(dnode_t *dn, uint64_t blkid, dmu_tx_t *tx); boolean_t dbuf_undirty(dmu_buf_impl_t *db, dmu_tx_t *tx); +boolean_t dbuf_is_hole(dmu_buf_impl_t *db, dnode_t *dn, blkptr_t *bp); int dmu_buf_get_bp_from_dbuf(dmu_buf_impl_t *db, blkptr_t **bp); int dmu_buf_untransform_direct(dmu_buf_impl_t *db, spa_t *spa); void dmu_buf_write_embedded(dmu_buf_t *dbuf, void *data, diff --git a/sys/contrib/openzfs/module/zfs/dbuf.c b/sys/contrib/openzfs/module/zfs/dbuf.c index 3e3cd9d64eac..e291fcf6def8 100644 --- a/sys/contrib/openzfs/module/zfs/dbuf.c +++ b/sys/contrib/openzfs/module/zfs/dbuf.c @@ -1464,17 +1464,15 @@ dbuf_handle_indirect_hole(void *data, dnode_t *dn, blkptr_t *dbbp) } /* - * Handle reads on dbufs that are holes, if necessary. This function - * requires that the dbuf's mutex is held. Returns success (0) if action - * was taken, ENOENT if no action was taken. + * Check for a hole, including frees which have not yet been synced. + * The caller must hold db_mtx to stabilize the dirty records. */ -static int -dbuf_read_hole(dmu_buf_impl_t *db, dnode_t *dn, blkptr_t *bp) +boolean_t +dbuf_is_hole(dmu_buf_impl_t *db, dnode_t *dn, blkptr_t *bp) { ASSERT(MUTEX_HELD(&db->db_mtx)); - arc_buf_t *db_data; - int is_hole = bp == NULL || BP_IS_HOLE(bp); + boolean_t is_hole = bp == NULL || BP_IS_HOLE(bp); /* * For level 0 blocks only, if the above check didn't find a hole, * consult dnode_block_freed() to check for pending frees. @@ -1504,7 +1502,21 @@ dbuf_read_hole(dmu_buf_impl_t *db, dnode_t *dn, blkptr_t *bp) } } - if (is_hole) { + return (is_hole); +} + +/* + * Handle reads on dbufs that are holes, if necessary. This function + * requires that the dbuf's mutex is held. Returns success (0) if action + * was taken, ENOENT if no action was taken. + */ +static int +dbuf_read_hole(dmu_buf_impl_t *db, dnode_t *dn, blkptr_t *bp) +{ + ASSERT(MUTEX_HELD(&db->db_mtx)); + arc_buf_t *db_data; + + if (dbuf_is_hole(db, dn, bp)) { db_data = dbuf_alloc_arcbuf(db); memset(db_data->b_data, 0, db->db.db_size); diff --git a/sys/contrib/openzfs/module/zfs/dmu_direct.c b/sys/contrib/openzfs/module/zfs/dmu_direct.c index 5b00698da728..496f4d2afdf2 100644 --- a/sys/contrib/openzfs/module/zfs/dmu_direct.c +++ b/sys/contrib/openzfs/module/zfs/dmu_direct.c @@ -298,7 +298,7 @@ dmu_read_abd(dnode_t *dn, uint64_t offset, uint64_t size, * cached. This will not be considered a direct read for IO * accounting in the same way that an ARC hit is not counted. */ - if (bp == NULL || BP_IS_HOLE(bp) || db->db_state == DB_CACHED) { + if (db->db_state == DB_CACHED || dbuf_is_hole(db, dn, bp)) { size_t aoff = offset < db->db.db_offset ? db->db.db_offset - offset : 0; size_t boff = offset > db->db.db_offset ? |
