Skip to contentSkip to conversation

Should seed device be allowed to be mounted multiple times?

DISCUSSION Qu Wenruo 6 participants 13 messages Aug 2, 2025 – Aug 8, 2025

Subsystems (2)
lore
Share & tools
lore

Qu Wenruo

author
#0 lore raw

Hi,

There is the test case misc/046 from btrfs-progs, that the same seed device is mounted multiple times while a sprouted fs already being mounted.

However after kernel commit e04bf5d6da76 ("btrfs: restrict writes to opened btrfs devices"), every device can only be opened once.

Thus the same read-only seed device can not be mounted multiple times anymore.

I'm wondering what is the proper way to handle it.

Should we revert the patch and lose the extra protection, or change the docs to drop the "seed multiple filesystems, at the same time" part?

Personally speaking, I'd prefer the latter solution for the sake of safety (no one can write our block devices when it's mounted).

Thanks,
Qu

author
#1 lore raw
Quoted 11 lines · Qu Wenruo

Hi,

There is the test case misc/046 from btrfs-progs, that the same seed device is mounted multiple times while a sprouted fs already being mounted.

However after kernel commit e04bf5d6da76 ("btrfs: restrict writes to opened btrfs devices"), every device can only be opened once.

Thus the same read-only seed device can not be mounted multiple times anymore.

I'm wondering what is the proper way to handle it.

Should we revert the patch and lose the extra protection, or change the docs to drop the "seed multiple filesystems, at the same time" part?

BTW, reverting will not be that simple anymore.

The problem is we're now using unique blk dev holder (super block) for each filesystem.

Thus each block device can not have two different super blocks.

Thanks,
Qu

Quoted 6 lines

Personally speaking, I'd prefer the latter solution for the sake of safety (no one can write our block devices when it's mounted).

Thanks,
Qu

#2 lore raw
Quoted 15 lines · Qu Wenruo
Quoted 11 lines · Qu Wenruo

Hi,

There is the test case misc/046 from btrfs-progs, that the same seed device is mounted multiple times while a sprouted fs already being mounted.

However after kernel commit e04bf5d6da76 ("btrfs: restrict writes to opened btrfs devices"), every device can only be opened once.

Thus the same read-only seed device can not be mounted multiple times anymore.

I'm wondering what is the proper way to handle it.

Should we revert the patch and lose the extra protection, or change the docs to drop the "seed multiple filesystems, at the same time" part?

Quoted 11 lines

BTW, reverting will not be that simple anymore.

The problem is we're now using unique blk dev holder (super block) for each filesystem.

Thus each block device can not have two different super blocks.

Thanks,
Qu

Quoted 2 lines

Personally speaking, I'd prefer the latter solution for the sake of safety (no one can write our block devices when it's mounted).

This is expected to work- it's a key feature.
------------

$ mount /dev/sda /btrfs
mount: /btrfs: WARNING: source write-protected, mounted read-only.
$ btrfs dev add -f /dev/sdb /btrfs
$ mount -o remount,rw /btrfs
$ mount /dev/sda /btrfs1
mount: /btrfs1: /dev/sda already mounted or mount point busy.
       dmesg(1) may have more information after failed mount system call.
[130903.161395] BTRFS error: failed to open device for path /dev/sda with flags 0x23: -16
$ mount -o ro /dev/sda /btrfs1
mount: /btrfs1: /dev/sda already mounted or mount point busy.
       dmesg(1) may have more information after failed mount system call.
[130943.678745] BTRFS error: failed to open device for path /dev/sda with flags 0x21: -16

------------

One workaround is to mount all devices first, then add the sprout.
But that's not practical, as the full list of mount points may not be known ahead of time.

------------

$ mount /dev/sda /btrfs
mount: /btrfs: WARNING: source write-protected, mounted read-only.
$ mount /dev/sda /btrfs1
mount: /btrfs1: WARNING: source write-protected, mounted read-only.
$ btrfs dev add -f /dev/sdb /btrfs
$ mount -o remount,rw /btrfs
$ btrfs dev add -f /dev/sdc /btrfs1
$ mount -o remount,rw /btrfs1
---------------

