Mounting a Glusterfs volume with read only option in /etc/fstab fails
Environment
- Red Hat Enterprise Linux 5, 6
- Red Hat Storage Server 2.0
- GlusterFS native client
Issue
- It is not possible to mount a Red Hat Storage volume read-only through the GlusterFS native client. The configuration in
/etc/fstabincludesroin the mount options:
$ grep glusterfs /etc/fstab
rh-storage:/test /shared/test glusterfs ro,_netdev 0 0
- Mounting fails with an error like this:
$ mount /shared/test
Mount failed. Please check the log file for more details.
Resolution
-
Red Hat Storage 2.0 native clients on Red Hat Enterprise Linux 6
- Update the client to glusterfs-3.3.0.7rhs-1 (RHSA-2013:0691-1) or newer.
-
Red Hat Storage 2.0 native clients on Red Hat Enterprise Linux 5
- Update the client to Red Hat Storage 2.1 enhancement and bug fix update #1 (RHBA-2013:1769-1) or newer.
Root Cause
-
The GlusterFS native client does not support mounting volumes read-only anymore. This is not intentional and a regression compared to the Red Hat Software Storage Appliance 3.2 (RHSSA-3.2), the previous release of a Red Hat product containing GlusterFS.
-
A patch was posted for review. With this patch the GlusterFS native client (which uses FUSE) regains support for read-only mounting of Red Hat Storage volumes. An additional patch has been proposed to fix the issue in RHEL-5 as well.
Diagnostic Steps
- Reproducing the issue on RHEL-5:
[root@vm-61 ~]# mount -t glusterfs -o ro storage-1:/test-vol /mnt
[root@vm-61 ~]# grep test-vol /proc/mounts
glusterfs#storage-1:/test-vol /mnt fuse rw,user_id=0,group_id=0,default_permissions,allow_other,max_read=131072 0 0
[root@vm-61 ~]# mount | grep test-vol
glusterfs#storage-1:/test-vol on /mnt type fuse (ro,default_permissions,allow_other,max_read=131072)
[root@vm-61 ~]# ps ax | grep glusterfs
2427 ? Ssl 0:00 /usr/sbin/glusterfs --read-only --volfile-id=/test-vol --volfile-server=storage-1 /mnt
[root@vm-61 ~]# touch /mnt/hello
[root@vm-61 ~]# rm -f /mnt/hello
- Note that
/proc/mountsshows "rw" as option, not "ro".
$ strace -f -e mount /usr/sbin/glusterfs --log-level=TRACE --read-only --volfile-id=/test-vol --volfile-server=storage-1 /mnt
1983 mount("storage-1:/test-vol", "/mnt", "fuse.glusterfs", MS_RDONLY, "default_permissions,allow_other,") = -1 ENODEV (No such device)
1983 mount("glusterfs#storage-1:/test-vol", "/mnt", "fuse", 0, "default_permissions,allow_other,") = 0
-
The first
mount()fails, and the second with a little different format works. But, the second does not pass theMS_RDONLYflag. -
The matching code is in
contrib/fuse-lib/mount.c:
536 ret = mount (source, mountpoint, fstype, mountflags,
537 mnt_param_mnt);
538 if (ret == -1 && errno == ENODEV) {
539 /* fs subtype support was added by 79c0b2df aka
540 v2.6.21-3159-g79c0b2d. Probably we have an
541 older kernel ... */
542 fstype = "fuse";
543 ret = asprintf (&source, "glusterfs#%s", fsname);
...
549 ret = mount (source, mountpoint, fstype, 0,
550 mnt_param_mnt);
551 }
- Note the
mount()syscall on line 549, themountflagsare not passed like it is done on line 536.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
