From patchwork Mon Apr 17 12:36:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 13213794 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 6FE7AC77B72 for ; Mon, 17 Apr 2023 12:36:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230128AbjDQMg3 (ORCPT ); Mon, 17 Apr 2023 08:36:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229914AbjDQMg1 (ORCPT ); Mon, 17 Apr 2023 08:36:27 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FB7B131 for ; Mon, 17 Apr 2023 05:36:24 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230417123621euoutp02c1276ca9db610d83755473379bd9933e~WuQ5NZmuH2960829608euoutp02F for ; Mon, 17 Apr 2023 12:36:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230417123621euoutp02c1276ca9db610d83755473379bd9933e~WuQ5NZmuH2960829608euoutp02F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1681734981; bh=ToDE43tRnz0p+L+A0Gpl2BjRfNRIfbZq1R5380heax8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kiT0q720f7N78z3fYHrOCC6zwrEGXRce+WcTWuSF5XrnEW5exXzM0HxujixhWqwS1 Dvrc1EBWVj9dFinkyUld+fNc7kZOhVSmgvkgW3LM98qS5gUbeVgw08dWFN5Hkq0EPc gRmTZg+yvemfZaHiWMeT/DtEGfjVuzAckaGNpfAw= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230417123621eucas1p2a869a48f275fbd8a8a171ab8a1f4290c~WuQ4fpo5Z0719007190eucas1p24; Mon, 17 Apr 2023 12:36:21 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 56.2D.09503.54D3D346; Mon, 17 Apr 2023 13:36:21 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20230417123620eucas1p266aa61d2213f94bbe028a98be73b70fc~WuQ4MOQPw0505405054eucas1p2n; Mon, 17 Apr 2023 12:36:20 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230417123620eusmtrp1b947be1384c5f0806db168e9ae7fa1c8~WuQ4LqdSR2401824018eusmtrp1z; Mon, 17 Apr 2023 12:36:20 +0000 (GMT) X-AuditID: cbfec7f2-e8fff7000000251f-40-643d3d458b9b Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 6D.38.34412.44D3D346; Mon, 17 Apr 2023 13:36:20 +0100 (BST) Received: from localhost (unknown [106.210.248.243]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230417123620eusmtip1b098fac03c10a0314c030e184a2a48be~WuQ39Emx92069820698eusmtip1T; Mon, 17 Apr 2023 12:36:20 +0000 (GMT) From: Pankaj Raghav To: viro@zeniv.linux.org.uk, brauner@kernel.org, willy@infradead.org, akpm@linux-foundation.org Cc: linux-fsdevel@vger.kernel.org, mcgrof@kernel.org, linux-kernel@vger.kernel.org, hare@suse.de, gost.dev@samsung.com, Pankaj Raghav Subject: [PATCH 1/4] fs/buffer: add folio_set_bh helper Date: Mon, 17 Apr 2023 14:36:15 +0200 Message-Id: <20230417123618.22094-2-p.raghav@samsung.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230417123618.22094-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrKKsWRmVeSWpSXmKPExsWy7djP87qutrYpBitWcFjMWb+GzeL14U+M FjcP7GSy2LNoEpDYe5LF4vKuOWwWNyY8ZbT4vLSF3eL83+OsFr9/zGFz4PLYvELLY9OqTjaP EzN+s3j0bVnF6LH5dLXH501yHpuevGUKYI/isklJzcksSy3St0vgyph/fy5rwR+eivPf+RoY b3F1MXJySAiYSDR8fcPYxcjFISSwglHi96U2FgjnC6PEnIdr2CCcz4wSJ+9+YYRrOXGMFcQW EljOKLFyTiBE0UtGiWX3W4ESHBxsAloSjZ3sIDUiAokSi/d0g61gFljAKPHkzxpmkISwgLnE t+5XYEUsAqoSM38tZAKxeQUsJSZ9mcAEsUxeYv/Bs2D1nAJWEis29zBD1AhKnJz5hAXEZgaq ad46mxlkgYTAHQ6Jx/sOsoMcISHgIvFwpwXEHGGJV8e3sEPYMhKnJ/ewQNjVEk9v/IbqbWGU 6N+5ng2i11qi70wOiMksoCmxfpc+RLmjROvsSVAVfBI33gpCXMAnMWnbdGaIMK9ER5sQRLWS xM6fT6CWSkhcbpoDtdRD4tP2BpYJjIqzkPwyC8kvsxD2LmBkXsUonlpanJueWmyYl1quV5yY W1yal66XnJ+7iRGYkk7/O/5pB+PcVx/1DjEycTAeYpTgYFYS4T3japUixJuSWFmVWpQfX1Sa k1p8iFGag0VJnFfb9mSykEB6YklqdmpqQWoRTJaJg1OqgSk3Zp1MZJ97xNWb8q9fqL/eXnJI 6q6sg2SEyzFul1miTL9FzZ5d27n0QPOvwpu/g/4ctdh98OH5BOb3gZLuT2f+qLPT7RVdee1c tOPhk/UXIp7ezZv37+49x/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zbvkT28XDDb2/8qlIPVb8XflQ+5iG2Yzul7518XEecZ+Pbv11Qyhiy/TCc38fibY1 KHiz3InvdbMInrb5/ZqZOclhPUYePM/3bOgNObuGi1tow0J92xlvLVhO2T886fXTfMee5Gl3 76mv5Ii8uf6HP+dbN9s40xBDn3zvSUJphyNzZy8NitysPUt5afuXWdsWTr7wm8c6V2r3hNWp IffbJv/1t9r+ersSS3FGoqEWc1FxIgD2gHHgKAMAAA== X-CMS-MailID: 20230417123620eucas1p266aa61d2213f94bbe028a98be73b70fc X-Msg-Generator: CA X-RootMTR: 20230417123620eucas1p266aa61d2213f94bbe028a98be73b70fc X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230417123620eucas1p266aa61d2213f94bbe028a98be73b70fc References: <20230417123618.22094-1-p.raghav@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org The folio version of set_bh_page(). This is required to convert create_page_buffers() to folio_create_buffers() later in the series. Signed-off-by: Pankaj Raghav Reviewed-by: Matthew Wilcox (Oracle) Reviewed-by: Hannes Reinecke --- fs/buffer.c | 15 +++++++++++++++ include/linux/buffer_head.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/fs/buffer.c b/fs/buffer.c index b3eb905f87d6..7e74bd77a81b 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -1484,6 +1484,21 @@ void set_bh_page(struct buffer_head *bh, } EXPORT_SYMBOL(set_bh_page); +void folio_set_bh(struct buffer_head *bh, struct folio *folio, + unsigned long offset) +{ + bh->b_folio = folio; + BUG_ON(offset >= folio_size(folio)); + if (folio_test_highmem(folio)) + /* + * This catches illegal uses and preserves the offset: + */ + bh->b_data = (char *)(0 + offset); + else + bh->b_data = folio_address(folio) + offset; +} +EXPORT_SYMBOL(folio_set_bh); + /* * Called when truncating a buffer on a page completely. */ diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h index 8f14dca5fed7..7e92d23f4782 100644 --- a/include/linux/buffer_head.h +++ b/include/linux/buffer_head.h @@ -196,6 +196,8 @@ void mark_buffer_write_io_error(struct buffer_head *bh); void touch_buffer(struct buffer_head *bh); void set_bh_page(struct buffer_head *bh, struct page *page, unsigned long offset); +void folio_set_bh(struct buffer_head *bh, struct folio *folio, + unsigned long offset); bool try_to_free_buffers(struct folio *); struct buffer_head *alloc_page_buffers(struct page *page, unsigned long size, bool retry); From patchwork Mon Apr 17 12:36:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 13213793 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 52F7FC77B70 for ; Mon, 17 Apr 2023 12:36:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229981AbjDQMg1 (ORCPT ); Mon, 17 Apr 2023 08:36:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229574AbjDQMg0 (ORCPT ); Mon, 17 Apr 2023 08:36:26 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F7DFF1 for ; Mon, 17 Apr 2023 05:36:24 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230417123622euoutp01b64fd1e36a43147f7736e095aadeb4b9~WuQ57rpFw3228632286euoutp01Y for ; Mon, 17 Apr 2023 12:36:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230417123622euoutp01b64fd1e36a43147f7736e095aadeb4b9~WuQ57rpFw3228632286euoutp01Y DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1681734982; bh=bGcZjkjJ2aM3lpU75XSeXq9MOtiINBQOzSIq1D3EodY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YvAkyhrBZx+BRyji3Fz1+rlU5UKvoOzrB1jpobWMk2lRQV0B+xd85fqqFDCpOl6rj LRq6vk7nN+KBvu9CMNTPscVgMtSOIteoPFQsJUsAAt1HeaiQl2LM0nQMmQJPm4x6i2 k+Evgb/fWcY/42FyHTTQha4YkgzxEEAnvJRLkeVQ= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20230417123621eucas1p139372fab40849df20985f6a1e2899c8d~WuQ5BP4dA1535115351eucas1p1V; Mon, 17 Apr 2023 12:36:21 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 90.B5.10014.54D3D346; Mon, 17 Apr 2023 13:36:21 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230417123621eucas1p12ef0592f7d9b97bf105ff9990da22a48~WuQ4tsdj51535615356eucas1p1V; Mon, 17 Apr 2023 12:36:21 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230417123621eusmtrp10c912ff1810f75113d98d5e84f637179~WuQ4s-jJ82401524015eusmtrp15; Mon, 17 Apr 2023 12:36:21 +0000 (GMT) X-AuditID: cbfec7f5-ba1ff7000000271e-97-643d3d452f22 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id A4.57.22108.54D3D346; Mon, 17 Apr 2023 13:36:21 +0100 (BST) Received: from localhost (unknown [106.210.248.243]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230417123621eusmtip2e5020cca319222f9f2ec463a15392570~WuQ4ewl9d0520705207eusmtip2u; Mon, 17 Apr 2023 12:36:21 +0000 (GMT) From: Pankaj Raghav To: viro@zeniv.linux.org.uk, brauner@kernel.org, willy@infradead.org, akpm@linux-foundation.org Cc: linux-fsdevel@vger.kernel.org, mcgrof@kernel.org, linux-kernel@vger.kernel.org, hare@suse.de, gost.dev@samsung.com, Pankaj Raghav Subject: [PATCH 2/4] buffer: add folio_alloc_buffers() helper Date: Mon, 17 Apr 2023 14:36:16 +0200 Message-Id: <20230417123618.22094-3-p.raghav@samsung.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230417123618.22094-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrOKsWRmVeSWpSXmKPExsWy7djPc7qutrYpBr1tmhZz1q9hs3h9+BOj xc0DO5ks9iyaBCT2nmSxuLxrDpvFjQlPGS0+L21htzj/9zirxe8fc9gcuDw2r9Dy2LSqk83j xIzfLB59W1Yxemw+Xe3xeZOcx6Ynb5kC2KO4bFJSczLLUov07RK4Mvbt6GQteCpV0bbqDlMD 42vRLkYODgkBE4k/B+K7GLk4hARWMEr8nruDDcL5wihxcNEURgjnM6PElce/WLsYOcE6tszs g0osZ5RYsmYdO4TzklHiQV8fE8hcNgEticZOdpAGEYFEicV7usEamAUWMEo8+bOGGSQhLGAr 0blpJhOIzSKgKvF8yUawDbwClhILfy5jhtgmL7H/4Fkwm1PASmLF5h5miBpBiZMzn7CA2MxA Nc1bZzODLJAQeMAh0TdrHhNEs4vEw7U7oc4Wlnh1fAs7hC0jcXpyDwuEXS3x9MZvqOYWRon+ nevZICFjLdF3JgfEZBbQlFi/Sx+i3FFieu9dVogKPokbbwUhTuCTmLRtOjNEmFeio00IolpJ YufPJ1BLJSQuN82BWuohsWPnfqYJjIqzkDwzC8kzsxD2LmBkXsUonlpanJueWmycl1quV5yY W1yal66XnJ+7iRGYlk7/O/51B+OKVx/1DjEycTAeYpTgYFYS4T3japUixJuSWFmVWpQfX1Sa k1p8iFGag0VJnFfb9mSykEB6YklqdmpqQWoRTJaJg1OqgWlTlN1cCXdlbZ8t+3ZOVnh3wMzq xXPegPJz6Ws7+iV6I3fx9HfvqI2/LOCpZTD55tzvL613Ou06NbXlJB+ba8Xat30adzmrcp8t YTs25/YU33qTNYem729hWfTv63tB8QJ/S6+Qp20PV/R/LZOQ/Smlzm/tb2aZvGN5VduvLV/S jMOlVxww3DU1c11QvsnyfQcERBb479vg0WshWd82x/LDTfd7EqLvjeSiXpecn+9T4dC5NPCb s87sev21/dZJ0aGxrF/8k/ryO2w6vU4XbM79450YEb/u8BruAs98b54DLZfnJFp9adzi8br0 8qXVM/kblMW/zJy504s/ytH5tYfyrY4YOblVyorLg1bqKLEUZyQaajEXFScCABpiAdi6AwAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprGIsWRmVeSWpSXmKPExsVy+t/xe7qutrYpBjP3CljMWb+GzeL14U+M FjcP7GSy2LNoEpDYe5LF4vKuOWwWNyY8ZbT4vLSF3eL83+OsFr9/zGFz4PLYvELLY9OqTjaP EzN+s3j0bVnF6LH5dLXH501yHpuevGUKYI/SsynKLy1JVcjILy6xVYo2tDDSM7S00DMysdQz NDaPtTIyVdK3s0lJzcksSy3St0vQy9i3o5O14KlURduqO0wNjK9Fuxg5OSQETCS2zOxj7GLk 4hASWMoosX/zLDaIhITE7YVNjBC2sMSfa11gcSGB54wSZ7oFuhg5ONgEtCQaO9lBwiICqRIr /txhA5nDLLCMUeLw97vMIAlhAVuJzk0zmUBsFgFViedLNrKC2LwClhILfy5jhpgvL7H/4Fkw m1PASmLF5h5miF2WEvcvbWOGqBeUODnzCQuIzQxU37x1NvMERoFZSFKzkKQWMDKtYhRJLS3O Tc8tNtQrTswtLs1L10vOz93ECIygbcd+bt7BOO/VR71DjEwcjIcYJTiYlUR4z7hapQjxpiRW VqUW5ccXleakFh9iNAW6eyKzlGhyPjCG80riDc0MTA1NzCwNTC3NjJXEeT0LOhKFBNITS1Kz U1MLUotg+pg4OKUamLhzjL7wrDfTu5Ylm9M/t26flt3CjukXV+zauHOyyoa3X3ZmxTfyXZgW +G6Pp3Onybafaw7/unRos/aTj/buJQpCpmvncH67/tD6foRU7/SnVnL9hxUb6+wTSvIZ1QNW V+baywmkLC1j3/ykUUn+b9bN4Jh6+fCiaw5sekIOTjNvzZNunq5xSGL7pPrVFYu5pv65fbej T+TKZp3qtJ6NVrp6LQXHVsYt27M3Lrzl4Nsrm3w+ywatLGz3cPwS/ExS9OvJyfsCIrzueeot Ozkr7t+x2C+dG44ct5O+ntIx2/Hk+zOb7vv8XJiSrMLZ3PjhZCQjA9t+SWUeTTmhhYUTnBZ9 npj6etX5jBcaMxdOylZiKc5INNRiLipOBAC6C1IPKQMAAA== X-CMS-MailID: 20230417123621eucas1p12ef0592f7d9b97bf105ff9990da22a48 X-Msg-Generator: CA X-RootMTR: 20230417123621eucas1p12ef0592f7d9b97bf105ff9990da22a48 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230417123621eucas1p12ef0592f7d9b97bf105ff9990da22a48 References: <20230417123618.22094-1-p.raghav@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Folio version of alloc_page_buffers() helper. This is required to convert create_page_buffers() to folio_create_buffers() later in the series. alloc_page_buffers() has been modified to call folio_alloc_buffers() which adds one call to compound_head() but folio_alloc_buffers() removes one call to compound_head() compared to the existing alloc_page_buffers() implementation. Signed-off-by: Pankaj Raghav Reviewed-by: Matthew Wilcox (Oracle) Reviewed-by: Hannes Reinecke --- fs/buffer.c | 23 +++++++++++++++-------- include/linux/buffer_head.h | 2 ++ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/fs/buffer.c b/fs/buffer.c index 7e74bd77a81b..75415170e286 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -842,7 +842,7 @@ int remove_inode_buffers(struct inode *inode) } /* - * Create the appropriate buffers when given a page for data area and + * Create the appropriate buffers when given a folio for data area and * the size of each buffer.. Use the bh->b_this_page linked list to * follow the buffers created. Return NULL if unable to create more * buffers. @@ -850,8 +850,8 @@ int remove_inode_buffers(struct inode *inode) * The retry flag is used to differentiate async IO (paging, swapping) * which may not fail from ordinary buffer allocations. */ -struct buffer_head *alloc_page_buffers(struct page *page, unsigned long size, - bool retry) +struct buffer_head *folio_alloc_buffers(struct folio *folio, unsigned long size, + bool retry) { struct buffer_head *bh, *head; gfp_t gfp = GFP_NOFS | __GFP_ACCOUNT; @@ -861,12 +861,12 @@ struct buffer_head *alloc_page_buffers(struct page *page, unsigned long size, if (retry) gfp |= __GFP_NOFAIL; - /* The page lock pins the memcg */ - memcg = page_memcg(page); + /* The folio lock pins the memcg */ + memcg = folio_memcg(folio); old_memcg = set_active_memcg(memcg); head = NULL; - offset = PAGE_SIZE; + offset = folio_size(folio); while ((offset -= size) >= 0) { bh = alloc_buffer_head(gfp); if (!bh) @@ -878,8 +878,8 @@ struct buffer_head *alloc_page_buffers(struct page *page, unsigned long size, bh->b_size = size; - /* Link the buffer to its page */ - set_bh_page(bh, page, offset); + /* Link the buffer to its folio */ + folio_set_bh(bh, folio, offset); } out: set_active_memcg(old_memcg); @@ -898,6 +898,13 @@ struct buffer_head *alloc_page_buffers(struct page *page, unsigned long size, goto out; } +EXPORT_SYMBOL_GPL(folio_alloc_buffers); + +struct buffer_head *alloc_page_buffers(struct page *page, unsigned long size, + bool retry) +{ + return folio_alloc_buffers(page_folio(page), size, retry); +} EXPORT_SYMBOL_GPL(alloc_page_buffers); static inline void diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h index 7e92d23f4782..0b14eab41bd1 100644 --- a/include/linux/buffer_head.h +++ b/include/linux/buffer_head.h @@ -199,6 +199,8 @@ void set_bh_page(struct buffer_head *bh, void folio_set_bh(struct buffer_head *bh, struct folio *folio, unsigned long offset); bool try_to_free_buffers(struct folio *); +struct buffer_head *folio_alloc_buffers(struct folio *folio, unsigned long size, + bool retry); struct buffer_head *alloc_page_buffers(struct page *page, unsigned long size, bool retry); void create_empty_buffers(struct page *, unsigned long, From patchwork Mon Apr 17 12:36:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 13213796 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 03432C77B72 for ; Mon, 17 Apr 2023 12:36:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230347AbjDQMgo (ORCPT ); Mon, 17 Apr 2023 08:36:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230003AbjDQMg2 (ORCPT ); Mon, 17 Apr 2023 08:36:28 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02AF110D3 for ; Mon, 17 Apr 2023 05:36:24 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230417123623euoutp01d34499be020ba52fb55cc393a42957c1~WuQ63wr-v3118431184euoutp01J for ; Mon, 17 Apr 2023 12:36:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230417123623euoutp01d34499be020ba52fb55cc393a42957c1~WuQ63wr-v3118431184euoutp01J DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1681734983; bh=aUa3E5V08ZikWfn868iXTDHcwcBH+bVBiRBvQzjddAI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EhbMnT/ME5sVdzudD7sKG5E6dvawpJVe//57oKg10ZZe0TMoFXy9NN1tejzmht/Ce wAIVy5bOSinapicc0O+nPH1CN2JOWk2h5h/bRfDuEyRFZTnvaKW/ILpAVSy9sjSHBz fiPBlolNP3Kg7q+LPLvrRWMJ3/4Jnet2zRJxARf8= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20230417123622eucas1p144b3a52f4b71560de8d65487f85afb8f~WuQ55FflM1948519485eucas1p1E; Mon, 17 Apr 2023 12:36:22 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 40.F7.09966.64D3D346; Mon, 17 Apr 2023 13:36:22 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20230417123621eucas1p23d1669a8b1e27d4dec64626dcb7fbd78~WuQ5N1jHM2018020180eucas1p2Z; Mon, 17 Apr 2023 12:36:21 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230417123621eusmtrp14d69488370c6e0b7f10b8b2f0b6a4f79~WuQ5NSxvr2401824018eusmtrp12; Mon, 17 Apr 2023 12:36:21 +0000 (GMT) X-AuditID: cbfec7f4-d39ff700000026ee-f8-643d3d468f24 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id AE.38.34412.54D3D346; Mon, 17 Apr 2023 13:36:21 +0100 (BST) Received: from localhost (unknown [106.210.248.243]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230417123621eusmtip295431b3fac9b584894e59afb3bd20519~WuQ490egw0739407394eusmtip2N; Mon, 17 Apr 2023 12:36:21 +0000 (GMT) From: Pankaj Raghav To: viro@zeniv.linux.org.uk, brauner@kernel.org, willy@infradead.org, akpm@linux-foundation.org Cc: linux-fsdevel@vger.kernel.org, mcgrof@kernel.org, linux-kernel@vger.kernel.org, hare@suse.de, gost.dev@samsung.com, Pankaj Raghav Subject: [PATCH 3/4] fs/buffer: add folio_create_empty_buffers helper Date: Mon, 17 Apr 2023 14:36:17 +0200 Message-Id: <20230417123618.22094-4-p.raghav@samsung.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230417123618.22094-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrGKsWRmVeSWpSXmKPExsWy7djPc7putrYpBud2qFnMWb+GzeL14U+M FjcP7GSy2LNoEpDYe5LF4vKuOWwWNyY8ZbT4vLSF3eL83+OsFr9/zGFz4PLYvELLY9OqTjaP EzN+s3j0bVnF6LH5dLXH501yHpuevGUKYI/isklJzcksSy3St0vgyng9+xtTQY9kxastE1ga GBtEuxg5OSQETCTetC9g62Lk4hASWMEosWj/EiYI5wujxPudG1ggnM+MElPf7gByOMBajjSo QMSXM0o0bN3JDuG8ZJT48/UEWBGbgJZEYyc7yAoRgUSJxXu6GUFqmAUWMEo8+bOGGSQhLOAq 0Xh9PZjNIqAqMWfnDDaQXl4BS4mWc2oQ58lL7D94FqyEU8BKYsXmHjCbV0BQ4uTMJywgNjNQ TfPW2cwg8yUE7nBI3D79iRGi2UVi+zWQmSC2sMSr41vYIWwZidOTe1gg7GqJpzd+QzW3MEr0 71zPBvGltUTfmRwQk1lAU2L9Ln2IckeJC3dA/gWp4JO48VYQ4gQ+iUnbpjNDhHklOtqEIKqV JHb+fAK1VELictMcqKUeEpeaP7BNYFScheSZWUiemYWwdwEj8ypG8dTS4tz01GKjvNRyveLE 3OLSvHS95PzcTYzApHT63/EvOxiXv/qod4iRiYPxEKMEB7OSCO8ZV6sUId6UxMqq1KL8+KLS nNTiQ4zSHCxK4rzatieThQTSE0tSs1NTC1KLYLJMHJxSDUwhj1yzHpQfMvyaZ2tWU73pbknR vbfH9u9T9pD6/P9ElXZq47au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z80oEZOv8U3LpiximxRc/LQyn/9pbqWGhNbTWSGfdtd+kjN5u7Tvc7dQSs4N368RYVpr 3+kXrruvbqGyr/lL2Af3zCszCzZ9qvhyzD9re/CRlwVT7eQf3rl66713np7CxOc7ly9LWyj6 xfFj5ySbrI8/vc4dV53R8WmfWZlgz7vH3zI1Lnz4Jjtdgc/OJPS+/+RgNkkJl9i4jY4mHDVa ynMfd0y83f+dd/LPUAb5zNCYxvjMFb2pbcv2K9y8xpv4JOaQ1t5pmqHTVUwyll98aH9b54m0 V+TC077LPz2+LXz2pRJLcUaioRZzUXEiAOnjU6wnAwAA X-CMS-MailID: 20230417123621eucas1p23d1669a8b1e27d4dec64626dcb7fbd78 X-Msg-Generator: CA X-RootMTR: 20230417123621eucas1p23d1669a8b1e27d4dec64626dcb7fbd78 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230417123621eucas1p23d1669a8b1e27d4dec64626dcb7fbd78 References: <20230417123618.22094-1-p.raghav@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Folio version of create_empty_buffers(). This is required to convert create_page_buffers() to folio_create_buffers() later in the series. It removes several calls to compound_head() as it works directly on folio compared to create_empty_buffers(). Hence, create_empty_buffers() has been modified to call folio_create_empty_buffers(). Signed-off-by: Pankaj Raghav Reviewed-by: Matthew Wilcox (Oracle) Reviewed-by: Hannes Reinecke --- fs/buffer.c | 28 +++++++++++++++++----------- include/linux/buffer_head.h | 2 ++ 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/fs/buffer.c b/fs/buffer.c index 75415170e286..13724ef7eec7 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -1593,18 +1593,17 @@ void block_invalidate_folio(struct folio *folio, size_t offset, size_t length) } EXPORT_SYMBOL(block_invalidate_folio); - /* * We attach and possibly dirty the buffers atomically wrt * block_dirty_folio() via private_lock. try_to_free_buffers - * is already excluded via the page lock. + * is already excluded via the folio lock. */ -void create_empty_buffers(struct page *page, - unsigned long blocksize, unsigned long b_state) +void folio_create_empty_buffers(struct folio *folio, unsigned long blocksize, + unsigned long b_state) { struct buffer_head *bh, *head, *tail; - head = alloc_page_buffers(page, blocksize, true); + head = folio_alloc_buffers(folio, blocksize, true); bh = head; do { bh->b_state |= b_state; @@ -1613,19 +1612,26 @@ void create_empty_buffers(struct page *page, } while (bh); tail->b_this_page = head; - spin_lock(&page->mapping->private_lock); - if (PageUptodate(page) || PageDirty(page)) { + spin_lock(&folio->mapping->private_lock); + if (folio_test_uptodate(folio) || folio_test_dirty(folio)) { bh = head; do { - if (PageDirty(page)) + if (folio_test_dirty(folio)) set_buffer_dirty(bh); - if (PageUptodate(page)) + if (folio_test_uptodate(folio)) set_buffer_uptodate(bh); bh = bh->b_this_page; } while (bh != head); } - attach_page_private(page, head); - spin_unlock(&page->mapping->private_lock); + folio_attach_private(folio, head); + spin_unlock(&folio->mapping->private_lock); +} +EXPORT_SYMBOL(folio_create_empty_buffers); + +void create_empty_buffers(struct page *page, + unsigned long blocksize, unsigned long b_state) +{ + folio_create_empty_buffers(page_folio(page), blocksize, b_state); } EXPORT_SYMBOL(create_empty_buffers); diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h index 0b14eab41bd1..1520793c72da 100644 --- a/include/linux/buffer_head.h +++ b/include/linux/buffer_head.h @@ -205,6 +205,8 @@ struct buffer_head *alloc_page_buffers(struct page *page, unsigned long size, bool retry); void create_empty_buffers(struct page *, unsigned long, unsigned long b_state); +void folio_create_empty_buffers(struct folio *folio, unsigned long blocksize, + unsigned long b_state); void end_buffer_read_sync(struct buffer_head *bh, int uptodate); void end_buffer_write_sync(struct buffer_head *bh, int uptodate); void end_buffer_async_write(struct buffer_head *bh, int uptodate); From patchwork Mon Apr 17 12:36:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 13213797 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 3F88DC77B72 for ; Mon, 17 Apr 2023 12:36:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231181AbjDQMgw (ORCPT ); Mon, 17 Apr 2023 08:36:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229914AbjDQMgn (ORCPT ); Mon, 17 Apr 2023 08:36:43 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9EC41706 for ; Mon, 17 Apr 2023 05:36:29 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230417123628euoutp022316f1640d22b970dc8b5172944804de~WuQ-jpkdO3116431164euoutp02i for ; Mon, 17 Apr 2023 12:36:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230417123628euoutp022316f1640d22b970dc8b5172944804de~WuQ-jpkdO3116431164euoutp02i DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1681734988; bh=75KNfTxhmRWwu1RZJ9toOVORdWlwvdSd8OTiAl+Smo4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lDU5O+BSMq3uWBx9pwmYtQeUNDTrnYAvVdxhb40HpyuQ7EHA3poUM5uEILk7vjpNa mRfuLEFC5OrZiBPL3ZOeWs/3e0+daD8ADsa/hf7VAWGeE3pHrwEpqJUtqPnipa8XHW rM2oHd87nwPh58UVJMZDRzb4zcw91I8MHbBZBWEA= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20230417123627eucas1p1c6760ed26e4ff1e4c75da5b623b23ba8~WuQ_xK_UR1066610666eucas1p1r; Mon, 17 Apr 2023 12:36:27 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 34.F7.09966.B4D3D346; Mon, 17 Apr 2023 13:36:27 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20230417123627eucas1p2d3e6824e87d4fdadf459be74845ea0a8~WuQ_aK0gu2096320963eucas1p2S; Mon, 17 Apr 2023 12:36:27 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230417123627eusmtrp11dd2fe97ce12e5ef91d4871ded5a761e~WuQ_Zi88U2401524015eusmtrp1E; Mon, 17 Apr 2023 12:36:27 +0000 (GMT) X-AuditID: cbfec7f4-d39ff700000026ee-0a-643d3d4b0190 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 87.57.22108.B4D3D346; Mon, 17 Apr 2023 13:36:27 +0100 (BST) Received: from localhost (unknown [106.210.248.243]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230417123627eusmtip2753e05ead6617a6d286d2128e6ae72a9~WuQ_OFEe20504505045eusmtip2e; Mon, 17 Apr 2023 12:36:27 +0000 (GMT) From: Pankaj Raghav To: viro@zeniv.linux.org.uk, brauner@kernel.org, willy@infradead.org, akpm@linux-foundation.org Cc: linux-fsdevel@vger.kernel.org, mcgrof@kernel.org, linux-kernel@vger.kernel.org, hare@suse.de, gost.dev@samsung.com, Pankaj Raghav Subject: [PATCH 4/4] fs/buffer: convert create_page_buffers to folio_create_buffers Date: Mon, 17 Apr 2023 14:36:18 +0200 Message-Id: <20230417123618.22094-5-p.raghav@samsung.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230417123618.22094-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrGKsWRmVeSWpSXmKPExsWy7djPc7retrYpBitfG1rMWb+GzeL14U+M FjcP7GSy2LNoEpDYe5LF4vKuOWwWNyY8ZbT4vLSF3eL83+OsFr9/zGFz4PLYvELLY9OqTjaP EzN+s3j0bVnF6LH5dLXH501yHpuevGUKYI/isklJzcksSy3St0vgyrj+6yFTQbtwxfJby9gb GC/zdzFyckgImEjsO/uYpYuRi0NIYAWjxNs965ggnC+MEvd23WKDcD4zSkw4coi9i5EDrOXX Bi+QbiGB5YwSF9akQNS8ZJTY+nQmK0gNm4CWRGMnO0iNiECixOI93YwgNcwCCxglnvxZwwyS EBYIlTix5yEriM0ioCpxaMEvFhCbV8BSouH0FHaI8+Ql9h88C1bPKWAlsWJzDzNEjaDEyZlP wOqZgWqat85mBlkgIXCHQ6Lz7z82iGYXifYNMxghbGGJV8e3QA2VkTg9uYcFwq6WeHrjN1Rz C6NE/871bBBfWkv0nckBMZkFNCXW79KHKHeUeLSoFxoOfBI33gpCnMAnMWnbdGaIMK9ER5sQ RLWSxM6fT6CWSkhcbpoDtdRD4lLrCuYJjIqzkDwzC8kzsxD2LmBkXsUonlpanJueWmyUl1qu V5yYW1yal66XnJ+7iRGYlE7/O/5lB+PyVx/1DjEycTAeYpTgYFYS4T3japUixJuSWFmVWpQf X1Sak1p8iFGag0VJnFfb9mSykEB6YklqdmpqQWoRTJaJg1Oqgckq1sx6i37bE5U/901/3X3z hFMuUNFiosyRNzfbdzk/ehSW3Lpx9ZdISZvsF7pB6Zr3/dI3P9i5wO9rPle6zzXBW7NP8KR+ ObmVnTG65nJt4POTMozzLh94e1Ny7qxrO6riVqgFG+ve/PpTtXrjlMd/vrDx84Y87zwuwvqM NcT3weXlqZnlVcveNjV9e9/9vWZCaIam6T5VI8FEnniWP1duXguVMJq47ael0dMTFfsS8yu1 7GxO1ttkbL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zez4q /eH/eyLbRPCJGts3g79xUytOBm3nrnxtFdoQIp56n/H3pULTjv21u9c5B10vXbvKS1aO2ebl +k1T2r7E9m+q+6YipsRSnJFoqMVcVJwIAHDzDbgoAwAA X-CMS-MailID: 20230417123627eucas1p2d3e6824e87d4fdadf459be74845ea0a8 X-Msg-Generator: CA X-RootMTR: 20230417123627eucas1p2d3e6824e87d4fdadf459be74845ea0a8 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230417123627eucas1p2d3e6824e87d4fdadf459be74845ea0a8 References: <20230417123618.22094-1-p.raghav@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org fs/buffer do not support large folios as there are many assumptions on the folio size to be the host page size. This conversion is one step towards removing that assumption. Also this conversion will reduce calls to compound_head() if folio_create_buffers() calls folio_create_empty_buffers(). Signed-off-by: Pankaj Raghav Reviewed-by: Matthew Wilcox (Oracle) Reviewed-by: Hannes Reinecke --- fs/buffer.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/fs/buffer.c b/fs/buffer.c index 13724ef7eec7..a7fc561758b1 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -1722,14 +1722,17 @@ static inline int block_size_bits(unsigned int blocksize) return ilog2(blocksize); } -static struct buffer_head *create_page_buffers(struct page *page, struct inode *inode, unsigned int b_state) +static struct buffer_head *folio_create_buffers(struct folio *folio, + struct inode *inode, + unsigned int b_state) { - BUG_ON(!PageLocked(page)); + BUG_ON(!folio_test_locked(folio)); - if (!page_has_buffers(page)) - create_empty_buffers(page, 1 << READ_ONCE(inode->i_blkbits), - b_state); - return page_buffers(page); + if (!folio_buffers(folio)) + folio_create_empty_buffers(folio, + 1 << READ_ONCE(inode->i_blkbits), + b_state); + return folio_buffers(folio); } /* @@ -1773,8 +1776,8 @@ int __block_write_full_page(struct inode *inode, struct page *page, int nr_underway = 0; blk_opf_t write_flags = wbc_to_write_flags(wbc); - head = create_page_buffers(page, inode, - (1 << BH_Dirty)|(1 << BH_Uptodate)); + head = folio_create_buffers(page_folio(page), inode, + (1 << BH_Dirty) | (1 << BH_Uptodate)); /* * Be very careful. We have no exclusion from block_dirty_folio @@ -2037,7 +2040,7 @@ int __block_write_begin_int(struct folio *folio, loff_t pos, unsigned len, BUG_ON(to > PAGE_SIZE); BUG_ON(from > to); - head = create_page_buffers(&folio->page, inode, 0); + head = folio_create_buffers(folio, inode, 0); blocksize = head->b_size; bbits = block_size_bits(blocksize); @@ -2323,7 +2326,7 @@ int block_read_full_folio(struct folio *folio, get_block_t *get_block) VM_BUG_ON_FOLIO(folio_test_large(folio), folio); - head = create_page_buffers(&folio->page, inode, 0); + head = folio_create_buffers(folio, inode, 0); blocksize = head->b_size; bbits = block_size_bits(blocksize);