Skip to contentSkip to conversation

Can't mount subvolume with ro option

DISCUSSION Sébastien ROHAUT 3 participants 7 messages Jun 27, 2014 – Jun 30, 2014 Btrfs file system

lore
Share & tools
lore
#0 lore raw

Hi,

In the wiki, it's said we can mount subvolumes with different mount options. nosuid, nodev, rw and ro are listed, as valid generic mount options.

https://btrfs.wiki.kernel.org/index.php/FAQ#Can_I_mount_subvolumes_with_different_mount_options.3F

But, when I try to mount my subvolume in read only I get an error.

# df
/dev/sdb1             5242880     352    4689856   1% /my_btrfs
# btrfs subvolume list /my_btrfs
ID 257 gen 10 top level 5 path subvol1

# LANG=C mount -t btrfs -o subvol=subvol1,ro /dev/sdb1 /my_btrfs/subvol1_mnt
mount: /dev/sdb1 is already mounted or /my_btrfs/subvol1_mnt busy
/dev/sdb1 is already mounted on /my_btrfs

nodev and nosuid are working.

Is there an error in the wiki, or do I do something wrong ?

Thanks,

Sebastien ROHAUT

Some infos :

# cat /etc/redhat-release
Fedora release 20 (Heisenbug)
# uname -a
Linux localhost.localdomain 3.14.7-200.fc20.x86_64 #1 SMP Wed Jun 11 22:38:05 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
# btrfs --version
Btrfs v3.14.1
# btrfs fi show
Label: none  uuid: 66e0f120-e478-4cac-b04a-82a0ffc4d6ce
    Total devices 1 FS bytes used 208.00KiB
    devid    1 size 5.00GiB used 548.00MiB path /dev/sdb1

Btrfs v3.14.1

# dmesg|grep -i btrfs

[    2.753052] Btrfs loaded
[    2.766655] BTRFS: device fsid 66e0f120-e478-4cac-b04a-82a0ffc4d6ce devid 1 transid 9 /dev/sdb1
[   36.382921] BTRFS: device fsid 66e0f120-e478-4cac-b04a-82a0ffc4d6ce devid 1 transid 9 /dev/sdb1
[   36.389497] BTRFS info (device sdb1): disk space caching is enabled
[   36.393462] SELinux: initialized (dev sdb1, type btrfs), uses xattr
[  860.375237] BTRFS: device fsid 66e0f120-e478-4cac-b04a-82a0ffc4d6ce devid 1 transid 9 /dev/sdb1
[ 1141.451952] BTRFS: device fsid 66e0f120-e478-4cac-b04a-82a0ffc4d6ce devid 1 transid 10 /dev/sdb1
[ 1379.802221] BTRFS info (device sdb1): disk space caching is enabled
[ 1513.815988] BTRFS info (device sdb1): disk space caching is enabled
[ 1529.839598] BTRFS: device fsid 66e0f120-e478-4cac-b04a-82a0ffc4d6ce devid 1 transid 11 /dev/sdb1
[ 1624.310822] BTRFS: device fsid 66e0f120-e478-4cac-b04a-82a0ffc4d6ce devid 1 transid 11 /dev/sdb1
[ 1650.630700] BTRFS: device fsid 66e0f120-e478-4cac-b04a-82a0ffc4d6ce devid 1 transid 11 /dev/sdb1
[ 2297.318435] BTRFS: device fsid 66e0f120-e478-4cac-b04a-82a0ffc4d6ce devid 1 transid 11 /dev/sdb1
[ 2305.110964] BTRFS: device fsid 66e0f120-e478-4cac-b04a-82a0ffc4d6ce devid 1 transid 11 /dev/sdb1
[ 2332.863021] BTRFS: device fsid 66e0f120-e478-4cac-b04a-82a0ffc4d6ce devid 1 transid 12 /dev/sdb1
[ 2344.573903] BTRFS: device fsid 66e0f120-e478-4cac-b04a-82a0ffc4d6ce devid 1 transid 12 /dev/sdb1
[ 2348.597860] BTRFS: device fsid 66e0f120-e478-4cac-b04a-82a0ffc4d6ce devid 1 transid 12 /dev/sdb1
[ 2580.620032] BTRFS: device fsid 66e0f120-e478-4cac-b04a-82a0ffc4d6ce devid 1 transid 13 /dev/sdb1
[ 2645.162881] BTRFS: device fsid 66e0f120-e478-4cac-b04a-82a0ffc4d6ce devid 1 transid 13 /dev/sdb1
[ 2706.458681] BTRFS: device fsid 66e0f120-e478-4cac-b04a-82a0ffc4d6ce devid 1 transid 13 /dev/sdb1
[ 2727.745959] BTRFS: device fsid 66e0f120-e478-4cac-b04a-82a0ffc4d6ce devid 1 transid 13 /dev/sdb1
[ 2797.601678] BTRFS: device fsid 66e0f120-e478-4cac-b04a-82a0ffc4d6ce devid 1 transid 13 /dev/sdb1
#1 lore raw
Quoted 3 lines · Sébastien ROHAUT

