diff options
author | Jeff Layton <jlayton@redhat.com> | 2008-09-02 19:25:05 +0000 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-09-08 03:20:18 -0700 |
commit | de9148e41ee5015feb2bfdc86ae65d8cea4c02d6 (patch) | |
tree | 75be0dee8a0ba6e75bab5a54673604fe2140a135 | |
parent | a9e93fe0ed25ec98c3f07fe0f2435f9f9a2cb962 (diff) | |
download | lwn-de9148e41ee5015feb2bfdc86ae65d8cea4c02d6.tar.gz lwn-de9148e41ee5015feb2bfdc86ae65d8cea4c02d6.zip |
cifs: fix O_APPEND on directio mounts
commit 838726c4756813576078203eb7e1e219db0da870 upstream
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>
Signed-off-by: Steve French <sfrench@us.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | fs/cifs/file.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 40b690073fc1..a80a91729ee9 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -835,6 +835,10 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data, return -EBADF; open_file = (struct cifsFileInfo *) file->private_data; + rc = generic_write_checks(file, poffset, &write_size, 0); + if (rc) + return rc; + xid = GetXid(); if (*poffset > file->f_path.dentry->d_inode->i_size) |