Bug 980770 - GlusterFS native client fails to mount a volume read-only
GlusterFS native client fails to mount a volume read-only
Product: GlusterFS
Classification: Community
Component: fuse (Show other bugs)
Unspecified Unspecified
unspecified Severity medium
: ---
: ---
Assigned To: Niels de Vos
: Patch
Depends On:
Blocks: 853895 980778
  Show dependency treegraph
Reported: 2013-07-03 04:17 EDT by Niels de Vos
Modified: 2013-09-02 03:43 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2013-07-24 13:53:58 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Niels de Vos 2013-07-03 04:17:40 EDT
Description of problem:

[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/mounts shows "rw" as option, not "ro". This can be seen in the
sosreport of the rhel-5 client too:
ivmis-s3bpu01-454285/proc/mounts:glusterfs#ivmis-s3brs01:/test /mnt fuse rw,user_id=0,group_id=0,default_permissions,allow_other,max_read=131072 0 0

How reproducible:

Expected results:
[root@storage-1 ~]# mount -t glusterfs -o ro localhost:/test-vol /mnt/test-vol
[root@storage-1 ~]# mount | grep test-vol
localhost:/test-vol on /mnt/test-vol type fuse.glusterfs (ro,default_permissions,allow_other,max_read=131072)
[root@storage-1 ~]# touch /mnt/test-vol/hello
touch: cannot touch `/mnt/test-vol/hello': Read-only file system

Additional info:
$ 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 the MS_RDONLY flag.

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);
544                 if (ret == -1) {
545                         GFFUSE_LOGERR ("Out of memory");
547                         goto out;
548                 }
549                 ret = mount (source, mountpoint, fstype, 0,
550                              mnt_param_mnt);
551         }

Note the mount() syscall on line 549, the 'mountflags' are not passed like it
is done on line 536.
Comment 1 Anand Avati 2013-07-03 04:22:54 EDT
REVIEW: http://review.gluster.org/5278 (fuse: pass the mountflags to older (< 2.6.21) kernels) posted (#1) for review on master by Niels de Vos (ndevos@redhat.com)
Comment 2 Anand Avati 2013-07-04 01:34:06 EDT
COMMIT: http://review.gluster.org/5278 committed in master by Vijay Bellur (vbellur@redhat.com) 
commit 37d2c255e46eea98df473fbc693931462882392e
Author: Niels de Vos <ndevos@redhat.com>
Date:   Wed Jul 3 09:45:41 2013 +0200

    fuse: pass the mountflags to older (< 2.6.21) kernels
    The change for Bug 853895 fixed mounting volumes read-only for recent
    kernels. Older kernels fail the first mount() syscall, and the second
    mount() did not add the 'mountflags'.
    Full analysis and a description for reproducing is in the bugreport. The
    test included in http://review.gluster.org/4163 would have caught this
    problem when the tests are executed on RHEL-5 or similar systems.
    Change-Id: I440591344a6a5af7b2018e37a2a1fda9de8b5ab2
    Bug: 980770
    Signed-off-by: Niels de Vos <ndevos@redhat.com>
    Reviewed-on: http://review.gluster.org/5278
    Tested-by: Gluster Build System <jenkins@build.gluster.com>
    Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Comment 3 Niels de Vos 2013-08-29 12:26:10 EDT
*** Bug 996768 has been marked as a duplicate of this bug. ***

Note You need to log in before you can comment on or make changes to this bug.