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
GBtEuxg5OSQETCTetC9g62Lk4hASW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sWlVJ5vH
iRm/WTz6tqxi9Nh8utrj8yY5j01P3jIFsEfp2RTll5akKmTkF5fYKkUbWhjpGVpa6BmZWOoZ
GpvHWhmZKunb2aSk5mSWpRbp2yXoZbye/Y2poEey4tWWCSwNjA2iXYwcHBICJhJHGlS6GDk5
hASWMkqcXqoFYksISEjcXtjECGELS/y51sXWxcgFVPOcUeLr+nvsIL1sAloSjZ3sIDUiAqkS
K/7cAathFljGKHH4+11mkISwgKtE4/X1YDaLgKrEnJ0z2EB6eQUsJVrOqUHMl5fYf/AsWAmn
gJXEis09zBD3WErcv7QNzOYVEJQ4OfMJC4jNDFTfvHU28wRGgVlIUrOQpBYwMq1iFEktLc5N
zy020itOzC0uzUvXS87P3cQIjJ5tx35u2cG48tVHvUOMTByMhxglOJiVRHjPuFqlCPGmJFZW
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);