Commit 14971657 authored by Nikolay Borisov's avatar Nikolay Borisov Committed by David Sterba

btrfs: cleanup local variables in btrfs_file_write_iter

First replace all inode instances with a pointer to btrfs_inode. This
removes multiple invocations of the BTRFS_I macro, subsequently remove
2 local variables as they are called only once and simply refer to
them directly.
Signed-off-by: default avatarNikolay Borisov <nborisov@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 3cc64e7e
...@@ -1997,9 +1997,7 @@ static ssize_t btrfs_file_write_iter(struct kiocb *iocb, ...@@ -1997,9 +1997,7 @@ static ssize_t btrfs_file_write_iter(struct kiocb *iocb,
struct iov_iter *from) struct iov_iter *from)
{ {
struct file *file = iocb->ki_filp; struct file *file = iocb->ki_filp;
struct inode *inode = file_inode(file); struct btrfs_inode *inode = BTRFS_I(file_inode(file));
struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
struct btrfs_root *root = BTRFS_I(inode)->root;
ssize_t num_written = 0; ssize_t num_written = 0;
const bool sync = iocb->ki_flags & IOCB_DSYNC; const bool sync = iocb->ki_flags & IOCB_DSYNC;
...@@ -2008,7 +2006,7 @@ static ssize_t btrfs_file_write_iter(struct kiocb *iocb, ...@@ -2008,7 +2006,7 @@ static ssize_t btrfs_file_write_iter(struct kiocb *iocb,
* have opened a file as writable, we have to stop this write operation * have opened a file as writable, we have to stop this write operation
* to ensure consistency. * to ensure consistency.
*/ */
if (test_bit(BTRFS_FS_STATE_ERROR, &fs_info->fs_state)) if (test_bit(BTRFS_FS_STATE_ERROR, &inode->root->fs_info->fs_state))
return -EROFS; return -EROFS;
if (!(iocb->ki_flags & IOCB_DIRECT) && if (!(iocb->ki_flags & IOCB_DIRECT) &&
...@@ -2016,7 +2014,7 @@ static ssize_t btrfs_file_write_iter(struct kiocb *iocb, ...@@ -2016,7 +2014,7 @@ static ssize_t btrfs_file_write_iter(struct kiocb *iocb,
return -EOPNOTSUPP; return -EOPNOTSUPP;
if (sync) if (sync)
atomic_inc(&BTRFS_I(inode)->sync_writers); atomic_inc(&inode->sync_writers);
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);
...@@ -2028,14 +2026,14 @@ static ssize_t btrfs_file_write_iter(struct kiocb *iocb, ...@@ -2028,14 +2026,14 @@ static ssize_t btrfs_file_write_iter(struct kiocb *iocb,
* otherwise subsequent syncs to a file that's been synced in this * otherwise subsequent syncs to a file that's been synced in this
* transaction will appear to have already occurred. * transaction will appear to have already occurred.
*/ */
spin_lock(&BTRFS_I(inode)->lock); spin_lock(&inode->lock);
BTRFS_I(inode)->last_sub_trans = root->log_transid; inode->last_sub_trans = inode->root->log_transid;
spin_unlock(&BTRFS_I(inode)->lock); spin_unlock(&inode->lock);
if (num_written > 0) if (num_written > 0)
num_written = generic_write_sync(iocb, num_written); num_written = generic_write_sync(iocb, num_written);
if (sync) if (sync)
atomic_dec(&BTRFS_I(inode)->sync_writers); atomic_dec(&inode->sync_writers);
current->backing_dev_info = NULL; current->backing_dev_info = NULL;
return num_written; return num_written;
......
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