* [PATCH] btrfs: Add comments on locking of several device-related fields
@ 2019-05-07 14:24 Nikolay Borisov
2019-05-09 13:55 ` David Sterba
0 siblings, 1 reply; 6+ messages in thread
From: Nikolay Borisov @ 2019-05-07 14:24 UTC (permalink / raw)
To: linux-btrfs; +Cc: Nikolay Borisov
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
fs/btrfs/volumes.h | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
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;
--
2.17.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] btrfs: Add comments on locking of several device-related fields
2019-05-07 14:24 [PATCH] btrfs: Add comments on locking of several device-related fields Nikolay Borisov
@ 2019-05-09 13:55 ` David Sterba
2019-05-09 14:12 ` Nikolay Borisov
2019-05-09 15:11 ` [PATCH v2] " Nikolay Borisov
0 siblings, 2 replies; 6+ messages in thread
From: David Sterba @ 2019-05-09 13:55 UTC (permalink / raw)
To: Nikolay Borisov; +Cc: linux-btrfs
On Tue, May 07, 2019 at 05:24:28PM +0300, Nikolay Borisov wrote:
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
> ---
> fs/btrfs/volumes.h | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> 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 */
Please update the documentation in the comment 'Device locking' in
volumes.c
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] btrfs: Add comments on locking of several device-related fields
2019-05-09 13:55 ` David Sterba
@ 2019-05-09 14:12 ` Nikolay Borisov
2019-05-09 14:31 ` David Sterba
2019-05-09 15:11 ` [PATCH v2] " Nikolay Borisov
1 sibling, 1 reply; 6+ messages in thread
From: Nikolay Borisov @ 2019-05-09 14:12 UTC (permalink / raw)
To: dsterba, linux-btrfs
On 9.05.19 г. 16:55 ч., David Sterba wrote:
> On Tue, May 07, 2019 at 05:24:28PM +0300, Nikolay Borisov wrote:
>> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
>> ---
>> fs/btrfs/volumes.h | 11 ++++++++---
>> 1 file changed, 8 insertions(+), 3 deletions(-)
>>
>> 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 */
>
> Please update the documentation in the comment 'Device locking' in
> volumes.c
>
Right the only thing that is missing from the Device Locking comment is
the mention of post_commit_list. However, dev_list and dev_alloc_list
are essentially "the other side" of btrfs_fs_devices::alloc_list hence
I've added them as inline comments. I think it makes more sense to those
small comments next to the variables at least as a remainder.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] btrfs: Add comments on locking of several device-related fields
2019-05-09 14:12 ` Nikolay Borisov
@ 2019-05-09 14:31 ` David Sterba
0 siblings, 0 replies; 6+ messages in thread
From: David Sterba @ 2019-05-09 14:31 UTC (permalink / raw)
To: Nikolay Borisov; +Cc: dsterba, linux-btrfs
On Thu, May 09, 2019 at 05:12:16PM +0300, Nikolay Borisov wrote:
>
>
> On 9.05.19 г. 16:55 ч., David Sterba wrote:
> > On Tue, May 07, 2019 at 05:24:28PM +0300, Nikolay Borisov wrote:
> >> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
> >> ---
> >> fs/btrfs/volumes.h | 11 ++++++++---
> >> 1 file changed, 8 insertions(+), 3 deletions(-)
> >>
> >> 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 */
> >
> > Please update the documentation in the comment 'Device locking' in
> > volumes.c
>
> Right the only thing that is missing from the Device Locking comment is
> the mention of post_commit_list. However, dev_list and dev_alloc_list
> are essentially "the other side" of btrfs_fs_devices::alloc_list hence
> I've added them as inline comments. I think it makes more sense to those
> small comments next to the variables at least as a remainder.
Ok.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2] btrfs: Add comments on locking of several device-related fields
2019-05-09 13:55 ` David Sterba
2019-05-09 14:12 ` Nikolay Borisov
@ 2019-05-09 15:11 ` Nikolay Borisov
2019-05-10 11:51 ` David Sterba
1 sibling, 1 reply; 6+ messages in thread
From: Nikolay Borisov @ 2019-05-09 15:11 UTC (permalink / raw)
To: linux-btrfs; +Cc: dsterba, Nikolay Borisov
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(-)
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;
--
2.17.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2] btrfs: Add comments on locking of several device-related fields
2019-05-09 15:11 ` [PATCH v2] " Nikolay Borisov
@ 2019-05-10 11:51 ` David Sterba
0 siblings, 0 replies; 6+ messages in thread
From: David Sterba @ 2019-05-10 11:51 UTC (permalink / raw)
To: Nikolay Borisov; +Cc: linux-btrfs, dsterba
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.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-05-10 11:50 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-07 14:24 [PATCH] btrfs: Add comments on locking of several device-related fields Nikolay Borisov
2019-05-09 13:55 ` David Sterba
2019-05-09 14:12 ` Nikolay Borisov
2019-05-09 14:31 ` David Sterba
2019-05-09 15:11 ` [PATCH v2] " Nikolay Borisov
2019-05-10 11:51 ` David Sterba
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).