Bug 739799 - NFSv4: inotify issue IN_MODIFY instead of IN_CREATE on file creation
Summary: NFSv4: inotify issue IN_MODIFY instead of IN_CREATE on file creation
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: kernel
Version: 6.3
Hardware: All
OS: Linux
Target Milestone: rc
: ---
Assignee: Jeff Layton
QA Contact: Red Hat Kernel QE team
Whiteboard: NFS
Depends On:
Blocks: 848655
TreeView+ depends on / blocked
Reported: 2011-09-20 04:29 UTC by Eryu Guan
Modified: 2014-03-18 19:06 UTC (History)
9 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 848655 (view as bug list)
Last Closed: 2014-03-18 19:06:42 UTC

Attachments (Terms of Use)
simple reproducer (255 bytes, text/plain)
2011-09-20 04:29 UTC, Eryu Guan
no flags Details

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):

How reproducible:

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 Product and 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 Product and 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.

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