BLK_OPEN_RESTRICT_WRITES appears to apply per block device or possibly per FSID (I'm not sure).?

Since seed devices are read-only, a second read-only mount should have been allowed.!!

After sprouting (device add), the FSID changes.
Looks like we need to inform the VFS of this update (guessing)?

Will work on a fix, appreciate the report.

Thanks.

PS:
I remember this (some other aswell) patch on the mailing list, it went in pretty quickly (3 days).
I couldn’t keep up with the pace. I suggest 2 weeks sock time.

author
#3 lore raw
Quoted 68 lines · Anand Jain
Quoted 15 lines · Qu Wenruo
Quoted 11 lines · Qu Wenruo

Hi,

There is the test case misc/046 from btrfs-progs, that the same seed device is mounted multiple times while a sprouted fs already being mounted.

However after kernel commit e04bf5d6da76 ("btrfs: restrict writes to opened btrfs devices"), every device can only be opened once.

Thus the same read-only seed device can not be mounted multiple times anymore.

I'm wondering what is the proper way to handle it.

Should we revert the patch and lose the extra protection, or change the docs to drop the "seed multiple filesystems, at the same time" part?

Quoted 11 lines

BTW, reverting will not be that simple anymore.

The problem is we're now using unique blk dev holder (super block) for each filesystem.

Thus each block device can not have two different super blocks.

Thanks,
Qu

Quoted 2 lines

Personally speaking, I'd prefer the latter solution for the sake of safety (no one can write our block devices when it's mounted).

This is expected to work- it's a key feature.
------------

$ mount /dev/sda /btrfs
mount: /btrfs: WARNING: source write-protected, mounted read-only.
$ btrfs dev add -f /dev/sdb /btrfs
$ mount -o remount,rw /btrfs
$ mount /dev/sda /btrfs1
mount: /btrfs1: /dev/sda already mounted or mount point busy.
        dmesg(1) may have more information after failed mount system call.
[130903.161395] BTRFS error: failed to open device for path /dev/sda with flags 0x23: -16
$ mount -o ro /dev/sda /btrfs1
mount: /btrfs1: /dev/sda already mounted or mount point busy.
        dmesg(1) may have more information after failed mount system call.
[130943.678745] BTRFS error: failed to open device for path /dev/sda with flags 0x21: -16

------------

One workaround is to mount all devices first, then add the sprout.
But that's not practical, as the full list of mount points may not be known ahead of time.

------------

$ mount /dev/sda /btrfs
mount: /btrfs: WARNING: source write-protected, mounted read-only.
$ mount /dev/sda /btrfs1
mount: /btrfs1: WARNING: source write-protected, mounted read-only.
$ btrfs dev add -f /dev/sdb /btrfs
$ mount -o remount,rw /btrfs
$ btrfs dev add -f /dev/sdc /btrfs1
$ mount -o remount,rw /btrfs1
---------------
Quoted 2 lines

BLK_OPEN_RESTRICT_WRITES appears to apply per block device or possibly per FSID (I'm not sure).?

That's one factor, but not all.

The problem is the new block dev holder. One can only open the bdev multiple times if the new holder is the same as the existing one.

Now since the block device will have a super block as the holder, it means it's impossible to have one block device belonging to two or more different filesystems.

Quoted 3 lines

Since seed devices are read-only, a second read-only mount should have been allowed.!!

I'd say the original design is too naive, allowing all mounted btrfs devices to share the same holder (fs type, which is never a common thing).

Previously we do not even properly implement all the device event handler, but now consider a situation, that the block device is going to be frozen.

Now which filesystem should be frozen?

Quoted 5 lines

After sprouting (device add), the FSID changes.
Looks like we need to inform the VFS of this update (guessing)?

Will work on a fix, appreciate the report.

Good luck, a good fix won't come up so easily.

Quoted 7 lines

Thanks.

PS:
I remember this (some other aswell) patch on the mailing list, it went in pretty quickly (3 days).
I couldn’t keep up with the pace. I suggest 2 weeks sock time.

The problem is not the new patches breaking the behavior, but the old behavior is never solid.

Let me be clear again, there is no fs except btrfs, allowing a block device belonging two different mounted fs.

We're abusing the block device holder, and just never realize it.

Now it's time for us to do the choice, continue the abuse and never act like a normal fs, or accept the behavior change and become a more normal fs.

Thanks,
Qu

#4 lore raw
Quoted 106 lines · Qu Wenruo
Quoted 68 lines · Anand Jain
Quoted 15 lines · Qu Wenruo
Quoted 11 lines · Qu Wenruo

Hi,

There is the test case misc/046 from btrfs-progs, that the same seed device is mounted multiple times while a sprouted fs already being mounted.

However after kernel commit e04bf5d6da76 ("btrfs: restrict writes to opened btrfs devices"), every device can only be opened once.

Thus the same read-only seed device can not be mounted multiple times anymore.

I'm wondering what is the proper way to handle it.

Should we revert the patch and lose the extra protection, or change the docs to drop the "seed multiple filesystems, at the same time" part?

Quoted 11 lines

BTW, reverting will not be that simple anymore.

The problem is we're now using unique blk dev holder (super block) for each filesystem.

Thus each block device can not have two different super blocks.

Thanks,
Qu

Quoted 2 lines

Personally speaking, I'd prefer the latter solution for the sake of safety (no one can write our block devices when it's mounted).