Hi,

In the wiki, it's said we can mount subvolumes with different mount options. nosuid, nodev, rw and ro are listed, as valid generic mount options.

This might require 3.15. I don't recall it working with early 3.14 kernels, but by 3.14.3 I'd moved onto testing 3.15.

[root@rawhide ~]# mount /dev/sda3 /mnt
[root@rawhide ~]# btrfs subvol create /mnt/test
Create subvolume '/mnt/test'
[root@rawhide ~]# umount /mnt
[root@rawhide ~]# mount -o ro,subvol=test /dev/sda3 /mnt
[root@rawhide ~]# mount | grep btrfs
/dev/sda3 on / type btrfs (rw,relatime,seclabel,space_cache,autodefrag)
/dev/sda3 on /home type btrfs (rw,relatime,seclabel,space_cache,autodefrag) /dev/sda3 on /var type btrfs (rw,relatime,seclabel,space_cache,autodefrag) /dev/sda3 on /boot type btrfs (rw,relatime,seclabel,space_cache,autodefrag) /dev/sda3 on /mnt type btrfs (ro,relatime,seclabel,space_cache,autodefrag) [root@rawhide ~]# cat /proc/self/mountinfo | grep btrfs
58 0 0:33 /root / rw,relatime shared:1 - btrfs /dev/sda3 rw,seclabel,space_cache,autodefrag 72 58 0:33 /home /home rw,relatime shared:29 - btrfs /dev/sda3 rw,seclabel,space_cache,autodefrag 74 58 0:33 /var /var rw,relatime shared:30 - btrfs /dev/sda3 rw,seclabel,space_cache,autodefrag 76 58 0:33 /boot /boot rw,relatime shared:31 - btrfs /dev/sda3 rw,seclabel,space_cache,autodefrag 84 58 0:33 /test /mnt ro,relatime shared:35 - btrfs /dev/sda3 rw,seclabel,space_cache,autodefrag

So on my end it seems like it's working correctly with 3.15.

Chris Murphy

#2 lore raw
Quoted 8 lines · Chris Murphy
Quoted 3 lines · Sébastien ROHAUT

Hi,

In the wiki, it's said we can mount subvolumes with different mount options. nosuid, nodev, rw and ro are listed, as valid generic mount options.

This might require 3.15. I don't recall it working with early 3.14 kernels, but by 3.14.3 I'd moved onto testing 3.15.

[root@f20v ~]# mount /dev/sda3 /mnt [root@f20v ~]# btrfs subvol create /mnt/test Create subvolume '/mnt/test'
[root@f20v ~]# umount /mnt
[root@f20v ~]# mount -o ro,subvol=test /dev/sda3 /mnt
mount: /dev/sda3 is already mounted or /mnt busy
/dev/sda3 is already mounted on / /dev/sda3 is already mounted on /home /dev/sda3 is already mounted on /var /dev/sda3 is already mounted on /boot
[root@f20v ~]# uname -r 3.14.6-200.fc20.x86_64

I don't know if this feature will be backported to stable kernels. If not, then probably the wiki should say it's a 3.15+ feature.

Chris Murphy

#3 lore raw
Quoted 23 lines · Chris Murphy
Quoted 6 lines · Chris Murphy
Quoted 3 lines · Sébastien ROHAUT

Hi,

In the wiki, it's said we can mount subvolumes with different mount options. nosuid, nodev, rw and ro are listed, as valid generic mount options.

This might require 3.15. I don't recall it working with early 3.14 kernels, but by 3.14.3 I'd moved onto testing 3.15.

[root@f20v ~]# mount /dev/sda3 /mnt [root@f20v ~]# btrfs subvol create /mnt/test Create subvolume '/mnt/test'
[root@f20v ~]# umount /mnt
[root@f20v ~]# mount -o ro,subvol=test /dev/sda3 /mnt
mount: /dev/sda3 is already mounted or /mnt busy
/dev/sda3 is already mounted on / /dev/sda3 is already mounted on /home /dev/sda3 is already mounted on /var /dev/sda3 is already mounted on /boot
[root@f20v ~]# uname -r 3.14.6-200.fc20.x86_64

Quoted 4 lines

I don't know if this feature will be backported to stable kernels. If not, then probably the wiki should say it's a 3.15+ feature. Chris Murphy

Thank you for your answer. I'm actually moving to a Fedora Rawhide (3.16 kernel).

Sebastien Rohaut

#4 lore raw

-------- Original Message --------
Subject: Re: Can't mount subvolume with ro option
From: Sébastien ROHAUT <[email protected]>
To: Chris Murphy <[email protected]>
Date: 2014年06月28日 19:02

Quoted 24 lines · Chris Murphy
Quoted 23 lines · Chris Murphy
Quoted 7 lines · Sébastien ROHAUT
Quoted 4 lines

Hi,

In the wiki, it's said we can mount subvolumes with different mount options. nosuid, nodev, rw and ro are listed, as valid generic mount options.

