Commit 70f1e5b6 authored by Anand Jain's avatar Anand Jain Committed by David Sterba

btrfs: rename err to ret in btrfs_direct_write()

Unify naming of return value to the preferred way.
Signed-off-by: default avatarAnand Jain <anand.jain@oracle.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent aefee7f1
...@@ -1465,7 +1465,7 @@ static ssize_t btrfs_direct_write(struct kiocb *iocb, struct iov_iter *from) ...@@ -1465,7 +1465,7 @@ static ssize_t btrfs_direct_write(struct kiocb *iocb, struct iov_iter *from)
ssize_t written_buffered; ssize_t written_buffered;
size_t prev_left = 0; size_t prev_left = 0;
loff_t endbyte; loff_t endbyte;
ssize_t err; ssize_t ret;
unsigned int ilock_flags = 0; unsigned int ilock_flags = 0;
struct iomap_dio *dio; struct iomap_dio *dio;
...@@ -1482,9 +1482,9 @@ static ssize_t btrfs_direct_write(struct kiocb *iocb, struct iov_iter *from) ...@@ -1482,9 +1482,9 @@ static ssize_t btrfs_direct_write(struct kiocb *iocb, struct iov_iter *from)
ilock_flags |= BTRFS_ILOCK_SHARED; ilock_flags |= BTRFS_ILOCK_SHARED;
relock: relock:
err = btrfs_inode_lock(BTRFS_I(inode), ilock_flags); ret = btrfs_inode_lock(BTRFS_I(inode), ilock_flags);
if (err < 0) if (ret < 0)
return err; return ret;
/* Shared lock cannot be used with security bits set. */ /* Shared lock cannot be used with security bits set. */
if ((ilock_flags & BTRFS_ILOCK_SHARED) && !IS_NOSEC(inode)) { if ((ilock_flags & BTRFS_ILOCK_SHARED) && !IS_NOSEC(inode)) {
...@@ -1493,14 +1493,14 @@ static ssize_t btrfs_direct_write(struct kiocb *iocb, struct iov_iter *from) ...@@ -1493,14 +1493,14 @@ static ssize_t btrfs_direct_write(struct kiocb *iocb, struct iov_iter *from)
goto relock; goto relock;
} }
err = generic_write_checks(iocb, from); ret = generic_write_checks(iocb, from);
if (err <= 0) { if (ret <= 0) {
btrfs_inode_unlock(BTRFS_I(inode), ilock_flags); btrfs_inode_unlock(BTRFS_I(inode), ilock_flags);
return err; return ret;
} }
err = btrfs_write_check(iocb, from, err); ret = btrfs_write_check(iocb, from, ret);
if (err < 0) { if (ret < 0) {
btrfs_inode_unlock(BTRFS_I(inode), ilock_flags); btrfs_inode_unlock(BTRFS_I(inode), ilock_flags);
goto out; goto out;
} }
...@@ -1552,15 +1552,15 @@ static ssize_t btrfs_direct_write(struct kiocb *iocb, struct iov_iter *from) ...@@ -1552,15 +1552,15 @@ static ssize_t btrfs_direct_write(struct kiocb *iocb, struct iov_iter *from)
btrfs_inode_unlock(BTRFS_I(inode), ilock_flags); btrfs_inode_unlock(BTRFS_I(inode), ilock_flags);
if (IS_ERR_OR_NULL(dio)) if (IS_ERR_OR_NULL(dio))
err = PTR_ERR_OR_ZERO(dio); ret = PTR_ERR_OR_ZERO(dio);
else else
err = iomap_dio_complete(dio); ret = iomap_dio_complete(dio);
/* No increment (+=) because iomap returns a cumulative value. */ /* No increment (+=) because iomap returns a cumulative value. */
if (err > 0) if (ret > 0)
written = err; written = ret;
if (iov_iter_count(from) > 0 && (err == -EFAULT || err > 0)) { if (iov_iter_count(from) > 0 && (ret == -EFAULT || ret > 0)) {
const size_t left = iov_iter_count(from); const size_t left = iov_iter_count(from);
/* /*
* We have more data left to write. Try to fault in as many as * We have more data left to write. Try to fault in as many as
...@@ -1577,7 +1577,7 @@ static ssize_t btrfs_direct_write(struct kiocb *iocb, struct iov_iter *from) ...@@ -1577,7 +1577,7 @@ static ssize_t btrfs_direct_write(struct kiocb *iocb, struct iov_iter *from)
* to buffered IO in case we haven't made any progress. * to buffered IO in case we haven't made any progress.
*/ */
if (left == prev_left) { if (left == prev_left) {
err = -ENOTBLK; ret = -ENOTBLK;
} else { } else {
fault_in_iov_iter_readable(from, left); fault_in_iov_iter_readable(from, left);
prev_left = left; prev_left = left;
...@@ -1586,10 +1586,10 @@ static ssize_t btrfs_direct_write(struct kiocb *iocb, struct iov_iter *from) ...@@ -1586,10 +1586,10 @@ static ssize_t btrfs_direct_write(struct kiocb *iocb, struct iov_iter *from)
} }
/* /*
* If 'err' is -ENOTBLK or we have not written all data, then it means * If 'ret' is -ENOTBLK or we have not written all data, then it means
* we must fallback to buffered IO. * we must fallback to buffered IO.
*/ */
if ((err < 0 && err != -ENOTBLK) || !iov_iter_count(from)) if ((ret < 0 && ret != -ENOTBLK) || !iov_iter_count(from))
goto out; goto out;
buffered: buffered:
...@@ -1600,14 +1600,14 @@ static ssize_t btrfs_direct_write(struct kiocb *iocb, struct iov_iter *from) ...@@ -1600,14 +1600,14 @@ static ssize_t btrfs_direct_write(struct kiocb *iocb, struct iov_iter *from)
* below, we will block when flushing and waiting for the IO. * below, we will block when flushing and waiting for the IO.
*/ */
if (iocb->ki_flags & IOCB_NOWAIT) { if (iocb->ki_flags & IOCB_NOWAIT) {
err = -EAGAIN; ret = -EAGAIN;
goto out; goto out;
} }
pos = iocb->ki_pos; pos = iocb->ki_pos;
written_buffered = btrfs_buffered_write(iocb, from); written_buffered = btrfs_buffered_write(iocb, from);
if (written_buffered < 0) { if (written_buffered < 0) {
err = written_buffered; ret = written_buffered;
goto out; goto out;
} }
/* /*
...@@ -1615,18 +1615,18 @@ static ssize_t btrfs_direct_write(struct kiocb *iocb, struct iov_iter *from) ...@@ -1615,18 +1615,18 @@ static ssize_t btrfs_direct_write(struct kiocb *iocb, struct iov_iter *from)
* able to read what was just written. * able to read what was just written.
*/ */
endbyte = pos + written_buffered - 1; endbyte = pos + written_buffered - 1;
err = btrfs_fdatawrite_range(inode, pos, endbyte); ret = btrfs_fdatawrite_range(inode, pos, endbyte);
if (err) if (ret)
goto out; goto out;
err = filemap_fdatawait_range(inode->i_mapping, pos, endbyte); ret = filemap_fdatawait_range(inode->i_mapping, pos, endbyte);
if (err) if (ret)
goto out; goto out;
written += written_buffered; written += written_buffered;
iocb->ki_pos = pos + written_buffered; iocb->ki_pos = pos + written_buffered;
invalidate_mapping_pages(file->f_mapping, pos >> PAGE_SHIFT, invalidate_mapping_pages(file->f_mapping, pos >> PAGE_SHIFT,
endbyte >> PAGE_SHIFT); endbyte >> PAGE_SHIFT);
out: out:
return err < 0 ? err : written; return ret < 0 ? ret : written;
} }
static ssize_t btrfs_encoded_write(struct kiocb *iocb, struct iov_iter *from, static ssize_t btrfs_encoded_write(struct kiocb *iocb, struct iov_iter *from,
......
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