From patchwork Fri May 10 11:47:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13661465 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9BD1EC25B10 for ; Fri, 10 May 2024 11:50:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3233C6B00C2; Fri, 10 May 2024 07:50:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2CF9B6B00C3; Fri, 10 May 2024 07:50:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 121776B00C4; Fri, 10 May 2024 07:50:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id E92786B00C2 for ; Fri, 10 May 2024 07:50:01 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 9AA3A1617E4 for ; Fri, 10 May 2024 11:50:01 +0000 (UTC) X-FDA: 82102317402.06.97BF7D3 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) by imf04.hostedemail.com (Postfix) with ESMTP id B2F6740004 for ; Fri, 10 May 2024 11:49:59 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=i7o18FTx; spf=pass (imf04.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.214.169 as permitted sender) smtp.mailfrom=ryncsn@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1715341799; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=AlJsO7PWN4Jf79ghcMCVByM1+QjN19p/5hJE9J581cg=; b=t+gSTP9Zv5XQHq3TKICW8/okqoqkOxZu2K/UdD/Par3uuCvQL0t0MA7X/WJ0d9C3XMr0kd S+atah1yOIrs3Ko81aVXHzk3vdOFdSrvG89EX3tFgyQUC6ynhKKPZt1nmPva82Wa39XzaD WghLKJ0G7KuV6rhc0TZ1OTWCA1M/orI= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=i7o18FTx; spf=pass (imf04.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.214.169 as permitted sender) smtp.mailfrom=ryncsn@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1715341799; a=rsa-sha256; cv=none; b=AoxpF+PGKNYUhLWwakvHP8YplUwS7A9BGu4tOVeEsA9WhUAvixBHhVoBBWggacpoJj4QS/ DmuKig7vUCHXBJsTUYxwReqJ74YXD8l6ZFJEfUSw1CbZodeMLkcpb5nP31gjVd8Yr+k+Xm i2fSFXXLtxy4x/XB95EkGCQegAY/2Gw= Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-1f0537e39b3so1580255ad.3 for ; Fri, 10 May 2024 04:49:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715341798; x=1715946598; darn=kvack.org; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=AlJsO7PWN4Jf79ghcMCVByM1+QjN19p/5hJE9J581cg=; b=i7o18FTxnMfC0P3JuyDHto+bRinfsPZ+tRVfxbRiKeo1MgGVk+NsOh/ZQlY4GP/j7+ NX7KtSt+P9Cq8BnyWBJY5zGYGX5X7tCBmikFkxZVVUmBMfJLJ04ig7jDtbNG6XkJZpjD nWCut50G95pmbUUCHdyVgXyx60eOcjHtbnm5JigJJHVjo34JiC21RRYEexcFV55DrcGN gfE+EjNzFL9NTNT1z1Fm15X0m2LwGVQ4oxNR6Css1ZsRJkrI1D/YnGDAYYz/5HG8ZQUj xoqGCd6BkdEA8JuI+YTWgqFW5LarMD0FKEwFM1Mx3vGUAE94liP2MDbEYKwjzAUD5CzX ehjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715341798; x=1715946598; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=AlJsO7PWN4Jf79ghcMCVByM1+QjN19p/5hJE9J581cg=; b=O09nlHEQXZg6Mnhy1VO+DkRwU8iyouVVyo6I6bC1A87guS0YpueSigNvBFTcy92lWO JSQzybLylMjyB5HlU5vJlAurpRl5/F6Yh2xg97SRI19M//IvLhxzB6GLABOBWCGbghgZ UtlbzEj2TFtWRUZ/IyO8kWJxJzwieolT6Im94oJfQ/kTDtUC/g4zpGporixz5m92ymQ2 q6VJ/hoedPJiGqii3vah5+Q3K/Licxrd+1LacwVpj4PkA4lMcZmgNPix5Q8UUm+OXykm /CjUOzlfF9lFKWYowktu2yZksjjbj03pJn0zJiBDZ8c/xxh0etp2ayWGg/iWeIfkZmfY tfug== X-Gm-Message-State: AOJu0Yyk0lsUZSNaqhXC8jpV8Ufg0zZkH4sfpBE89b3uVUh433JguxX+ D4BEwoqj2qOwxoNwVpFxVAESCvSiT8yIo9TRO31MEvpp7lysVz48d9H1cQQU2GcMKg== X-Google-Smtp-Source: AGHT+IEgC/5PItwGLdBO3mEfXM0RAVpswT1aq1A3QBfgABXJzBC0a91j/oU3l3ssnynmf+QFhY0xNQ== X-Received: by 2002:a17:902:c145:b0:1ec:659c:95fb with SMTP id d9443c01a7336-1ef43e25e5cmr22881935ad.32.1715341798221; Fri, 10 May 2024 04:49:58 -0700 (PDT) Received: from KASONG-MC4.tencent.com ([43.132.141.20]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1ef0c134155sm30183825ad.231.2024.05.10.04.49.54 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 10 May 2024 04:49:57 -0700 (PDT) From: Kairui Song To: linux-mm@kvack.org Cc: Andrew Morton , "Huang, Ying" , Matthew Wilcox , Chris Li , Barry Song , Ryan Roberts , Neil Brown , Minchan Kim , David Hildenbrand , Hugh Dickins , Yosry Ahmed , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Kairui Song , Ryusuke Konishi , linux-nilfs@vger.kernel.org Subject: [PATCH v5 02/12] nilfs2: drop usage of page_index Date: Fri, 10 May 2024 19:47:37 +0800 Message-ID: <20240510114747.21548-3-ryncsn@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240510114747.21548-1-ryncsn@gmail.com> References: <20240510114747.21548-1-ryncsn@gmail.com> Reply-To: Kairui Song MIME-Version: 1.0 X-Rspamd-Queue-Id: B2F6740004 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: n8ntxp6cmbx9hkr5tifztrqwuf5tunqo X-HE-Tag: 1715341799-395894 X-HE-Meta: U2FsdGVkX1/VlDy04bdhcNJucR3VVWvXOH4wY5kVRZm3oArBVx/LCO2E1zwl7e8Ky1AT1d9Pn9HXWL8hAvJfajyWQKiLL8+ktw8P+zIRcHF/egllDUckq7bJNh4JvmtnPXPIgkZ5vGvJwIzM8/QkWScDRIT3BJeir2YhsQayAnDE2z160n47ExQIzcXFHjcu5qQo9gG0nvDewKRkxxgb6jpR2BeQ1Xi1X2p2Gs27MZkxbRemmkxTRUClRRyYzqbviCK6YC8lrJ/noB0ahmROgL6f214fO1FdKIoQ4xzQRXsC4W8TUH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dYzsGSaInLIdBhSFr5BiWzhMq5UZk+DKKOjTov5JtoxVRKRCz7HEyLwoMgUuagMlQzUcpggy1F221CETvdB0vc3ZwEhBdeGXqUOjRQywi0udylH5Cre+n538uALHFTFEumRjVC8QcspwFjYEukjcrHWrWPmUDXrnO3ibO/OlFL0ldHt+ZpcuvRYg/kvfA1eHgYbk70auh6BG1jvS+x2YkwREbQBpOfAW7wA0iQeD/63ZWSWOhCYu50/08suVIe0qX+KqpemfwUxi5orjkdzxGlifd7w67Dcx5GKXNmGeq8SS7TevIM69rRNPEK3q896NYDjXoB3JTAX3v7B2FYxWx0r6atzwBJZdGZCuvAi/u8fjhZWIsaLfbdo9iXOuzBrh9awTExNriWqdRFXR5CRHNWXc+nd6eLDP6pQ3VvQGlseWNUIzH/yXxV6ow27DypB9CrqKztw1PKvMKhV5CBtyntJb3TJDYoo6cXrsNwA86hfLPPoTASbZLFYeUqg2WywzYZ3Jo X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Kairui Song page_index is only for mixed usage of page cache and swap cache, for pure page cache usage, the caller can just use page->index instead. It can't be a swap cache page here (being part of buffer head), so just drop it. And while we are at it, optimize the code by retrieving the offset of the buffer head within the folio directly using bh_offset, and get rid of the loop and usage of page helpers. Suggested-by: Matthew Wilcox Signed-off-by: Kairui Song Cc: Ryusuke Konishi Cc: linux-nilfs@vger.kernel.org Acked-by: Ryusuke Konishi --- fs/nilfs2/bmap.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/fs/nilfs2/bmap.c b/fs/nilfs2/bmap.c index 383f0afa2cea..cd14ea25968c 100644 --- a/fs/nilfs2/bmap.c +++ b/fs/nilfs2/bmap.c @@ -450,15 +450,9 @@ int nilfs_bmap_test_and_clear_dirty(struct nilfs_bmap *bmap) __u64 nilfs_bmap_data_get_key(const struct nilfs_bmap *bmap, const struct buffer_head *bh) { - struct buffer_head *pbh; - __u64 key; + loff_t pos = folio_pos(bh->b_folio) + bh_offset(bh); - key = page_index(bh->b_page) << (PAGE_SHIFT - - bmap->b_inode->i_blkbits); - for (pbh = page_buffers(bh->b_page); pbh != bh; pbh = pbh->b_this_page) - key++; - - return key; + return pos >> bmap->b_inode->i_blkbits; } __u64 nilfs_bmap_find_target_seq(const struct nilfs_bmap *bmap, __u64 key)