]> git.baikalelectronics.ru Git - kernel.git/commit
dm snapshot: Replace mutex with rw semaphore
authorNikos Tsironis <ntsironis@arrikto.com>
Sun, 17 Mar 2019 12:22:56 +0000 (14:22 +0200)
committerMike Snitzer <snitzer@redhat.com>
Thu, 18 Apr 2019 20:18:28 +0000 (16:18 -0400)
commit4eb9a6b66168f2f9cfdb8443b0a3524e0ad29615
treea99defd7c4628295894f37b6af5f1e5a2386883e
parent8db93d1194d84ac53c2c0902b5a3fcb8a5f9b17a
dm snapshot: Replace mutex with rw semaphore

dm-snapshot uses a single mutex to serialize every access to the
snapshot state. This includes all accesses to the complete and pending
exception tables, which occur at every origin write, every snapshot
read/write and every exception completion.

The lock statistics indicate that this mutex is a bottleneck (average
wait time ~480 usecs for 8 processes doing random 4K writes to the
origin device) preventing dm-snapshot to scale as the number of threads
doing IO increases.

The major contention points are __origin_write()/snapshot_map() and
pending_complete(), i.e., the submission and completion of pending
exceptions.

Replace this mutex with a rw semaphore.

We essentially revert commit c12e26564d5e87 ("dm snapshot: use mutex
instead of rw_semaphore") and together with the next two patches we
substitute the single mutex with a fine-grained locking scheme, where we
use a read-write semaphore to protect the mostly read fields of the
snapshot structure, e.g., valid, active, etc., and per-bucket bit
spinlocks to protect accesses to the complete and pending exception
tables.

Co-developed-by: Ilias Tsitsimpis <iliastsi@arrikto.com>
Signed-off-by: Nikos Tsironis <ntsironis@arrikto.com>
Acked-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
drivers/md/dm-snap.c