This might require 3.15. I don't recall it working with early 3.14 kernels, but by 3.14.3 I'd moved onto testing 3.15.

[root@f20v ~]# mount /dev/sda3 /mnt [root@f20v ~]# btrfs subvol create /mnt/test Create subvolume '/mnt/test'
[root@f20v ~]# umount /mnt
[root@f20v ~]# mount -o ro,subvol=test /dev/sda3 /mnt
mount: /dev/sda3 is already mounted or /mnt busy
/dev/sda3 is already mounted on / /dev/sda3 is already mounted on /home /dev/sda3 is already mounted on /var /dev/sda3 is already mounted on /boot
[root@f20v ~]# uname -r 3.14.6-200.fc20.x86_64

Quoted 11 lines
Quoted 4 lines

I don't know if this feature will be backported to stable kernels. If not, then probably the wiki should say it's a 3.15+ feature. Chris Murphy

Thank you for your answer. I'm actually moving to a Fedora Rawhide (3.16 kernel).

Sebastien Rohaut

Signature · 3 lines
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

When testing on 3.15.2-ARCH alone with 3.16-rc2, the problem can also be reproduced.

But I can't always reproduce it, sometimes I was able to mount subvol with ro, somtimes not.

So I think the problem needs to be investigated further.

Thanks,
Qu

#5 lore raw

-------- Original Message --------
Subject: Re: Can't mount subvolume with ro option
From: Qu Wenruo <[email protected]>
To: Sébastien ROHAUT <[email protected]>, Chris Murphy <[email protected]>
Date: 2014年06月30日 10:19

Quoted 43 lines

-------- Original Message --------
Subject: Re: Can't mount subvolume with ro option
From: Sébastien ROHAUT <[email protected]>
To: Chris Murphy <[email protected]>
Date: 2014年06月28日 19:02

Quoted 24 lines · Chris Murphy
Quoted 23 lines · Chris Murphy
Quoted 7 lines · Sébastien ROHAUT
Quoted 4 lines

Hi,

In the wiki, it's said we can mount subvolumes with different mount options. nosuid, nodev, rw and ro are listed, as valid generic mount options.

This might require 3.15. I don't recall it working with early 3.14 kernels, but by 3.14.3 I'd moved onto testing 3.15.

[root@f20v ~]# mount /dev/sda3 /mnt [root@f20v ~]# btrfs subvol create /mnt/test Create subvolume '/mnt/test'
[root@f20v ~]# umount /mnt
[root@f20v ~]# mount -o ro,subvol=test /dev/sda3 /mnt
mount: /dev/sda3 is already mounted or /mnt busy
/dev/sda3 is already mounted on / /dev/sda3 is already mounted on /home /dev/sda3 is already mounted on /var /dev/sda3 is already mounted on /boot
[root@f20v ~]# uname -r 3.14.6-200.fc20.x86_64

Quoted 11 lines
Quoted 4 lines

I don't know if this feature will be backported to stable kernels. If not, then probably the wiki should say it's a 3.15+ feature. Chris Murphy

Thank you for your answer. I'm actually moving to a Fedora Rawhide (3.16 kernel).

Sebastien Rohaut

Signature · 3 lines
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

When testing on 3.15.2-ARCH alone with 3.16-rc2, the problem can also be reproduced.

Quoted 11 lines

But I can't always reproduce it, sometimes I was able to mount subvol with ro, somtimes not.

So I think the problem needs to be investigated further.

Thanks,
Qu

Signature · 3 lines
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Finally find the stable method to reproduce the problem on 3.16-rc2, the point is if we mount subvol,ro first, then you can't mount the hole device:

# mkfs.btrfs  -f /dev/sda6
# mount /dev/sda6  /mnt/btrfs/
# btrfs sub create /mnt/btrfs/subv
Create subvolume '/mnt/btrfs/subv'
# umount /mnt/btrfs
# mount -o subvol=subv,ro /dev/sda6  /mnt/other/
# LANG=C mount /dev/sda6  /mnt/btrfs/
mount: /dev/sda6 is already mounted or /mnt/btrfs busy
       /dev/sda6 is already mounted on /mnt/other

Thanks,
Qu

#6 lore raw
Quoted 4 lines · Qu Wenruo
Quoted 1 line

Finally find the stable method to reproduce the problem on 3.16-rc2, the point is if we mount subvol,ro first, then you can't mount the hole device:

Quoted 9 lines
# mkfs.btrfs  -f /dev/sda6
# mount /dev/sda6  /mnt/btrfs/
# btrfs sub create /mnt/btrfs/subv
Create subvolume '/mnt/btrfs/subv'
# umount /mnt/btrfs
# mount -o subvol=subv,ro /dev/sda6  /mnt/other/
# LANG=C mount /dev/sda6  /mnt/btrfs/
mount: /dev/sda6 is already mounted or /mnt/btrfs busy
      /dev/sda6 is already mounted on /mnt/other

Similar problem: if you mount subvol,rw and then subvol,ro it succeeds, but then mount another subvol,rw it fails.

Chris Murphy