linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Nikolay Borisov <nborisov@suse.com>
Cc: dsterba@suse.cz, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 06/11] btrfs: document device locking
Date: Mon, 6 Nov 2017 16:09:16 +0100	[thread overview]
Message-ID: <20171106150916.GH28789@twin.jikos.cz> (raw)
In-Reply-To: <5661b2a4-3f0d-281e-6472-66cd48e08eca@suse.com>

On Mon, Nov 06, 2017 at 05:02:21PM +0200, Nikolay Borisov wrote:
> Right, I did a fresh read and indeed the structure now makes sense. I
> have completely missed the nesting though. Maybe you can nest more
> agressively, now every sentence is aligned to the header, perhaps we
> want to have it one level deeper? Or use more than one - at the mutex
> level ? I don't really have a clear-cut answer for you.

How about that:

/*
 * Device locking
 * ==============
 *
 * There are several mutexes that protect manipulation of devices and low-level
 * structures like chunks but not block groups, extents or files
 *
 * 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
 *
 * global::fs_devs - add, remove, updates to the global list
 *
 * does not protect: manipulation of the fs_devices::devices list!
 *
 * btrfs_device::name - renames (write side), read is RCU
 *
 * 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
 */

  reply	other threads:[~2017-11-06 15:11 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
2017-11-06 15:02       ` Nikolay Borisov
2017-11-06 15:09         ` David Sterba [this message]
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=20171106150916.GH28789@twin.jikos.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).