From patchwork Fri Apr 14 11:08: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: 13211283
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 CBD17C77B6E
for ;
Fri, 14 Apr 2023 11:08:36 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S230499AbjDNLIf (ORCPT
);
Fri, 14 Apr 2023 07:08:35 -0400
Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44540 "EHLO
lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S230329AbjDNLIc (ORCPT
);
Fri, 14 Apr 2023 07:08:32 -0400
Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com
[210.118.77.11])
by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 606D810CF
for ;
Fri, 14 Apr 2023 04:08:29 -0700 (PDT)
Received: from eucas1p1.samsung.com (unknown [182.198.249.206])
by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id
20230414110827euoutp0176f7a6cdc45270f78f14d542108da79c~VyIR2SI6k1324913249euoutp013
for ;
Fri, 14 Apr 2023 11:08:27 +0000 (GMT)
DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com
20230414110827euoutp0176f7a6cdc45270f78f14d542108da79c~VyIR2SI6k1324913249euoutp013
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com;
s=mail20170921; t=1681470507;
bh=bj8baqlJ3xbqI4cUC/UA6zmhZCxhKwgx39HkAQuD4fg=;
h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
b=gJISNXnTsYVWM4Je5xvVmkSAvxU8nLYiklXi+ekE7Us/8AYm36M37epx6EY7vOwDb
6RFXFTusHUK997hKX9krM8ZSxmrB4OxqZmY3wf7jKkbMqeC1s9HXo2MpSoFLG9grsp
qwq5sYtg1MxosYYUzrI0L0S3SZ0c0OpdJjs7RvE4=
Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTP id
20230414110826eucas1p2ce40f92dab528798642e4e76e1afb140~VyIQ_A9TV3129031290eucas1p26;
Fri, 14 Apr 2023 11:08:26 +0000 (GMT)
Received: from eucas1p2.samsung.com ( [182.198.249.207]) by
eusmges2new.samsung.com (EUCPMTA) with SMTP id 9B.25.09966.A2439346;
Fri, 14
Apr 2023 12:08:26 +0100 (BST)
Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTPA id
20230414110825eucas1p2faad8162ee3aac7ed17f735dcbfc2334~VyIQtuKk_0295002950eucas1p2C;
Fri, 14 Apr 2023 11:08:25 +0000 (GMT)
Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by
eusmtrp2.samsung.com (KnoxPortal) with ESMTP id
20230414110825eusmtrp205bbbc45cef585744a33e1411797f63e~VyIQtHsbg0970009700eusmtrp2R;
Fri, 14 Apr 2023 11:08:25 +0000 (GMT)
X-AuditID: cbfec7f4-d4fff700000026ee-e5-6439342af1b7
Received: from eusmtip2.samsung.com ( [203.254.199.222]) by
eusmgms2.samsung.com (EUCPMTA) with SMTP id 3D.39.34412.92439346;
Fri, 14
Apr 2023 12:08:25 +0100 (BST)
Received: from localhost (unknown [106.210.248.243]) by eusmtip2.samsung.com
(KnoxPortal) with ESMTPA id
20230414110825eusmtip2dfbef8e4c6f27559c80bf91e2d130d7b~VyIQhBV2z1802118021eusmtip2c;
Fri, 14 Apr 2023 11:08:25 +0000 (GMT)
From: Pankaj Raghav
To: brauner@kernel.org, willy@infradead.org, viro@zeniv.linux.org.uk,
akpm@linux-foundation.org
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
mcgrof@kernel.org, gost.dev@samsung.com, hare@suse.de,
Pankaj Raghav
Subject: [RFC 1/4] fs/buffer: add set_bh_folio helper
Date: Fri, 14 Apr 2023 13:08:18 +0200
Message-Id: <20230414110821.21548-2-p.raghav@samsung.com>
X-Mailer: git-send-email 2.34.1
In-Reply-To: <20230414110821.21548-1-p.raghav@samsung.com>
MIME-Version: 1.0
X-Brightmail-Tracker:
H4sIAAAAAAAAA+NgFlrKKsWRmVeSWpSXmKPExsWy7djP87paJpYpBg8fc1jMWb+GzeL14U+M
FjcP7GSy2LNoEpDYe5LF4vKuOWwWNyY8ZbT4vLSF3eL83+OsFr9/zGFz4PLYvELLY9OqTjaP
EzN+s3j0bVnF6LH5dLXH501yHpuevGUKYI/isklJzcksSy3St0vgyljx6TRLwR+eik8XHrI0
MN7i6mLk5JAQMJF4NuUNexcjF4eQwApGidvTbzCBJIQEvjBKrLlvApH4zChxacdDZpiOI5v+
M0EkljNKXP/RzwzR8ZJRYtoN7y5GDg42AS2Jxk52EFNEIFHi5nsFkHJmgQWMErduv2cHKRcW
MJXYs/gLWCuLgKrEgq5GNhCbV8BSYtmNdjaIXfIS+w+eBavhFLCSeLPsAlSNoMTJmU9YQGxm
oJrmrbOZQRZICNzhkGi7dYgVotlFYsW0qVC2sMSr41vYIWwZif875zNB2NUST2/8hmpuYZTo
37meDeRqCQFrib4zOSAms4CmxPpd+hDljhIv+/qZICr4JG68FYQ4gU9i0rbpzBBhXomONiGI
aiWJnT+fQC2VkLjcNIcFwvaQWDfjA9sERsVZSJ6ZheSZWQh7FzAyr2IUTy0tzk1PLTbKSy3X
K07MLS7NS9dLzs/dxAhMSaf/Hf+yg3H5q496hxiZOBgPMUpwMCuJ8P5wMU0R4k1JrKxKLcqP
LyrNSS0+xCjNwaIkzqttezJZSCA9sSQ1OzW1ILUIJsvEwSnVwCTy5lehfec1wR8vljTelPTf
3XP+sIHSs5O5OVqlLxus3pl6tHz/uVHE8cWB8K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OHNSYvO+U1XHdzzhmLH61x/1istvJ2wwPZbffHi6j3NynMKNlIYg
X/434lPuXbyo6P7+/tNr95KuK79+c/FP4N64Qts1d+YcrdWpqQoUSXpR9/um4b0fM2O2fFl9
frc523o2F5EjDQl172t0Sm94+l9Puf/pE7NigqZlYftHXe15npvi8iz2Mcje06lYkXKQZd0J
nRSX/ft7ryj+cZrwpOdUb6b6svSCW74n5YInHF1xutJpTdvi93qdfzYGRsosKuc7WPPRb++t
Y3tmv+raaHJ+WpkSS3FGoqEWc1FxIgC7JStKKgMAAA==
X-CMS-MailID: 20230414110825eucas1p2faad8162ee3aac7ed17f735dcbfc2334
X-Msg-Generator: CA
X-RootMTR: 20230414110825eucas1p2faad8162ee3aac7ed17f735dcbfc2334
X-EPHeader: CA
CMS-TYPE: 201P
X-CMS-RootMailID: 20230414110825eucas1p2faad8162ee3aac7ed17f735dcbfc2334
References: <20230414110821.21548-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 create_folio_buffers() later in the series.
Signed-off-by: Pankaj Raghav
---
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..44380ff3a31f 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 set_bh_folio(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(set_bh_folio);
+
/*
* 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..d5a2ef9b4cdf 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 set_bh_folio(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 Fri Apr 14 11:08:19 2023
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pankaj Raghav
X-Patchwork-Id: 13211282
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 DAA6EC77B6F
for ;
Fri, 14 Apr 2023 11:08:35 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S230479AbjDNLIe (ORCPT
);
Fri, 14 Apr 2023 07:08:34 -0400
Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44542 "EHLO
lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S230335AbjDNLIc (ORCPT
);
Fri, 14 Apr 2023 07:08:32 -0400
Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com
[210.118.77.12])
by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60344199
for ;
Fri, 14 Apr 2023 04:08:29 -0700 (PDT)
Received: from eucas1p2.samsung.com (unknown [182.198.249.207])
by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id
20230414110827euoutp02937ad90799f08982ff53b97a81f790fd~VyISSaBtr0810608106euoutp02f
for ;
Fri, 14 Apr 2023 11:08:27 +0000 (GMT)
DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com
20230414110827euoutp02937ad90799f08982ff53b97a81f790fd~VyISSaBtr0810608106euoutp02f
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com;
s=mail20170921; t=1681470507;
bh=lOgNCG8+j9glN6g01kkt3qiHQuDvi5vkCnsii6V5uAc=;
h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
b=iWE/tHfMioyKOEecs7lOsNIQD2wiGi4J7iD8mokUHLffG+SDIfB67l00xjQU6B7l8
SDbJgpoQjal9+YvVKmOUsjsoV0e9GkVPr184l8ekaZjt7e13/2G9v/YrDEpYeXsTjY
tm5O2pRzURtX+2At0XfxyEaJTluNzrFPEvCtFcCs=
Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTP id
20230414110826eucas1p2801083c055bbebf8b958862c5a463047~VyIRh-Xsc3134131341eucas1p21;
Fri, 14 Apr 2023 11:08:26 +0000 (GMT)
Received: from eucas1p2.samsung.com ( [182.198.249.207]) by
eusmges2new.samsung.com (EUCPMTA) with SMTP id 1D.25.09966.A2439346;
Fri, 14
Apr 2023 12:08:26 +0100 (BST)
Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTPA id
20230414110826eucas1p2c5afcbd64c536a803751b41d03eb9e99~VyIRPTb5z0087400874eucas1p2A;
Fri, 14 Apr 2023 11:08:26 +0000 (GMT)
Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by
eusmtrp2.samsung.com (KnoxPortal) with ESMTP id
20230414110826eusmtrp201580c3c89bd58675a349e7c6c7667b0~VyIROq8NL0913109131eusmtrp2V;
Fri, 14 Apr 2023 11:08:26 +0000 (GMT)
X-AuditID: cbfec7f4-d39ff700000026ee-e8-6439342a5fc5
Received: from eusmtip2.samsung.com ( [203.254.199.222]) by
eusmgms2.samsung.com (EUCPMTA) with SMTP id FD.39.34412.A2439346;
Fri, 14
Apr 2023 12:08:26 +0100 (BST)
Received: from localhost (unknown [106.210.248.243]) by eusmtip2.samsung.com
(KnoxPortal) with ESMTPA id
20230414110826eusmtip2f71aa69c101c25276f134b498a5df907~VyIRCV4Yn2606126061eusmtip2f;
Fri, 14 Apr 2023 11:08:26 +0000 (GMT)
From: Pankaj Raghav
To: brauner@kernel.org, willy@infradead.org, viro@zeniv.linux.org.uk,
akpm@linux-foundation.org
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
mcgrof@kernel.org, gost.dev@samsung.com, hare@suse.de,
Pankaj Raghav
Subject: [RFC 2/4] buffer: add alloc_folio_buffers() helper
Date: Fri, 14 Apr 2023 13:08:19 +0200
Message-Id: <20230414110821.21548-3-p.raghav@samsung.com>
X-Mailer: git-send-email 2.34.1
In-Reply-To: <20230414110821.21548-1-p.raghav@samsung.com>
MIME-Version: 1.0
X-Brightmail-Tracker:
H4sIAAAAAAAAA02Sa0hTYRjHe3fm2XE4Oc7KB7O0dTOb617HZlphdKI++KWIAm3p8VJz2ubK
MkIrlkuadsNLC+1m5qqRM2tm1IyctzAScjNQyllpmXjBVlLL0zHqy8vveZ7//7nAS2Diq16B
RKoqk1GrFEoJLuTXNn5vDw9bFZG4zHMinDKa7+DU5+cjiHI+s/Ko+mvnJ58nzXyqo86IU47C
PkSN3jwloNp/2r2oCbcR3yCkLZVhdHWVHqebiif4tKGmCtGW1mx6tHoOXe0a5MUKdgsjExll
6iFGvTRqrzDF9jguI98va3jYg+egDtEZ5E0AuQp+OnWCM0hIiMlKBOc8N3hcMIbA8L4XccEo
gp47bZMV4o/FrMNZt5i8hSC/7CCn6UdQ9sSOsxqcDINcvYDF6aQCnEMhrAQjyxF0vR0SsF5/
Ug4FZ99hrIZPLoB7RTPZtIiMgEsOC8YtFwxPbS//sDe5Dr5UvMI5jR80l7j4LGOTmpMPLmNs
fyAdBHzS26fWjIFc51qujz8M2GsEHAeBx1rG4zgb+hw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hAWiXlDi5MwnYDYzUH3z1tnMExgFZiFJzUKSWsDItIpRJLW0ODc9t9hI
rzgxt7g0L10vOT93EyMwerYd+7llB+PKVx/1DjEycTAeYpTgYFYS4f3hYpoixJuSWFmVWpQf
X1Sak1p8iNEU6OyJzFKiyfnA+M0riTc0MzA1NDGzNDC1NDNWEuf1LOhIFBJITyxJzU5NLUgt
gulj4uCUamCa+16y507ZkiPKpbof33/4c6v73aW7PjEptosKFrDFRIgEnt56I9QpaX1l3f5d
1TvNml4+PZddfO+gGt/K7zOic8xEk07sjeypyP70/qDA758tBjlG00PqJnz+z1uvvrL/jp7l
bFe9DfLhP6sfiNcKWNiHrby8hPX8lN/Z/h/dw7RF9y1fc0tn4UqvSQ+mBDU/vF3d+lTSQ9Wh
T8ghRHu7xAqDrY/vvQv9lauusOJsj/RE9d8KdpZph7UWvpNYNH/z2yLd+A8nvt/1bDcUWXE3
T3PmJPXC/hsRokz8uj9nrb0deXbbPd8Oh5uv1oWph79dlbO/5NodwbSHLDle7438pinnCC6v
nNIeYGH0Z/4XJZbijERDLeai4kQAKyWFnycDAAA=
X-CMS-MailID: 20230414110826eucas1p2c5afcbd64c536a803751b41d03eb9e99
X-Msg-Generator: CA
X-RootMTR: 20230414110826eucas1p2c5afcbd64c536a803751b41d03eb9e99
X-EPHeader: CA
CMS-TYPE: 201P
X-CMS-RootMailID: 20230414110826eucas1p2c5afcbd64c536a803751b41d03eb9e99
References: <20230414110821.21548-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 create_folio_buffers() later in the series.
It removes one call to compound_head() compared to alloc_page_buffers().
Signed-off-by: Pankaj Raghav
---
fs/buffer.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 59 insertions(+)
diff --git a/fs/buffer.c b/fs/buffer.c
index 44380ff3a31f..0f9c2127543d 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -900,6 +900,65 @@ struct buffer_head *alloc_page_buffers(struct page *page, unsigned long size,
}
EXPORT_SYMBOL_GPL(alloc_page_buffers);
+/*
+ * 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.
+ *
+ * The retry flag is used to differentiate async IO (paging, swapping)
+ * which may not fail from ordinary buffer allocations.
+ */
+struct buffer_head *alloc_folio_buffers(struct folio *folio, unsigned long size,
+ bool retry)
+{
+ struct buffer_head *bh, *head;
+ gfp_t gfp = GFP_NOFS | __GFP_ACCOUNT;
+ long offset;
+ struct mem_cgroup *memcg, *old_memcg;
+
+ if (retry)
+ gfp |= __GFP_NOFAIL;
+
+ /* The folio lock pins the memcg */
+ memcg = folio_memcg(folio);
+ old_memcg = set_active_memcg(memcg);
+
+ head = NULL;
+ offset = folio_size(folio);
+ while ((offset -= size) >= 0) {
+ bh = alloc_buffer_head(gfp);
+ if (!bh)
+ goto no_grow;
+
+ bh->b_this_page = head;
+ bh->b_blocknr = -1;
+ head = bh;
+
+ bh->b_size = size;
+
+ /* Link the buffer to its folio */
+ set_bh_folio(bh, folio, offset);
+ }
+out:
+ set_active_memcg(old_memcg);
+ return head;
+/*
+ * In case anything failed, we just free everything we got.
+ */
+no_grow:
+ if (head) {
+ do {
+ bh = head;
+ head = head->b_this_page;
+ free_buffer_head(bh);
+ } while (head);
+ }
+
+ goto out;
+}
+EXPORT_SYMBOL_GPL(alloc_folio_buffers);
+
static inline void
link_dev_buffers(struct page *page, struct buffer_head *head)
{
From patchwork Fri Apr 14 11:08:20 2023
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pankaj Raghav
X-Patchwork-Id: 13211285
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 AFFD1C77B70
for ;
Fri, 14 Apr 2023 11:08:46 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S230399AbjDNLIp (ORCPT
);
Fri, 14 Apr 2023 07:08:45 -0400
Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44566 "EHLO
lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S230463AbjDNLId (ORCPT
);
Fri, 14 Apr 2023 07:08:33 -0400
Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com
[210.118.77.11])
by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48376199
for ;
Fri, 14 Apr 2023 04:08:32 -0700 (PDT)
Received: from eucas1p1.samsung.com (unknown [182.198.249.206])
by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id
20230414110828euoutp01b80a6f1c999863b761e11d2132973803~VyITFP6hH1543415434euoutp01B
for ;
Fri, 14 Apr 2023 11:08:28 +0000 (GMT)
DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com
20230414110828euoutp01b80a6f1c999863b761e11d2132973803~VyITFP6hH1543415434euoutp01B
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com;
s=mail20170921; t=1681470508;
bh=RSOGq3FrSoWTKQkTpr/5r4j+YAAPIjwLJMcrhoIlH+4=;
h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
b=IAd/6DAlYvu1XMnSEnNRo3E1VZqJdS/vehvklGbj1gkudXKyHHQgllpmPwUYlwy9f
8QKY2GBaMdc3Bp4CijVny51VDtGZD8eMm0jFmIDiWSQoZJkPd3HuckBU868rTPnw/n
y85BWFmn1YmUBdo8/3VDatm6ptTtHaC4n6WXRO2E=
Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTP id
20230414110827eucas1p207835504e487b376ebad539ba5144250~VyISKgiwV0186801868eucas1p2t;
Fri, 14 Apr 2023 11:08:27 +0000 (GMT)
Received: from eucas1p1.samsung.com ( [182.198.249.206]) by
eusmges1new.samsung.com (EUCPMTA) with SMTP id 32.9A.09503.B2439346;
Fri, 14
Apr 2023 12:08:27 +0100 (BST)
Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by
eucas1p1.samsung.com (KnoxPortal) with ESMTPA id
20230414110827eucas1p1b872c350b7e81f01e65ba0985082ba20~VyIR1VkI60084500845eucas1p1O;
Fri, 14 Apr 2023 11:08:27 +0000 (GMT)
Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by
eusmtrp2.samsung.com (KnoxPortal) with ESMTP id
20230414110827eusmtrp21c4f119e4cab5295de4520b22e69c302~VyIR0o5fz0913109131eusmtrp2W;
Fri, 14 Apr 2023 11:08:27 +0000 (GMT)
X-AuditID: cbfec7f2-e8fff7000000251f-9c-6439342b055f
Received: from eusmtip1.samsung.com ( [203.254.199.221]) by
eusmgms2.samsung.com (EUCPMTA) with SMTP id CE.39.34412.A2439346;
Fri, 14
Apr 2023 12:08:26 +0100 (BST)
Received: from localhost (unknown [106.210.248.243]) by eusmtip1.samsung.com
(KnoxPortal) with ESMTPA id
20230414110826eusmtip1e7db1c25fda031f3dd0ba138dcb74441~VyIRme_cz1969519695eusmtip1h;
Fri, 14 Apr 2023 11:08:26 +0000 (GMT)
From: Pankaj Raghav
To: brauner@kernel.org, willy@infradead.org, viro@zeniv.linux.org.uk,
akpm@linux-foundation.org
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
mcgrof@kernel.org, gost.dev@samsung.com, hare@suse.de,
Pankaj Raghav
Subject: [RFC 3/4] fs/buffer: add folio_create_empty_buffers helper
Date: Fri, 14 Apr 2023 13:08:20 +0200
Message-Id: <20230414110821.21548-4-p.raghav@samsung.com>
X-Mailer: git-send-email 2.34.1
In-Reply-To: <20230414110821.21548-1-p.raghav@samsung.com>
MIME-Version: 1.0
X-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GBy8UFgn0OgpuFjryYHrbhR9dSZlNk3Py771bseXjpYPi5eXJ7x7djU47Fs92
0KYnR+f7HWZ7JZbijERDLeai4kQAfZNdcigDAAA=
X-CMS-MailID: 20230414110827eucas1p1b872c350b7e81f01e65ba0985082ba20
X-Msg-Generator: CA
X-RootMTR: 20230414110827eucas1p1b872c350b7e81f01e65ba0985082ba20
X-EPHeader: CA
CMS-TYPE: 201P
X-CMS-RootMailID: 20230414110827eucas1p1b872c350b7e81f01e65ba0985082ba20
References: <20230414110821.21548-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 create_folio_buffers() later in the series.
It removes several calls to compound_head() as it works directly on folio
compared to create_empty_buffers().
Signed-off-by: Pankaj Raghav
---
fs/buffer.c | 34 ++++++++++++++++++++++++++++++++++
include/linux/buffer_head.h | 2 ++
2 files changed, 36 insertions(+)
diff --git a/fs/buffer.c b/fs/buffer.c
index 0f9c2127543d..9e6a1a738fb5 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -1645,6 +1645,40 @@ 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 folio lock.
+ */
+void folio_create_empty_buffers(struct folio *folio, unsigned long blocksize,
+ unsigned long b_state)
+{
+ struct buffer_head *bh, *head, *tail;
+
+ head = alloc_folio_buffers(folio, blocksize, true);
+ bh = head;
+ do {
+ bh->b_state |= b_state;
+ tail = bh;
+ bh = bh->b_this_page;
+ } while (bh);
+ tail->b_this_page = head;
+
+ spin_lock(&folio->mapping->private_lock);
+ if (folio_test_uptodate(folio) || folio_test_dirty(folio)) {
+ bh = head;
+ do {
+ if (folio_test_dirty(folio))
+ set_buffer_dirty(bh);
+ if (folio_test_uptodate(folio))
+ set_buffer_uptodate(bh);
+ bh = bh->b_this_page;
+ } while (bh != head);
+ }
+ folio_attach_private(folio, head);
+ spin_unlock(&folio->mapping->private_lock);
+}
+EXPORT_SYMBOL(folio_create_empty_buffers);
/*
* We attach and possibly dirty the buffers atomically wrt
diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h
index d5a2ef9b4cdf..8afa91cbb8e2 100644
--- a/include/linux/buffer_head.h
+++ b/include/linux/buffer_head.h
@@ -203,6 +203,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 *, unsigned long,
+ 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 Fri Apr 14 11:08:21 2023
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pankaj Raghav
X-Patchwork-Id: 13211284
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 190CCC77B77
for ;
Fri, 14 Apr 2023 11:08:38 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S231124AbjDNLIg (ORCPT
);
Fri, 14 Apr 2023 07:08:36 -0400
Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44548 "EHLO
lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S230385AbjDNLIc (ORCPT
);
Fri, 14 Apr 2023 07:08:32 -0400
Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com
[210.118.77.12])
by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40DBE2683
for ;
Fri, 14 Apr 2023 04:08:30 -0700 (PDT)
Received: from eucas1p2.samsung.com (unknown [182.198.249.207])
by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id
20230414110829euoutp02af8c0c92427fff057ed68d6ca9b76c6a~VyITtjsUI0816708167euoutp02Q
for ;
Fri, 14 Apr 2023 11:08:29 +0000 (GMT)
DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com
20230414110829euoutp02af8c0c92427fff057ed68d6ca9b76c6a~VyITtjsUI0816708167euoutp02Q
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com;
s=mail20170921; t=1681470509;
bh=mYP1zNZlkNSFYYEZy1X4gVz5Ukcj0nQ95dBohrnlJJM=;
h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
b=Fbx4sqB55TW2FIa6EbR+LpMXJuU6PZqdqlPW/7FVdgNspqOTNdJZizrnu3VNCjKVj
MDk67wo/G75wy+a3bsVu0xUQ5UBYyzQbr4ayulLqmdMgKGD4REB/O6NVtKTZw5tJch
GpZavB1tnFRYrQEdoVsy0S4bYjXMx2/UdbJ2HMHE=
Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTP id
20230414110828eucas1p27a02cf6a0489c892cebb71a142cd12d6~VyIS6P83_0295002950eucas1p2D;
Fri, 14 Apr 2023 11:08:28 +0000 (GMT)
Received: from eucas1p2.samsung.com ( [182.198.249.207]) by
eusmges1new.samsung.com (EUCPMTA) with SMTP id 73.9A.09503.C2439346;
Fri, 14
Apr 2023 12:08:28 +0100 (BST)
Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTPA id
20230414110827eucas1p20e5f6bc74025acfb62b13465f267fa84~VyISX3-6I0896208962eucas1p2W;
Fri, 14 Apr 2023 11:08:27 +0000 (GMT)
Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by
eusmtrp2.samsung.com (KnoxPortal) with ESMTP id
20230414110827eusmtrp23a6f6eb3620adf6cec0cd8f777b64956~VyISXJW7G0913109131eusmtrp2X;
Fri, 14 Apr 2023 11:08:27 +0000 (GMT)
X-AuditID: cbfec7f2-ea5ff7000000251f-9f-6439342c4e39
Received: from eusmtip2.samsung.com ( [203.254.199.222]) by
eusmgms2.samsung.com (EUCPMTA) with SMTP id DF.39.34412.B2439346;
Fri, 14
Apr 2023 12:08:27 +0100 (BST)
Received: from localhost (unknown [106.210.248.243]) by eusmtip2.samsung.com
(KnoxPortal) with ESMTPA id
20230414110827eusmtip23f72b25a7070947a365203c3b088f67a~VyISIV5tx2822728227eusmtip2L;
Fri, 14 Apr 2023 11:08:27 +0000 (GMT)
From: Pankaj Raghav
To: brauner@kernel.org, willy@infradead.org, viro@zeniv.linux.org.uk,
akpm@linux-foundation.org
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
mcgrof@kernel.org, gost.dev@samsung.com, hare@suse.de,
Pankaj Raghav
Subject: [RFC 4/4] fs/buffer: convert create_page_buffers to
create_folio_buffers
Date: Fri, 14 Apr 2023 13:08:21 +0200
Message-Id: <20230414110821.21548-5-p.raghav@samsung.com>
X-Mailer: git-send-email 2.34.1
In-Reply-To: <20230414110821.21548-1-p.raghav@samsung.com>
MIME-Version: 1.0
X-Brightmail-Tracker:
H4sIAAAAAAAAA+NgFlrGKsWRmVeSWpSXmKPExsWy7djP87o6JpYpBk/XcVjMWb+GzeL14U+M
FjcP7GSy2LNoEpDYe5LF4vKuOWwWNyY8ZbT4vLSF3eL83+OsFr9/zGFz4PLYvELLY9OqTjaP
EzN+s3j0bVnF6LH5dLXH501yHpuevGUKYI/isklJzcksSy3St0vgytjbuJCxoF244tduqQbG
y/xdjJwcEgImEtOOXGTpYuTiEBJYwSjRsuAmE4TzhVFi9c6b7BDOZ0aJxdP+M8O0XN92gBEi
sRwo0TwFynnJKLFxfS9bFyMHB5uAlkRjJzuIKSKQKHHzvQJICbPAAkaJW7ffs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y9jbuJCxoF244tduqQbGy/xdjJwcEgImEte3HWDsYuTi
EBJYyihx7vEadoiEhMTthU2MELawxJ9rXWwQRc8ZJW6fX8jcxcjBwSagJdHYCVYvIpAqcfrE
R7AaZoFljBJr5r5gA0kICwRKrJ9+GMxmEVCVuHV8J5jNK2ApcXjtZqhl8hL7D55lBrE5Bawk
3iy7AFYjBFTTvmUJC0S9oMTJmU/AbGag+uats5knMArMQpKahSS1gJFpFaNIamlxbnpusZFe
cWJucWleul5yfu4mRmAEbTv2c8sOxpWvPuodYmTiYDzEKMHBrCTC+8PFNEWINyWxsiq1KD++
qDQntfgQoynQ3ROZpUST84ExnFcSb2hmYGpoYmZpYGppZqwkzutZ0JEoJJCeWJKanZpakFoE
08fEwSnVwMT7/2TDms6105SNpu9nZNOK+uijlX7i3v5gRmdzb0nvkGjdBRtuZbIKcJvt6pOc
t1htV7GXiL9+gHr1PC6rurkX7z0+73D2dZ92euW+s8es/5zV9Lt83VvnvNbW6sCXsyfs/Dc/
fK1qZE0c56Svhu7KNvPZ9V6onSsXV8pc9FPX+rLVw8vXdVOTzX97vGXPkC5SUWc7GxCy1k3n
zCm5cLXVHu/Ko5bEHPKpCZRLYlL52a63Yv0LpxNBalN3TWUr3nxs63qvBfcnTfFJ97fyuHF0
9pxVd2w2l7/e8CJ/y8t0tdql1Y4+taxL/PKF3YsF9DhsLm/w+N24MPzfzay5Z1/8kk59XM95
dNucwoqrm5VYijMSDbWYi4oTAdGKN2opAwAA
X-CMS-MailID: 20230414110827eucas1p20e5f6bc74025acfb62b13465f267fa84
X-Msg-Generator: CA
X-RootMTR: 20230414110827eucas1p20e5f6bc74025acfb62b13465f267fa84
X-EPHeader: CA
CMS-TYPE: 201P
X-CMS-RootMailID: 20230414110827eucas1p20e5f6bc74025acfb62b13465f267fa84
References: <20230414110821.21548-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 create_folio_buffers() calls
folio_create_empty_buffers().
Signed-off-by: Pankaj Raghav
---
fs/buffer.c | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/fs/buffer.c b/fs/buffer.c
index 9e6a1a738fb5..a83d9bf78ca5 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -1802,14 +1802,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 *create_folio_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);
}
/*
@@ -1853,8 +1856,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 = create_folio_buffers(page_folio(page), inode,
+ (1 << BH_Dirty) | (1 << BH_Uptodate));
/*
* Be very careful. We have no exclusion from block_dirty_folio
@@ -2117,7 +2120,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 = create_folio_buffers(folio, inode, 0);
blocksize = head->b_size;
bbits = block_size_bits(blocksize);
@@ -2403,7 +2406,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 = create_folio_buffers(folio, inode, 0);
blocksize = head->b_size;
bbits = block_size_bits(blocksize);