Commit 6618a24a authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'nowait-aio-btrfs-fixup' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux

Pull btrfs fix from David Sterba:
 "This fixes a user-visible bug introduced by the nowait-aio patches
  merged in this cycle"

* 'nowait-aio-btrfs-fixup' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux:
  btrfs: nowait aio: Correct assignment of pos
parents 1d07b6cb ff0fa732
...@@ -1881,16 +1881,25 @@ static ssize_t btrfs_file_write_iter(struct kiocb *iocb, ...@@ -1881,16 +1881,25 @@ static ssize_t btrfs_file_write_iter(struct kiocb *iocb,
ssize_t num_written = 0; ssize_t num_written = 0;
bool sync = (file->f_flags & O_DSYNC) || IS_SYNC(file->f_mapping->host); bool sync = (file->f_flags & O_DSYNC) || IS_SYNC(file->f_mapping->host);
ssize_t err; ssize_t err;
loff_t pos = iocb->ki_pos; loff_t pos;
size_t count = iov_iter_count(from); size_t count = iov_iter_count(from);
loff_t oldsize; loff_t oldsize;
int clean_page = 0; int clean_page = 0;
if ((iocb->ki_flags & IOCB_NOWAIT) && if (!inode_trylock(inode)) {
(iocb->ki_flags & IOCB_DIRECT)) { if (iocb->ki_flags & IOCB_NOWAIT)
/* Don't sleep on inode rwsem */
if (!inode_trylock(inode))
return -EAGAIN; return -EAGAIN;
inode_lock(inode);
}
err = generic_write_checks(iocb, from);
if (err <= 0) {
inode_unlock(inode);
return err;
}
pos = iocb->ki_pos;
if (iocb->ki_flags & IOCB_NOWAIT) {
/* /*
* We will allocate space in case nodatacow is not set, * We will allocate space in case nodatacow is not set,
* so bail * so bail
...@@ -1901,13 +1910,6 @@ static ssize_t btrfs_file_write_iter(struct kiocb *iocb, ...@@ -1901,13 +1910,6 @@ static ssize_t btrfs_file_write_iter(struct kiocb *iocb,
inode_unlock(inode); inode_unlock(inode);
return -EAGAIN; return -EAGAIN;
} }
} else
inode_lock(inode);
err = generic_write_checks(iocb, from);
if (err <= 0) {
inode_unlock(inode);
return err;
} }
current->backing_dev_info = inode_to_bdi(inode); current->backing_dev_info = inode_to_bdi(inode);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment