mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-23 02:44:41 +03:00
Polish db_rwlock scope
dbuf_verify(): Don't need the lock, since we only compare pointers. dbuf_findbp(): Don't need the lock, since aside of unneeded assert we only produce the pointer, but don't de-reference it. dnode_next_offset_level(): When working on top level indirection should lock dnode buffer's db_rwlock, since it is our parent. If dnode has no buffer, then it is meta-dnode or one of quotas and we should lock the dataset's ds_bp_rwlock instead. Reviewed-by: Alan Somers <asomers@gmail.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Alexander Motin <mav@FreeBSD.org> Sponsored by: iXsystems, Inc. Closes #17441
This commit is contained in:
@@ -2559,6 +2559,11 @@ dnode_next_offset_level(dnode_t *dn, int flags, uint64_t *offset,
|
||||
error = 0;
|
||||
epb = dn->dn_phys->dn_nblkptr;
|
||||
data = dn->dn_phys->dn_blkptr;
|
||||
if (dn->dn_dbuf != NULL)
|
||||
rw_enter(&dn->dn_dbuf->db_rwlock, RW_READER);
|
||||
else if (dmu_objset_ds(dn->dn_objset) != NULL)
|
||||
rrw_enter(&dmu_objset_ds(dn->dn_objset)->ds_bp_rwlock,
|
||||
RW_READER, FTAG);
|
||||
} else {
|
||||
uint64_t blkid = dbuf_whichblock(dn, lvl, *offset);
|
||||
error = dbuf_hold_impl(dn, lvl, blkid, TRUE, FALSE, FTAG, &db);
|
||||
@@ -2663,6 +2668,12 @@ dnode_next_offset_level(dnode_t *dn, int flags, uint64_t *offset,
|
||||
if (db != NULL) {
|
||||
rw_exit(&db->db_rwlock);
|
||||
dbuf_rele(db, FTAG);
|
||||
} else {
|
||||
if (dn->dn_dbuf != NULL)
|
||||
rw_exit(&dn->dn_dbuf->db_rwlock);
|
||||
else if (dmu_objset_ds(dn->dn_objset) != NULL)
|
||||
rrw_exit(&dmu_objset_ds(dn->dn_objset)->ds_bp_rwlock,
|
||||
FTAG);
|
||||
}
|
||||
|
||||
return (error);
|
||||
|
||||
Reference in New Issue
Block a user