On 31.10.2017 19:44, David Sterba wrote: > Overview of the main locks protecting various device-related structures. > > Signed-off-by: David Sterba <dsterba@xxxxxxxx> > --- > fs/btrfs/volumes.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 66 insertions(+) > > diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c > index 75aed8ec64bd..098affc58361 100644 > --- a/fs/btrfs/volumes.c > +++ b/fs/btrfs/volumes.c > @@ -145,6 +145,72 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info, > struct btrfs_bio **bbio_ret, > int mirror_num, int need_raid_map); > > +/* > + * Device locking > + * ============== > + * > + * There are several mutexes that protect manipulation of devices and low-level > + * structures like chunks but not block groups, extents or files This sentence suggests you are describing the various mutexes but it seems you are also describing data structure below i.e. global::fs_devs/btrfs_device::name > + * > + * - uuid_mutex (global lock) > + * > + * protects the fs_uuids list that tracks all per-fs fs_devices, resulting > + * from the SCAN_DEV ioctl registration or from mount either implicitly > + * (the first device) or requested by the device= mount option > + * > + * the mutex can be very coarse and can cover long-running operations > + * > + * protects: updates to fs_devices counters like missing devices, rw devices, > + * seeding, structure cloning, openning/closing devices at mount/umount time Perhaps move the uuid_mutex description after btrfs_device::name. That way mutexes are grouped together and data structures are grouped as well. > + * > + * global::fs_devs - add, remove, updates to the global list You seem to be describing a data structure here rather than a mutex > + * > + * does not protect: manipulation of the fs_devices::devices list! but this sentence is written as if you've just described a mutex. The end result is that it's not clear what mutex you are referring to here. > + * > + * btrfs_device::name - renames (write side), read is RCU It's not clear how the write side is protected. > + * > + * - fs_devices::device_list_mutex (per-fs, with RCU) > + * > + * protects updates to fs_devices::devices, ie. adding and deleting > + * > + * simple list traversal with read-only actions can be done with RCU > + * protection > + * > + * may be used to exclude some operations from running concurrently without > + * any modifications to the list (see write_all_supers) > + * > + * - volume_mutex > + * > + * coarse lock owned by a mounted filesystem; used to exclude some operations > + * that cannot run in parallel and affect the higher-level properties of the > + * filesystem like: device add/deleting/resize/replace, or balance > + * > + * - balance_mutex > + * > + * protects balance structures (status, state) and context accessed from > + * several places (internally, ioctl) > + * > + * - chunk_mutex > + * > + * protects chunks, adding or removing during allocation, trim or when > + * a new device is added/removed > + * > + * - cleaner_mutex > + * > + * a big lock that is held by the cleaner thread and prevents running > + * subvolume cleaning together with relocation or delayed iputs > + * > + * > + * Lock nesting > + * ------------ > + * > + * uuid_mutex > + * volume_mutex > + * device_list_mutex > + * chunk_mutex > + * balance_mutex > + * > + */ > DEFINE_MUTEX(uuid_mutex); > static LIST_HEAD(fs_uuids); > struct list_head *btrfs_get_fs_uuids(void) > -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html
