From patchwork Mon Aug 26 07:10:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 13777254 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 06CDCC5472D for ; Mon, 26 Aug 2024 07:02:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E29636B0196; Mon, 26 Aug 2024 03:02:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DB22B6B019C; Mon, 26 Aug 2024 03:02:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C04066B019A; Mon, 26 Aug 2024 03:02:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 93F9A6B0183 for ; Mon, 26 Aug 2024 03:02:48 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 4D635A90D4 for ; Mon, 26 Aug 2024 07:02:48 +0000 (UTC) X-FDA: 82493504016.28.27D5647 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf16.hostedemail.com (Postfix) with ESMTP id 3CDF418000E for ; Mon, 26 Aug 2024 07:02:44 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=none; spf=pass (imf16.hostedemail.com: domain of lizetao1@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=lizetao1@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724655723; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IdYck1qNecS5dQgVKhiAyjVtc+jOS4S+Yl68bl7Ucxo=; b=7h2t/ZyXEke5tFg5rPQNYX/9QLb7+Js9jXARdmq+K/E+zOnnePGcaPJ9+y90lRAUMGSgub qD8ZRlWzUmCwt/XUtd+4RU1OBf5vBczWul7qrnTmWVpqjbaVRV3WXyZVzVEXTYZweJBhuW omex6jjQ6vg9kwtormlFWI9liTBL3JA= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=none; spf=pass (imf16.hostedemail.com: domain of lizetao1@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=lizetao1@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724655723; a=rsa-sha256; cv=none; b=k8tlb7MtnStFtwSckjUCb+x+Wf/zqnmyMVb7R/hgIZQ/Nk9qGQw+ggqKXcSyckIOxhaXzl PhDkStMqpfq0r6CSMBHm9nqt2HsB4f05eUFA0410s0oRVoUdV9g0xsDYEw2uGMRXwRqYrh 5vRUCvmAK9/OpOWuL3wnEW1ndjFpDDI= Received: from mail.maildlp.com (unknown [172.19.88.105]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4WshR33d8NzpTNf; Mon, 26 Aug 2024 15:01:03 +0800 (CST) Received: from kwepemd500012.china.huawei.com (unknown [7.221.188.25]) by mail.maildlp.com (Postfix) with ESMTPS id 3E8061401F0; Mon, 26 Aug 2024 15:02:42 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemd500012.china.huawei.com (7.221.188.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.34; Mon, 26 Aug 2024 15:02:41 +0800 From: Li Zetao To: , , , , CC: , , , Subject: [RFC PATCH -next 2/3] buffer: Using scope-based resource instead of folio_lock/unlock Date: Mon, 26 Aug 2024 15:10:35 +0800 Message-ID: <20240826071036.2445717-3-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240826071036.2445717-1-lizetao1@huawei.com> References: <20240826071036.2445717-1-lizetao1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemd500012.china.huawei.com (7.221.188.25) X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 3CDF418000E X-Stat-Signature: x1j5gu3r7y48gjw5i1d6xdheorxtzayo X-HE-Tag: 1724655764-209843 X-HE-Meta: U2FsdGVkX1+7wGbXhs9V9LSN+BOUQQyyNJTYj+DwLtYawhdTkfbQE9RY00cyAIK3BG4Avth6c0mK/LSk0tIoH7Q22cTGJ/COwKlCeq+GQcg0oXqwdpHmUScsGOkYFk6ttaemFZhbsRKTmMiJAHvaVWUbmzkPIhgWfK8JHmFvCDPeCcGFV3YBeCWKGQzNzKZJ+3wCWmCS5WcZBBV6b/O1J/mIKXVXbICKY5ahrlp2SGMexPPDgz2BTkSfKlnF5/qz+EQ+2kETNo6CjX1h/FqyeqkSGnjNdJQbO7FjNz68v54BJfJEuzuFc0LhPQ7rq2e/hPeR6osKTB9S6fE/qtBMvIAFKJoC4keJRQgwQFjaUYI0Inz//aAKJjjGlZP2TvlMY5a5NErtTxUtcKj2coIx/cPeBD1RAGUMxXpqNKTZbmoWYUNPvKt+sXqJZRhoVMYF28YObBdmml3BtiYNUmjF8xX8XlTr8BeIzTy2CNMsNUX0sHGP7lvvED60sy94D4Tfk3c6kjKZG3+HfHvxlSipOQpoVBgLjvUClWxltxdEZq5tSPjYLpa1N/tvr5ra2IaSK3T2J8iH7C1LULZtjNsSqnL0WQdpxAID9MMJiIeG//BTmQqmkDLeFWofrx+0QteKWAelTl0qwPb3tL3IZ9SHmULbMFggU/mKw+eh1qHNfk8dgz3vAGXk3E6WqG4hCZvYyxQSSElgeMUHX5OSf9CPSwJt2mx5H6aCzh25c5FAWe3YcGbnsPyi+gKtH7rdAsGQ2tIz+ptWAzjHdY6w+7tpisn1dZnkwiuRkrNl9FOcqYbufWR/vQ/nelid1OdfegoXBVOOC8f52Iw/EbrhY4B2pyqmWqbe/kvd2uyQaj0Fs+npcoSYu3z8yh5jzR2VaZvWg50al+C4xvYWYprmFCEZBaiYUiVS2vc1TYW//Aqt4lC7ct/CND/AO1KqLm8+jg18kc6HlFMvKMniY7oS5GD AX4eYVsD GiEKtJ7Cy+jVk151FmpB4IGTGura58CUEua6V2rt/Vj/UW0Ns6LqLVJXq6lWYa/+c45KWQ0ekb7sMReiKXzjPECb4+7uVPMr1c1yn8x+72nrQeEhc+L+YFtxI8TQBjavSsQeX4/uI9lpJafkAVoM4eQtgOahcwOw1Nl43l1Bf9DkOZkt0o5KiVq0cLB6WIo04oKmEoPIOVOhewL1G7uz8spn3rdGR9i6wUwA8 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: List-Subscribe: List-Unsubscribe: Use guard() to manage locking and unlocking a folio, thus avoiding the use of goto unlock code. Remove the unlock_page label, and return directly when an error occurs, allowing the compiler to release the folio's lock. Signed-off-by: Li Zetao --- fs/buffer.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/fs/buffer.c b/fs/buffer.c index 45eb06cb1a4e..77ab93531a33 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -1740,11 +1740,11 @@ void clean_bdev_aliases(struct block_device *bdev, sector_t block, sector_t len) * to pin buffers here since we can afford to sleep and * it scales better than a global spinlock lock. */ - folio_lock(folio); + guard(folio)(folio); /* Recheck when the folio is locked which pins bhs */ head = folio_buffers(folio); if (!head) - goto unlock_page; + continue; bh = head; do { if (!buffer_mapped(bh) || (bh->b_blocknr < block)) @@ -1757,8 +1757,6 @@ void clean_bdev_aliases(struct block_device *bdev, sector_t block, sector_t len) next: bh = bh->b_this_page; } while (bh != head); -unlock_page: - folio_unlock(folio); } folio_batch_release(&fbatch); cond_resched();