public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Anand Jain <anand.jain@oracle.com>
To: linux-btrfs@vger.kernel.org
Cc: wqu@suse.com
Subject: [PATCH v2 0/2] btrfs-progs: read device fsid from the sysfs
Date: Mon, 13 Feb 2023 17:37:40 +0800	[thread overview]
Message-ID: <cover.1676124188.git.anand.jain@oracle.com> (raw)

v2:
 Almost a resend; no code was altered, except for the change log.

The following test scenario (as in fstests btrfs/249) shows an issue
where the "usage" subcommand fails to retrieve the fsid from the
superblock for a missing device.

Create a raid1 seed device while one of its device missing.
   $ mkfs.btrfs -f -draid1 -mraid1 $DEV1 $DEV2
   $ btrfstune -S 1 $DEV1
   $ wipefs -a $DEV2

Mount the seed device
   $ btrfs device scan --forget
   $ mount -o degraded $DEV1 /btrfs

Add a sprout device
   $ btrfs device add $DEV3 /btrfs -f

The usage subommand fails because we try to read superblock for the missing
device
   $ btrfs filesystem usage /btrfs
     ERROR: unexpected number of devices: 1 >= 1
     ERROR: if seed device is used, try running this command as root

The commit a26d60dedf9a ("btrfs: sysfs: add devinfo/fsid to retrieve
actual fsid from the device") introduced a sysfs interface for
retrieving the fsid of a device. This change allows for the reading of the
device fsid through the sysfs interface in the kernel, while retaining the
old method of reading the superblock from the disk for backward
compatibility during normal, non-missing device conditions.

Anand Jain (2):
  btrfs-progs: prepare helper device_is_seed
  btrfs-progs: read fsid from the sysfs in device_is_seed

 cmds/filesystem-usage.c | 47 ++++++++++++++++++++++++++++++++++++-----
 1 file changed, 42 insertions(+), 5 deletions(-)

--
2.39.1

             reply	other threads:[~2023-02-13  9:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-13  9:37 Anand Jain [this message]
2023-02-13  9:37 ` [PATCH 1/2] btrfs-progs: prepare helper device_is_seed Anand Jain
2023-02-21 23:16   ` David Sterba
2023-02-13  9:37 ` [PATCH 2/2] btrfs-progs: read fsid from the sysfs in device_is_seed Anand Jain
2023-02-21 23:17   ` David Sterba
2023-02-21 21:39 ` [PATCH v2 0/2] btrfs-progs: read device fsid from the sysfs David Sterba
2023-02-22  3:16   ` Anand Jain

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.1676124188.git.anand.jain@oracle.com \
    --to=anand.jain@oracle.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=wqu@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