Bug 739799

Summary: NFSv4: inotify issue IN_MODIFY instead of IN_CREATE on file creation
Product: Red Hat Enterprise Linux 6 Reporter: Eryu Guan <eguan>
Component: kernelAssignee: Jeff Layton <jlayton>
Status: CLOSED WONTFIX QA Contact: Red Hat Kernel QE team <kernel-qe>
Severity: low Docs Contact:
Priority: unspecified    
Version: 6.3CC: bfields, dhowells, eparis, jlayton, nmurray, rwheeler, sprabhu, steved, yanwang
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard: NFS
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 848655 (view as bug list) Environment:
Last Closed: 2014-03-18 19:06:42 UTC Type: ---
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: 848655    
Attachments:
Description Flags
simple reproducer none

Description Eryu Guan 2011-09-20 04:29:08 UTC
Created attachment 523948 [details]
simple reproducer

Description of problem:
Creating a new file on nfs4 mount using creat(2) (open(2) with O_CREAT will not reproduce), inotify will issue IN_MODIFY event instead of IN_CREATE

NFSv3 doesn't have this issue.

Version-Release number of selected component (if applicable):
kernel-2.6.32-193.el6

How reproducible:
100%

Steps to Reproduce:
1. compile attached nfscreate.c, gcc -o nfscreate nfscreate.c
2. mount nfs4 on client, mount -t nfs -o vers=4,proto=tcp server:/export /mnt/nfs
3. install inotify-tools and monitor the nfs mount, inotifywait -m /mnt/nfs
4. on another terminal, ./nfscreate /mnt/nfs/newfile
  
Actual results:
inotifywait got MODIFY event
# inotifywait -m /mnt/testarea/nfs4
Setting up watches.
Watches established.
/mnt/testarea/nfs4/ MODIFY testfile ==========> MODIFY event
/mnt/testarea/nfs4/ OPEN testfile
/mnt/testarea/nfs4/ CLOSE_WRITE,CLOSE testfile

Expected results:
# inotifywait -m /mnt/testarea/nfs3
Setting up watches.
Watches established.
/mnt/testarea/nfs3/ CREATE testfile  ============> CREATE event
/mnt/testarea/nfs3/ OPEN testfile
/mnt/testarea/nfs3/ CLOSE_WRITE,CLOSE testfile

Additional info:
I'm not sure if this is really a bug, found this by running inotify02 from LTP

Comment 2 RHEL Program Management 2011-10-07 15:48:53 UTC
Since RHEL 6.2 External Beta has begun, and this bug remains
unresolved, it has been rejected as it is not proposed as
exception or blocker.

Red Hat invites you to ask your support representative to
propose this request, if appropriate and relevant, in the
next release of Red Hat Enterprise Linux.

Comment 5 Jeff Layton 2014-03-12 20:47:11 UTC
I don't see those results on relatively current RHEL6. Here's what I see:

/mnt/sikun/testdir/ OPEN foo
/mnt/sikun/testdir/ ATTRIB foo
/mnt/sikun/testdir/ CLOSE_WRITE,CLOSE foo

...did inotify-tools change, or was it the kernel?

In any case, we have a bit of a dilemma here -- the OPEN call doesn't necessarily tell you whether a file was actually created or not, unless you happened to do an O_EXCL create.

Also, it sort of looks like RHEL7 may behave a little better here, but I'll need to do a bit more experimentation to know for sure.

Comment 6 Jeff Layton 2014-03-18 18:47:14 UTC
Yeah, RHEL7 seems to handle this correctly, primarily because it has the atomic_open infrastructure that went upstream prior to 3.10.

For RHEL6, backporting atomic_open is a non-starter. We probably could try to emulate how these events work, but that would be pretty nasty too. Given that this is a low priority bug, I'd suggest that we just call this WONTFIX for RHEL6 and point anyone who cares about this toward RHEL7.

Comment 7 RHEL Program Management 2014-03-18 19:06:42 UTC
Development Management has reviewed and declined this request.
You may appeal this decision by reopening this request.