mirror of
https://github.com/torvalds/linux
synced 2024-11-05 18:23:50 +00:00
CIFS: Fix wrong pos argument of cifs_find_lock_conflict
and use generic_file_aio_write rather than __generic_file_aio_write in cifs_writev. Signed-off-by: Pavel Shilovsky <piastry@etersoft.ru> Reported-by: Al Viro <viro@ZenIV.linux.org.uk> Signed-off-by: Steve French <smfrench@gmail.com>
This commit is contained in:
parent
f9b080803e
commit
6b1168e161
1 changed files with 6 additions and 18 deletions
|
@ -2579,31 +2579,19 @@ cifs_writev(struct kiocb *iocb, const struct iovec *iov,
|
|||
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 = pos;
|
||||
|
||||
BUG_ON(iocb->ki_pos != pos);
|
||||
|
||||
if (file->f_flags & O_APPEND)
|
||||
lock_pos = i_size_read(inode);
|
||||
/*
|
||||
* We need to hold the sem to be sure nobody modifies lock list
|
||||
* with a brlock that prevents writing.
|
||||
*/
|
||||
down_read(&cinode->lock_sem);
|
||||
if (!cifs_find_lock_conflict(cfile, pos, iov_length(iov, nr_segs),
|
||||
if (!cifs_find_lock_conflict(cfile, lock_pos, iov_length(iov, nr_segs),
|
||||
server->vals->exclusive_lock_type, NULL,
|
||||
CIFS_WRITE_OP)) {
|
||||
mutex_lock(&inode->i_mutex);
|
||||
rc = __generic_file_aio_write(iocb, iov, nr_segs,
|
||||
&iocb->ki_pos);
|
||||
mutex_unlock(&inode->i_mutex);
|
||||
}
|
||||
|
||||
if (rc > 0) {
|
||||
ssize_t err;
|
||||
|
||||
err = generic_write_sync(file, iocb->ki_pos - rc, rc);
|
||||
if (err < 0)
|
||||
rc = err;
|
||||
}
|
||||
|
||||
CIFS_WRITE_OP))
|
||||
rc = generic_file_aio_write(iocb, iov, nr_segs, pos);
|
||||
up_read(&cinode->lock_sem);
|
||||
return rc;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue