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: 83362 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp305991vqo; Fri, 14 Apr 2023 04:27:54 -0700 (PDT) X-Google-Smtp-Source: AKy350ZeSSThfAqGzGzY+IAS9NLHf5ENlALHAP+yl7UpoR2mnhO/wjB/z6BQhhrp/JRYEOAR9Jnc X-Received: by 2002:a05:6a20:4d85:b0:cc:d96c:1090 with SMTP id gj5-20020a056a204d8500b000ccd96c1090mr5215230pzb.2.1681471674290; Fri, 14 Apr 2023 04:27:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681471674; cv=none; d=google.com; s=arc-20160816; b=OsIIDaLQoX3d2RP7MRv9z3JXTwaf3sKhf7ZCBwnB+lZGe6gvsh4/dyY2zJTXIZQBVp B28Ww9Kyb+MxduqaKTan5rwrJ3xxU2z5s9NHKOI2tt0SMKN1Yw086Vl3ejI1l7U2J65V LzyOpTjGcNDGX6Ykx4ahgUgH+PT6EzrxlhuuEgYSfz68vh3obPmiEzIHVtJkCBXG+8dD IX9UyT9NFWSN0yd8J4Q0NpHXEA54p6aTjq+5k9N15lxnSDt0WwgtjxiKIV1551L/Is+X +5Y5FxPxZLwKrKiO4rnBpwTHJ+NimxStBFV/y6NfdvAKV8ILXlndexip1Rtr7nbSf45r xmwg== 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=RSOGq3FrSoWTKQkTpr/5r4j+YAAPIjwLJMcrhoIlH+4=; b=cKWu/AX3P3/6IVvoXn1xTU+Ea1kV+Vvu3Gc/LnvnNs/QxVjtRa/0iU3+ENrMneM5eM /TeExbhrJL1P2ZYo5Oth8ky1B2IFzptQ0fQbrgdz7ZJC5hCXE1oYEdIaqJTCyjK4ANbX AMo0ByEIT1xUYDUOHCTG2jzY/srOQ9Cxzampp1DE8m5XLezfMPy3NkOR6DebK8ipLdWm vSHLSyOIPXmU8tSIieXw/tRv8nNCI/1qszhp6XWSp4xi1NguSV0xUXG9FGJU0SORuBy4 PCTBLCXyP9btClurZQXhWmrykshYrhz+uXVI93D6yswBGTFZzFHmC4UuME0LznzLGtg4 ZA/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b="IAd/6DAl"; 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 bs193-20020a6328ca000000b0051a650b8f62si4241136pgb.836.2023.04.14.04.27.40; Fri, 14 Apr 2023 04:27:54 -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="IAd/6DAl"; 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 S231150AbjDNLIl (ORCPT + 99 others); Fri, 14 Apr 2023 07:08:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230368AbjDNLIc (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 8E1AA1BEA 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 20230414110828euoutp01963132ba3500087a17ade7da0ed6b08b~VyITErBUj1325113251euoutp01r for ; Fri, 14 Apr 2023 11:08:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230414110828euoutp01963132ba3500087a17ade7da0ed6b08b~VyITErBUj1325113251euoutp01r 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-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrCKsWRmVeSWpSXmKPExsWy7djPc7raJpYpBt+/iFrMWb+GzeL14U+M FjcP7GSy2LNoEpDYe5LF4vKuOWwWNyY8ZbT4vLSF3eL83+OsFr9/zGFz4PLYvELLY9OqTjaP EzN+s3j0bVnF6LH5dLXH501yHpuevGUKYI/isklJzcksSy3St0vgypj7XqFgu3DFhg9/mRoY pwp0MXJwSAiYSFzZUdfFyMUhJLCCUeLu3P9MEM4XRom1O1sZIZzPjBKH7nxj7WLkBOuYs+cC K0RiOaPEpR8vmEASQgIvGSWW3uQDGcsmoCX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JalFunbJehlzH2vULBduGLDh79MDYxTBboYOTkkBEwk5uy5wNrFyMUh JLCUUeLtydMsEAkJidsLmxghbGGJP9e62CCKnjNKHLg0GaiDg4NNQEuisZMdpEZEIFXi9ImP YDXMAssYJdbMfcEGkhAWcJaYtL8ZrIhFQFVi7/b9YDavgKVE9/lp7BAL5CX2HzzLDGJzClhJ vFl2AaxXCKimfcsSFoh6QYmTM5+A2cxA9c1bZzNPYBSYhSQ1C0lqASPTKkaR1NLi3PTcYiO9 4sTc4tK8dL3k/NxNjMD42Xbs55YdjCtffdQ7xMjEwXiIUYKDWUmE94eLaYoQb0piZVVqUX58 UWlOavEhRlOguycyS4km5wMjOK8k3tDMwNTQxMzSwNTSzFhJnNezoCNRSCA9sSQ1OzW1ILUI po+Jg1OqgaljJst23cpHUYuNHir4nD4dOJvx7fn1H64smVIRbCGhLfr+6poNNT7f5KeGv+wP q+r6JLFkkVdFtfa9qU8f2C+W8g3dtC6eYf/cFjP5P5Mv/DOeYBMn1bv/0RfJe38VZp9lXM7w je/Zn2IJ9nMWNd5Of6VsTrw8NyUhQ4Or2JORo/RLT8CSld1Hn3+9uORs1k6/zy+Co45u8qy4 tLDK8L6UHO//1Bn93035n65iuns68m96x9PMWQr7Yt4KMj7IurZC/bPbxzM7RI8uUarc8mGp bnPb4YzSkKKGBy8UFgn0OgpuFjryYHrbhR9dSZlNk3Py771bseXjpYPi5eXJ7x7djU47Fs92 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> 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?1763150842287256019?= X-GMAIL-MSGID: =?utf-8?q?1763150842287256019?= 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);