Page MenuHomeFreeBSD

D61528.1795433587.diff
No OneTemporary

Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None

D61528.1795433587.diff

diff --git a/sys/contrib/openzfs/include/sys/dbuf.h b/sys/contrib/openzfs/include/sys/dbuf.h
--- 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_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
--- a/sys/contrib/openzfs/module/zfs/dbuf.c
+++ b/sys/contrib/openzfs/module/zfs/dbuf.c
@@ -1464,17 +1464,15 @@
}
/*
- * 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 @@
}
}
- 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
--- a/sys/contrib/openzfs/module/zfs/dmu_direct.c
+++ b/sys/contrib/openzfs/module/zfs/dmu_direct.c
@@ -298,7 +298,7 @@
* 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 ?

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 23, 11:33 AM (11 h, 30 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41929467
Default Alt Text
D61528.1795433587.diff (2 KB)

Event Timeline