From patchwork Sat May 27 08:16:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 9751655 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BB8446037E for ; Sat, 27 May 2017 08:17:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC9EA28455 for ; Sat, 27 May 2017 08:17:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A1A6C28474; Sat, 27 May 2017 08:17:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4B99128455 for ; Sat, 27 May 2017 08:17:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753898AbdE0IRO (ORCPT ); Sat, 27 May 2017 04:17:14 -0400 Received: from bombadil.infradead.org ([65.50.211.133]:44514 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753845AbdE0IRN (ORCPT ); Sat, 27 May 2017 04:17:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=6tKMALALaYcnnbrlEyNHoPcLtgWckxgRb9LAiO5i6Ig=; b=myzBSKskRu60upHwOuL928sR4 ks2P4IMxaud8RzcFWJoXYva2iA5Y3o4AYQEn3n8I/bedHq+UVY5meB+K39s0u/HOzSgFakIfu/8rH O3h+7djQxyifF9n1D5S9ceSal7dBoBxfI/Hps5ZisD3p2/a21bqtwIPN9qM2uZYanRQFpMhUeu0yO AkHlwBz/1v4uwzMHFfSpbHEk7HrAR8w/eGCd4jbyBRerwNf+9WcIqO/UlFWMNX3GnnnyBh+ZZMFSn 1AHn0gYOe5dx/odwdOI2zP9UjaoWeseu2AV5xEePcdpPQrBdatKFLie3sWrZmf7ydyFJzlAV64qJ2 gC+Dn+ZrQ==; Received: from shol69.static.otenet.gr ([83.235.170.67] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat Linux)) id 1dEWuN-0001YX-Mw; Sat, 27 May 2017 08:17:12 +0000 From: Christoph Hellwig To: Alexander Viro Cc: "J. Bruce Fields" , Jeff Layton , 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 Message-Id: <20170527081654.15957-4-hch@lst.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170527081654.15957-1-hch@lst.de> References: <20170527081654.15957-1-hch@lst.de> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP opencode it in both callers to simplify the call stack a bit. Signed-off-by: Christoph Hellwig --- 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);