Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1158046

Summary: nfs: remount ro will make the other nfs mount from the same server readonly too
Product: Red Hat Enterprise Linux 7 Reporter: Eryu Guan <eguan>
Component: kernelAssignee: nfs-maint
kernel sub component: NFS QA Contact: JianHong Yin <jiyin>
Status: CLOSED NOTABUG Docs Contact:
Severity: medium    
Priority: medium CC: bfields, eguan, jiyin, steved
Version: 7.1   
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1158285 (view as bug list) Environment:
Last Closed: 2014-11-05 05:02:51 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: 1158285    

Description Eryu Guan 2014-10-28 12:17:56 UTC
Description of problem:
I've setup two different exports on the same server and mount the two exports from the same client.

So on server I have /mnt/nfsexport and /mnt/nfsscratch exported
/mnt/nfsexport *(rw,no_root_squash)
/mnt/nfsscratch *(rw,no_root_squash)

On client, mount the two exports with the same mount option(all default)
mount -t nfs server:/mnt/nfsexport /mnt/test
mount -t nfs server:/mnt/nfsscratch /mnt/scratch

Now I remount nfsscratch to readonly, the first mount will be readonly too

mount -t nfs -o remount,ro server:/mnt/nfsscratch /mnt/scratch
touch /mnt/test/testfile   <======== touch fails here because of EROFS

Version-Release number of selected component (if applicable):
kernel-3.10.0-193.el7
upstream 3.18-rc2 kernel

How reproducible:
always

Steps to Reproduce:
# mount two different exports on the same server
[root@ibm-x3650m4-08 nfs-remount]# mount -t nfs hp-dl388eg8-01.rhts.eng.nay.redhat.com:/mnt/nfsexport /mnt/test
[root@ibm-x3650m4-08 nfs-remount]# mount -t nfs hp-dl388eg8-01.rhts.eng.nay.redhat.com:/mnt/nfsscratch /mnt/scratch

# The two mounts are all rw
[root@ibm-x3650m4-08 nfs-remount]# grep dl388 /proc/mounts 
hp-dl388eg8-01.rhts.eng.nay.redhat.com:/mnt/nfsexport /mnt/test nfs4 rw,relatime,vers=4.0,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=10.66.86.161,local_lock=none,addr=10.66.86.132 0 0
hp-dl388eg8-01.rhts.eng.nay.redhat.com:/mnt/nfsscratch /mnt/scratch nfs4 rw,relatime,vers=4.0,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=10.66.86.161,local_lock=none,addr=10.66.86.132 0 0

# remount the second ro
[root@ibm-x3650m4-08 nfs-remount]# mount -t nfs -o remount,ro hp-dl388eg8-01.rhts.eng.nay.redhat.com:/mnt/nfsscratch /mnt/scratch

# check mount options again, the first mount is ro too
[root@ibm-x3650m4-08 nfs-remount]# grep dl388 /proc/mounts 
hp-dl388eg8-01.rhts.eng.nay.redhat.com:/mnt/nfsexport /mnt/test nfs4 ro,relatime,vers=4.0,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=10.66.86.161,local_lock=none,addr=10.66.86.132 0 0
hp-dl388eg8-01.rhts.eng.nay.redhat.com:/mnt/nfsscratch /mnt/scratch nfs4 ro,relatime,vers=4.0,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=10.66.86.161,local_lock=none,addr=10.66.86.132 0 0

# touch will fail
[root@ibm-x3650m4-08 nfs-remount]# touch /mnt/test/testfile
touch: cannot touch ‘/mnt/test/testfile’: Read-only file system

Actual results:
the first mount becomes ro too

Expected results:
the first mount is still rw

Additional info:
mount with nosharecache option will fix this issue.

Not sure if it's really a bug, but I don't this should be the right behavior.

Comment 1 Eryu Guan 2014-10-28 12:23:22 UTC
The problem is the second mount use the first mount's superblock, nfs treats the two mounts are mounting the same export.

Comment 2 Steve Dickson 2014-11-03 18:35:19 UTC
Try using the -o nosharecache mount option....

Comment 3 Eryu Guan 2014-11-04 02:51:55 UTC
Yes, I know the nosharecache mount option could workaround this issue (as stated in the "Additional info" section in comment 0).

I'm just not sure if it's a bug in the not mounting with nosharecache option situation. From the nfs(5) I can see the description for sharecache/nosharecache

"Determines how the client's data cache and attribute cache are shared when mounting the same  export  more  than  once  concurrently."

So I think nosharecache option should only make difference when the exports are identical. But in this bug we're mounting two different exports.

Comment 4 J. Bruce Fields 2014-11-04 14:11:45 UTC
(In reply to Eryu Guan from comment #3)
> So I think nosharecache option should only make difference when the exports
> are identical. But in this bug we're mounting two different exports.

If the two different exports are from the same server and share the same fsid (so they're really part of the same filesystem on the server) then I'd expect the client to treat them as the same export.

Comment 5 Eryu Guan 2014-11-05 05:02:51 UTC
(In reply to J. Bruce Fields from comment #4)
> If the two different exports are from the same server and share the same
> fsid (so they're really part of the same filesystem on the server) then I'd
> expect the client to treat them as the same export.

Yes, you're right, I missed that. Tested by exporting different filesystems on server and remount ro just worked fine, only one mountpoint became readonly.

Thanks for the explanation. Closed as NOTABUG.