From patchwork Sat May 27 08:16:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 9751663 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 8DC136037E for ; Sat, 27 May 2017 08:17:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7EBF828455 for ; Sat, 27 May 2017 08:17:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 73C9028474; Sat, 27 May 2017 08:17:28 +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=ham 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 1E08628455 for ; Sat, 27 May 2017 08:17:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753915AbdE0IR0 (ORCPT ); Sat, 27 May 2017 04:17:26 -0400 Received: from bombadil.infradead.org ([65.50.211.133]:48686 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753845AbdE0IRY (ORCPT ); Sat, 27 May 2017 04:17:24 -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=EDVePcoS2K+DxU4enCalvpFKGX/wY/4WbW2zQzR9Xtw=; b=qlovNKYvb82VwxlO9wOpI3UVx vebuAIMFlu4pSqeklVPMLcyERds0xiug3OL7BKkOgwRLZh1sRlIUpcHZSBBLS9/Eavyyldz+XgwTd 3nil7jT9nR92vNCpzb87UDXNGR/F0KhczqKrYGRZdYCcpAYn7Bc7W5wVLAPdK2KK7Ul5zrA/DUqcZ bPSdhkB/wQhseULi1j2oMQtzomjp2hueXU1ogxLLeEidrqCtU1dfr0DDIeAlrcvRG1aWVKXxJwlSt KyGMDail0biebCnor/bt0EE8tfNYOSYaFAmt2uv4lCiy0GWUT3i991wsibKG87fyWIGWjNZKT4cDV GvQwjcZoQ==; 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 1dEWuZ-0001bR-6Q; Sat, 27 May 2017 08:17:23 +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 06/10] fs: set kernel address limit in do_loop_readv_writev Date: Sat, 27 May 2017 11:16:50 +0300 Message-Id: <20170527081654.15957-7-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 This will allow to use all iov_iter based read/write for ITER_KVEC without having to check if the file has the iter version of the read/write ops, which will allow us to get rid of a large number of get_fs/set_fs calls in drivers. Signed-off-by: Christoph Hellwig --- fs/read_write.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/fs/read_write.c b/fs/read_write.c index 64b61a032a56..60c64a996ab2 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -704,9 +704,18 @@ static ssize_t do_loop_readv_writev(struct file *filp, struct iov_iter *iter, loff_t *ppos, int type, int flags) { ssize_t ret = 0; + mm_segment_t uninitialized_var(old_fs); if (flags & ~RWF_HIPRI) return -EOPNOTSUPP; + if (iter->type & (ITER_BVEC | ITER_PIPE)) + return -EOPNOTSUPP; + + /* adjust the address limit for in-kernel I/O */ + if (iter->type & ITER_KVEC) { + old_fs = get_fs(); + set_fs(get_ds()); + } while (iov_iter_count(iter)) { struct iovec iovec = iov_iter_iovec(iter); @@ -731,6 +740,8 @@ static ssize_t do_loop_readv_writev(struct file *filp, struct iov_iter *iter, iov_iter_advance(iter, nr); } + if (iter->type & ITER_KVEC) + set_fs(old_fs); return ret; }