diff mbox series

[5/6] btrfs: Block writes to seed devices

Message ID 20230704125702.23180-5-jack@suse.cz (mailing list archive)
State Deferred, archived
Headers show
Series block: Add config option to not allow writing to mounted devices | expand

Commit Message

Jan Kara July 4, 2023, 12:56 p.m. UTC
When opening seed devices, ask block layer to not allow other writers to
open block device.

Signed-off-by: Jan Kara <jack@suse.cz>
---
 fs/btrfs/volumes.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

David Sterba July 12, 2023, 2:33 p.m. UTC | #1
On Tue, Jul 04, 2023 at 02:56:53PM +0200, Jan Kara wrote:
> When opening seed devices, ask block layer to not allow other writers to
> open block device.

Makes sense, thanks.

Acked-by: David Sterba <dsterba@suse.com>
diff mbox series

Patch

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index fb7082426498..496e0b6d86ab 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -6898,7 +6898,8 @@  static struct btrfs_fs_devices *open_seed_devices(struct btrfs_fs_info *fs_info,
 	if (IS_ERR(fs_devices))
 		return fs_devices;
 
-	ret = open_fs_devices(fs_devices, BLK_OPEN_READ, fs_info->bdev_holder);
+	ret = open_fs_devices(fs_devices, BLK_OPEN_READ | BLK_OPEN_BLOCK_WRITES,
+			      fs_info->bdev_holder);
 	if (ret) {
 		free_fs_devices(fs_devices);
 		return ERR_PTR(ret);