From patchwork Wed Jun 14 14:03:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13280093 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B01B2EB64DB for ; Wed, 14 Jun 2023 14:03:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245357AbjFNOD4 (ORCPT ); Wed, 14 Jun 2023 10:03:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245361AbjFNODw (ORCPT ); Wed, 14 Jun 2023 10:03:52 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B30C198; Wed, 14 Jun 2023 07:03:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=N0NqQg1rr3XivzomKAcpH5XXjeENykGjUWnON9YOFfw=; b=lPM87SRljs2UXLESTnsqKCjCS+ 6drtMRyhslDM0yWnYUb29V02Vkx/iEzseEOR6OdAh9d3EGwuFAEbLL6ravyYr4UQtmLx3AsHzVCmU dmMMHGauPBWNIWcQgzUrC2Cfg/XQlpPR0bZAkNncVTo3K2pwZ2YzA/K34An9KIgAzj5CqxahN6BRq BrFzffW01wWRLM/cwKXE4jwuIyv3QSOhyolAET2ajFEAHtkV+OyMnGXDkPo8V4aBtSQVsGURPkXGn G8RuFeh7e0rkuCtZnCdh/WTSmLgfa4oSeNFbIG0860m5WOTLeS+bb4H9JtYY7hdBPP4kJn5lt09rn 1TlJ1qJg==; Received: from 2a02-8389-2341-5b80-39d3-4735-9a3c-88d8.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:39d3:4735:9a3c:88d8] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1q9R6C-00Br9O-2N; Wed, 14 Jun 2023 14:03:49 +0000 From: Christoph Hellwig To: Jens Axboe Cc: Alexander Viro , Christian Brauner , linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 1/4] splice: don't call file_accessed in copy_splice_read Date: Wed, 14 Jun 2023 16:03:38 +0200 Message-Id: <20230614140341.521331-2-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230614140341.521331-1-hch@lst.de> References: <20230614140341.521331-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org copy_splice_read calls into ->read_iter to read the data, which already calls file_accessed. Fixes: 33b3b041543e ("splice: Add a func to do a splice from an O_DIRECT file without ITER_PIPE") Signed-off-by: Christoph Hellwig Reviewed-by: Johannes Thumshirn Reviewed-by: Christian Brauner --- fs/splice.c | 1 - 1 file changed, 1 deletion(-) diff --git a/fs/splice.c b/fs/splice.c index 2420ead610a727..87c69fdb333dab 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -368,7 +368,6 @@ ssize_t copy_splice_read(struct file *in, loff_t *ppos, if (ret > 0) { keep = DIV_ROUND_UP(ret, PAGE_SIZE); *ppos = kiocb.ki_pos; - file_accessed(in); } else if (ret < 0) { /* * callers of ->splice_read() expect -EAGAIN on From patchwork Wed Jun 14 14:03:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13280094 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A712EB64DC for ; Wed, 14 Jun 2023 14:03:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245367AbjFNOD6 (ORCPT ); Wed, 14 Jun 2023 10:03:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245360AbjFNOD5 (ORCPT ); Wed, 14 Jun 2023 10:03:57 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C92511FD5; Wed, 14 Jun 2023 07:03:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=kqzcuvv5+ni30kABbm+RVPgUdj7KFWVibordNlWqX6g=; b=AWae5lUZJZR0gw6CSaF6i8Dbxw skKovZPT6h+rF/aDaEp8pP7DgsSXnQrSqPZnWmt9PMms2TIM/n7YOGPZOS9kW6/dkL5mEeoDCi8ci CHw7rVcx8+IzodkylR66w5rxYKABLuEcjnW9FXVsXfxiriTcUW52Rvm5xCYU5qOh2l9YtJgxrnkUZ 9RUnI3tAjmXW7XjVSoMebO+UoJ7IkB74NuLwNbaD05DdUCgKQqjke0k0NA8CCBXU1IYVE7RvH5H8S j/YGXqap3mu2Nuo3AL0ak86ioLKyQXQ+A0kToo4HDQONuALJlfV4l7OvT/x1dx9IIztqgxdEQo7Yk fLHADayw==; Received: from 2a02-8389-2341-5b80-39d3-4735-9a3c-88d8.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:39d3:4735:9a3c:88d8] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1q9R6G-00Br9k-0L; Wed, 14 Jun 2023 14:03:52 +0000 From: Christoph Hellwig To: Jens Axboe Cc: Alexander Viro , Christian Brauner , linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 2/4] splice: simplify a conditional in copy_splice_read Date: Wed, 14 Jun 2023 16:03:39 +0200 Message-Id: <20230614140341.521331-3-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230614140341.521331-1-hch@lst.de> References: <20230614140341.521331-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Check for -EFAULT instead of wrapping the check in an ret < 0 block. Signed-off-by: Christoph Hellwig Reviewed-by: Johannes Thumshirn Reviewed-by: Christian Brauner --- fs/splice.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/fs/splice.c b/fs/splice.c index 87c69fdb333dab..7a9565d8ec4f9d 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -368,15 +368,15 @@ ssize_t copy_splice_read(struct file *in, loff_t *ppos, if (ret > 0) { keep = DIV_ROUND_UP(ret, PAGE_SIZE); *ppos = kiocb.ki_pos; - } else if (ret < 0) { - /* - * callers of ->splice_read() expect -EAGAIN on - * "can't put anything in there", rather than -EFAULT. - */ - if (ret == -EFAULT) - ret = -EAGAIN; } + /* + * Callers of ->splice_read() expect -EAGAIN on "can't put anything in + * there", rather than -EFAULT. + */ + if (ret == -EFAULT) + ret = -EAGAIN; + /* Free any pages that didn't get touched at all. */ if (keep < npages) release_pages(pages + keep, npages - keep); From patchwork Wed Jun 14 14:03:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13280095 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD4ABEB64DB for ; Wed, 14 Jun 2023 14:04:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245383AbjFNOEF (ORCPT ); Wed, 14 Jun 2023 10:04:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245371AbjFNOEA (ORCPT ); Wed, 14 Jun 2023 10:04:00 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDEC41BC6; Wed, 14 Jun 2023 07:03:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=y2VOAWVYmfWhLAJZWae0zYCsa52UbsbyvWfbxWr+KKg=; b=a79fBkGGSuBaMmrsdRjJTl2aMx kJNlMRrXEuqahHUEQpJV4QgQ3Ym+2E6bzMPM7oBmx6GxrLhjk58gQyn97sDE2abZhSHDDOayelUCo +pPQkPnwIebiR1qELno5bE9IaEnVDydbBCPcpxtvEuoRXyqfUBdFrGClWaT9p53o4XgV8eCYWyUqU 0ymKFTi0dBeNsEFcD07nQBpAMOpvx8xnJifD7244k42gKzfuhiJYs91PZtxY4g9n5HPIUuWUFaCMy +BkCCiyIWzwl3ALP879d/OVOE1a2Id4lHj7XOL8NP/70kqvgawsOf+0bEJzVWCtNxsQ/i9iTNcMPy PQHNbeOw==; Received: from 2a02-8389-2341-5b80-39d3-4735-9a3c-88d8.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:39d3:4735:9a3c:88d8] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1q9R6J-00BrAS-0M; Wed, 14 Jun 2023 14:03:55 +0000 From: Christoph Hellwig To: Jens Axboe Cc: Alexander Viro , Christian Brauner , linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 3/4] block: remove BIO_PAGE_REFFED Date: Wed, 14 Jun 2023 16:03:40 +0200 Message-Id: <20230614140341.521331-4-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230614140341.521331-1-hch@lst.de> References: <20230614140341.521331-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Now that all block direct I/O helpers use page pinning, this flag is unused. Signed-off-by: Christoph Hellwig Reviewed-by: Johannes Thumshirn Reviewed-by: Christian Brauner --- block/blk.h | 2 -- include/linux/bio.h | 3 +-- include/linux/blk_types.h | 1 - 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/block/blk.h b/block/blk.h index 768852a84fefb3..608c5dcc516b55 100644 --- a/block/blk.h +++ b/block/blk.h @@ -445,8 +445,6 @@ static inline void bio_release_page(struct bio *bio, struct page *page) { if (bio_flagged(bio, BIO_PAGE_PINNED)) unpin_user_page(page); - else if (bio_flagged(bio, BIO_PAGE_REFFED)) - put_page(page); } struct request_queue *blk_alloc_queue(int node_id); diff --git a/include/linux/bio.h b/include/linux/bio.h index 61752292896494..c4f5b5228105fe 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -492,8 +492,7 @@ void zero_fill_bio(struct bio *bio); static inline void bio_release_pages(struct bio *bio, bool mark_dirty) { - if (bio_flagged(bio, BIO_PAGE_REFFED) || - bio_flagged(bio, BIO_PAGE_PINNED)) + if (bio_flagged(bio, BIO_PAGE_PINNED)) __bio_release_pages(bio, mark_dirty); } diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h index deb69eeab6bd7b..752a54e3284b27 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h @@ -326,7 +326,6 @@ struct bio { */ enum { BIO_PAGE_PINNED, /* Unpin pages in bio_release_pages() */ - BIO_PAGE_REFFED, /* put pages in bio_release_pages() */ BIO_CLONED, /* doesn't own data */ BIO_BOUNCED, /* bio is a bounce bio */ BIO_QUIET, /* Make BIO Quiet */ From patchwork Wed Jun 14 14:03:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13280096 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D0CEEB64D8 for ; Wed, 14 Jun 2023 14:04:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245380AbjFNOEK (ORCPT ); Wed, 14 Jun 2023 10:04:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245381AbjFNOEE (ORCPT ); Wed, 14 Jun 2023 10:04:04 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D04BF1FDD; Wed, 14 Jun 2023 07:03:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=OSL1nuzwKsIXKnJLJ9bC7aLj85J8tz1NUL8M/RaHueI=; b=ziPVkzsoToBw8HyGoGo9Kf60kr DXGZHzJDufMZHkMkzaSO/9+2+j1wNF+GamUI4o0mc7O/a1uImkC4/BEi+hxSZnwOV7XrQeX4Tuhhs gLuF62QFXBt67QuX+6VtHDp9Pe7OXB3dJKVx1yAZJxANAtb3Z4cD0IixWtY3Z93P23eHgFct8w/Uu Rad+DpGdHuUWHb9psr5TiLOu3kPHyDy8UbQsDWo3+ccBViUGk+5CCGTElZ+o9xjhY1gkg29U4hHPJ uhj+x577LPkev3s8yO28j0ThfCeauPs7Cp0/ClV8ASFPJoXdPW+DSo3zOePupmnoh54bUOvjW+DKP Bb89Zj6A==; Received: from 2a02-8389-2341-5b80-39d3-4735-9a3c-88d8.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:39d3:4735:9a3c:88d8] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1q9R6L-00BrAj-2a; Wed, 14 Jun 2023 14:03:58 +0000 From: Christoph Hellwig To: Jens Axboe Cc: Alexander Viro , Christian Brauner , linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 4/4] iov_iter: remove iov_iter_get_pages and iov_iter_get_pages_alloc Date: Wed, 14 Jun 2023 16:03:41 +0200 Message-Id: <20230614140341.521331-5-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230614140341.521331-1-hch@lst.de> References: <20230614140341.521331-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Now that the direct I/O helpers have switched to use iov_iter_extract_pages, these helpers are unused. Signed-off-by: Christoph Hellwig Reviewed-by: Christian Brauner --- include/linux/uio.h | 6 ------ lib/iov_iter.c | 35 +++++++---------------------------- 2 files changed, 7 insertions(+), 34 deletions(-) diff --git a/include/linux/uio.h b/include/linux/uio.h index 60c342bb7ab89f..8e7d2c425340c5 100644 --- a/include/linux/uio.h +++ b/include/linux/uio.h @@ -277,14 +277,8 @@ void iov_iter_bvec(struct iov_iter *i, unsigned int direction, const struct bio_ void iov_iter_discard(struct iov_iter *i, unsigned int direction, size_t count); void iov_iter_xarray(struct iov_iter *i, unsigned int direction, struct xarray *xarray, loff_t start, size_t count); -ssize_t iov_iter_get_pages(struct iov_iter *i, struct page **pages, - size_t maxsize, unsigned maxpages, size_t *start, - iov_iter_extraction_t extraction_flags); ssize_t iov_iter_get_pages2(struct iov_iter *i, struct page **pages, size_t maxsize, unsigned maxpages, size_t *start); -ssize_t iov_iter_get_pages_alloc(struct iov_iter *i, - struct page ***pages, size_t maxsize, size_t *start, - iov_iter_extraction_t extraction_flags); ssize_t iov_iter_get_pages_alloc2(struct iov_iter *i, struct page ***pages, size_t maxsize, size_t *start); int iov_iter_npages(const struct iov_iter *i, int maxpages); diff --git a/lib/iov_iter.c b/lib/iov_iter.c index f18138e0292ae4..b667b1e2f68866 100644 --- a/lib/iov_iter.c +++ b/lib/iov_iter.c @@ -1082,8 +1082,7 @@ static struct page *first_bvec_segment(const struct iov_iter *i, static ssize_t __iov_iter_get_pages_alloc(struct iov_iter *i, struct page ***pages, size_t maxsize, - unsigned int maxpages, size_t *start, - iov_iter_extraction_t extraction_flags) + unsigned int maxpages, size_t *start) { unsigned int n, gup_flags = 0; @@ -1093,8 +1092,6 @@ static ssize_t __iov_iter_get_pages_alloc(struct iov_iter *i, return 0; if (maxsize > MAX_RW_COUNT) maxsize = MAX_RW_COUNT; - if (extraction_flags & ITER_ALLOW_P2PDMA) - gup_flags |= FOLL_PCI_P2PDMA; if (likely(user_backed_iter(i))) { unsigned long addr; @@ -1144,49 +1141,31 @@ static ssize_t __iov_iter_get_pages_alloc(struct iov_iter *i, return -EFAULT; } -ssize_t iov_iter_get_pages(struct iov_iter *i, - struct page **pages, size_t maxsize, unsigned maxpages, - size_t *start, iov_iter_extraction_t extraction_flags) +ssize_t iov_iter_get_pages2(struct iov_iter *i, struct page **pages, + size_t maxsize, unsigned maxpages, size_t *start) { if (!maxpages) return 0; BUG_ON(!pages); - return __iov_iter_get_pages_alloc(i, &pages, maxsize, maxpages, - start, extraction_flags); -} -EXPORT_SYMBOL_GPL(iov_iter_get_pages); - -ssize_t iov_iter_get_pages2(struct iov_iter *i, struct page **pages, - size_t maxsize, unsigned maxpages, size_t *start) -{ - return iov_iter_get_pages(i, pages, maxsize, maxpages, start, 0); + return __iov_iter_get_pages_alloc(i, &pages, maxsize, maxpages, start); } EXPORT_SYMBOL(iov_iter_get_pages2); -ssize_t iov_iter_get_pages_alloc(struct iov_iter *i, - struct page ***pages, size_t maxsize, - size_t *start, iov_iter_extraction_t extraction_flags) +ssize_t iov_iter_get_pages_alloc2(struct iov_iter *i, + struct page ***pages, size_t maxsize, size_t *start) { ssize_t len; *pages = NULL; - len = __iov_iter_get_pages_alloc(i, pages, maxsize, ~0U, start, - extraction_flags); + len = __iov_iter_get_pages_alloc(i, pages, maxsize, ~0U, start); if (len <= 0) { kvfree(*pages); *pages = NULL; } return len; } -EXPORT_SYMBOL_GPL(iov_iter_get_pages_alloc); - -ssize_t iov_iter_get_pages_alloc2(struct iov_iter *i, - struct page ***pages, size_t maxsize, size_t *start) -{ - return iov_iter_get_pages_alloc(i, pages, maxsize, start, 0); -} EXPORT_SYMBOL(iov_iter_get_pages_alloc2); size_t csum_and_copy_from_iter(void *addr, size_t bytes, __wsum *csum,