This is expected to work- it's a key feature.
------------

$ mount /dev/sda /btrfs
mount: /btrfs: WARNING: source write-protected, mounted read-only.
$ btrfs dev add -f /dev/sdb /btrfs
$ mount -o remount,rw /btrfs
$ mount /dev/sda /btrfs1
mount: /btrfs1: /dev/sda already mounted or mount point busy.
        dmesg(1) may have more information after failed mount system call.
[130903.161395] BTRFS error: failed to open device for path /dev/sda with flags 0x23: -16
$ mount -o ro /dev/sda /btrfs1
mount: /btrfs1: /dev/sda already mounted or mount point busy.
        dmesg(1) may have more information after failed mount system call.
[130943.678745] BTRFS error: failed to open device for path /dev/sda with flags 0x21: -16

------------

One workaround is to mount all devices first, then add the sprout.
But that's not practical, as the full list of mount points may not be known ahead of time.

------------

$ mount /dev/sda /btrfs
mount: /btrfs: WARNING: source write-protected, mounted read-only.
$ mount /dev/sda /btrfs1
mount: /btrfs1: WARNING: source write-protected, mounted read-only.
$ btrfs dev add -f /dev/sdb /btrfs
$ mount -o remount,rw /btrfs
$ btrfs dev add -f /dev/sdc /btrfs1
$ mount -o remount,rw /btrfs1
---------------
Quoted 2 lines

BLK_OPEN_RESTRICT_WRITES appears to apply per block device or possibly per FSID (I'm not sure).?

That's one factor, but not all.

The problem is the new block dev holder. One can only open the bdev multiple times if the new holder is the same as the existing one.

Now since the block device will have a super block as the holder, it means it's impossible to have one block device belonging to two or more different filesystems.

Quoted 3 lines

Since seed devices are read-only, a second read-only mount should have been allowed.!!

I'd say the original design is too naive, allowing all mounted btrfs devices to share the same holder (fs type, which is never a common thing).

Previously we do not even properly implement all the device event handler, but now consider a situation, that the block device is going to be frozen.

Now which filesystem should be frozen?

Quoted 5 lines

After sprouting (device add), the FSID changes.
Looks like we need to inform the VFS of this update (guessing)?

Will work on a fix, appreciate the report.

Good luck, a good fix won't come up so easily.

Quoted 7 lines

Thanks.

PS:
I remember this (some other aswell) patch on the mailing list, it went in pretty quickly (3 days).
I couldn’t keep up with the pace. I suggest 2 weeks sock time.

Quoted 7 lines

The problem is not the new patches breaking the behavior, but the old behavior is never solid.

Let me be clear again, there is no fs except btrfs, allowing a block device belonging two different mounted fs.

We're abusing the block device holder, and just never realize it.

Now it's time for us to do the choice, continue the abuse and never act like a normal fs, or accept the behavior change and become a more normal fs.

Thanks for the comments.
Our seed block device use-case doesn’t fall under the kind of risk that BLK_OPEN_RESTRICT_WRITES is meant to guard against—it’s not a typical multi-FS RW setup. Seed devices are readonly, so it might be reasonable to handle this at the block layer—or maybe it’s not feasible.

We did have another commit reverted recently. A two-week soak time sounds fair to me.

Thanks, Anand

#5 lore raw
Quoted 115 lines · Anand Jain
Quoted 112 lines · Qu Wenruo
Quoted 68 lines · Anand Jain
Quoted 15 lines · Qu Wenruo
Quoted 11 lines · Qu Wenruo

Hi,

There is the test case misc/046 from btrfs-progs, that the same seed device is mounted multiple times while a sprouted fs already being mounted.

However after kernel commit e04bf5d6da76 ("btrfs: restrict writes to opened btrfs devices"), every device can only be opened once.

Thus the same read-only seed device can not be mounted multiple times anymore.

I'm wondering what is the proper way to handle it.

Should we revert the patch and lose the extra protection, or change the docs to drop the "seed multiple filesystems, at the same time" part?

Quoted 11 lines

BTW, reverting will not be that simple anymore.

The problem is we're now using unique blk dev holder (super block) for each filesystem.

Thus each block device can not have two different super blocks.

Thanks,
Qu

Quoted 2 lines

Personally speaking, I'd prefer the latter solution for the sake of safety (no one can write our block devices when it's mounted).

