All of lore.kernel.org
 help / color / mirror / Atom feed
From: Boris Burkov <boris@bur.io>
To: linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: [PATCH 2/2] btrfs-progs: add udev rule to forget removed device
Date: Thu, 29 Feb 2024 10:36:55 -0800	[thread overview]
Message-ID: <80545243dec10a48562bf8a9b5d10b8ba6f16983.1709231441.git.boris@bur.io> (raw)
In-Reply-To: <cover.1709231441.git.boris@bur.io>

Now that btrfs supports forgetting devices that don't exist, we can add
a udev rule to take advantage of that. This avoids bad edge cases
with cached devices in multi-device filesystems without having to rescan
all the devices on every change.

Signed-of-by: Boris Burkov <boris@bur.io>
---
 64-btrfs-rm.rules | 7 +++++++
 Makefile          | 2 +-
 2 files changed, 8 insertions(+), 1 deletion(-)
 create mode 100644 64-btrfs-rm.rules

diff --git a/64-btrfs-rm.rules b/64-btrfs-rm.rules
new file mode 100644
index 000000000..852155d28
--- /dev/null
+++ b/64-btrfs-rm.rules
@@ -0,0 +1,7 @@
+SUBSYSTEM!="block", GOTO="btrfs_rm_end"
+ACTION!="remove", GOTO="btrfs_rm_end"
+ENV{ID_FS_TYPE}!="btrfs", GOTO="btrfs_rm_end"
+
+RUN+="/usr/local/bin/btrfs device scan -u $devnode"
+
+LABEL="btrfs_rm_end"
diff --git a/Makefile b/Makefile
index 374f59b99..eaeed9baf 100644
--- a/Makefile
+++ b/Makefile
@@ -271,7 +271,7 @@ tune_objects = tune/main.o tune/seeding.o tune/change-uuid.o tune/change-metadat
 all_objects = $(objects) $(cmds_objects) $(libbtrfs_objects) $(convert_objects) \
 	      $(mkfs_objects) $(image_objects) $(tune_objects) $(libbtrfsutil_objects)
 
-udev_rules = 64-btrfs-dm.rules 64-btrfs-zoned.rules
+udev_rules = 64-btrfs-dm.rules 64-btrfs-zoned.rules 64-btrfs-rm.rules
 
 ifeq ("$(origin V)", "command line")
   BUILD_VERBOSE = $(V)
-- 
2.43.0


  parent reply	other threads:[~2024-02-29 18:35 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-29 18:36 [PATCH 0/2] btrfs-progs: forget removed devices Boris Burkov
2024-02-29 18:36 ` [PATCH 1/2] btrfs-progs: allow btrfs device scan -u on dead dev Boris Burkov
2024-02-29 18:36 ` Boris Burkov [this message]
2024-02-29 19:53   ` [PATCH 2/2] btrfs-progs: add udev rule to forget removed device David Sterba
2024-02-29 20:34     ` Boris Burkov
2024-03-01  2:31 ` [PATCH 0/2] btrfs-progs: forget removed devices Anand Jain
2024-03-01 11:54   ` David Sterba
2024-03-01 15:44     ` Boris Burkov
2024-03-04 18:07       ` David Sterba
2024-03-04 21:27         ` Boris Burkov

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=80545243dec10a48562bf8a9b5d10b8ba6f16983.1709231441.git.boris@bur.io \
    --to=boris@bur.io \
    --cc=kernel-team@fb.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.