From mboxrd@z Thu Jan 1 00:00:00 1970 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CD1DEC433F5 for ; Tue, 15 Feb 2022 08:32:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4CD926B0078; Tue, 15 Feb 2022 03:32:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 47C996B007B; Tue, 15 Feb 2022 03:32:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 36C076B007D; Tue, 15 Feb 2022 03:32:25 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0226.hostedemail.com [216.40.44.226]) by kanga.kvack.org (Postfix) with ESMTP id 247476B0078 for ; Tue, 15 Feb 2022 03:32:25 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id E05CD9006C for ; Tue, 15 Feb 2022 08:32:24 +0000 (UTC) X-FDA: 79144347408.08.0EC8B79 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf13.hostedemail.com (Postfix) with ESMTP id D19BB20007 for ; Tue, 15 Feb 2022 08:32:23 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4JyZ6X6hwhz9shc; Tue, 15 Feb 2022 16:30:44 +0800 (CST) Received: from [10.174.177.76] (10.174.177.76) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Tue, 15 Feb 2022 16:32:21 +0800 Subject: Re: [PATCH 01/10] splice: Use a folio in page_cache_pipe_buf_try_steal() To: "Matthew Wilcox (Oracle)" , , References: <20220214200017.3150590-1-willy@infradead.org> <20220214200017.3150590-2-willy@infradead.org> From: Miaohe Lin Message-ID: Date: Tue, 15 Feb 2022 16:32:20 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <20220214200017.3150590-2-willy@infradead.org> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.76] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Stat-Signature: wat4zwu7yff696epp57rb3tubhfj7yft X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: D19BB20007 Authentication-Results: imf13.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf13.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Rspam-User: X-HE-Tag: 1644913943-348409 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 2022/2/15 4:00, Matthew Wilcox (Oracle) wrote: > This saves a lot of calls to compound_head(). > > Signed-off-by: Matthew Wilcox (Oracle) > --- > fs/splice.c | 21 +++++++++++---------- > 1 file changed, 11 insertions(+), 10 deletions(-) > LGTM. Thanks. Reviewed-by: Miaohe Lin > diff --git a/fs/splice.c b/fs/splice.c > index 5dbce4dcc1a7..23ff9c303abc 100644 > --- a/fs/splice.c > +++ b/fs/splice.c > @@ -47,26 +47,27 @@ static bool page_cache_pipe_buf_try_steal(struct pipe_inode_info *pipe, > struct pipe_buffer *buf) > { > struct page *page = buf->page; > + struct folio *folio = page_folio(page); > struct address_space *mapping; > > - lock_page(page); > + folio_lock(folio); > > - mapping = page_mapping(page); > + mapping = folio_mapping(folio); > if (mapping) { > - WARN_ON(!PageUptodate(page)); > + WARN_ON(!folio_test_uptodate(folio)); > > /* > * At least for ext2 with nobh option, we need to wait on > - * writeback completing on this page, since we'll remove it > + * writeback completing on this folio, since we'll remove it > * from the pagecache. Otherwise truncate wont wait on the > - * page, allowing the disk blocks to be reused by someone else > + * folio, allowing the disk blocks to be reused by someone else > * before we actually wrote our data to them. fs corruption > * ensues. > */ > - wait_on_page_writeback(page); > + folio_wait_writeback(folio); > > - if (page_has_private(page) && > - !try_to_release_page(page, GFP_KERNEL)) > + if (folio_has_private(folio) && > + !filemap_release_folio(folio, GFP_KERNEL)) > goto out_unlock; > > /* > @@ -80,11 +81,11 @@ static bool page_cache_pipe_buf_try_steal(struct pipe_inode_info *pipe, > } > > /* > - * Raced with truncate or failed to remove page from current > + * Raced with truncate or failed to remove folio from current > * address space, unlock and return failure. > */ > out_unlock: > - unlock_page(page); > + folio_unlock(folio); > return false; > } > >