Bug 15789

Summary: Bind mounts broken when used with NFSv4
Product: File System Reporter: Ian Dall (ian)
Component: NFSAssignee: Trond Myklebust (trondmy)
Status: CLOSED CODE_FIX    
Severity: high CC: alan
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 2.6.32.9-70 Subsystem:
Regression: No Bisected commit-id:
Attachments: Dont' do atomic open on a mountpoint

Description Ian Dall 2010-04-15 14:33:17 UTC
There is some serious weirdness if you try and use bind mounts in conjunction with nfs4 mounts.

 $ df -T /var/tmp
Filesystem    Type   1K-blocks      Used Available Use% Mounted on
fs.beware.dropbear.id.au:/tmp/
              nfs4     5160576    403968   4494464   9% /var/tmp
 $ df -T /tmp
Filesystem    Type   1K-blocks      Used Available Use% Mounted on
/tmp         tmpfs      921600         4    921596   1% /tmp
 $ cat /tmp/foo
Over The Lazy Dogs Back
 $ cat /var/tmp/foo
The Quick Brown Fox
#
# So /var/tmp/foo is on an nfs4 mounted filesystem
# /tmp/foo is on a tmpfs. Both files are different.
#
 $ mount --bind /tmp/foo /var/tmp/foo
 $ cat /tmp/foo
Over The Lazy Dogs Back
 $ cat /var/tmp/foo
The Quick Brown Fox
#
# Both files should be the same. ie "Over The Lazy Dogs Back"
#
# In other oddity, ls -l correctly shows both files the same size (31),
# and ls -i correctly shows both have the same inode number, yet:
 $ cat /tmp/foo | wc -c
31
 $ cat /var/tmp/foo | wc -c
20
#
# So much for reading. Now what about writing?
#
 $ echo blah blah > /var/tmp/foo
 $ cat /var/tmp/foo
blah blah
Brown Fox
#
# This should have been truncated
#
 $ cat /tmp/foo
#
# /tmp/foo has been truncated, but it should have "blah blah" in it
#
 $ umount /var/tmp/foo
 $ cat /var/tmp/foo
blah blah
Brown Fox
 $cat /tmp/foo
# Empty
Comment 1 Trond Myklebust 2010-04-15 20:13:10 UTC
Created attachment 26023 [details]
Dont' do atomic open on a mountpoint
Comment 2 Trond Myklebust 2010-04-15 20:13:40 UTC
Does the above patch fix the bug?
Comment 3 Ian Dall 2010-04-15 23:14:30 UTC
That's an impressively quick turn around! Unfortunately, it'll take a bit longer to build and test.
Comment 4 Ian Dall 2010-04-17 03:54:51 UTC
That work fine. Thanks!