This is expected to work- it's a key feature.
------------

$ mount /dev/sda /btrfs
mount: /btrfs: WARNING: source write-protected, mounted read-only.
$ btrfs dev add -f /dev/sdb /btrfs
$ mount -o remount,rw /btrfs
$ mount /dev/sda /btrfs1
mount: /btrfs1: /dev/sda already mounted or mount point busy.
        dmesg(1) may have more information after failed mount system call.
[130903.161395] BTRFS error: failed to open device for path /dev/sda with flags 0x23: -16
$ mount -o ro /dev/sda /btrfs1
mount: /btrfs1: /dev/sda already mounted or mount point busy.
        dmesg(1) may have more information after failed mount system call.
[130943.678745] BTRFS error: failed to open device for path /dev/sda with flags 0x21: -16

------------

One workaround is to mount all devices first, then add the sprout.
But that's not practical, as the full list of mount points may not be known ahead of time.

------------

$ mount /dev/sda /btrfs
mount: /btrfs: WARNING: source write-protected, mounted read-only.
$ mount /dev/sda /btrfs1
mount: /btrfs1: WARNING: source write-protected, mounted read-only.
$ btrfs dev add -f /dev/sdb /btrfs
$ mount -o remount,rw /btrfs
$ btrfs dev add -f /dev/sdc /btrfs1
$ mount -o remount,rw /btrfs1
---------------
Quoted 2 lines

