All of lore.kernel.org
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 0/2] btrfs: implement blk_holder_ops call backs
Date: Fri,  6 Jun 2025 15:17:14 +0930	[thread overview]
Message-ID: <cover.1749188673.git.wqu@suse.com> (raw)

Although test case generic/730 is going to be skipped for btrfs due to
the missing shutdown support, it still exposed a problem that btrfs has
no implementation for blk_holder_ops, thus even if lower level driver
wants to notify btrfs there is a device that is going to be removed,
btrfs can do nothing but ignore such critical info.

This series will implement all 4 callbacks for blk_holder_ops, 3 of them
are straightforward, just call the full-fs version of
sync/freeze/unfreeze.

The trickier one is the mark_dead(), all other fses with shutdown
support will shutdown the fs, making all operations to return error,
even if there is a cached page.

For btrfs we do not yet have full shutdown support, but at least we can
notify such problem through dmesg, then check if the fs can still
maintain its RW operations.
If not then mark the fs error, so no more new writes will happen,
preventing further data loss.

Now btrfs will output something like this if the only device of a btrfs
is removed, instead of aborting transaction later due to IO error:

 BTRFS info (device sda): devid 1 device sda path /dev/sda is going to be removed
 BTRFS: error (device sda) in btrfs_dev_mark_dead:294: errno=-5 IO failure (btrfs can no longer maintain read-write due to missing device(s))
 BTRFS info (device sda state E): forced readonly

Future full-fs shutdown will depend on this feature to properly pass
generic/730.

Qu Wenruo (2):
  btrfs: use fs_info as the block device holder
  btrfs: add a simple dead device detection mechanism

 fs/btrfs/dev-replace.c |  2 +-
 fs/btrfs/fs.h          |  2 -
 fs/btrfs/super.c       |  7 ++--
 fs/btrfs/super.h       |  2 +
 fs/btrfs/volumes.c     | 90 ++++++++++++++++++++++++++++++++++++++++--
 fs/btrfs/volumes.h     |  6 +++
 6 files changed, 99 insertions(+), 10 deletions(-)

-- 
2.49.0


             reply	other threads:[~2025-06-06  5:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-06  5:47 Qu Wenruo [this message]
2025-06-06  5:47 ` [PATCH 1/2] btrfs: use fs_info as the block device holder Qu Wenruo
2025-06-06  5:47 ` [PATCH 2/2] btrfs: add a simple dead device detection mechanism Qu Wenruo
2025-06-06  8:18 ` [PATCH 0/2] btrfs: implement blk_holder_ops call backs Qu Wenruo

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.1749188673.git.wqu@suse.com \
    --to=wqu@suse.com \
    --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.