* [PATCH] btrfs: allow mounting btrfs subvolumes with different ro/rw options
@ 2013-06-18 15:29 harald
2013-09-02 10:55 ` Harald Hoyer
0 siblings, 1 reply; 8+ messages in thread
From: harald @ 2013-06-18 15:29 UTC (permalink / raw)
To: linux-btrfs; +Cc: Harald Hoyer
From: Harald Hoyer <harald@redhat.com>
Given the following /etc/fstab entries:
/dev/sda3 /mnt/foo btrfs subvol=foo,ro 0
/dev/sda3 /mnt/bar btrfs subvol=bar,rw 0
you can't issue:
$ mount /mnt/foo
$ mount /mnt/bar
You would have to do:
$ mount /mnt/foo
$ mount -o remount,rw /mnt/foo
$ mount --bind -o remount,ro /mnt/foo
$ mount /bar
or
$ mount /mnt/bar
$ mount --rw /mnt/foo
$ mount --bind -o remount,ro /mnt/foo
With this patch you can do
$ mount /mnt/foo
$ mount /mnt/bar
$ cat /proc/self/mountinfo
49 33 0:41 /foo /mnt/foo ro,relatime shared:36 - btrfs /dev/sda3 rw,ssd,space_cache
87 33 0:41 /bar /mnt/bar rw,relatime shared:74 - btrfs /dev/sda3 rw,ssd,space_cache
---
fs/btrfs/super.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index f0857e0..80ed3e2 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -64,6 +64,8 @@
static const struct super_operations btrfs_super_ops;
static struct file_system_type btrfs_fs_type;
+static int btrfs_remount(struct super_block *sb, int *flags, char *data);
+
static const char *btrfs_decode_error(int errno)
{
char *errstr = "unknown";
@@ -1036,6 +1038,26 @@ static struct dentry *mount_subvol(const char *subvol_name, int flags,
mnt = vfs_kern_mount(&btrfs_fs_type, flags, device_name,
newargs);
kfree(newargs);
+
+ if (PTR_RET(mnt) == -EBUSY) {
+ if (flags & MS_RDONLY) {
+ mnt = vfs_kern_mount(&btrfs_fs_type, flags & ~MS_RDONLY, device_name,
+ newargs);
+ } else {
+ int r;
+ mnt = vfs_kern_mount(&btrfs_fs_type, flags | MS_RDONLY, device_name,
+ newargs);
+ if (IS_ERR(mnt))
+ return ERR_CAST(mnt);
+
+ r = btrfs_remount(mnt->mnt_sb, &flags, NULL);
+ if (r < 0) {
+ /* FIXME: release vfsmount mnt ??*/
+ return ERR_PTR(r);
+ }
+ }
+ }
+
if (IS_ERR(mnt))
return ERR_CAST(mnt);
--
1.8.2.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] btrfs: allow mounting btrfs subvolumes with different ro/rw options
2013-06-18 15:29 harald
@ 2013-09-02 10:55 ` Harald Hoyer
2013-09-14 11:26 ` Harald Hoyer
0 siblings, 1 reply; 8+ messages in thread
From: Harald Hoyer @ 2013-09-02 10:55 UTC (permalink / raw)
To: linux-btrfs
On 06/18/2013 05:29 PM, harald@redhat.com wrote:
> From: Harald Hoyer <harald@redhat.com>
>
> Given the following /etc/fstab entries:
>
> /dev/sda3 /mnt/foo btrfs subvol=foo,ro 0
> /dev/sda3 /mnt/bar btrfs subvol=bar,rw 0
>
> you can't issue:
>
> $ mount /mnt/foo
> $ mount /mnt/bar
>
> You would have to do:
>
> $ mount /mnt/foo
> $ mount -o remount,rw /mnt/foo
> $ mount --bind -o remount,ro /mnt/foo
> $ mount /bar
>
> or
>
> $ mount /mnt/bar
> $ mount --rw /mnt/foo
> $ mount --bind -o remount,ro /mnt/foo
>
> With this patch you can do
>
> $ mount /mnt/foo
> $ mount /mnt/bar
>
> $ cat /proc/self/mountinfo
> 49 33 0:41 /foo /mnt/foo ro,relatime shared:36 - btrfs /dev/sda3 rw,ssd,space_cache
> 87 33 0:41 /bar /mnt/bar rw,relatime shared:74 - btrfs /dev/sda3 rw,ssd,space_cache
> ---
> fs/btrfs/super.c | 22 ++++++++++++++++++++++
> 1 file changed, 22 insertions(+)
>
> diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
> index f0857e0..80ed3e2 100644
> --- a/fs/btrfs/super.c
> +++ b/fs/btrfs/super.c
> @@ -64,6 +64,8 @@
> static const struct super_operations btrfs_super_ops;
> static struct file_system_type btrfs_fs_type;
>
> +static int btrfs_remount(struct super_block *sb, int *flags, char *data);
> +
> static const char *btrfs_decode_error(int errno)
> {
> char *errstr = "unknown";
> @@ -1036,6 +1038,26 @@ static struct dentry *mount_subvol(const char *subvol_name, int flags,
> mnt = vfs_kern_mount(&btrfs_fs_type, flags, device_name,
> newargs);
> kfree(newargs);
> +
> + if (PTR_RET(mnt) == -EBUSY) {
> + if (flags & MS_RDONLY) {
> + mnt = vfs_kern_mount(&btrfs_fs_type, flags & ~MS_RDONLY, device_name,
> + newargs);
> + } else {
> + int r;
> + mnt = vfs_kern_mount(&btrfs_fs_type, flags | MS_RDONLY, device_name,
> + newargs);
> + if (IS_ERR(mnt))
> + return ERR_CAST(mnt);
> +
> + r = btrfs_remount(mnt->mnt_sb, &flags, NULL);
> + if (r < 0) {
> + /* FIXME: release vfsmount mnt ??*/
> + return ERR_PTR(r);
> + }
> + }
> + }
> +
> if (IS_ERR(mnt))
> return ERR_CAST(mnt);
>
>
Any comments?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] btrfs: allow mounting btrfs subvolumes with different ro/rw options
2013-09-02 10:55 ` Harald Hoyer
@ 2013-09-14 11:26 ` Harald Hoyer
2013-11-18 10:53 ` David Sterba
0 siblings, 1 reply; 8+ messages in thread
From: Harald Hoyer @ 2013-09-14 11:26 UTC (permalink / raw)
To: linux-btrfs
On 09/02/2013 12:55 PM, Harald Hoyer wrote:
> On 06/18/2013 05:29 PM, harald@redhat.com wrote:
>> From: Harald Hoyer <harald@redhat.com>
>>
>> Given the following /etc/fstab entries:
>>
>> /dev/sda3 /mnt/foo btrfs subvol=foo,ro 0
>> /dev/sda3 /mnt/bar btrfs subvol=bar,rw 0
>>
>> you can't issue:
>>
>> $ mount /mnt/foo
>> $ mount /mnt/bar
>>
>> You would have to do:
>>
>> $ mount /mnt/foo
>> $ mount -o remount,rw /mnt/foo
>> $ mount --bind -o remount,ro /mnt/foo
>> $ mount /bar
>>
>> or
>>
>> $ mount /mnt/bar
>> $ mount --rw /mnt/foo
>> $ mount --bind -o remount,ro /mnt/foo
>>
>> With this patch you can do
>>
>> $ mount /mnt/foo
>> $ mount /mnt/bar
>>
>> $ cat /proc/self/mountinfo
>> 49 33 0:41 /foo /mnt/foo ro,relatime shared:36 - btrfs /dev/sda3 rw,ssd,space_cache
>> 87 33 0:41 /bar /mnt/bar rw,relatime shared:74 - btrfs /dev/sda3 rw,ssd,space_cache
>> ---
>> fs/btrfs/super.c | 22 ++++++++++++++++++++++
>> 1 file changed, 22 insertions(+)
>>
>> diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
>> index f0857e0..80ed3e2 100644
>> --- a/fs/btrfs/super.c
>> +++ b/fs/btrfs/super.c
>> @@ -64,6 +64,8 @@
>> static const struct super_operations btrfs_super_ops;
>> static struct file_system_type btrfs_fs_type;
>>
>> +static int btrfs_remount(struct super_block *sb, int *flags, char *data);
>> +
>> static const char *btrfs_decode_error(int errno)
>> {
>> char *errstr = "unknown";
>> @@ -1036,6 +1038,26 @@ static struct dentry *mount_subvol(const char *subvol_name, int flags,
>> mnt = vfs_kern_mount(&btrfs_fs_type, flags, device_name,
>> newargs);
>> kfree(newargs);
>> +
>> + if (PTR_RET(mnt) == -EBUSY) {
>> + if (flags & MS_RDONLY) {
>> + mnt = vfs_kern_mount(&btrfs_fs_type, flags & ~MS_RDONLY, device_name,
>> + newargs);
>> + } else {
>> + int r;
>> + mnt = vfs_kern_mount(&btrfs_fs_type, flags | MS_RDONLY, device_name,
>> + newargs);
>> + if (IS_ERR(mnt))
>> + return ERR_CAST(mnt);
>> +
>> + r = btrfs_remount(mnt->mnt_sb, &flags, NULL);
>> + if (r < 0) {
>> + /* FIXME: release vfsmount mnt ??*/
>> + return ERR_PTR(r);
>> + }
>> + }
>> + }
>> +
>> if (IS_ERR(mnt))
>> return ERR_CAST(mnt);
>>
>>
>
> Any comments?
>
Not even a "no, we don't want that" ?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] btrfs: allow mounting btrfs subvolumes with different ro/rw options
2013-09-14 11:26 ` Harald Hoyer
@ 2013-11-18 10:53 ` David Sterba
2013-11-19 10:36 ` Harald Hoyer
0 siblings, 1 reply; 8+ messages in thread
From: David Sterba @ 2013-11-18 10:53 UTC (permalink / raw)
To: Harald Hoyer; +Cc: linux-btrfs
On Sat, Sep 14, 2013 at 01:26:22PM +0200, Harald Hoyer wrote:
> > Any comments?
> Not even a "no, we don't want that" ?
Please resend.
david
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] btrfs: allow mounting btrfs subvolumes with different ro/rw options
@ 2013-11-19 10:36 harald
2013-11-19 14:35 ` Chris Mason
0 siblings, 1 reply; 8+ messages in thread
From: harald @ 2013-11-19 10:36 UTC (permalink / raw)
To: linux-btrfs; +Cc: Harald Hoyer
From: Harald Hoyer <harald@redhat.com>
Given the following /etc/fstab entries:
/dev/sda3 /mnt/foo btrfs subvol=foo,ro 0 0
/dev/sda3 /mnt/bar btrfs subvol=bar,rw 0 0
you can't issue:
$ mount /mnt/foo
$ mount /mnt/bar
You would have to do:
$ mount /mnt/foo
$ mount -o remount,rw /mnt/foo
$ mount --bind -o remount,ro /mnt/foo
$ mount /mnt/bar
or
$ mount /mnt/bar
$ mount --rw /mnt/foo
$ mount --bind -o remount,ro /mnt/foo
With this patch you can do
$ mount /mnt/foo
$ mount /mnt/bar
$ cat /proc/self/mountinfo
49 33 0:41 /foo /mnt/foo ro,relatime shared:36 - btrfs /dev/sda3 rw,ssd,space_cache
87 33 0:41 /bar /mnt/bar rw,relatime shared:74 - btrfs /dev/sda3 rw,ssd,space_cache
---
fs/btrfs/super.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 2d8ac1b..cd55f02 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -64,6 +64,8 @@
static const struct super_operations btrfs_super_ops;
static struct file_system_type btrfs_fs_type;
+static int btrfs_remount(struct super_block *sb, int *flags, char *data);
+
static const char *btrfs_decode_error(int errno)
{
char *errstr = "unknown";
@@ -1106,6 +1108,26 @@ static struct dentry *mount_subvol(const char *subvol_name, int flags,
mnt = vfs_kern_mount(&btrfs_fs_type, flags, device_name,
newargs);
kfree(newargs);
+
+ if (PTR_RET(mnt) == -EBUSY) {
+ if (flags & MS_RDONLY) {
+ mnt = vfs_kern_mount(&btrfs_fs_type, flags & ~MS_RDONLY, device_name,
+ newargs);
+ } else {
+ int r;
+ mnt = vfs_kern_mount(&btrfs_fs_type, flags | MS_RDONLY, device_name,
+ newargs);
+ if (IS_ERR(mnt))
+ return ERR_CAST(mnt);
+
+ r = btrfs_remount(mnt->mnt_sb, &flags, NULL);
+ if (r < 0) {
+ /* FIXME: release vfsmount mnt ??*/
+ return ERR_PTR(r);
+ }
+ }
+ }
+
if (IS_ERR(mnt))
return ERR_CAST(mnt);
--
1.8.4.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] btrfs: allow mounting btrfs subvolumes with different ro/rw options
2013-11-18 10:53 ` David Sterba
@ 2013-11-19 10:36 ` Harald Hoyer
0 siblings, 0 replies; 8+ messages in thread
From: Harald Hoyer @ 2013-11-19 10:36 UTC (permalink / raw)
To: dsterba, linux-btrfs
On 11/18/2013 11:53 AM, David Sterba wrote:
> On Sat, Sep 14, 2013 at 01:26:22PM +0200, Harald Hoyer wrote:
>>> Any comments?
>> Not even a "no, we don't want that" ?
>
> Please resend.
>
> david
>
done
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] btrfs: allow mounting btrfs subvolumes with different ro/rw options
2013-11-19 10:36 [PATCH] btrfs: allow mounting btrfs subvolumes with different ro/rw options harald
@ 2013-11-19 14:35 ` Chris Mason
2014-04-03 17:45 ` David Sterba
0 siblings, 1 reply; 8+ messages in thread
From: Chris Mason @ 2013-11-19 14:35 UTC (permalink / raw)
To: harald, linux-btrfs; +Cc: Harald Hoyer
Quoting harald@redhat.com (2013-11-19 05:36:05)
> From: Harald Hoyer <harald@redhat.com>
>
[ create new vfsmounts with different states ]
Thanks for resending Harald. I'll give this a shot and see if I can
find any problems with it.
-chris
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] btrfs: allow mounting btrfs subvolumes with different ro/rw options
2013-11-19 14:35 ` Chris Mason
@ 2014-04-03 17:45 ` David Sterba
0 siblings, 0 replies; 8+ messages in thread
From: David Sterba @ 2014-04-03 17:45 UTC (permalink / raw)
To: Chris Mason; +Cc: harald, linux-btrfs
On Tue, Nov 19, 2013 at 09:35:32AM -0500, Chris Mason wrote:
> Quoting harald@redhat.com (2013-11-19 05:36:05)
> > From: Harald Hoyer <harald@redhat.com>
> >
> [ create new vfsmounts with different states ]
>
> Thanks for resending Harald. I'll give this a shot and see if I can
> find any problems with it.
Is this patch queued for 3.15? Thanks.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2014-04-03 17:45 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-19 10:36 [PATCH] btrfs: allow mounting btrfs subvolumes with different ro/rw options harald
2013-11-19 14:35 ` Chris Mason
2014-04-03 17:45 ` David Sterba
-- strict thread matches above, loose matches on Subject: below --
2013-06-18 15:29 harald
2013-09-02 10:55 ` Harald Hoyer
2013-09-14 11:26 ` Harald Hoyer
2013-11-18 10:53 ` David Sterba
2013-11-19 10:36 ` Harald Hoyer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).