btrfs: Use iocb to derive pos instead of passing a separate parameter
struct kiocb carries the ki_pos, so there is no need to pass it as a separate function parameter. generic_file_direct_write() increments ki_pos, so we now assign pos after the function. Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com> Reviewed-by: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com> [ rename to btrfs_buffered_write ] Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
893bf4b115
commit
e4af400a9c
|
@ -1568,10 +1568,11 @@ static noinline int check_can_nocow(struct btrfs_inode *inode, loff_t pos,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static noinline ssize_t __btrfs_buffered_write(struct file *file,
|
static noinline ssize_t btrfs_buffered_write(struct kiocb *iocb,
|
||||||
struct iov_iter *i,
|
struct iov_iter *i)
|
||||||
loff_t pos)
|
|
||||||
{
|
{
|
||||||
|
struct file *file = iocb->ki_filp;
|
||||||
|
loff_t pos = iocb->ki_pos;
|
||||||
struct inode *inode = file_inode(file);
|
struct inode *inode = file_inode(file);
|
||||||
struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
|
struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
|
||||||
struct btrfs_root *root = BTRFS_I(inode)->root;
|
struct btrfs_root *root = BTRFS_I(inode)->root;
|
||||||
|
@ -1803,7 +1804,7 @@ static ssize_t __btrfs_direct_write(struct kiocb *iocb, struct iov_iter *from)
|
||||||
{
|
{
|
||||||
struct file *file = iocb->ki_filp;
|
struct file *file = iocb->ki_filp;
|
||||||
struct inode *inode = file_inode(file);
|
struct inode *inode = file_inode(file);
|
||||||
loff_t pos = iocb->ki_pos;
|
loff_t pos;
|
||||||
ssize_t written;
|
ssize_t written;
|
||||||
ssize_t written_buffered;
|
ssize_t written_buffered;
|
||||||
loff_t endbyte;
|
loff_t endbyte;
|
||||||
|
@ -1814,8 +1815,8 @@ static ssize_t __btrfs_direct_write(struct kiocb *iocb, struct iov_iter *from)
|
||||||
if (written < 0 || !iov_iter_count(from))
|
if (written < 0 || !iov_iter_count(from))
|
||||||
return written;
|
return written;
|
||||||
|
|
||||||
pos += written;
|
pos = iocb->ki_pos;
|
||||||
written_buffered = __btrfs_buffered_write(file, from, pos);
|
written_buffered = btrfs_buffered_write(iocb, from);
|
||||||
if (written_buffered < 0) {
|
if (written_buffered < 0) {
|
||||||
err = written_buffered;
|
err = written_buffered;
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -1952,7 +1953,7 @@ static ssize_t btrfs_file_write_iter(struct kiocb *iocb,
|
||||||
if (iocb->ki_flags & IOCB_DIRECT) {
|
if (iocb->ki_flags & IOCB_DIRECT) {
|
||||||
num_written = __btrfs_direct_write(iocb, from);
|
num_written = __btrfs_direct_write(iocb, from);
|
||||||
} else {
|
} else {
|
||||||
num_written = __btrfs_buffered_write(file, from, pos);
|
num_written = btrfs_buffered_write(iocb, from);
|
||||||
if (num_written > 0)
|
if (num_written > 0)
|
||||||
iocb->ki_pos = pos + num_written;
|
iocb->ki_pos = pos + num_written;
|
||||||
if (clean_page)
|
if (clean_page)
|
||||||
|
|
Loading…
Reference in a new issue