BLK_OPEN_RESTRICT_WRITES appears to apply per block device or possibly per FSID (I'm not sure).?

That's one factor, but not all.

The problem is the new block dev holder. One can only open the bdev multiple times if the new holder is the same as the existing one.

Now since the block device will have a super block as the holder, it means it's impossible to have one block device belonging to two or more different filesystems.

Quoted 3 lines

Since seed devices are read-only, a second read-only mount should have been allowed.!!

I'd say the original design is too naive, allowing all mounted btrfs devices to share the same holder (fs type, which is never a common thing).

Previously we do not even properly implement all the device event handler, but now consider a situation, that the block device is going to be frozen.

Now which filesystem should be frozen?

Quoted 5 lines

After sprouting (device add), the FSID changes.
Looks like we need to inform the VFS of this update (guessing)?

Will work on a fix, appreciate the report.

Good luck, a good fix won't come up so easily.

Quoted 7 lines

Thanks.

PS:
I remember this (some other aswell) patch on the mailing list, it went in pretty quickly (3 days).
I couldn’t keep up with the pace. I suggest 2 weeks sock time.

The problem is not the new patches breaking the behavior, but the old behavior is never solid.

Let me be clear again, there is no fs except btrfs, allowing a block device belonging two different mounted fs.

We're abusing the block device holder, and just never realize it.

Quoted 8 lines
Quoted 1 line

Now it's time for us to do the choice, continue the abuse and never act like a normal fs, or accept the behavior change and become a more normal fs.

Thanks for the comments.
Our seed block device use-case doesn’t fall under the kind of risk that BLK_OPEN_RESTRICT_WRITES is meant to guard against—it’s not a typical multi-FS RW setup. Seed devices are readonly, so it might be reasonable to handle this at the block layer—or maybe it’s not feasible.

Read-only doesn't prevent the device from being removed suddenly.

You still didn't know that the whole fs_holder_ops is based on the assumption that one block device should only belong to one mounted fs.

And I see that assumption completely valid.

I didn't see any reason why any sane people want to mount the sported fs and the seed device at the same time.

If the use case is to sprout a fs based on the seed device multiple times, it's still possible, just unmount the sprout fs before mounting the seed device again.

I didn't see why you're stubbornly insist that mounting sprout and seed device at the same time is a hard requirement.

Quoted 3 lines

We did have another commit reverted recently. A two-week soak time sounds fair to me.

You need some solid reason to revert.

Just to revert to an initially insane behavior doesn't sound sane to me.

Thanks,
Qu

Quoted 3 lines

Thanks, Anand

#6 lore raw
Quoted 10 lines
Quoted 7 lines

Thanks for the comments.
Our seed block device use-case doesn’t fall under the kind of risk that BLK_OPEN_RESTRICT_WRITES is meant to guard against—it’s not a typical multi-FS RW setup. Seed devices are readonly, so it might be reasonable to handle this at the block layer—or maybe it’s not feasible.

Read-only doesn't prevent the device from being removed suddenly.

I don't see how this is related to the BLK_OPEN_RESTRICT_WRITES flag. Can you clarify?

------
/* open is exclusive wrt all other BLK_OPEN_WRITE opens to the device */
#define BLK_OPEN_RESTRICT_WRITES ((__force blk_mode_t)(1 << 5))
------

Quoted 1 line

You still didn't know that the whole fs_holder_ops is based on the assumption that one block device should only belong to one mounted fs.

You're missing the point: after a sprout, Btrfs internally becomes a new filesystem with a new FSID. Some may call it insane—but it's different, useful, and it works.

During that transition, fs_holder (or equivalent) needs to be updated to reflect the change. If that's not currently possible, we may need to add support for it.

The problem is that fs_holder_ops still sees it as a seed device, which is risky—we don’t know what else could break if the FSID change isn’t properly handled.

Quoted 3 lines

And I see that assumption completely valid.

I didn't see any reason why any sane people want to mount the sported fs and the seed device at the same time.

Neither of us has data on how it’s being used. And as I’ve hinted, it does violate kABI from a technical standpoint.

Quoted 1 line

If the use case is to sprout a fs based on the seed device multiple times, it's still possible, just unmount the sprout fs before mounting the seed device again.

In a datacenter environment, unmounting isn’t always a viable option.

Now that there’s a regression and a feature has been broken, let’s not shift the discussion to whether that feature was useful. I prefer to keep things technical—not personal—and I expect respectful communication to be mutual, not taken for granted.

Btrfs has some unique behaviors, and it’s possible we’ll need changes in the block layer or fs_holder_ops. That still needs to be figured out.

Thanks, Anand

#7 lore raw
Quoted 9 lines · Anand Jain
Quoted 7 lines
Quoted 7 lines

Thanks for the comments.
Our seed block device use-case doesn’t fall under the kind of risk that BLK_OPEN_RESTRICT_WRITES is meant to guard against—it’s not a typical multi-FS RW setup. Seed devices are readonly, so it might be reasonable to handle this at the block layer—or maybe it’s not feasible.

Quoted 3 lines
Quoted 1 line

Read-only doesn't prevent the device from being removed suddenly.

I don't see how this is related to the BLK_OPEN_RESTRICT_WRITES flag. Can you clarify?

It's not related to that flag, I'm talking about the fs_bdev_mark_dead(), and the remaining 3 callbacks.

Those call backs are all depending on the bdev holder to grab a super block.

Thus a block device should and can not have multiple super blocks.

Quoted 11 lines

------
/* open is exclusive wrt all other BLK_OPEN_WRITE opens to the device */ #define BLK_OPEN_RESTRICT_WRITES        ((__force blk_mode_t)(1 << 5))
------

Quoted 1 line

You still didn't know that the whole fs_holder_ops is based on the assumption that one block device should only belong to one mounted fs.

You're missing the point: after a sprout, Btrfs internally becomes a new filesystem with a new FSID. Some may call it insane—but it's different, useful, and it works.

I totally know that, it's you don't understand how bdev holder works, nor willing to spend any time reading the details about bdev_open().

Just search the @holder inside that function, even without RESTRICT_WRITES flag, it will still fail at bd_may_reclaim() due to the holder (super block) mismatch.

Quoted 8 lines

During that transition, fs_holder (or equivalent) needs to be updated to reflect the change. If that's not currently possible, we may need to add support for it.

The problem is that fs_holder_ops still sees it as a seed device, which is risky—we don’t know what else could break if the FSID change isn’t properly handled.

Nope, it's super simple, you just can not mount have a block device with two different holders.

Quoted 6 lines
Quoted 4 lines

And I see that assumption completely valid.

I didn't see any reason why any sane people want to mount the sported fs and the seed device at the same time.

Neither of us has data on how it’s being used.

Just read all the other filesystems' code.

Either it's pushing super block as bdev holder, so that we can easily grab the fs from bdev through bdev_super_lock(), or it's bcachefs doing the similar thing, but without using the existing helpers.

Quoted 5 lines

And as I’ve hinted, it
does violate kABI from a technical standpoint.

Quoted 1 line

If the use case is to sprout a fs based on the seed device multiple times, it's still possible, just unmount the sprout fs before mounting the seed device again.

In a datacenter environment, unmounting isn’t always a viable option.

If you're mounting the fs already, why you can not umount suddenly?

If you're talking about rootfs, it's no deal breaker, just remove the seed device from the sprout fs, then mount the seed device again.

Quoted 5 lines

Now that there’s a regression and a feature has been broken, let’s not shift the discussion to whether that feature was useful. I prefer to keep things technical—not personal—and I expect respectful communication to be mutual, not taken for granted.

I have explained the technical details enough. If you are not willing to understand, sure call it whatever you want.

Quoted 3 lines

Btrfs has some unique behaviors, and it’s possible we’ll need changes in the block layer or fs_holder_ops. That still needs to be figured out.

Unique doesn't mean correct nor sane.

And seed device is nothing special. If you don't want to accept that one mounted block device should only belong to one mounted fs, sure go ahead and see what everyone else thinks.

Quoted 3 lines

Thanks, Anand

#8 lore raw
Quoted 17 lines · Qu Wenruo
Quoted 9 lines · Anand Jain
Quoted 7 lines
Quoted 7 lines

Thanks for the comments.
Our seed block device use-case doesn’t fall under the kind of risk that BLK_OPEN_RESTRICT_WRITES is meant to guard against—it’s not a typical multi-FS RW setup. Seed devices are readonly, so it might be reasonable to handle this at the block layer—or maybe it’s not feasible.

Quoted 4 lines
Quoted 1 line

Read-only doesn't prevent the device from being removed suddenly.

I don't see how this is related to the BLK_OPEN_RESTRICT_WRITES flag. Can you clarify?

Quoted 6 lines

It's not related to that flag, I'm talking about the fs_bdev_mark_dead(), and the remaining 3 callbacks.

Those call backs are all depending on the bdev holder to grab a super block.

Thus a block device should and can not have multiple super blocks.

I'm pretty sure you can't just break the seed device sharing use-case without causing a lot of regressions...

If you know what the seed devices are than you can change the code to simply use the btrfs filesystem type as the holder without any holder operations but just for seed devices. Then seed devices can be opened by/shared with any btrfs filesystem.

The only restriction is that you cannot use a device as a seed device that another btrfs filesystem uses as a non-seed device because then it will be fully owned by the other btrfs filesystem. But Josef tells me you can only use it as a seed device anyway.

IOW, if you have a concept of shareable devices between different btrfs filesystems then it's fine to reflect that in the code. If really needed you can later add custom block holder ops for seed devices so you can e.g., iterate through all filesystems that share the device.

#9 lore raw
Quoted 21 lines · Christian Brauner
Quoted 20 lines · Qu Wenruo
Quoted 9 lines · Anand Jain
Quoted 7 lines
Quoted 7 lines

Thanks for the comments.
Our seed block device use-case doesn’t fall under the kind of risk that BLK_OPEN_RESTRICT_WRITES is meant to guard against—it’s not a typical multi-FS RW setup. Seed devices are readonly, so it might be reasonable to handle this at the block layer—or maybe it’s not feasible.

Quoted 4 lines
Quoted 1 line

Read-only doesn't prevent the device from being removed suddenly.

I don't see how this is related to the BLK_OPEN_RESTRICT_WRITES flag. Can you clarify?

It's not related to that flag, I'm talking about the fs_bdev_mark_dead(), and the remaining 3 callbacks.

Quoted 6 lines
Quoted 3 lines

Those call backs are all depending on the bdev holder to grab a super block.

Thus a block device should and can not have multiple super blocks.

I'm pretty sure you can't just break the seed device sharing use-case without causing a lot of regressions...

It's not that widely affecting, we can still share the same seed device for all different sprout fses, just only one of them can be mounted at the same time.

And even with that limitation, it won't affect most (or any) real world use cases.

Even the most complex case like using seed devices as rootfs, and we want to sprout the rootfs again, just remove the seed device from the current rootfs, then one can mount the seed device again.

Quoted 5 lines

If you know what the seed devices are than you can change the code to simply use the btrfs filesystem type as the holder without any holder operations but just for seed devices. Then seed devices can be opened by/shared with any btrfs filesystem.

But we will lose all the bdev related events.

We still want to sync/freeze/thaw the real sprouted fs in the end.

Quoted 10 lines

The only restriction is that you cannot use a device as a seed device that another btrfs filesystem uses as a non-seed device because then it will be fully owned by the other btrfs filesystem. But Josef tells me you can only use it as a seed device anyway.

IOW, if you have a concept of shareable devices between different btrfs filesystems then it's fine to reflect that in the code. If really needed you can later add custom block holder ops for seed devices so you can e.g., iterate through all filesystems that share the device.

Sure it's possible, with a lot of extra code looking up where the seed device belongs, and all the extra bdev event proxy.

But I'd say, the seed device specification is not well specified in the very beginning, thus it results a lot of "creative" but not practical use cases.

Yes, this will result some regression, but I'd prefer a more sounding and simpler logic for the whole seed device, with minimal impact to the most common existing use cases.

Thanks,
Qu

#10 lore raw
Quoted 67 lines · Qu Wenruo
Quoted 21 lines · Christian Brauner
Quoted 20 lines · Qu Wenruo
Quoted 9 lines · Anand Jain
Quoted 7 lines
Quoted 7 lines

Thanks for the comments.
Our seed block device use-case doesn’t fall under the kind of risk that BLK_OPEN_RESTRICT_WRITES is meant to guard against—it’s not a typical multi-FS RW setup. Seed devices are readonly, so it might be reasonable to handle this at the block layer—or maybe it’s not feasible.

Quoted 4 lines
Quoted 1 line

Read-only doesn't prevent the device from being removed suddenly.

I don't see how this is related to the BLK_OPEN_RESTRICT_WRITES flag. Can you clarify?

It's not related to that flag, I'm talking about the fs_bdev_mark_dead(), and the remaining 3 callbacks.

Quoted 6 lines
Quoted 3 lines

Those call backs are all depending on the bdev holder to grab a super block.

Thus a block device should and can not have multiple super blocks.

I'm pretty sure you can't just break the seed device sharing use-case without causing a lot of regressions...

It's not that widely affecting, we can still share the same seed device for all different sprout fses, just only one of them can be mounted at the same time.

And even with that limitation, it won't affect most (or any) real world use cases.

Even the most complex case like using seed devices as rootfs, and we want to sprout the rootfs again, just remove the seed device from the current rootfs, then one can mount the seed device again.

Quoted 5 lines

If you know what the seed devices are than you can change the code to simply use the btrfs filesystem type as the holder without any holder operations but just for seed devices. Then seed devices can be opened by/shared with any btrfs filesystem.

But we will lose all the bdev related events.

We still want to sync/freeze/thaw the real sprouted fs in the end.

Quoted 10 lines

The only restriction is that you cannot use a device as a seed device that another btrfs filesystem uses as a non-seed device because then it will be fully owned by the other btrfs filesystem. But Josef tells me you can only use it as a seed device anyway.

IOW, if you have a concept of shareable devices between different btrfs filesystems then it's fine to reflect that in the code. If really needed you can later add custom block holder ops for seed devices so you can e.g., iterate through all filesystems that share the device.

Sure it's possible, with a lot of extra code looking up where the seed device belongs, and all the extra bdev event proxy.

Quoted 6 lines

But I'd say, the seed device specification is not well specified in the very beginning, thus it results a lot of "creative" but not practical use cases.

Yes, this will result some regression, but I'd prefer a more sounding and simpler logic for the whole seed device, with minimal impact to the most common existing use cases.

Ok, I'm not in a position to argue this effectively. If you think you an reasonably get away with this regression so be it. But if this ends up in a total revert of the conversion even though we'd have alternative solution I'm not going to be happy...

#11 lore raw
In reply to Qu Wenruo

Hi Qu,

First of all, thanks for your work on BTRFS. I also want to thank the entire team. Regarding the device opening restrictions from commit e04bf5d6da76, I wanted to check on potential impacts for btrbk, a commonly used BTRFS backup tool.

btrbk's documentation recommends mounting BTRFS filesystems with "subvolid=5" for backup operations (see
https://digint.ch/btrbk/doc/readme.html). Many users following this guidance mount the top-level subvolume specifically for btrbk while also having other subvolumes mounted for regular use.

While I believe typical single-filesystem scenarios should be unaffected (multiple subvolume mounts from the same device), I wanted to confirm that common btrbk use cases won't be impacted by the new restrictions. This includes:

Mounting subvolid=5 alongside other subvolumes from the same filesystem Multiple BTRFS filesystems being backed up on the same system Any network backup scenarios where device access patterns might differ

Could you clarify whether btrbk's recommended mounting patterns are compatible with the changes being considered now?

Thanks for considering the broader ecosystem impact. Have a great day!

Dave

Quoted 23 lines · Qu Wenruo

Hi,

There is the test case misc/046 from btrfs-progs, that the same seed device is mounted multiple times while a sprouted fs already being mounted.

However after kernel commit e04bf5d6da76 ("btrfs: restrict writes to opened btrfs devices"), every device can only be opened once.

Thus the same read-only seed device can not be mounted multiple times anymore.

I'm wondering what is the proper way to handle it.

Should we revert the patch and lose the extra protection, or change the docs to drop the "seed multiple filesystems, at the same time" part?

Personally speaking, I'd prefer the latter solution for the sake of safety (no one can write our block devices when it's mounted).

