Created attachment 523948 [details]
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):
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
inotifywait got MODIFY event
# inotifywait -m /mnt/testarea/nfs4
Setting up watches.
/mnt/testarea/nfs4/ MODIFY testfile ==========> MODIFY event
/mnt/testarea/nfs4/ OPEN testfile
/mnt/testarea/nfs4/ CLOSE_WRITE,CLOSE testfile
# inotifywait -m /mnt/testarea/nfs3
Setting up watches.
/mnt/testarea/nfs3/ CREATE testfile ============> CREATE event
/mnt/testarea/nfs3/ OPEN testfile
/mnt/testarea/nfs3/ CLOSE_WRITE,CLOSE testfile
I'm not sure if this is really a bug, found this by running inotify02 from LTP
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.
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.
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.
Development Management has reviewed and declined this request.
You may appeal this decision by reopening this request.