Decrease contention on dn_struct_rwlock
Port of OpenZFS #8946:
Currently, sequential async write workloads spend a lot of time
contending on the dn_struct_rwlock. This lock is responsible for
protecting the entire block tree below it; this naturally results
in some serialization during heavy write workloads. This can be
resolved by having per-dbuf locking, which will allow multiple
writers in the same object at the same time.
We introduce a new rwlock, the db_rwlock. This lock is responsible
for protecting the contents of the dbuf that it is a part of; when
reading a block pointer from a dbuf, you hold the lock as a reader.
When writing data to a dbuf, you hold it as a writer. This allows
multiple threads to write to different parts of a file at the same
Reviewed by: Brad Lewis <email@example.com>
Reviewed by: Matt Ahrens firstname.lastname@example.org
Reviewed by: George Wilson email@example.com
Reviewed-by: Brian Behlendorf <firstname.lastname@example.org>
Signed-off-by: Paul Dagnelie <email@example.com>
This is mostly to simplify porting some additional L2ARC changes, but improved write parallelism is a bonus.