Skip to content

Commit f3e49b0

Browse files
robnbehlendorf
authored andcommitted
dnode_is_dirty: reimplement in terms of dn_dirtycnt
Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Robert Evans <[email protected]> Reviewed-by: Adam Moss <[email protected]> Reviewed-by: Alexander Motin <[email protected]> Signed-off-by: Rob Norris <[email protected]> Closes #16297 Closes #17652 Closes #17658
1 parent 3abf72b commit f3e49b0

File tree

1 file changed

+7
-18
lines changed

1 file changed

+7
-18
lines changed

module/zfs/dnode.c

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1842,31 +1842,20 @@ dnode_try_claim(objset_t *os, uint64_t object, int slots)
18421842
}
18431843

18441844
/*
1845-
* Checks if the dnode itself is dirty, or is carrying any uncommitted records.
1846-
* It is important to check both conditions, as some operations (eg appending
1847-
* to a file) can dirty both as a single logical unit, but they are not synced
1848-
* out atomically, so checking one and not the other can result in an object
1849-
* appearing to be clean mid-way through a commit.
1845+
* Test if the dnode is dirty, or carrying uncommitted records.
18501846
*
1851-
* Do not change this lightly! If you get it wrong, dmu_offset_next() can
1852-
* detect a hole where there is really data, leading to silent corruption.
1847+
* dn_dirtycnt is the number of txgs this dnode is dirty on. It's incremented
1848+
* in dnode_setdirty() the first time the dnode is dirtied on a txg, and
1849+
* decremented in either dnode_rele_task() or userquota_updates_task() when the
1850+
* txg is synced out.
18531851
*/
18541852
boolean_t
18551853
dnode_is_dirty(dnode_t *dn)
18561854
{
18571855
mutex_enter(&dn->dn_mtx);
1858-
1859-
for (int i = 0; i < TXG_SIZE; i++) {
1860-
if (multilist_link_active(&dn->dn_dirty_link[i]) ||
1861-
!list_is_empty(&dn->dn_dirty_records[i])) {
1862-
mutex_exit(&dn->dn_mtx);
1863-
return (B_TRUE);
1864-
}
1865-
}
1866-
1856+
boolean_t dirty = (dn->dn_dirtycnt != 0);
18671857
mutex_exit(&dn->dn_mtx);
1868-
1869-
return (B_FALSE);
1858+
return (dirty);
18701859
}
18711860

18721861
void

0 commit comments

Comments
 (0)