Use rw_tryupgrade() in dmu_bonus_hold_by_dnode()
When dn->dn_bonus == NULL, dmu_bonus_hold_by_dnode() will unlock its read lock on dn->dn_struct_rwlock and grab a write lock. This can be micro-optimized by calling rw_tryupgrade(). Linux will not benefit from this since it does not support rwlock upgrades, but FreeBSD will. Reviewed-by: Ryan Moeller <ryan@iXsystems.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Brian Atkinson <batkinson@lanl.gov> Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu> Closes #14517
This commit is contained in:
parent
d9e64a4030
commit
c9e39da9a4
|
@ -357,8 +357,10 @@ int dmu_bonus_hold_by_dnode(dnode_t *dn, const void *tag, dmu_buf_t **dbp,
|
|||
|
||||
rw_enter(&dn->dn_struct_rwlock, RW_READER);
|
||||
if (dn->dn_bonus == NULL) {
|
||||
if (!rw_tryupgrade(&dn->dn_struct_rwlock)) {
|
||||
rw_exit(&dn->dn_struct_rwlock);
|
||||
rw_enter(&dn->dn_struct_rwlock, RW_WRITER);
|
||||
}
|
||||
if (dn->dn_bonus == NULL)
|
||||
dbuf_create_bonus(dn);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue