From: David Sterba <dsterba@suse.cz>
To: Nikolay Borisov <nborisov@suse.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 06/11] btrfs: document device locking
Date: Mon, 6 Nov 2017 14:51:56 +0100 [thread overview]
Message-ID: <20171106135156.GD28789@suse.cz> (raw)
In-Reply-To: <eb745210-9d49-1d74-5715-9fc29f6cb3c1@suse.com>
On Thu, Nov 02, 2017 at 12:29:17PM +0200, Nikolay Borisov wrote:
> 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@suse.com>
> > ---
> > 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
In my understanding, documenting a mutex means defining the context and
data that are protected in the context. So I can start with the mutex,
or the data itself, but the mutex makes IMO more sense to start.
> > + * - 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.
The grouping is by mutex.
> > + *
> > + * global::fs_devs - add, remove, updates to the global list
>
> You seem to be describing a data structure here rather than a mutex
As I read it, this means "if this mutex is taken, it protects
global::fs_devs in this way".
> > + * 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.
That's the mutex in the section above "- uuid_mutex (global lock)".
> > + * btrfs_device::name - renames (write side), read is RCU
>
> It's not clear how the write side is protected.
same answer, it's under the 'uuid_mutex', so the write side is protected
by that, with exception of reads protected by RCU.
I wonder what kind of documentation structure do you expect as it seems
to me you missed it completely. Which is a valuable feedback to me, but
I don't know how to fix it, other than make the sections more visible
with underlining or indenting or more whitespace.
next prev parent reply other threads:[~2017-11-06 13:54 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-31 17:44 [PATCH 00/11] Device fixes and cleanups David Sterba
2017-10-31 17:44 ` [PATCH 01/11] btrfs: add missing device::flush_bio puts David Sterba
2017-11-02 9:41 ` Nikolay Borisov
2017-11-06 13:24 ` David Sterba
2017-11-02 10:40 ` Anand Jain
2017-10-31 17:44 ` [PATCH 02/11] btrfs: rename device free rcu helper to free_device_rcu David Sterba
2017-10-31 17:44 ` [PATCH 03/11] btrfs: introduce free_device helper David Sterba
2017-10-31 17:44 ` [PATCH 04/11] btrfs: use free_device where opencoded David Sterba
2017-11-02 11:25 ` Anand Jain
2017-10-31 17:44 ` [PATCH 05/11] btrfs: simplify exit paths in btrfs_init_new_device David Sterba
2017-11-06 1:53 ` Anand Jain
2017-10-31 17:44 ` [PATCH 06/11] btrfs: document device locking David Sterba
2017-11-02 10:29 ` Nikolay Borisov
2017-11-06 13:51 ` David Sterba [this message]
2017-11-06 15:02 ` Nikolay Borisov
2017-11-06 15:09 ` David Sterba
2017-11-03 11:13 ` Anand Jain
2017-11-06 2:32 ` Anand Jain
2017-11-06 13:40 ` David Sterba
2017-11-06 13:36 ` David Sterba
2017-10-31 17:44 ` [PATCH 07/11] btrfs: dev_alloc_list is not protected by RCU, use normal list_del David Sterba
2017-10-31 17:44 ` [PATCH 08/11] btrfs: simplify btrfs_close_bdev David Sterba
2017-10-31 17:44 ` [PATCH 09/11] btrfs: switch to RCU for device traversal in btrfs_ioctl_dev_info David Sterba
2017-10-31 17:44 ` [PATCH 10/11] btrfs: switch to RCU for device traversal in btrfs_ioctl_fs_info David Sterba
2017-10-31 17:44 ` [PATCH 11/11] btrfs: use non-RCU list traversal in write_all_supers callees David Sterba
2017-11-02 9:49 ` Nikolay Borisov
2017-11-06 13:59 ` David Sterba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171106135156.GD28789@suse.cz \
--to=dsterba@suse.cz \
--cc=linux-btrfs@vger.kernel.org \
--cc=nborisov@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).