diff mbox series

[v2] btrfs: Add comments on locking of several device-related fields

Message ID 20190509151111.12203-1-nborisov@suse.com (mailing list archive)
State New, archived
Headers show
Series [v2] btrfs: Add comments on locking of several device-related fields | expand

Commit Message

Nikolay Borisov May 9, 2019, 3:11 p.m. UTC
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---

V2: 
 * Document post_commit_list is protected by chunk_mutex in the "Device Locking"
 section. 

 fs/btrfs/volumes.c |  4 +++-
 fs/btrfs/volumes.h | 11 ++++++++---
 2 files changed, 11 insertions(+), 4 deletions(-)

Comments

David Sterba May 10, 2019, 11:51 a.m. UTC | #1
On Thu, May 09, 2019 at 06:11:11PM +0300, Nikolay Borisov wrote:
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>

Added to 5.3 queue, thanks.
diff mbox series

Patch

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index b85ff32f851c..83603be86891 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -237,7 +237,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
  * -------------
diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h
index 3b97e8092ba7..514799362244 100644
--- a/fs/btrfs/volumes.h
+++ b/fs/btrfs/volumes.h
@@ -52,8 +52,8 @@  struct btrfs_io_geometry {
 #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;
@@ -238,9 +238,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;