Commit 19c73586 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Al Viro

fs: remove __do_readv_writev

Split it into one helper each for reads vs writes.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 26c87fb7
...@@ -916,8 +916,8 @@ ssize_t compat_rw_copy_check_uvector(int type, ...@@ -916,8 +916,8 @@ ssize_t compat_rw_copy_check_uvector(int type,
} }
#endif #endif
static ssize_t __do_readv_writev(int type, struct file *file, static ssize_t do_iter_read(struct file *file, struct iov_iter *iter,
struct iov_iter *iter, loff_t *pos, int flags) loff_t *pos, int flags)
{ {
size_t tot_len; size_t tot_len;
ssize_t ret = 0; ssize_t ret = 0;
...@@ -925,29 +925,41 @@ static ssize_t __do_readv_writev(int type, struct file *file, ...@@ -925,29 +925,41 @@ static ssize_t __do_readv_writev(int type, struct file *file,
tot_len = iov_iter_count(iter); tot_len = iov_iter_count(iter);
if (!tot_len) if (!tot_len)
goto out; goto out;
ret = rw_verify_area(type, file, pos, tot_len); ret = rw_verify_area(READ, file, pos, tot_len);
if (ret < 0) if (ret < 0)
goto out; return ret;
if (type != READ)
file_start_write(file);
if ((type == READ && file->f_op->read_iter) || if (file->f_op->read_iter)
(type == WRITE && file->f_op->write_iter)) ret = do_iter_readv_writev(file, iter, pos, READ, flags);
ret = do_iter_readv_writev(file, iter, pos, type, flags);
else else
ret = do_loop_readv_writev(file, iter, pos, type, flags); ret = do_loop_readv_writev(file, iter, pos, READ, flags);
out:
if (ret >= 0)
fsnotify_access(file);
return ret;
}
if (type != READ) static ssize_t do_iter_write(struct file *file, struct iov_iter *iter,
file_end_write(file); loff_t *pos, int flags)
{
size_t tot_len;
ssize_t ret = 0;
out: tot_len = iov_iter_count(iter);
if ((ret + (type == READ)) > 0) { if (!tot_len)
if (type == READ) return 0;
fsnotify_access(file); ret = rw_verify_area(WRITE, file, pos, tot_len);
else if (ret < 0)
fsnotify_modify(file); return ret;
}
file_start_write(file);
if (file->f_op->write_iter)
ret = do_iter_readv_writev(file, iter, pos, WRITE, flags);
else
ret = do_loop_readv_writev(file, iter, pos, WRITE, flags);
file_end_write(file);
if (ret > 0)
fsnotify_modify(file);
return ret; return ret;
} }
...@@ -968,7 +980,7 @@ ssize_t vfs_readv(struct file *file, const struct iovec __user *vec, ...@@ -968,7 +980,7 @@ ssize_t vfs_readv(struct file *file, const struct iovec __user *vec,
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = __do_readv_writev(READ, file, &iter, pos, flags); ret = do_iter_read(file, &iter, pos, flags);
kfree(iov); kfree(iov);
return ret; return ret;
} }
...@@ -991,7 +1003,7 @@ ssize_t vfs_writev(struct file *file, const struct iovec __user *vec, ...@@ -991,7 +1003,7 @@ ssize_t vfs_writev(struct file *file, const struct iovec __user *vec,
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = __do_readv_writev(WRITE, file, &iter, pos, flags); ret = do_iter_write(file, &iter, pos, flags);
kfree(iov); kfree(iov);
return ret; return ret;
} }
...@@ -1161,7 +1173,7 @@ static size_t compat_readv(struct file *file, ...@@ -1161,7 +1173,7 @@ static size_t compat_readv(struct file *file,
ret = compat_import_iovec(READ, vec, vlen, UIO_FASTIOV, &iov, &iter); ret = compat_import_iovec(READ, vec, vlen, UIO_FASTIOV, &iov, &iter);
if (ret < 0) if (ret < 0)
goto out; goto out;
ret = __do_readv_writev(READ, file, &iter, pos, flags); ret = do_iter_read(file, &iter, pos, flags);
kfree(iov); kfree(iov);
out: out:
if (ret > 0) if (ret > 0)
...@@ -1274,7 +1286,7 @@ static size_t compat_writev(struct file *file, ...@@ -1274,7 +1286,7 @@ static size_t compat_writev(struct file *file,
ret = compat_import_iovec(WRITE, vec, vlen, UIO_FASTIOV, &iov, &iter); ret = compat_import_iovec(WRITE, vec, vlen, UIO_FASTIOV, &iov, &iter);
if (ret < 0) if (ret < 0)
goto out; goto out;
ret = __do_readv_writev(WRITE, file, &iter, pos, flags); ret = do_iter_write(file, &iter, pos, flags);
kfree(iov); kfree(iov);
out: out:
if (ret > 0) if (ret > 0)
......
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