direct_IO: use iov_iter_rw() instead of rw everywhere
The rw parameter to direct_IO is redundant with iov_iter->type, and treated slightly differently just about everywhere it's used: some users do rw & WRITE, and others do rw == WRITE where they should be doing a bitwise check. Simplify this with the new iov_iter_rw() helper, which always returns either READ or WRITE. Signed-off-by: Omar Sandoval <osandov@osandov.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
@@ -642,8 +642,8 @@ out:
|
||||
* crashes then stale disk data _may_ be exposed inside the file. But current
|
||||
* VFS code falls back into buffered path in that case so we are safe.
|
||||
*/
|
||||
ssize_t ext4_ind_direct_IO(int rw, struct kiocb *iocb,
|
||||
struct iov_iter *iter, loff_t offset)
|
||||
ssize_t ext4_ind_direct_IO(struct kiocb *iocb, struct iov_iter *iter,
|
||||
loff_t offset)
|
||||
{
|
||||
struct file *file = iocb->ki_filp;
|
||||
struct inode *inode = file->f_mapping->host;
|
||||
@@ -654,7 +654,7 @@ ssize_t ext4_ind_direct_IO(int rw, struct kiocb *iocb,
|
||||
size_t count = iov_iter_count(iter);
|
||||
int retries = 0;
|
||||
|
||||
if (rw == WRITE) {
|
||||
if (iov_iter_rw(iter) == WRITE) {
|
||||
loff_t final_size = offset + count;
|
||||
|
||||
if (final_size > inode->i_size) {
|
||||
@@ -676,7 +676,7 @@ ssize_t ext4_ind_direct_IO(int rw, struct kiocb *iocb,
|
||||
}
|
||||
|
||||
retry:
|
||||
if (rw == READ && ext4_should_dioread_nolock(inode)) {
|
||||
if (iov_iter_rw(iter) == READ && ext4_should_dioread_nolock(inode)) {
|
||||
/*
|
||||
* Nolock dioread optimization may be dynamically disabled
|
||||
* via ext4_inode_block_unlocked_dio(). Check inode's state
|
||||
@@ -707,7 +707,7 @@ locked:
|
||||
ret = blockdev_direct_IO(iocb, inode, iter, offset,
|
||||
ext4_get_block);
|
||||
|
||||
if (unlikely((rw & WRITE) && ret < 0)) {
|
||||
if (unlikely(iov_iter_rw(iter) == WRITE && ret < 0)) {
|
||||
loff_t isize = i_size_read(inode);
|
||||
loff_t end = offset + count;
|
||||
|
||||
|
Reference in New Issue
Block a user