OSDN Git Service

loop: scale loop device by introducing per device lock
authorPavel Tatashin <pasha.tatashin@soleen.com>
Tue, 26 Jan 2021 14:46:30 +0000 (09:46 -0500)
committerJens Axboe <axboe@kernel.dk>
Tue, 26 Jan 2021 20:08:54 +0000 (13:08 -0700)
commit6cc8e7430801fa238bd7d3acae1eb406c6e02fe1
tree56cd7cc2a0396ec04459122368b05771873e8b77
parent767630c63bb23acf022adb265574996ca39a4645
loop: scale loop device by introducing per device lock

Currently, loop device has only one global lock: loop_ctl_mutex.

This becomes hot in scenarios where many loop devices are used.

Scale it by introducing per-device lock: lo_mutex that protects
modifications of all fields in struct loop_device.

Keep loop_ctl_mutex to protect global data: loop_index_idr, loop_lookup,
loop_add.

The new lock ordering requirement is that loop_ctl_mutex must be taken
before lo_mutex.

Signed-off-by: Pavel Tatashin <pasha.tatashin@soleen.com>
Reviewed-by: Tyler Hicks <tyhicks@linux.microsoft.com>
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/loop.c
drivers/block/loop.h