summaryrefslogtreecommitdiffstats
path: root/fs/cifs
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2015-04-07 11:28:12 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2015-04-11 22:29:47 -0400
commit5f380c7fa7e01f15ca0816bd241ece9a64a73192 (patch)
tree2136f54098eb85d21d17ee43f73724a5befd70a1 /fs/cifs
parent0b8def9d6dfa6b2a9a2740cf81d8d2c134688d39 (diff)
downloadlinux-5f380c7fa7e01f15ca0816bd241ece9a64a73192.tar.gz
linux-5f380c7fa7e01f15ca0816bd241ece9a64a73192.tar.bz2
linux-5f380c7fa7e01f15ca0816bd241ece9a64a73192.zip
lift generic_write_checks() into callers of __generic_file_write_iter()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/cifs')
-rw-r--r--fs/cifs/file.c39
1 files changed, 23 insertions, 16 deletions
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 3cb04129ddb1..3c5c9bc5cbaf 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -2673,8 +2673,8 @@ cifs_writev(struct kiocb *iocb, struct iov_iter *from)
struct inode *inode = file->f_mapping->host;
struct cifsInodeInfo *cinode = CIFS_I(inode);
struct TCP_Server_Info *server = tlink_tcon(cfile->tlink)->ses->server;
- ssize_t rc = -EACCES;
- loff_t lock_pos = iocb->ki_pos;
+ ssize_t rc;
+ size_t count;
/*
* We need to hold the sem to be sure nobody modifies lock list
@@ -2682,23 +2682,30 @@ cifs_writev(struct kiocb *iocb, struct iov_iter *from)
*/
down_read(&cinode->lock_sem);
mutex_lock(&inode->i_mutex);
- if (file->f_flags & O_APPEND)
- lock_pos = i_size_read(inode);
- if (!cifs_find_lock_conflict(cfile, lock_pos, iov_iter_count(from),
+
+ count = iov_iter_count(from);
+ rc = generic_write_checks(file, &iocb->ki_pos, &count, 0);
+ if (rc)
+ goto out;
+
+ if (count == 0)
+ goto out;
+
+ iov_iter_truncate(from, count);
+
+ if (!cifs_find_lock_conflict(cfile, iocb->ki_pos, iov_iter_count(from),
server->vals->exclusive_lock_type, NULL,
- CIFS_WRITE_OP)) {
+ CIFS_WRITE_OP))
rc = __generic_file_write_iter(iocb, from);
- mutex_unlock(&inode->i_mutex);
-
- if (rc > 0) {
- ssize_t err;
+ else
+ rc = -EACCES;
+out:
+ mutex_unlock(&inode->i_mutex);
- err = generic_write_sync(file, iocb->ki_pos - rc, rc);
- if (err < 0)
- rc = err;
- }
- } else {
- mutex_unlock(&inode->i_mutex);
+ if (rc > 0) {
+ ssize_t err = generic_write_sync(file, iocb->ki_pos - rc, rc);
+ if (err < 0)
+ rc = err;
}
up_read(&cinode->lock_sem);
return rc;