]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
cifs: fix O_APPEND on directio mounts
authorJeff Layton <jlayton@redhat.com>
Thu, 28 Aug 2008 11:54:59 +0000 (07:54 -0400)
committerSteve French <sfrench@us.ibm.com>
Thu, 28 Aug 2008 14:15:32 +0000 (14:15 +0000)
commit838726c4756813576078203eb7e1e219db0da870
tree3ae8b22db6060244d0ab2b23342b04897682e835
parent6405c9cd9bf7b1c35ed76ef8ee3e217056285702
cifs: fix O_APPEND on directio mounts

The direct I/O write codepath for CIFS is done through
cifs_user_write(). That function does not currently call
generic_write_checks() so the file position isn't being properly set
when the file is opened with O_APPEND.  It's also not doing the other
"normal" checks that should be done for a write call.

The problem is currently that when you open a file with O_APPEND on a
mount with the directio mount option, the file position is set to the
beginning of the file. This makes any subsequent writes clobber the data
in the file starting at the beginning.

This seems to fix the problem in cursory testing. It is, however
important to note that NFS disallows the combination of
(O_DIRECT|O_APPEND). If my understanding is correct, the concern is
races with multiple clients appending to a file clobbering each others'
data. Since the write model for CIFS and NFS is pretty similar in this
regard, CIFS is probably subject to the same sort of races. What's
unclear to me is why this is a particular problem with O_DIRECT and not
with buffered writes...

Regardless, disallowing O_APPEND on an entire mount is probably not
reasonable, so we'll probably just have to deal with it and reevaluate
this flag combination when we get proper support for O_DIRECT. In the
meantime this patch at least fixes the existing problem.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
Cc: Stable Tree <stable@kernel.org>
Signed-off-by: Steve French <sfrench@us.ibm.com>
fs/cifs/file.c