Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F177848795
D61526.1795425320.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
D61526.1795425320.diff
View Options
diff --git a/sys/contrib/openzfs/module/zfs/dmu.c b/sys/contrib/openzfs/module/zfs/dmu.c
--- a/sys/contrib/openzfs/module/zfs/dmu.c
+++ b/sys/contrib/openzfs/module/zfs/dmu.c
@@ -2668,6 +2668,44 @@
bp = db->db_blkptr;
}
+ /*
+ * A block with a pending free (a truncate or hole
+ * punch not yet synced) must not be cloned: the clone
+ * would add a BRT reference to a block about to be
+ * freed, so the pending clone would apply onto an
+ * already-freed DVA and double free it. Report
+ * EAGAIN and let the caller retry once the free
+ * syncs (the block then reads as a hole).
+ *
+ * A hole (or absent BP) has nothing to free and is
+ * cloned as a hole below. When the head dirty record
+ * overrode the BP (a clone in this txg) only frees
+ * recorded after the override count against it;
+ * earlier frees predate it. This mirrors
+ * dbuf_read_hole().
+ */
+ if (bp != NULL && !BP_IS_HOLE(bp)) {
+ dbuf_dirty_record_t *dr =
+ list_head(&db->db_dirty_records);
+ boolean_t freed;
+
+ DB_DNODE_ENTER(db);
+ dnode_t *rdn = DB_DNODE(db);
+ if (dr != NULL && dr->dt.dl.dr_brtwrite) {
+ freed = dnode_block_freed_after(rdn,
+ db->db_blkid, dr->dr_txg);
+ } else {
+ freed = dnode_block_freed(rdn,
+ db->db_blkid);
+ }
+ DB_DNODE_EXIT(db);
+ if (freed) {
+ mutex_exit(&db->db_mtx);
+ error = SET_ERROR(EAGAIN);
+ goto out;
+ }
+ }
+
mutex_exit(&db->db_mtx);
if (bp == NULL) {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 23, 9:15 AM (9 h, 13 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41736797
Default Alt Text
D61526.1795425320.diff (1 KB)
Attached To
Mode
D61526: MFC: Fix double free when cloning a block with a pending free
Attached
Detach File
Event Timeline