Commit a95cd631 authored by Omar Sandoval's avatar Omar Sandoval Committed by Al Viro

Remove rw from dax_{do_,}io()

And use iov_iter_rw() instead.
Signed-off-by: default avatarOmar Sandoval <osandov@osandov.com>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 17f8c842
...@@ -98,9 +98,9 @@ static bool buffer_size_valid(struct buffer_head *bh) ...@@ -98,9 +98,9 @@ static bool buffer_size_valid(struct buffer_head *bh)
return bh->b_state != 0; return bh->b_state != 0;
} }
static ssize_t dax_io(int rw, struct inode *inode, struct iov_iter *iter, static ssize_t dax_io(struct inode *inode, struct iov_iter *iter,
loff_t start, loff_t end, get_block_t get_block, loff_t start, loff_t end, get_block_t get_block,
struct buffer_head *bh) struct buffer_head *bh)
{ {
ssize_t retval = 0; ssize_t retval = 0;
loff_t pos = start; loff_t pos = start;
...@@ -109,7 +109,7 @@ static ssize_t dax_io(int rw, struct inode *inode, struct iov_iter *iter, ...@@ -109,7 +109,7 @@ static ssize_t dax_io(int rw, struct inode *inode, struct iov_iter *iter,
void *addr; void *addr;
bool hole = false; bool hole = false;
if (rw != WRITE) if (iov_iter_rw(iter) != WRITE)
end = min(end, i_size_read(inode)); end = min(end, i_size_read(inode));
while (pos < end) { while (pos < end) {
...@@ -124,7 +124,7 @@ static ssize_t dax_io(int rw, struct inode *inode, struct iov_iter *iter, ...@@ -124,7 +124,7 @@ static ssize_t dax_io(int rw, struct inode *inode, struct iov_iter *iter,
bh->b_size = PAGE_ALIGN(end - pos); bh->b_size = PAGE_ALIGN(end - pos);
bh->b_state = 0; bh->b_state = 0;
retval = get_block(inode, block, bh, retval = get_block(inode, block, bh,
rw == WRITE); iov_iter_rw(iter) == WRITE);
if (retval) if (retval)
break; break;
if (!buffer_size_valid(bh)) if (!buffer_size_valid(bh))
...@@ -137,7 +137,7 @@ static ssize_t dax_io(int rw, struct inode *inode, struct iov_iter *iter, ...@@ -137,7 +137,7 @@ static ssize_t dax_io(int rw, struct inode *inode, struct iov_iter *iter,
bh->b_size -= done; bh->b_size -= done;
} }
hole = (rw != WRITE) && !buffer_written(bh); hole = iov_iter_rw(iter) != WRITE && !buffer_written(bh);
if (hole) { if (hole) {
addr = NULL; addr = NULL;
size = bh->b_size - first; size = bh->b_size - first;
...@@ -154,7 +154,7 @@ static ssize_t dax_io(int rw, struct inode *inode, struct iov_iter *iter, ...@@ -154,7 +154,7 @@ static ssize_t dax_io(int rw, struct inode *inode, struct iov_iter *iter,
max = min(pos + size, end); max = min(pos + size, end);
} }
if (rw == WRITE) if (iov_iter_rw(iter) == WRITE)
len = copy_from_iter(addr, max - pos, iter); len = copy_from_iter(addr, max - pos, iter);
else if (!hole) else if (!hole)
len = copy_to_iter(addr, max - pos, iter); len = copy_to_iter(addr, max - pos, iter);
...@@ -173,7 +173,6 @@ static ssize_t dax_io(int rw, struct inode *inode, struct iov_iter *iter, ...@@ -173,7 +173,6 @@ static ssize_t dax_io(int rw, struct inode *inode, struct iov_iter *iter,
/** /**
* dax_do_io - Perform I/O to a DAX file * dax_do_io - Perform I/O to a DAX file
* @rw: READ to read or WRITE to write
* @iocb: The control block for this I/O * @iocb: The control block for this I/O
* @inode: The file which the I/O is directed at * @inode: The file which the I/O is directed at
* @iter: The addresses to do I/O from or to * @iter: The addresses to do I/O from or to
...@@ -189,9 +188,9 @@ static ssize_t dax_io(int rw, struct inode *inode, struct iov_iter *iter, ...@@ -189,9 +188,9 @@ static ssize_t dax_io(int rw, struct inode *inode, struct iov_iter *iter,
* As with do_blockdev_direct_IO(), we increment i_dio_count while the I/O * As with do_blockdev_direct_IO(), we increment i_dio_count while the I/O
* is in progress. * is in progress.
*/ */
ssize_t dax_do_io(int rw, struct kiocb *iocb, struct inode *inode, ssize_t dax_do_io(struct kiocb *iocb, struct inode *inode,
struct iov_iter *iter, loff_t pos, struct iov_iter *iter, loff_t pos, get_block_t get_block,
get_block_t get_block, dio_iodone_t end_io, int flags) dio_iodone_t end_io, int flags)
{ {
struct buffer_head bh; struct buffer_head bh;
ssize_t retval = -EINVAL; ssize_t retval = -EINVAL;
...@@ -199,7 +198,7 @@ ssize_t dax_do_io(int rw, struct kiocb *iocb, struct inode *inode, ...@@ -199,7 +198,7 @@ ssize_t dax_do_io(int rw, struct kiocb *iocb, struct inode *inode,
memset(&bh, 0, sizeof(bh)); memset(&bh, 0, sizeof(bh));
if ((flags & DIO_LOCKING) && (rw == READ)) { if ((flags & DIO_LOCKING) && iov_iter_rw(iter) == READ) {
struct address_space *mapping = inode->i_mapping; struct address_space *mapping = inode->i_mapping;
mutex_lock(&inode->i_mutex); mutex_lock(&inode->i_mutex);
retval = filemap_write_and_wait_range(mapping, pos, end - 1); retval = filemap_write_and_wait_range(mapping, pos, end - 1);
...@@ -212,9 +211,9 @@ ssize_t dax_do_io(int rw, struct kiocb *iocb, struct inode *inode, ...@@ -212,9 +211,9 @@ ssize_t dax_do_io(int rw, struct kiocb *iocb, struct inode *inode,
/* Protects against truncate */ /* Protects against truncate */
atomic_inc(&inode->i_dio_count); atomic_inc(&inode->i_dio_count);
retval = dax_io(rw, inode, iter, pos, end, get_block, &bh); retval = dax_io(inode, iter, pos, end, get_block, &bh);
if ((flags & DIO_LOCKING) && (rw == READ)) if ((flags & DIO_LOCKING) && iov_iter_rw(iter) == READ)
mutex_unlock(&inode->i_mutex); mutex_unlock(&inode->i_mutex);
if ((retval > 0) && end_io) if ((retval > 0) && end_io)
......
...@@ -861,8 +861,8 @@ ext2_direct_IO(int rw, struct kiocb *iocb, struct iov_iter *iter, ...@@ -861,8 +861,8 @@ ext2_direct_IO(int rw, struct kiocb *iocb, struct iov_iter *iter,
ssize_t ret; ssize_t ret;
if (IS_DAX(inode)) if (IS_DAX(inode))
ret = dax_do_io(rw, iocb, inode, iter, offset, ext2_get_block, ret = dax_do_io(iocb, inode, iter, offset, ext2_get_block, NULL,
NULL, DIO_LOCKING); DIO_LOCKING);
else else
ret = blockdev_direct_IO(iocb, inode, iter, offset, ret = blockdev_direct_IO(iocb, inode, iter, offset,
ext2_get_block); ext2_get_block);
......
...@@ -690,7 +690,7 @@ ssize_t ext4_ind_direct_IO(int rw, struct kiocb *iocb, ...@@ -690,7 +690,7 @@ ssize_t ext4_ind_direct_IO(int rw, struct kiocb *iocb,
goto locked; goto locked;
} }
if (IS_DAX(inode)) if (IS_DAX(inode))
ret = dax_do_io(rw, iocb, inode, iter, offset, ret = dax_do_io(iocb, inode, iter, offset,
ext4_get_block, NULL, 0); ext4_get_block, NULL, 0);
else else
ret = __blockdev_direct_IO(iocb, inode, ret = __blockdev_direct_IO(iocb, inode,
...@@ -701,7 +701,7 @@ ssize_t ext4_ind_direct_IO(int rw, struct kiocb *iocb, ...@@ -701,7 +701,7 @@ ssize_t ext4_ind_direct_IO(int rw, struct kiocb *iocb,
} else { } else {
locked: locked:
if (IS_DAX(inode)) if (IS_DAX(inode))
ret = dax_do_io(rw, iocb, inode, iter, offset, ret = dax_do_io(iocb, inode, iter, offset,
ext4_get_block, NULL, DIO_LOCKING); ext4_get_block, NULL, DIO_LOCKING);
else else
ret = blockdev_direct_IO(iocb, inode, iter, offset, ret = blockdev_direct_IO(iocb, inode, iter, offset,
......
...@@ -3034,7 +3034,7 @@ static ssize_t ext4_ext_direct_IO(int rw, struct kiocb *iocb, ...@@ -3034,7 +3034,7 @@ static ssize_t ext4_ext_direct_IO(int rw, struct kiocb *iocb,
dio_flags = DIO_LOCKING; dio_flags = DIO_LOCKING;
} }
if (IS_DAX(inode)) if (IS_DAX(inode))
ret = dax_do_io(rw, iocb, inode, iter, offset, get_block_func, ret = dax_do_io(iocb, inode, iter, offset, get_block_func,
ext4_end_io_dio, dio_flags); ext4_end_io_dio, dio_flags);
else else
ret = __blockdev_direct_IO(iocb, inode, ret = __blockdev_direct_IO(iocb, inode,
......
...@@ -2609,8 +2609,8 @@ extern loff_t fixed_size_llseek(struct file *file, loff_t offset, ...@@ -2609,8 +2609,8 @@ extern loff_t fixed_size_llseek(struct file *file, loff_t offset,
extern int generic_file_open(struct inode * inode, struct file * filp); extern int generic_file_open(struct inode * inode, struct file * filp);
extern int nonseekable_open(struct inode * inode, struct file * filp); extern int nonseekable_open(struct inode * inode, struct file * filp);
ssize_t dax_do_io(int rw, struct kiocb *, struct inode *, struct iov_iter *, ssize_t dax_do_io(struct kiocb *, struct inode *, struct iov_iter *, loff_t,
loff_t, get_block_t, dio_iodone_t, int flags); get_block_t, dio_iodone_t, int flags);
int dax_clear_blocks(struct inode *, sector_t block, long size); int dax_clear_blocks(struct inode *, sector_t block, long size);
int dax_zero_page_range(struct inode *, loff_t from, unsigned len, get_block_t); int dax_zero_page_range(struct inode *, loff_t from, unsigned len, get_block_t);
int dax_truncate_page(struct inode *, loff_t from, get_block_t); int dax_truncate_page(struct inode *, loff_t from, get_block_t);
......
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