Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 980770

Summary: GlusterFS native client fails to mount a volume read-only
Product: [Community] GlusterFS Reporter: Niels de Vos <ndevos>
Component: fuseAssignee: Niels de Vos <ndevos>
Status: CLOSED UPSTREAM QA Contact:
Severity: medium Docs Contact:
Priority: unspecified    
Version: mainlineCC: gluster-bugs, khoi.mai2008
Target Milestone: ---Keywords: Patch
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-07-24 17:53:58 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 853895, 980778    

Description Niels de Vos 2013-07-03 08:17:40 UTC
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:
100%

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");
546 
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 08:22:54 UTC
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)

Comment 2 Anand Avati 2013-07-04 05:34:06 UTC
COMMIT: http://review.gluster.org/5278 committed in master by Vijay Bellur (vbellur) 
------
commit 37d2c255e46eea98df473fbc693931462882392e
Author: Niels de Vos <ndevos>
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>
    Reviewed-on: http://review.gluster.org/5278
    Tested-by: Gluster Build System <jenkins.com>
    Reviewed-by: Vijay Bellur <vbellur>

Comment 3 Niels de Vos 2013-08-29 16:26:10 UTC
*** Bug 996768 has been marked as a duplicate of this bug. ***