Thanks,
Qu

#12 lore raw
Quoted 7 lines · Dave T

Hi Qu,

First of all, thanks for your work on BTRFS. I also want to thank the entire team. Regarding the device opening restrictions from commit e04bf5d6da76, I wanted to check on potential impacts for btrbk, a commonly used BTRFS backup tool.

Quoted 5 lines

btrbk's documentation recommends mounting BTRFS filesystems with "subvolid=5" for backup operations (see
https://digint.ch/btrbk/doc/readme.html). Many users following this guidance mount the top-level subvolume specifically for btrbk while also having other subvolumes mounted for regular use.

It's completely unrelated.

The "mounted multiple times" is not mounting a subvolume on to different location.

It's about the same seed device mounted belonging to different filesystems.

E.g. a sprouted fs mounted using the seed device, meanwhile the seed device itself also mounted somewhere else.

Such seed device usage should not affect most users.

Quoted 43 lines

While I believe typical single-filesystem scenarios should be unaffected (multiple subvolume mounts from the same device), I wanted to confirm that common btrbk use cases won't be impacted by the new restrictions. This includes:

Mounting subvolid=5 alongside other subvolumes from the same filesystem Multiple BTRFS filesystems being backed up on the same system Any network backup scenarios where device access patterns might differ

Could you clarify whether btrbk's recommended mounting patterns are compatible with the changes being considered now?

Thanks for considering the broader ecosystem impact. Have a great day!

Dave

Quoted 23 lines · Qu Wenruo

Hi,

There is the test case misc/046 from btrfs-progs, that the same seed device is mounted multiple times while a sprouted fs already being mounted.

However after kernel commit e04bf5d6da76 ("btrfs: restrict writes to opened btrfs devices"), every device can only be opened once.

Thus the same read-only seed device can not be mounted multiple times anymore.

I'm wondering what is the proper way to handle it.

Should we revert the patch and lose the extra protection, or change the docs to drop the "seed multiple filesystems, at the same time" part?

Personally speaking, I'd prefer the latter solution for the sake of safety (no one can write our block devices when it's mounted).

Thanks,
Qu