From patchwork Tue May 21 17:58:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13669610 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 C6156C25B78 for ; Tue, 21 May 2024 17:59:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5CB436B008A; Tue, 21 May 2024 13:59:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 579F06B008C; Tue, 21 May 2024 13:59:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 41D006B0092; Tue, 21 May 2024 13:59:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 1B4E66B008A for ; Tue, 21 May 2024 13:59:15 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id ADBBC1212E7 for ; Tue, 21 May 2024 17:59:14 +0000 (UTC) X-FDA: 82143164628.10.0A50084 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by imf07.hostedemail.com (Postfix) with ESMTP id CD47C4001A for ; Tue, 21 May 2024 17:59:11 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=FrUzrLLI; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf07.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.214.178 as permitted sender) smtp.mailfrom=ryncsn@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1716314351; 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=xFpAHzqRgSiz2xm2CXznKixemcT6aD8kBzQB3tTCfzo=; b=KQpwq8EPLvCNJIszgQHno+r01gwcQ+66u+KxMm0gfm4vwA+24vZ+Z24wvho3c7eIx3xNVj rDfnyRCSGb2MqiywcXYhojK8JFkA5LqjXOQogzhI5xrYDGpspmQ6XM6+8JkwJaSEdGmv0f Ql0f7crEwhe0YOdAY4xO8cOzNertZCI= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=FrUzrLLI; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf07.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.214.178 as permitted sender) smtp.mailfrom=ryncsn@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716314351; a=rsa-sha256; cv=none; b=7bF8XTxuGo/9If6A5b9JYeoVDWdPLcve15RmadnULaWAcqio1U7jd3kTIVtSBISSmOMcqY LFA0wXH6fNcOhyVSUqbstBCboi/GB46wyzdZvqROa7vATGGj3l+UeC6mnTVJE83bLGx5YT //Zs3gDZJ3AWYfTEKPJancRYFqPMyyI= Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-1f0937479f8so3811025ad.3 for ; Tue, 21 May 2024 10:59:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716314350; x=1716919150; 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=xFpAHzqRgSiz2xm2CXznKixemcT6aD8kBzQB3tTCfzo=; b=FrUzrLLIYjoq37G/pJ0ha+R5hg6+6GZ3xMSxXoxSlbitVH3YhumwHZysY7XT20e0aD zInR20DAOB0gK9u1lqtV5xuXgSkx98g90tZFRhLyK/vbbuuckNBb2MYLZziL1hH9+tje +dvh0zuI1RpDtvam2mehiJLB3Zh4XCSthyIpZ9CN1Fam3NyfFEYDSURo7jbXxoNnZPoM d327tzZ9D6oLqA0fPL4ay3qLGX/VZTC+PmmXOhia/KnufEIavqrkiVwdCkupM7db/r+I xDV9EIueW5MLG58c4P9K4s+U1AcqqrU0/NOBaMAWZqbbwlMLhX7pV6QaqIFnuhqVbiTz 3xsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716314350; x=1716919150; 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=xFpAHzqRgSiz2xm2CXznKixemcT6aD8kBzQB3tTCfzo=; b=VhVAK82sOYOQQf6fg4dEWSQzMPjLIT2TJoXMCsOBCdnCQ1KSW/uZcgPIfHUs03ehzk 03qpOZjg6xvqwf2qOScNyForOAXPssh5VP/44y7ID1GXWVa81rkeYDnKjmjwMx8q9kRo o7hskjOs2JsoJh2M+4t8aY8UIx2cewq9+tohn8hlPu2NbVCCoD2Ps4ut9gizbBBipxvh uwORqyyHblBSGhXJt/10odgCuhLdYAGoW4oa3v+cY26YYhJWiMs/FtmPyuP2ASIRmuU4 t7223bz72i+pzMgpntoQYGG9mu7O9a9YcGxUHTRH8ozcQkdmV3sY34pbEehKiPfT/xvL MYLA== X-Gm-Message-State: AOJu0YzjDYwOU3Gj+NmSbB+H+zKeGCH4yrN0JFCcGX47+qOepWg27y8a 5nbJ/YAFCLAnyrJ+tq6EkiYYDcxnzN+B39b8N2db+KsfvnIB095VWGp32tiFZUA= X-Google-Smtp-Source: AGHT+IEQVix1xCQAJ7lu1JC4bqBxGgwlzW9PigTCcx2l2HRAdtg3GNuIH6M9NtM55RShJgSvR61swA== X-Received: by 2002:a17:902:c407:b0:1e4:3b58:7720 with SMTP id d9443c01a7336-1ef43c0c962mr357191475ad.2.1716314350150; Tue, 21 May 2024 10:59:10 -0700 (PDT) Received: from localhost.localdomain ([101.32.222.185]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f2fcdf87besm44646935ad.105.2024.05.21.10.59.06 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 21 May 2024 10:59:09 -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 v6 02/11] nilfs2: drop usage of page_index Date: Wed, 22 May 2024 01:58:44 +0800 Message-ID: <20240521175854.96038-3-ryncsn@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240521175854.96038-1-ryncsn@gmail.com> References: <20240521175854.96038-1-ryncsn@gmail.com> Reply-To: Kairui Song MIME-Version: 1.0 X-Rspamd-Queue-Id: CD47C4001A X-Stat-Signature: m9ocone656z1r85b83f8zssf35wis5xw X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1716314351-257546 X-HE-Meta: U2FsdGVkX18hxQHVC2PGmqAoRvNOm9xYMjxJn8ze363egV/djejCaWxnmUkTs1yPtoIks7JY+YVWY7iIYh1/IAMaf2T4FH/aOFHsFv9eMCleFFrmj+cCdBuBWtF+HwMwl4y3ibf8rx5uPNV2wpWFIuTZZFrEgzotdVTo/G0B71AI/Gdocrsz/x+IQHcd1f3yEpSylRCkmBEw388x8IPnLVSC2Uf81ngTF70aUqvCjCPTBLBzQXgNUnqqu8a4Bto+DJO58cB7DhPDF7jIP2z/h+pTXTvTZc5fjWxbZp1elJizjtTcRJS6TuQZNXGjeXGer8xn432tIJ82NRIM/tULbef+80/3O6xC5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no4UX25kKCv9BBuB2wxyXG0WLojiG9Gx5ydK4ICf5d6EAEcS7ZkR5ur1e/4fFvoB2dYAvZ2bcoiEptBlIc2ig7iDbLiy9HZgLQ9ovibyWNcsyRbUAeE7S7s/B3AxbAIi6o/9WsiKFwb/dQiIZJV0u1MC/0hDO+QFRQzKqG39dSoZFq0KeGBN6xitd9e2nJQpYjm+jmK2d7RHyECZePv/dKECXKIjJSgipyIN4x1wf6IEan5cGHyOjDC1NJJfzZ55qp77Tag57mjnZVpF7a3Lqh2d3yy78olbYMLLO++FMvE1bG+6NOUgMoArOQbSqisF88xynxXHV3MO6L2yWTaclzCzmqGJtHgi2gTkuiwebGU8+vDkzkgOm2mt3vf97qTI44L219jTndtBpDyqhCA0DEaJeExki0Ba+slfI9UeoRVSSNAG71i9ofFgI8lc2lY9SjPfkzRQp4pw07zGaTyuQz5ZcNpGF6k+8xRHivUA8EJIxtgykyhp+s59768do4Gsvk/UfaEZBIVCDzvINkxOCE3zCuKaDk33jyaGQ= 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 Acked-by: Ryusuke Konishi Cc: Ryusuke Konishi Cc: linux-nilfs@vger.kernel.org --- 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)