]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
btrfs: Add comments on locking of several device-related fields
authorNikolay Borisov <nborisov@suse.com>
Thu, 9 May 2019 15:11:11 +0000 (18:11 +0300)
committerDavid Sterba <dsterba@suse.com>
Mon, 1 Jul 2019 11:34:59 +0000 (13:34 +0200)
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/volumes.c
fs/btrfs/volumes.h

index 5514ae801f4c3954bc78866b53d1b2f01bbb3ac2..776f5c7ca7c5a533dc1d8f046c667adb53b33c29 100644 (file)
@@ -239,7 +239,9 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info,
  * chunk_mutex
  * -----------
  * protects chunks, adding or removing during allocation, trim or when a new
- * device is added/removed
+ * device is added/removed. Additionally it also protects post_commit_list of
+ * individual devices, since they can be added to the transaction's
+ * post_commit_list only with chunk_mutex held.
  *
  * cleaner_mutex
  * -------------
index 4a7a4d90ded8e41a3e6f9789b6311ed3415966dd..fea7b65a712e09ec646f96667139e50cc3d805d4 100644 (file)
@@ -43,8 +43,8 @@ struct btrfs_pending_bios {
 #define BTRFS_DEV_STATE_FLUSH_SENT     (4)
 
 struct btrfs_device {
-       struct list_head dev_list;
-       struct list_head dev_alloc_list;
+       struct list_head dev_list; /* device_list_mutex */
+       struct list_head dev_alloc_list; /* chunk mutex */
        struct list_head post_commit_list; /* chunk mutex */
        struct btrfs_fs_devices *fs_devices;
        struct btrfs_fs_info *fs_info;
@@ -229,9 +229,14 @@ struct btrfs_fs_devices {
         * this mutex lock.
         */
        struct mutex device_list_mutex;
+
+       /* List of all devices, protected by device_list_mutex */
        struct list_head devices;
 
-       /* devices not currently being allocated */
+       /*
+        * Devices which can satisfy space allocation. Protected by
+        * chunk_mutex
+        */
        struct list_head alloc_list;
 
        struct btrfs_fs_devices *seed;