From: Christoph Hellwig <hch@lst.de>
To: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: "J. Bruce Fields" <bfields@fieldses.org>,
Jeff Layton <jlayton@poochiereds.net>,
linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: [PATCH 03/10] fs: remove do_compat_readv_writev
Date: Sat, 27 May 2017 11:16:47 +0300 [thread overview]
Message-ID: <20170527081654.15957-4-hch@lst.de> (raw)
In-Reply-To: <20170527081654.15957-1-hch@lst.de>
opencode it in both callers to simplify the call stack a bit.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/read_write.c | 42 ++++++++++++++++--------------------------
1 file changed, 16 insertions(+), 26 deletions(-)
diff --git a/fs/read_write.c b/fs/read_write.c
index 94cb71058098..5cbdf23d924f 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1142,32 +1142,13 @@ SYSCALL_DEFINE6(pwritev2, unsigned long, fd, const struct iovec __user *, vec,
}
#ifdef CONFIG_COMPAT
-
-static ssize_t compat_do_readv_writev(int type, struct file *file,
- const struct compat_iovec __user *uvector,
- unsigned long nr_segs, loff_t *pos,
- int flags)
-{
- struct iovec iovstack[UIO_FASTIOV];
- struct iovec *iov = iovstack;
- struct iov_iter iter;
- ssize_t ret;
-
- ret = compat_import_iovec(type, uvector, nr_segs,
- UIO_FASTIOV, &iov, &iter);
- if (ret < 0)
- return ret;
-
- ret = __do_readv_writev(type, file, &iter, pos, flags);
- kfree(iov);
-
- return ret;
-}
-
static size_t compat_readv(struct file *file,
const struct compat_iovec __user *vec,
unsigned long vlen, loff_t *pos, int flags)
{
+ struct iovec iovstack[UIO_FASTIOV];
+ struct iovec *iov = iovstack;
+ struct iov_iter iter;
ssize_t ret = -EBADF;
if (!(file->f_mode & FMODE_READ))
@@ -1177,8 +1158,11 @@ static size_t compat_readv(struct file *file,
if (!(file->f_mode & FMODE_CAN_READ))
goto out;
- ret = compat_do_readv_writev(READ, file, vec, vlen, pos, flags);
-
+ ret = compat_import_iovec(READ, vec, vlen, UIO_FASTIOV, &iov, &iter);
+ if (ret < 0)
+ goto out;
+ ret = __do_readv_writev(READ, file, &iter, pos, flags);
+ kfree(iov);
out:
if (ret > 0)
add_rchar(current, ret);
@@ -1275,6 +1259,9 @@ static size_t compat_writev(struct file *file,
const struct compat_iovec __user *vec,
unsigned long vlen, loff_t *pos, int flags)
{
+ struct iovec iovstack[UIO_FASTIOV];
+ struct iovec *iov = iovstack;
+ struct iov_iter iter;
ssize_t ret = -EBADF;
if (!(file->f_mode & FMODE_WRITE))
@@ -1284,8 +1271,11 @@ static size_t compat_writev(struct file *file,
if (!(file->f_mode & FMODE_CAN_WRITE))
goto out;
- ret = compat_do_readv_writev(WRITE, file, vec, vlen, pos, flags);
-
+ ret = compat_import_iovec(WRITE, vec, vlen, UIO_FASTIOV, &iov, &iter);
+ if (ret < 0)
+ goto out;
+ ret = __do_readv_writev(WRITE, file, &iter, pos, flags);
+ kfree(iov);
out:
if (ret > 0)
add_wchar(current, ret);
--
2.11.0
next prev parent reply other threads:[~2017-05-27 8:17 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-27 8:16 clean up readv/writev helpers Christoph Hellwig
2017-05-27 8:16 ` [PATCH 01/10] fs: pass on flags in compat_writev Christoph Hellwig
2017-05-27 8:16 ` [PATCH 02/10] fs: remove do_readv_writev Christoph Hellwig
2017-05-27 8:16 ` Christoph Hellwig [this message]
2017-05-27 8:16 ` [PATCH 04/10] fs: remove __do_readv_writev Christoph Hellwig
2017-05-27 8:16 ` [PATCH 05/10] fs: move more code into do_iter_read/do_iter_write Christoph Hellwig
2017-05-27 8:16 ` [PATCH 06/10] fs: set kernel address limit in do_loop_readv_writev Christoph Hellwig
2017-05-27 8:19 ` Christoph Hellwig
2017-05-27 8:16 ` [PATCH 07/10] fs: implement vfs_iter_read using do_iter_read Christoph Hellwig
2017-05-27 8:16 ` [PATCH 08/10] fs: implement vfs_iter_write using do_iter_write Christoph Hellwig
2017-05-27 8:16 ` [PATCH 09/10] nfsd: use vfs_iter_read/write Christoph Hellwig
2017-05-30 18:02 ` J. Bruce Fields
2017-05-27 8:16 ` [PATCH 10/10] nfsd: remove nfsd_vfs_read Christoph Hellwig
2017-05-30 18:03 ` J. Bruce Fields
2017-05-27 19:32 ` clean up readv/writev helpers Al Viro
2017-06-28 14:35 ` Christoph Hellwig
2017-06-28 16:37 ` Al Viro
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170527081654.15957-4-hch@lst.de \
--to=hch@lst.de \
--cc=bfields@fieldses.org \
--cc=jlayton@poochiereds.net \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).