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: 84215 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2103423vqo; Mon, 17 Apr 2023 05:58:25 -0700 (PDT) X-Google-Smtp-Source: AKy350aWv4kkTyPw3SUelcDFbdzhCSWc2a58Hmmh8BbIDxbN2cSbaxMjrUFTFVn+wGJQ8mE/kYwY X-Received: by 2002:a05:6a20:3423:b0:e7:56ad:5a40 with SMTP id i35-20020a056a20342300b000e756ad5a40mr13448536pzd.36.1681736305462; Mon, 17 Apr 2023 05:58:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681736305; cv=none; d=google.com; s=arc-20160816; b=FgJwa0++Hva990ALE+raVPv5v3hG47HVS+rQcr1zkrVPBFXd1BsKOr3SCeHNC3Udxl bxij4YhEHe9wIBieq5/swYRiblle0yMJUkg7vQDdVu6Yer50zOnGBXCTsuTd/rk2yt1T RUINCjXOnU+ZZbK+xlTOgKMvBTeLM8ouVSAwJwDBDhDVdDkr7msQvKvbJSEQ+ZyPqnNu BrnwfFybo/KhspDCwEZx2Evv0ws2DHR+dyFWIgkjk1bSgAjVfT/YvIu8Hi5mEknC/Mfm LBGMLnBE7RLF5c2oiiIWPaNj6Y+jB1ofZ9/e0+R9qClYFf9UnXKrH2OESL/XHaL9i2E6 H5tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:cms-type:content-transfer-encoding :mime-version:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=ToDE43tRnz0p+L+A0Gpl2BjRfNRIfbZq1R5380heax8=; b=pJxoZsORsy4JC6R0uOJMWMAO4nOo60UaKKIuGtlGaJQ7EEeJsCCLt3HSRv5NffbQFB X2yEHv5+6Y9Fo4L1suiZVXOZ4SvR6U2iLM9szPv68SqC36xA3VsoTnn8zVncT3H1futt /RFA/u9oKFT+4XumpODsn/bmFW1m8H5JWmV6hL5oL6QVrJ1m+TLhUBE/1r0qBpbW95ox EhE+vUl3W+2oo1Juwui8mzKLOvCD+SSuyknoHhKsVzCouyHliXYcrp1vKPOVvnJOu/ej 8p6QpGwS4INEaeZPDpgRDytl0LL/QEhYd8lhuiXESxHgfg4nCpHS8MhGzWphLQ29pmCM 49ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=kiT0q720; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k189-20020a6384c6000000b0051b2dfa3e3dsi12663422pgd.738.2023.04.17.05.58.06; Mon, 17 Apr 2023 05:58:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=kiT0q720; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229682AbjDQMgd (ORCPT + 99 others); Mon, 17 Apr 2023 08:36:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229483AbjDQMg1 (ORCPT ); Mon, 17 Apr 2023 08:36:27 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F97D121 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 20230417123621euoutp011ab9098571986831c86447ecd212769b~WuQ5NZkfP3118831188euoutp01S for ; Mon, 17 Apr 2023 12:36:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230417123621euoutp011ab9098571986831c86447ecd212769b~WuQ5NZkfP3118831188euoutp01S 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/d0g61g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fy5rwR+eivPf+RoYb3F1MXJySAiYSDScOMYKYgsJ LGWUeLJMDyIuIXF7YRMjhC0s8edaF1sXIxdQzXNGicmz5zJ1MXJwsAloSTR2soPUiAikSqz4 cweshllgGaPE4e93mUESwgLmEt+6X4EVsQioSsz8tZAJxOYVsJSY9GUCE8QCeYn9B8+C1XMK WEms2NzDDHGQpcT9S9uYIeoFJU7OfMICYjMD1Tdvnc08gVFgFpLULCSpBYxMqxhFUkuLc9Nz i430ihNzi0vz0vWS83M3MQLjZ9uxn1t2MK589VHvECMTB+MhRgkOZiUR3jOuVilCvCmJlVWp RfnxRaU5qcWHGE2B7p7ILCWanA+M4LySeEMzA1NDEzNLA1NLM2MlcV7Pgo5EIYH0xJLU7NTU gtQimD4mDk6pBqb2oPRfH1xeHc1qb/t55b7PrIT1MlGtyaX+972y2Z8uT/s0Sf8vz88ZQl76 x6pk/XSuLeE6r9IntuvPzTs2OcfPp82ySU9vV5MKMJI/21tcdn2t5BfzrK0dFn7XT2te8H8X p3LtmvgzbvkT28XDDb2/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> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763428328245281399?= X-GMAIL-MSGID: =?utf-8?q?1763428328245281399?= 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: 84210 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2102605vqo; Mon, 17 Apr 2023 05:57:00 -0700 (PDT) X-Google-Smtp-Source: AKy350YfZjOXz3iBZ1bXgf5AtNi9I+cnVF1AObHMODtKq7yUhMIAd73rECX6VKCbTPYTOLkhYB/Z X-Received: by 2002:a05:6a00:988:b0:63b:8324:df with SMTP id u8-20020a056a00098800b0063b832400dfmr9801134pfg.0.1681736219860; Mon, 17 Apr 2023 05:56:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681736219; cv=none; d=google.com; s=arc-20160816; b=Zpyy0AJRPtC+LEot/lWLARt/4VHhbueYp1n8EE6Ek/OeGhiMmTFoISrWBlHbRmLAXG n5f+xfS6fohTk+JfZBT3NZPw7Rn/Lnas3W3REqVOG1hVpKXuqOPd7GsM2s/07yrihuAw IyuZFnzuxYZwg/sWyLU/QGrshuk/OtpDQ+hAy8765RFddzGaJdlAC3FimW3z3K129CEi DEynzpqdS/vOSUvfuNtZDh4cdYReoVSaUw2ko/tjl7R3y8OvYWSUkzvDDWkXzZXsIuyI En/5EfwfS+k06SntT7h9XnrQHXdSGfKeAF+nDhTGzP1XABM/jC9puPYuwDwvjZYfZO86 kufg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:cms-type:content-transfer-encoding :mime-version:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=bGcZjkjJ2aM3lpU75XSeXq9MOtiINBQOzSIq1D3EodY=; b=B1FRB3S+ufKY7aHJUoBrXwQyq/9I6Hz9Q8zXcy9EiBri9wpUnG02H+vSYe3amvRCya woOL7fS1n8aMhGZN8dDziN2CgUr9dQsgPh4CuH0QT2t10NLcLUMlNIXhHArffDcP75O0 n7axUbG1AOva+0IZ3SDPbQkkUcFnPHH9H+1bTuXDTSwcHFmetoEFENjA+mqoQ4jlbSsm PoUIfn+OvErk4Xj2hjCgxbzGKt57doSXOuspbyGgaOlM0OAjNp32tpDUpTWIO6kVMGoS xT4urYzzWgB4W3Md93nZdopjymJILzXZKh9jeLxtlAP2CV6YDxojAbgzqy+jjdZ1hiQR 3CXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=YvAkyhrB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w2-20020a623002000000b006262531b3cdsi10976568pfw.356.2023.04.17.05.56.46; Mon, 17 Apr 2023 05:56:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=YvAkyhrB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230185AbjDQMg3 (ORCPT + 99 others); Mon, 17 Apr 2023 08:36:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229957AbjDQMg1 (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 3EE51EE 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 20230417123622euoutp02109b6f669844637eaab7e4aba00f505f~WuQ57q-ZU3115431154euoutp02h for ; Mon, 17 Apr 2023 12:36:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230417123622euoutp02109b6f669844637eaab7e4aba00f505f~WuQ57q-ZU3115431154euoutp02h 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 g0osZ5RYs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zcksSy3St0vQy9i3o5O14KlURduqO0wNjK9Fuxg5OSQETCS2zOxj7GLk 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> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763428238507721831?= X-GMAIL-MSGID: =?utf-8?q?1763428238507721831?= 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: 84205 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2097544vqo; Mon, 17 Apr 2023 05:47:47 -0700 (PDT) X-Google-Smtp-Source: AKy350ZRLAslMDMDogP67OTMh+akyoXqOZZ804FzKH/Jvsic8OJ3c22EQrhbuyZ0Sbwz04nKPmnp X-Received: by 2002:a17:903:138a:b0:1a6:ce48:5700 with SMTP id jx10-20020a170903138a00b001a6ce485700mr5317818plb.33.1681735667124; Mon, 17 Apr 2023 05:47:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681735667; cv=none; d=google.com; s=arc-20160816; b=mmkA4dBg/9RjelRYj/ly3Iq2WV3/JUiI9PkFenCIofzsF8Ebgr2ivDidWNDjGMldhQ Tv8zWoY517suAMu9m64/7zpSwIdLNlMhrs/z7DnNFdqeIA0OJ51Is6j4GWj+H0fby03N lSKwt5qoI9kypqEwFhr9hiRZ/ikP4wNO2BV2AbxZlMBXRamUZVsiUaM0tgctQHdpQY6v GafsqUUEipQ6KW9gVHW0NilSJT+IfRwizUUqnkShj0t1P1DWitYXR4pAWxOd7Z0YBDX3 CUSihW4/yQXlA5Ms1EFHqeUMIhGx4fG0lT8cdhluh9xVCG9ltXjLcFHK4awC10KY+2J4 wtgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:cms-type:content-transfer-encoding :mime-version:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=aUa3E5V08ZikWfn868iXTDHcwcBH+bVBiRBvQzjddAI=; b=mfxSeOOyb0fwU2aaDd1tfdd4ThJI9EEGThuN6k7vQBWYWFrpFHY2QSQatsGeT2/hRe 1OSRUEoyB1Qii8zcN3+EEXOH33WVQwB9XjPgfdK11ihlOfu7Svssej/9WGzEbTcBneri XCQYWGA7dQvxjwPXyWNPClXmT+b0Z3KpHpJIXTV0ZFUAAspFr9yfe4i6khVKhZQd9sZ8 hFddgfH4Dbe3Lbf+EB3cqJg976ocI+7EuiFuZc9J/opbfNLq8BCCfchkPWEivfITHNkL chmCdhggrow4xPkH0p6EecJfABjWijApmXdJF0qvaBIq470dV1wN+Z/o0oIybbjPy2F3 ia3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b="EhbMnT/M"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c18-20020a170902d49200b0019f33cb669asi12767846plg.615.2023.04.17.05.47.33; Mon, 17 Apr 2023 05:47:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b="EhbMnT/M"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230509AbjDQMgo (ORCPT + 99 others); Mon, 17 Apr 2023 08:36:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230000AbjDQMg2 (ORCPT ); Mon, 17 Apr 2023 08:36:28 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02BC210FA for ; Mon, 17 Apr 2023 05:36:24 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230417123623euoutp02f5ce65b8a3214331d451e57a405c48b9~WuQ63zRwT2961429614euoutp02T for ; Mon, 17 Apr 2023 12:36:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230417123623euoutp02f5ce65b8a3214331d451e57a405c48b9~WuQ63zRwT2961429614euoutp02T 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+fAK1VELictMcqKUeEp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020itOzC0uzUvXS87P3cQIjJ5tx35u2cG48tVHvUOMTByMhxglOJiVRHjPuFqlCPGmJFZW pRblxxeV5qQWH2I0BTp7IrOUaHI+MH7zSuINzQxMDU3MLA1MLc2MlcR5PQs6EoUE0hNLUrNT UwtSi2D6mDg4pRqYeP490HK5IX6Sp+5L0JVpKVfm9D84+2fypNVr9CwFcjzuap83K3pU5fFJ r3QFz80oEZOv8U3LpiximxRc/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> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763427658438002561?= X-GMAIL-MSGID: =?utf-8?q?1763427658438002561?= 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: 84218 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2103713vqo; Mon, 17 Apr 2023 05:58:55 -0700 (PDT) X-Google-Smtp-Source: AKy350ZFUlIW+hZn1wyheij1KDyIVL/u1ZqSbbMcFh6Clh14KblLHpKJA3iZT6an3JNbHw1oYwYO X-Received: by 2002:a17:90a:654a:b0:234:d78:9b4c with SMTP id f10-20020a17090a654a00b002340d789b4cmr15063921pjs.18.1681736335026; Mon, 17 Apr 2023 05:58:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681736335; cv=none; d=google.com; s=arc-20160816; b=gYsi/dqScSsCuSSya1nW4fnAduw8eGcViifGaejt51obfkyqjbwG5UryfobDMW5pMr TEw6/jLotfVBLD59u0JQLiwoz7xlGExIIhdPyFWH1Hk5H8BGWZ1gXVk0VHeAKwLE4yf6 Hlev4g6mCtaDR+3oR8uO67ikbyiBQcpZQk5VT+Kw1/ZI8SA8srNdAXXY0EMtS6+pl5B2 +f1/2DmAU+Xi8eHhAf1JiOm/JX/6wldiT09XE5XBOSafdDJEjwwsjPX5nFO+3Q+WJeia afsH0iHdMsFa3zULFCuc+ODjremYpc6hzbkP6WUO9iUVHl4EMdmRNQhqNu0P3cB7PVAP Tvnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:cms-type:content-transfer-encoding :mime-version:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=75KNfTxhmRWwu1RZJ9toOVORdWlwvdSd8OTiAl+Smo4=; b=NRp24C1F2O88WKvcGlPaAO+5+taOz3xPHRAH10EGRyqgsv39Bjb5hHrcafrEj1SMoL yymy5fuivyhJy3DoKef2FxfqpwsDp6La9d2Qoxcd+/nHZGkylXI9c5BaV9wcl1RrPHmA EtNn8drSCc+HMVosRKul2x8oDKuyeX28evtiqCIXQb4MeMJyBxmDF/lnfyfFo6kNGWz4 YYq6gvozpLEEtCIzWBuPDHSdn7xMy+kURPkyfDT7tgf6qqZexQDXqQYHJHxKorOukgV2 xTqS3lIGaaPIebAf9pUCEk5+/RiCtZ6CTFAXRnlwfdUVIM462tXwOEK3oPDAqwNu4mct ovBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=lDU5O+BS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kk1-20020a17090b4a0100b0024730b93a6asi10693049pjb.147.2023.04.17.05.58.42; Mon, 17 Apr 2023 05:58:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=lDU5O+BS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230498AbjDQMgw (ORCPT + 99 others); Mon, 17 Apr 2023 08:36:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229574AbjDQMgn (ORCPT ); Mon, 17 Apr 2023 08:36:43 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DAFD0199C for ; Mon, 17 Apr 2023 05:36:29 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230417123628euoutp01780e5e6266e9d5769c1025e164cdd21f~WuQ-kKgVG3176731767euoutp01u for ; Mon, 17 Apr 2023 12:36:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230417123628euoutp01780e5e6266e9d5769c1025e164cdd21f~WuQ-kKgVG3176731767euoutp01u 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 NcT3weXlqZnlVcve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H5O4mvZqaVDZtaU3n+TnOVoHpU/oaHfZbHXwy8Wn/dPzTrVMWv9U7M3UW4Kzez4q /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> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763428359365408839?= X-GMAIL-MSGID: =?utf-8?q?1763428359365408839?= 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);