All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anand Jain <anand.jain@oracle.com>
To: linux-btrfs@vger.kernel.org
Cc: dsterba@suse.com, l@damenly.su
Subject: [PATCH V5 0/4] btrf_show_devname related fixes
Date: Tue, 24 Aug 2021 13:05:18 +0800	[thread overview]
Message-ID: <cover.1629780501.git.anand.jain@oracle.com> (raw)

v5: Patches reorged.
 Patch (btrfs: consolidate device_list_mutex in prepare_sprout to its parent)
 moved into a new set as it has a dependency on an older patch in the ML.
 Change log updated.
v4: Fix unrelated changes
v3: Add missing rcu_lock in show_devname
v2: Use latest_dev so that device path is also shown

Su Yue reported [1] warn() as a result of a race between the following two
threads,
  Thread-A: function stack leading to btrfs_prepare_sprout()
and
  Thread-B: function stack leading to btrfs_show_devname()

[1]  https://patchwork.kernel.org/project/linux-btrfs/patch/20210818041944.5793-1-l@damenly.su/

While btrfs_prepare_sprout() moves the fs_devices::devices into
fs_devices::seed_list, the btrfs_show_devname searched for the devices
and found none, leading to the warning as in [1] (above).

The btrfs_prepare_sprout() uses device_list_mutex however
btrfs_show_devname() don't and, the device_list_mutex in
btrfs_show_devname() was removed by the patch 88c14590cdd6
(btrfs: use RCU in btrfs_show_devname for device list traversal)
for the perforamcne reasons.

This series does not intend to reintroduce the device_list_mutex in
btrfs_prepare_sprout() but instead saves the pointer to btrfs_devices
in the fs_devices::latest_dev so that btrfs_show_devname() can use it.

patch 1 converts fs_devices::latest_bdev type from struct block_device to
        struct btrfs_device and renames it to latest_dev
patch 2 btrfs_show_devname() uses the fs_devices::latest_dev::name to show
        the device path in the /proc/self/mounts
patch 3 fixes a stale latest_dev pointer after the sprout operation
patch 4 fixes an old comment about the function btrfs_show_devname()

Anand Jain (4):
  btrfs: convert latest_bdev type to struct btrfs_device and rename
  btrfs: use latest_dev in btrfs_show_devname
  btrfs: update latest_dev when we sprout
  btrfs: fix comment about the btrfs_show_devname

 fs/btrfs/disk-io.c   |  6 +++---
 fs/btrfs/extent_io.c |  2 +-
 fs/btrfs/inode.c     |  2 +-
 fs/btrfs/super.c     | 26 ++++----------------------
 fs/btrfs/volumes.c   | 17 ++++++++---------
 fs/btrfs/volumes.h   |  2 +-
 6 files changed, 18 insertions(+), 37 deletions(-)

-- 
2.31.1


             reply	other threads:[~2021-08-24  5:05 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-24  5:05 Anand Jain [this message]
2021-08-24  5:05 ` [PATCH V5 1/4] btrfs: convert latest_bdev type to struct btrfs_device and rename Anand Jain
2021-08-24  5:05 ` [PATCH RFC V5 2/4] btrfs: use latest_dev in btrfs_show_devname Anand Jain
2021-09-02 13:47   ` David Sterba
2021-08-24  5:05 ` [PATCH V5 3/4] btrfs: update latest_dev when we sprout Anand Jain
2021-08-24  5:05 ` [PATCH V5 4/4] btrfs: fix comment about the btrfs_show_devname Anand Jain
2021-09-02 14:26   ` David Sterba
2021-09-02 14:38   ` David Sterba
2021-08-30 22:41 ` [PATCH V5 0/4] btrf_show_devname related fixes Anand Jain
2021-08-31 14:28   ` Su Yue
2021-08-31 15:41     ` David Sterba
2021-08-31 23:55       ` Su Yue
2021-08-31 23:58 ` Su Yue
2021-09-02 15:26 ` 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=cover.1629780501.git.anand.jain@oracle.com \
    --to=anand.jain@oracle.com \
    --cc=dsterba@suse.com \
    --cc=l@damenly.su \
    --cc=linux-btrfs@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.