From patchwork Tue May 21 17:58:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13669609 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 6A6E2C25B74 for ; Tue, 21 May 2024 17:59:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C341C6B0085; Tue, 21 May 2024 13:59:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BE29F6B0088; Tue, 21 May 2024 13:59:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A83A26B008A; Tue, 21 May 2024 13:59:09 -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 8B8B16B0085 for ; Tue, 21 May 2024 13:59:09 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 24EA2A2A62 for ; Tue, 21 May 2024 17:59:09 +0000 (UTC) X-FDA: 82143164418.14.27DCAAB Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) by imf01.hostedemail.com (Postfix) with ESMTP id 4897F40008 for ; Tue, 21 May 2024 17:59:07 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=QLxxOSEi; spf=pass (imf01.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.214.172 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=1716314347; 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=R7lhdO5v0hVN0l2qTLtMelKVtmq+aBFR854K3Ld5uQo=; b=5XnK4NBCW5atxMzK9kJO8aE0org96Kpw/+DzMpG66FLQo1MkJ0OhLnDAmyWRe4TZhytrRS QiCGCA8jTCKr7j3UkV95XFhD4t4uqC2tFlCRbdqUVCU0ZzuVcmoMJVATlwTVxYEu8sF2If zXuczn2pv1pT8X+hGrSK0p8Afmc7fig= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=QLxxOSEi; spf=pass (imf01.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.214.172 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=1716314347; a=rsa-sha256; cv=none; b=qU57K7iMxyVD6RxU29chf1ger9r2cspxanT2nrz0FxURykb0EPWqnZYe15Qllmyd3c9qUR s5bzsw+WhNPCfiNz4OaMmJhZaPz3oer7nf/7nf8ictiSWkb78I3mS9WACFewmWZAQG0A/Q c1dmgyjrY4diHJUYjNbJwmEvPI/75TI= Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-1eeabda8590so3746785ad.0 for ; Tue, 21 May 2024 10:59:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716314346; x=1716919146; 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=R7lhdO5v0hVN0l2qTLtMelKVtmq+aBFR854K3Ld5uQo=; b=QLxxOSEinfqQ1AHH2Sjx3p7Kq2nGzaPgSUFBriKSMbYYX9sczeqcHKhh/21mAtF41m SBnBThjYLLH48J+3QKWlXIea8r6jMgwBuI9UXQQ19UMJL89dLStIur2RIAjOHH67dEul XHuR4kgHNLzjBK3Bogz71BE/fJ9uj967sxNOb4kP4SysJIuqwOgtKcPv+1CKeJfp369N /wYblXyzpu3OOuPPGDn8nNC6+35BF8Gk/oKuzKtIl9517J5NGAkiZ99frqhb0tts/NSv BVKj/7JyG438pCcEVfhHkKHm9Wb7mkC7jOqtbO3TW3uIV3QIWtZtZkvtX5cG5NPTmuAs Mixg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716314346; x=1716919146; 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=R7lhdO5v0hVN0l2qTLtMelKVtmq+aBFR854K3Ld5uQo=; b=uo4fk6iFfhEK+DXoZR3bWitGLeg6LP3pE8CLEycMvknlZRzYz098Ow3GJfsMhOXPik +rJUt4w1WwXp4DbYvwDzZKj/BqLHHDdw3Vm3p5K3QVg95SdmJ3+Dw2iY88ZIauE2at2Y qtreSVk0nsxIza62SnCFdxshjXFRc4tQ20qSFHbEFmeyfak8uiXxd/zIcko6rr4Q6BZB mmq8aCOkFiQ1uTBb+tvDDcD5jxs9n4+bwbs/N/blh54brcqNHE/x7Zg2hOi3FcQzl5E8 5lvMdfDKT9HLzq4jWm8nPVk6/Y5jbD3Hxbt3kw8f0tibD+L5wJK0UUDn7sLRS8K6hHew UJ8w== X-Gm-Message-State: AOJu0YxV57xMmn9JEGAWQNRb34/wmEC0q/pNrNCiYHM0aXJfwZU+i1aS 81p6DJXKn9wFfDFoqKb475PXc0Y/dVjOarg3miA9naAFW3SATYGWfFDQJlWDnFA= X-Google-Smtp-Source: AGHT+IEPpozMM0L+20HNGIEKpe29SmAQZrslVrxqPFNwn5ThpFi4hMV2N2JdR99RXw3BFqLPSnJwLg== X-Received: by 2002:a17:903:245:b0:1e4:4ade:f504 with SMTP id d9443c01a7336-1ef44161e45mr347769925ad.46.1716314345665; Tue, 21 May 2024 10:59:05 -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.01 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 21 May 2024 10:59:05 -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 , Chao Yu , Jaegeuk Kim , linux-f2fs-devel@lists.sourceforge.net Subject: [PATCH v6 01/11] f2fs: drop usage of page_index Date: Wed, 22 May 2024 01:58:43 +0800 Message-ID: <20240521175854.96038-2-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-Stat-Signature: 9rmbey3ym13zg76p5cje8peicebt9hrg X-Rspamd-Queue-Id: 4897F40008 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1716314347-923703 X-HE-Meta: U2FsdGVkX189ilZJQDg5dpt2mDCav408+TYwMFdHaeAo715HcAlfY9tFEA/XfoLxTtSl3ANL6yfgyjSCEiUJbNS90zr7Y3zWHKgGwrTCXG6jw/6XrI83CGUa19GrN5BoSNM16NPssjTIRPv8Aqo/FmyZWrcj2zyd4qLR6mSfa++2wPVMUFbWYd9L0QDS4Vt2nN8tA+3F/UGTuPCwMHQReiI5nEquCDVPo6kYmV9XiFVp/YfzVIaVWqOVzlNvA7SfVeBwitHu9ACuDZxteYBTo5A9w8PdXJpG5TCUjxxThKLvXnuSFP4eW0xMrj7WR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EJjr9Q0CtAABMYVwNz5XbA8g2O4mOoxMKad82JrYvgqa0Wt2insfAivrNpuil+jnoUlUeJEjZLHkrT8L2HvRUQOMERCKXx5oH0Faztl5A8HvcdmRTgipjRcapCEnn5saZrX2oDKZlNf/kNoI5jAA5rvx/YE35Ue8xyBEMZjb56usXO5yxI2hg0nFD14Er2OYu+2Y1ML96SR4quoAXj8OJttdhtduAl+K+EN9Bl5YodzXGikbSI0QfaGjkW48ioAN/pU0aWqnIqulpnaY2t2hA+tBctn2B8EasZCH28mxbYgGPobamSJg6mKO6gv72s+v4yOV17r0PJbvqRM3aAFwnds3cTnnSdKG31mmZP/U0IoNwiQI19ZlI33NS2u0hvh1E6rLUmhrr7wnvc3ovPM9SWXFhEXQRnaNhjAMYb+f5U7Ah+hff6IcvQZjtrCs0Pq43WsYnuWtDjpFKy2orsOJ2uUQQLVYoCNr7rz3wus/sMOttG2R+SZG8KI1in5ntdr2ZuA== 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 needed 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, so just drop it. [ This commit will not be needed once f2fs converted f2fs_mpage_readpages() to use folio] Signed-off-by: Kairui Song Cc: Chao Yu Cc: Jaegeuk Kim Cc: linux-f2fs-devel@lists.sourceforge.net --- fs/f2fs/data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 961e6ff77c72..c0e1459702e6 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -2057,7 +2057,7 @@ static int f2fs_read_single_page(struct inode *inode, struct page *page, sector_t block_nr; int ret = 0; - block_in_file = (sector_t)page_index(page); + block_in_file = (sector_t)page->index; last_block = block_in_file + nr_pages; last_block_in_file = bytes_to_blks(inode, f2fs_readpage_limit(inode) + blocksize - 1); 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+pTXTvTZc5fjWxbZp1elJizjtTcRJS6TuQZNXGjeXGer8xn432tIJ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NAU7FL24r3If/Ctlbwcndnno4UX25kKCv9BBuB2wxyXG0WLojiG9Gx5ydK4ICf5d6EAEcS7ZkR5ur1e/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) From patchwork Tue May 21 17:58:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13669611 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 609C6C25B78 for ; Tue, 21 May 2024 17:59:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E7D986B0092; Tue, 21 May 2024 13:59:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E2DF66B0093; Tue, 21 May 2024 13:59:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CCDE16B0095; Tue, 21 May 2024 13:59:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id AD2C16B0092 for ; Tue, 21 May 2024 13:59:19 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 6F360A2A62 for ; Tue, 21 May 2024 17:59:19 +0000 (UTC) X-FDA: 82143164838.13.5F9E642 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) by imf18.hostedemail.com (Postfix) with ESMTP id A06D91C0014 for ; Tue, 21 May 2024 17:59:16 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="eCP/LQPb"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf18.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.214.179 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=1716314356; 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=XI4mdMYQHMDzDk9xWjXkWCPqz9rl1k4l8GTTN28ztKU=; b=7NKYsDS8yiz3eLRHitvB3YVJhx3ClhpjqFBlXF+2Hv4yFmK6s7vxssKy8PrpB/kVQdzKyt DVy0gG+BtJAurmu+QhH1UAYo13CYKC20LylhnKUtTtWowlkPwfG3V6H7XBc3rCz67e0WJl s9JpAdt9Mni0sRh3qIQVVKpxw4Sp83E= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="eCP/LQPb"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf18.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.214.179 as permitted sender) smtp.mailfrom=ryncsn@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716314356; a=rsa-sha256; cv=none; b=b+nHrkV13VP4QW4xvy+j7C/m5qTp4zeewro/IiXtg4Rx4of/+/n/8kIFPDjMwbMZXJYH1h md52ZyiYcm3OYvpffr1SnIHkwQD680jIcEp6aAqTnXOdkE7OFQQzuEeN1AxGR2W9+5IG7m vk2JcWAPPfGHFbWSWW1lbSHTJbiEvqg= Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-1ecddf96313so94011395ad.2 for ; Tue, 21 May 2024 10:59:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716314355; x=1716919155; 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=XI4mdMYQHMDzDk9xWjXkWCPqz9rl1k4l8GTTN28ztKU=; b=eCP/LQPbXY5rQJy41iQJpQS2UL0tS5VLzO5nEnN3d7nKkDDzCxcoQhd4frhhAUqXq9 TXLIhmYIXrQYf+6TdxrTXeiS2LA/p7F6OX3YSy33XWGdtAG43d0/bVvACcHxwiHkGIdR 1i5PcIUGu/4k3Pnem4u24NCNKEhH2ix/ZEtOpkFubmCUPtud9Vp8pi5ZE52WGogRXn4E U66uJd6O6ZeMUf2CEje2nWohjvonCtct9pffEBR/6dHUNTUg0MoFL4udGSJm9hWIbyu0 onNYdnD8iCzOGYpcCihI9LWXQuWofxpOpLuejeAMAHQt4ij6PVb6uj5EzjWtu9avExiN Wv5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716314355; x=1716919155; 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=XI4mdMYQHMDzDk9xWjXkWCPqz9rl1k4l8GTTN28ztKU=; b=nkoWzJHoBKHIUTsea5dAF6gLvf/h0gqaptLM1LaD7Yz7LyXaTTQI88IcNVhqgN6vgT ebLuQ0wnBiCstWgPC989aI+VCiSYfa85IH8nkBRujOEoe5gpfLFspciuCOHtLvNQW8mI 5vAFjIIMOgSloLlZghYGtxakXcVp+RzZhm2AAD6ndPz5lu2iDU57ZhwRL4mfDwV+dDcM 69obGgqP1C914IozwA6ItPpaWr7g/4ZT3GYRhQznH7dF1owDe+Mx9dTTtO6h40trPlVX dJBdq3fPmoAWc9CyVus/ux4SnFryJmjg9nWfmsjet1OmjOso4XJrGye6kxD0RMHLX8rj ye6Q== X-Gm-Message-State: AOJu0YxJp1u0po/UIH3HEmaa/b9I+R+INDE7uKu+288jKDdgIlKuBVhZ +rH7qq4jMQd6i7a+WpAWbkNr/OHnmffaPm0a78vBaIjtKam9OWJXGu5Plc7PhTw= X-Google-Smtp-Source: AGHT+IHhaw8cihGDeGD+zUXeJgbKIcB5gsMYz1cB7sCZetbMXuUWE1Yeub/1vlqxEDZ7M5X2P6lZ2Q== X-Received: by 2002:a17:902:7845:b0:1e2:a807:7159 with SMTP id d9443c01a7336-1ef43c09602mr364682635ad.6.1716314355180; Tue, 21 May 2024 10:59:15 -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.10 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 21 May 2024 10:59:14 -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 , Xiubo Li , Ilya Dryomov , Jeff Layton , ceph-devel@vger.kernel.org Subject: [PATCH v6 03/11] ceph: drop usage of page_index Date: Wed, 22 May 2024 01:58:45 +0800 Message-ID: <20240521175854.96038-4-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-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: A06D91C0014 X-Stat-Signature: 9yuxuobia1armg184yfcuczsktk5o9re X-HE-Tag: 1716314356-234312 X-HE-Meta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b6lIGJQ9l3g44D9FhRFWkP/CPiPgGqxREbFCY3wRddwkevYwUWeeWPjeLLUcPKdB64DwL7koD/U3a5kOo85O0B34RPo4Y0pRxPVab6Y4jO/gODUfKxJKb5Erjr8I0Y4WQRhAn2mcbNCn58ClYaH3mdcYvfbIOQkbKx5mZfR0wCwcreJ571ovJ6Buc+XoMkh/gFdFItT6Z7MwRfqcJ89N+UjoWe2fK913BFGl9n8jquFlIjO+l/9iRX54Cdgw4mGWl2rCsffX8fWoDrpETdMaXdmGhcVamvqA8i+YRkUzRTy9IGKmbhPGUGbSFHZkmcpagfXvkyIEcDD2EMM2FR29S+w8BM7oS6KqQMQ5vxXs2dfOKHH80SAzKw8oWVzCdS40nQwBs5GExC7d1o7EvXbW8YIq6LzMbUZr3/3DOxABoryY6Mf9fCnfVN7bV9Ymjz6oeYTj98x0kt7orI4A+V9hTGDcPMW1ksvGhCPDWqJ2N2yBvBZDeyU5Xb5tACGT5YKM2N+3ggwEpUO5dmPGXbD47B1bCzMVBaYhpxtgxqjAO4OS6gTcLB2M96L4Qzr0XjmsK+6diL7lPzWH4RLtoCLVvgMxoN5Di65RlqNGXf6AQyif/8aqFTfuHaHs9w1H5XFe9nwmeVFZrQJsHUTnw5+PezN7++ZOLHurLQ1YlPW5Y76UymceKD5eN4+wYjM1a/rqYSl8AQttK14NAtk2ByQBlxSCTjglqmdTx6XgvBp0j5/oLiJi30qu/p5eZCY78QxkpaeYU4VBnKpXJKgWzB64XsfZ65F3U/IO2Dw3uqYOPoaCoFYA3ptV2JrCeUkdWnOCPZ8z88hbzww5hwRhM= 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 needed 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, so just drop it. Signed-off-by: Kairui Song Cc: Xiubo Li Cc: Ilya Dryomov Cc: Jeff Layton Cc: ceph-devel@vger.kernel.org Reviewed-by: Xiubo Li --- fs/ceph/dir.c | 2 +- fs/ceph/inode.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c index 0e9f56eaba1e..570a9d634cc5 100644 --- a/fs/ceph/dir.c +++ b/fs/ceph/dir.c @@ -141,7 +141,7 @@ __dcache_find_get_entry(struct dentry *parent, u64 idx, if (ptr_pos >= i_size_read(dir)) return NULL; - if (!cache_ctl->page || ptr_pgoff != page_index(cache_ctl->page)) { + if (!cache_ctl->page || ptr_pgoff != cache_ctl->page->index) { ceph_readdir_cache_release(cache_ctl); cache_ctl->page = find_lock_page(&dir->i_data, ptr_pgoff); if (!cache_ctl->page) { diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index 99561fddcb38..a69570ea2c19 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -1863,7 +1863,7 @@ static int fill_readdir_cache(struct inode *dir, struct dentry *dn, unsigned idx = ctl->index % nsize; pgoff_t pgoff = ctl->index / nsize; - if (!ctl->page || pgoff != page_index(ctl->page)) { + if (!ctl->page || pgoff != ctl->page->index) { ceph_readdir_cache_release(ctl); if (idx == 0) ctl->page = grab_cache_page(&dir->i_data, pgoff); From patchwork Tue May 21 17:58:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13669612 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 60CB7C25B74 for ; Tue, 21 May 2024 17:59:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DE1886B0095; Tue, 21 May 2024 13:59:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D69866B0096; Tue, 21 May 2024 13:59:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BE47F6B0098; Tue, 21 May 2024 13:59:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 9CAFD6B0095 for ; Tue, 21 May 2024 13:59:23 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 57D20808DD for ; Tue, 21 May 2024 17:59:23 +0000 (UTC) X-FDA: 82143165006.27.5D720E2 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) by imf20.hostedemail.com (Postfix) with ESMTP id 859A11C0003 for ; Tue, 21 May 2024 17:59:21 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Cd0j+GbR; spf=pass (imf20.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.214.174 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=1716314361; 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=T/Y01wUoc8GqRpvXAplln3XTaKFYbBI0hlcfHL66MPg=; b=oFfzYt0CF3HNks2CB37HMPp4PPqVX0Kd/+3SY4YfJI3GJAcBXBhB9RbzeE7EMAu9a+2So1 QsJ/ZQMKDUtBa4y8Q2ARTGcFT1PvO29Qf4u7y7YMkccNmlJ00AKeg08EPwVZAaBbORwUPy JHcGBUqx1GLD+LPgnk9PKG/m4sYwTcI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716314361; a=rsa-sha256; cv=none; b=Lc8KKKHzmacOdz3lKsdI18VaMTuiTH2eRnLZODSb1viRPe0gK/8TXEXn5TqMJwq4I36yka HOoFX/V9yyRs8eUDxi4c2+ft02skidngGErv5qzdbPPOkRfShiiKvWgDZrIkg/wALQb7M6 mgm8DdiwCxdgcQ9KIw0uOLQaINfx9A4= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Cd0j+GbR; spf=pass (imf20.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.214.174 as permitted sender) smtp.mailfrom=ryncsn@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-1ed835f3c3cso3881065ad.3 for ; Tue, 21 May 2024 10:59:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716314360; x=1716919160; 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=T/Y01wUoc8GqRpvXAplln3XTaKFYbBI0hlcfHL66MPg=; b=Cd0j+GbRcjQ2etBAT5NsR9Qjt++sZm4RYwYLNJlparKGVhw0yTd1vQwPpHGoo5Fszf pQ8S/lIHcEJiMFdkrztlx7tlgOmKxUGAzAuledp2+5+O1iooWYxycse6/ZLB4RfPMP83 ds9iMttkBFPQ8LT24kEZb3e/7LoMOFq77G7XpxTgrsxO5nhPxYm+BqTJcvCvpnBHwnA9 5QEktjR/WQsawMg5w2N+o75d8HxHDmR1zwkSLFqRch53Gv2s9M5aC6v6lBGZyBFV95Ub LU+87TYUwUpZxnxi++Aj4Vy6VT1Xu+pdlvbMb2eTskuJqELdZ6+HgSFHPKvEN1mQop5m BHig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716314360; x=1716919160; 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=T/Y01wUoc8GqRpvXAplln3XTaKFYbBI0hlcfHL66MPg=; b=CS+5M3brQdovKOvryA+ptNhJ6saRkd2SF/VVmuNgge4J9/WxEgwfnq6kypc8HlONSO LiTQPF3hLAgcP2JIrsy2vn+mQePjZrN+6g+Kkgab7uZkxYlzXj42X9moa51lkr/TYkbK GFyugnZgyiV4qFUVaFPh3tpd+tw7Qk4R3aQjAiJjnLKHHGq90si/zOGhaXWzYnxR/6hS N0JU/FglfunX/WVfInu/u/R8YHPc3j0foOsgkc5M+wFNaDjolMd8WgXjRPdo/pR5D87n YzseMxLRLcG8yc2v5x3vvxhrjwUnRuBZlCxSXOOHc079P9TM1W95AaMWHD1tBmEiZfbI cN2A== X-Gm-Message-State: AOJu0YyhuDNKydsrcXBIbMznf3ULJ+9sZSfhTCQ7rhsMr5E2MZuIzU10 2VL68f1CLUwpA1LJLCv9ZhX4TyXTY3MtjU2ZJ8Cu5YbbA9CvmtTC6MubUaX1g5o= X-Google-Smtp-Source: AGHT+IHoEUt/0l1rn7y24nEEjHG5IB3IdC9BGhTGoiXG18qSAHAVRm5IJU0l3mpAfVMLarJhvGzQmA== X-Received: by 2002:a17:902:e847:b0:1f3:21e:23c4 with SMTP id d9443c01a7336-1f3021e275bmr80072115ad.21.1716314359988; Tue, 21 May 2024 10:59:19 -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.15 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 21 May 2024 10:59:19 -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 , Trond Myklebust , Anna Schumaker , linux-nfs@vger.kernel.org Subject: [PATCH v6 04/11] NFS: remove nfs_page_lengthg and usage of page_index Date: Wed, 22 May 2024 01:58:46 +0800 Message-ID: <20240521175854.96038-5-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-Rspam-User: X-Stat-Signature: ytxw3czawdzsrhassgxm36g1gpg4gtn3 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 859A11C0003 X-HE-Tag: 1716314361-646060 X-HE-Meta: U2FsdGVkX19DsKAQdPqVoglWx8FYAmilpmZ+XTWd1xINk0bxVMRWL9n1jd4jtExDBY03eswwD1s1tmKVt8mnFbf43VZ1RE9fAoaDVrJ3LJamq+65CgMrVZZHCiuZS5s5xeKopbJoLeduETWQtANMj6512pplnQC0mNcwLNTcYE6ziVSjSPJ5loNa0gkO2AtawH+5cYFpJNB311n55UEoKE8R7xMY692vdjOajqPr3OI60xXvItQATrhpp7UFn8SXkR35y42ktaPfNIMygt8Nvl1Pgp2S0qODFxhvOXRu5v9a/ZvKsGRC8OJSlghxU601rUSugfs1ICMVbmhkIAsv31MBXaSMRvagsi8uZ8yr1KfmMZU0+FQU7swmO4o0M/xez1mjqAN2OO0t/dyv3N7XOSzNMcE3fFSyCuPzhWv6SgIw9UQ2LYMQlQEGdyoCcRMkqiM5nimsoQG8YRiMcf/eBKdu+suTvX56YYP0aq/glOe/C9VpzZnHAXwabuedI5Z3hXfXEpTzxcUnZkuUhJ3nez3d2Hdl4yULFu0jP5jL/bQnbnjZjDY8Pc3g5qgXX6m++yIx8xSa26j7JeSm4FLIE/Z65T1EgLXKx/Sxv5ihvI587vTtobkXiuxYei1EsZZyZdpgERQ0jHQNDZdb8ys4KFOh1vC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nEouKOsT77uyxl5r2h1I9JsjxkJTuEBc4UG04vPW2uQOG52LaithGk1IH/L7BmqVw5WYWTFfx2LitOjXDNZNQ4sCMeeF5Iqq0ZMQTqJ81h0hksEU5JHV0= 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 This function is no longer used after commit 4fa7a717b432 ("NFS: Fix up nfs_vm_page_mkwrite() for folios"), all users have been converted to use folio instead, just delete it to remove usage of page_index. Signed-off-by: Kairui Song Cc: Trond Myklebust Cc: Anna Schumaker Cc: linux-nfs@vger.kernel.org --- fs/nfs/internal.h | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h index 06253695fe53..deac98dce6ac 100644 --- a/fs/nfs/internal.h +++ b/fs/nfs/internal.h @@ -790,25 +790,6 @@ static inline void nfs_folio_mark_unstable(struct folio *folio, } } -/* - * Determine the number of bytes of data the page contains - */ -static inline -unsigned int nfs_page_length(struct page *page) -{ - loff_t i_size = i_size_read(page_file_mapping(page)->host); - - if (i_size > 0) { - pgoff_t index = page_index(page); - pgoff_t end_index = (i_size - 1) >> PAGE_SHIFT; - if (index < end_index) - return PAGE_SIZE; - if (index == end_index) - return ((i_size - 1) & ~PAGE_MASK) + 1; - } - return 0; -} - /* * Determine the number of bytes of data the page contains */ From patchwork Tue May 21 17:58:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13669613 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 55CF3C25B74 for ; Tue, 21 May 2024 17:59:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E07BF6B0098; Tue, 21 May 2024 13:59:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DB7676B0099; Tue, 21 May 2024 13:59:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C59A26B009A; Tue, 21 May 2024 13:59:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id A651B6B0098 for ; Tue, 21 May 2024 13:59:29 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 1FDFE80F73 for ; Tue, 21 May 2024 17:59:29 +0000 (UTC) X-FDA: 82143165258.08.2BE0BED Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by imf01.hostedemail.com (Postfix) with ESMTP id 431A340002 for ; Tue, 21 May 2024 17:59:26 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=HoU7u37L; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf01.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=1716314366; 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=P42QJurgga8X3tClV+VU5iyd0pTaBz/Ss0EAkzfZsy4=; b=Ai/XQI+ApU8/hPn4qXS7yxENUI5QLepmcyykjqzhrO7CpQESafMMUgiVe2Zb/DxtWqMIK+ n4dacw5D2crMV/VXIDiqkFhN10XH/ahCiQNgCLeFx75hz5oncmnQ1yUIV+Fa31xdx5YRil gn+zjz68cQ1ips+X6TK64XjMspfyeh4= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=HoU7u37L; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf01.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=1716314366; a=rsa-sha256; cv=none; b=l3ttmYmm7rLHR4Wx3sS3dwfEo7rC2h1FTcUj0pHs6ahUJlT4+3f9cpdQGAbk+QmqkhSVK5 mB9m6HLHMQtXiiCI95BTql9cS53gzzg4t5pf5a8ePWKXGOQLd7YLFfi8LpvdRiJZEYufac L8vE97g4qTyf/9tE08WjraKHrMre5HE= Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-1ed41eb3382so3746615ad.0 for ; Tue, 21 May 2024 10:59:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716314365; x=1716919165; 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=P42QJurgga8X3tClV+VU5iyd0pTaBz/Ss0EAkzfZsy4=; b=HoU7u37LEqiKMvTwMcWIhl1CMsKNqyGd6b1OjrYrw/OCynL9c3j28IZGU0b15xN1Tf f3TNNuT4NihRKTRhA/2AWwMAjnPWgL6K5gIyhSxlXf/TEqh23HZIUgkBEV5+OOuSMCn4 KSKCzgUUdiTDXfSs1FUo/z5ywZ0iaDx2nTkc2yfKikwrTZDkOpZm87EXY+H7+cWfeNQn JJNAt4trNOS2q06GcauJOeehO8tA1WvYK+vTFCYicCszEJY4pvoKGTSPO3Uvw/FPRqOz WT7Gcwnlm5yXKoQO2+GcuIYSwPK8AB7WksD/MbZIUfzx+wNLqpi66UAL99HQDzhkvciz RVyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716314365; x=1716919165; 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=P42QJurgga8X3tClV+VU5iyd0pTaBz/Ss0EAkzfZsy4=; b=W07W6Ttbs42dy0pvrZ8ORfUoPksJoKYJdjLCxzcxtfYgvfTSKjP1cgSanuZZzJ3oGC SXkBAQzcpUN1wK2FFMg9S8K4vwLSV3jE5brvIsZ8XrQCANplTrLgSExepRjkDledvEyU YMA2CYESESEAdspvwwKp+U+ugb61Cx8oEx2fD+tNfriTzaaQlpqfuXJjFaIRrZesHAAZ MyfHY/o1CpgSPdDHBG/97VG959IKpKsq82PHHpXAM5flEQKjK4qX3QThBMTyEKt3SDPy +MR8wTw3QszhaX02GuIY5f6/NWnFKZpQvYkJ1yymd3hvH+CU69CBsN3XFoT3bB4MrBzH VNLg== X-Gm-Message-State: AOJu0YzRZRJLikWC8YvKl6zf3pmtWC3Q33mpiIin6wIF5XMu6QIt+6AJ h85LWHsjIbbc0qDF2jAGOi1EiQ3HcYwidzN6DgXXFJLote0iVhiZq+txPV3bUfs= X-Google-Smtp-Source: AGHT+IF1cRebeOkZju1vxHpZ1ZTdsLqq2r6EkmnYiCv6kOq5t90eVHUHeUPz1jz1sKsUOH9AfM/KuQ== X-Received: by 2002:a17:902:760e:b0:1e5:a025:12f9 with SMTP id d9443c01a7336-1ef43d2836fmr395328615ad.28.1716314364758; Tue, 21 May 2024 10:59:24 -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.20 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 21 May 2024 10:59:24 -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 , David Howells , Marc Dionne , linux-afs@lists.infradead.org Subject: [PATCH v6 05/11] afs: drop usage of folio_file_pos Date: Wed, 22 May 2024 01:58:47 +0800 Message-ID: <20240521175854.96038-6-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: 431A340002 X-Stat-Signature: xrzy6giz7kpp4oz1ehnkqzk8yyydjkqc X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1716314366-410358 X-HE-Meta: U2FsdGVkX1/Cq/81C0aWGcWw24KCGKKCD94MC6a9LO8s9XuBR6Cc1p2H53XDiKn4i190mM1X66GV1rQdWwTubOjWnko+ZSkhco0cDiJS2RNHNjWuXTM6iVBTv7eVs8jO+02S4riz9STqtKvnmVsCUF6ciL7BEx094B8gI3lgMGF4e9rrmk2NSMT9EzN7LosCJBDfTQo/6oVE5bf5r/emUw/Or/D0XfWdPD7wQFT0MJNMra279M0GFiPQhdLDIttNwSYzXM6z9ATBz4AqTL/Nvujj+yhnbz0nXLrnh5uHunD6R782sK/zGMHK457NpKRmBRTwKpADSM5eUU8md9WLtrjyBYPNeNYFH7BU2PrLFMVmioq8TPe0pclz+QRitPQY6NGa/rAgONFd2CFb0Ox1SJP9DR/z57jyisWN+NMCUm7Z3bTwtaj8LP8DIqx+GRzAaLXQF0pe9b4vgxD8SSOR5UDfycU4kUxQCQvfP555VokO2ppRCQfCYqkWFfOmPZHi+9fu4c5X+hHMGW6vvQ882+tfI3LGNq2cMAWJl1whTnD6qbqj65nqjMm0ZIKFX0RO5BxLSgmDyiNLqSzzOKT+0jWDcbgB7DSD4fr3dfS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g1jyeWbdlPPqK6SyktVyoRJJ5qufAL0b1tp4sj7tPc+KspRNV0toAgZCERAP/nm9yHaQ2zR40ilt2GnE4CmLwE8Xb7kaUHSeni6YESQJ51ysnU+L+V/AlsQ+RmfQZ8fvmJIVthmEgnkVUCfMzV21uYRDMYcdBjAIiE1ltGWoH6z34SZCb606LSSuxzktQ/DrM7wuLx26WTvSri1FQQeu2u0r7r+e0AESrIlaUrWzzSuCfNEl6MdwhO5nnMaKFBAnqA= 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 folio_file_pos is only needed for mixed usage of page cache and swap cache, for pure page cache usage, the caller can just use folio_pos instead. It can't be a swap cache page here. Swap mapping may only call into fs through swap_rw and that is not supported for afs. So just drop it and use folio_pos instead. Signed-off-by: Kairui Song Cc: David Howells Cc: Marc Dionne Cc: linux-afs@lists.infradead.org --- fs/afs/dir.c | 6 +++--- fs/afs/dir_edit.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/afs/dir.c b/fs/afs/dir.c index 67afe68972d5..f8622ed72e08 100644 --- a/fs/afs/dir.c +++ b/fs/afs/dir.c @@ -533,14 +533,14 @@ static int afs_dir_iterate(struct inode *dir, struct dir_context *ctx, break; } - offset = round_down(ctx->pos, sizeof(*dblock)) - folio_file_pos(folio); + offset = round_down(ctx->pos, sizeof(*dblock)) - folio_pos(folio); size = min_t(loff_t, folio_size(folio), - req->actual_len - folio_file_pos(folio)); + req->actual_len - folio_pos(folio)); do { dblock = kmap_local_folio(folio, offset); ret = afs_dir_iterate_block(dvnode, ctx, dblock, - folio_file_pos(folio) + offset); + folio_pos(folio) + offset); kunmap_local(dblock); if (ret != 1) goto out; diff --git a/fs/afs/dir_edit.c b/fs/afs/dir_edit.c index e2fa577b66fe..a71bff10496b 100644 --- a/fs/afs/dir_edit.c +++ b/fs/afs/dir_edit.c @@ -256,7 +256,7 @@ void afs_edit_dir_add(struct afs_vnode *vnode, folio = folio0; } - block = kmap_local_folio(folio, b * AFS_DIR_BLOCK_SIZE - folio_file_pos(folio)); + block = kmap_local_folio(folio, b * AFS_DIR_BLOCK_SIZE - folio_pos(folio)); /* Abandon the edit if we got a callback break. */ if (!test_bit(AFS_VNODE_DIR_VALID, &vnode->flags)) @@ -417,7 +417,7 @@ void afs_edit_dir_remove(struct afs_vnode *vnode, folio = folio0; } - block = kmap_local_folio(folio, b * AFS_DIR_BLOCK_SIZE - folio_file_pos(folio)); + block = kmap_local_folio(folio, b * AFS_DIR_BLOCK_SIZE - folio_pos(folio)); /* Abandon the edit if we got a callback break. */ if (!test_bit(AFS_VNODE_DIR_VALID, &vnode->flags)) From patchwork Tue May 21 17:58:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13669614 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 BE190C25B74 for ; Tue, 21 May 2024 17:59:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5561E6B009A; Tue, 21 May 2024 13:59:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 505746B009B; Tue, 21 May 2024 13:59:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3A6156B009C; Tue, 21 May 2024 13:59:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 168DD6B009A for ; Tue, 21 May 2024 13:59:33 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id C23DBC08EF for ; Tue, 21 May 2024 17:59:32 +0000 (UTC) X-FDA: 82143165384.24.EA6DA52 Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) by imf21.hostedemail.com (Postfix) with ESMTP id 2318B1C0012 for ; Tue, 21 May 2024 17:59:30 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=W3N0kn8v; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf21.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.210.179 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=1716314371; 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=Xg2lyZdavS/xqDWMBFosXrNzMBl51D2SBqOTVmsbmqo=; b=BpiWvSO2ftHpt3iplyYiEavYwHn+rIwI2tGJX8b8TxsHczMpV6dPhf+rsUyEGQyuLQCY/Y ZAxjhRkgc2LR0zcvDnGJzMFkAX+17R4vfz5dAB+gjdVbOFGHSecnDzabXs7utZh4U7eRkK 1txq6SkO5ywxQNEZrxn/XfA8zJ41oW4= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=W3N0kn8v; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf21.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.210.179 as permitted sender) smtp.mailfrom=ryncsn@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716314371; a=rsa-sha256; cv=none; b=FwP7AdAcmXuqDOP+OtegEJbbf7Yh2JI4xn5FF549rNVwsQkNrezTdTb+f8nw590ZIjRdpc +zEq33a/7y9Ig6bi1+ld3Mfh1eu61XEYCt1MNnBlz0jZ+lwJ1iEYoTwJXx8Pl8LIzSMd3P jPJGvojnzCXKUR7pZy3d2UnuYiIAmwM= Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-6f6911d16b4so709850b3a.3 for ; Tue, 21 May 2024 10:59:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716314370; x=1716919170; 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=Xg2lyZdavS/xqDWMBFosXrNzMBl51D2SBqOTVmsbmqo=; b=W3N0kn8v+5Vwb2D5QlIw7/x+1i9pwr7qZ+/+ZdJ+clPgr53mwjwnDTyBvluAIWejW/ AsCokFIEcc0DJySqQfPbekSEBz+vLz7L3+87NzlGsPsit2ytIBp2ls+MXEWYP2W08MT+ zgMzcY1kK7UHvWSNhf5yHjqNCMlcrC0AMHixkTj/2+LZCjuO0hYKUJRMYgXJkvFGmT5u xD5f8lwe4hhel2dTVbCbLVtLc+Atl3fyA683HtaLb2+bvGwwaI4b3H0yYTAir+Jy2lzi vZwYYwnwLzAttyL5YvtII3aV9IaeC7qFOrWJU2LhP/ja4lBcF2k7+GsL39Q7qQuccacu 7yDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716314370; x=1716919170; 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=Xg2lyZdavS/xqDWMBFosXrNzMBl51D2SBqOTVmsbmqo=; b=G258Kj0Gh5jDd9yfHHl+qeNbVvLxkYkz1j4jYjix4w+3mlHIXucRUh/VoiYlTU9GUK GqoovIbHQT+0HS3x7pEh7/8SVzS1g66byKZZ7XKcc5itFgV0gOgGbIQwSklfz3dPbihu LUd3y3HNNW47rpSFTgsnpmlvYkSOZHEis4fe90n/z0E0r8oGhWxvynUYWR8aD/n4/0rO mH5wFxNWeZnW404j+0kAYkswRmesSRLjLXq8VoVQhR2yOVF+Pe4zS8qWetQgDOjH97u0 jPmC7olgzvLqHeoqjfaADkrbxnYDA54hGe2VuYUwhpPiOmrXJxdqj8FpXDQlC0ahbwnK jBrg== X-Gm-Message-State: AOJu0Yxod72dc+Y7O1k4bSJGbyC878aIspkDRc4fHXQcarIWtj4xy+Fh OB7KUmEjhP7O1mZJbTQlY/s0oooqB2ECKSgQna4lLPGI8NVfvixaqCKoj5l8YQY= X-Google-Smtp-Source: AGHT+IFJcbaL2RYoor2pNfsZrFdmKgf74KAMgNVGow1v7hTBzhmhyuQsxHRR2tBe0moomC0BGjEz7g== X-Received: by 2002:a17:902:d4c4:b0:1f2:eff9:cd4 with SMTP id d9443c01a7336-1f2eff910a4mr117995375ad.0.1716314369672; Tue, 21 May 2024 10:59:29 -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.25 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 21 May 2024 10:59:29 -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 , David Howells , Jeff Layton , netfs@lists.linux.dev Subject: [PATCH v6 06/11] netfs: drop usage of folio_file_pos Date: Wed, 22 May 2024 01:58:48 +0800 Message-ID: <20240521175854.96038-7-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: 2318B1C0012 X-Stat-Signature: xkfeu36mypyituyophsbbkqxicii4j7b X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1716314370-481328 X-HE-Meta: U2FsdGVkX184ve+XnwajKFEzFhuCo3ojbOlOTF2K/UA6YMYnWn2fG4LG6fyuXAenmvCqr2JxSAIAwOwXiOe+WM7t7c4aNhctyPpmJftYUlVwac7hCmpBl9nQCBKJzIlfb+dCG4hXy4cv1GaehwBrljQiX41PPy2VMAdIOjx2HZnf0L6hs1i8CzGo0sQxNAODfs8QaeLUu6KQ5OXSHnVowS7+hUMKWNqpYnCQh/qJn1Mfb2/wc/qkYOK1ikVUkFJgq+99ij6j3NmSUljfm795bLqf1ALScmd+w43xDSk+mVL8k6OewQa6g7u8Wnt2fPFsW5tFojIUMpiadBGJx/0r8wvq1J7EKJkViSCBTPIb6VtZTrQRDuLuvB41xyB7ZEBxSYl5A4XRJaSh9y2E47+SMcogwPbM/uCKqnLMXjwxxRpPse3nZPmbWZghcR54jlL5GYt7KFgpez7fxql39+7gIU2sIA/nIXLXtuDgKVTKqTr+1uhuxdiIqqFldpclYztP8BR1rd+PoWwVtFJEQteMbcKkP+WMpfIk2dG/FfGGOMEkZzk1iqUJiylNpvn+CR+mfY4PGLVdiN4rTfUH9xktTErwlld9jtjQEXIF5mhYJcJH7ipG4o6lJBCwN/dRGIwQrJu5d5aceLKRrx+eVhLKhmMVQvlKqoh0nHokv1jp3n750ZvERu238RHIeAq0vJOKVt5Uaf7z8qF1QUEjqRBts69zke94OA08b1ozdCFDmCxZ7hykOi8WyypdocsAVcSRIICO9AM3DSRcFSzgTeTByZqQiMnHTTQEeKJwhOMwsXnncjXDDhSdIAazs+gbQaIspku9eFO39vQVJbVAP1QoIKbeIS37U2nk7yK+HUHD8PmTGUydFPYxWjvhl6gpupUHRm29T1ouNlqzSZyrJNQV6vRA6tV6rOd6OwkCo6uBK9/6OR6AJOriqcAN+QHQX4EsFzwnWHpgBv+ULnZFJwr AKaCPUYK 7MDIlh4NmhkZaByiyBheTYr6RI/fI460tIHzkrCReHrvJmYXaMUyTuJ4rfVHpY54RgNz21BVWIooxh2Tn4YCPvdzremKUS7Vqsks4ftg+wwad5GO0QxD7L9QdZi8ZX82vvdBKsR5Fcg053qFAjkngJQTB2jiA/NQVHiX3OP3iD1V3XwWSSx9Nl7L14uaUGDwwGMcQAUVdsdbkhjjOg6XF8xI37iSYGi4lwFz+PQe+zU8tx5JuxCEeWhlAhxN2IO96M1KJYHvtJOyFOoHZoOcJiF9Kauw8J9eWrBjqlDLg3abdBE2HHfy19MjxdTyoUv2IlR5Doba/bTR33RoOTqkPPBsBIhoFhrIxYc2YmKY2xgICbmocYrC2ffCOQNZXCBDCh/rjw9UqD/mEOfWUxaOMRvRxCZja/lGgOZOl9xumXfuAU4Cv6t46FrTCFluRCo65rS00oN+3zq24FEs= 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 folio_file_pos is only needed for mixed usage of page cache and swap cache, for pure page cache usage, the caller can just use folio_pos instead. It can't be a swap cache page here. Swap mapping may only call into fs through swap_rw and that is not supported for netfs. So just drop it and use folio_pos instead. Signed-off-by: Kairui Song Cc: David Howells Cc: Jeff Layton Cc: netfs@lists.linux.dev --- fs/netfs/buffered_read.c | 4 ++-- fs/netfs/buffered_write.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/netfs/buffered_read.c b/fs/netfs/buffered_read.c index a6bb03bea920..a688d4c75d99 100644 --- a/fs/netfs/buffered_read.c +++ b/fs/netfs/buffered_read.c @@ -271,7 +271,7 @@ int netfs_read_folio(struct file *file, struct folio *folio) _enter("%lx", folio->index); rreq = netfs_alloc_request(mapping, file, - folio_file_pos(folio), folio_size(folio), + folio_pos(folio), folio_size(folio), NETFS_READPAGE); if (IS_ERR(rreq)) { ret = PTR_ERR(rreq); @@ -470,7 +470,7 @@ int netfs_write_begin(struct netfs_inode *ctx, } rreq = netfs_alloc_request(mapping, file, - folio_file_pos(folio), folio_size(folio), + folio_pos(folio), folio_size(folio), NETFS_READ_FOR_WRITE); if (IS_ERR(rreq)) { ret = PTR_ERR(rreq); diff --git a/fs/netfs/buffered_write.c b/fs/netfs/buffered_write.c index 1121601536d1..b3a6b7b41192 100644 --- a/fs/netfs/buffered_write.c +++ b/fs/netfs/buffered_write.c @@ -54,7 +54,7 @@ static enum netfs_how_to_modify netfs_how_to_modify(struct netfs_inode *ctx, { struct netfs_folio *finfo = netfs_folio_info(folio); struct netfs_group *group = netfs_folio_group(folio); - loff_t pos = folio_file_pos(folio); + loff_t pos = folio_pos(folio); _enter(""); From patchwork Tue May 21 17:58:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13669615 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 0A426C25B7C for ; Tue, 21 May 2024 17:59:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 864006B009C; Tue, 21 May 2024 13:59:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 812C56B009D; Tue, 21 May 2024 13:59:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6B3FA6B009E; Tue, 21 May 2024 13:59:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 4AA1C6B009C for ; Tue, 21 May 2024 13:59:38 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id CB2E31A1249 for ; Tue, 21 May 2024 17:59:37 +0000 (UTC) X-FDA: 82143165594.03.F0C6982 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) by imf20.hostedemail.com (Postfix) with ESMTP id E9ABA1C000F for ; Tue, 21 May 2024 17:59:35 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=TOi8vh1E; spf=pass (imf20.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.214.175 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=1716314376; 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=vrfVlxH6/yrMp6Vv9D3jm93+yp0/ZPJ6N0ZTxwsTE5E=; b=RvwqPd1lyKCGrlw7sJ3Vq5+ae76iERjuYsGU80yKbaBpGqcoX2WHArBoQxUWk4+fZNLxcV NWAU9JyEfmxtn3OxjnKeVb+StUhS32i79SDOOqjc5QGkmJuC/H8bHnjFI4XV64EO14Xnp8 lmtmqIXSALNim75Hu8VnTvrk5AKERPI= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=TOi8vh1E; spf=pass (imf20.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.214.175 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=1716314376; a=rsa-sha256; cv=none; b=jl/DBrD/7HbudxIVwtyBT30RZaXYpF7o6hFm+TOmcSlZvvw1ZoqTND38spxq035doo99dG rFRHxifuaut0ZKbG4NUz+iNP5vsrDPi8t9859/ZZXumXPYFj1dzqae9rzDXB8wcMFgw0Yx mFXIPzsGRwP25M/7C265GEhFGDENA9o= Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-1ed41eb3382so3748035ad.0 for ; Tue, 21 May 2024 10:59:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716314374; x=1716919174; 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=vrfVlxH6/yrMp6Vv9D3jm93+yp0/ZPJ6N0ZTxwsTE5E=; b=TOi8vh1EfW4/PF1mbIw1Lo/Gt6aWHmORFy0ahAokSu599hwHjL7VRyKHb6QD21wvH0 p8GcMGCtAZaPl3H1j/+P+g1jg3gfaPvAUG6YXVCN/6XMdbMq4lCUMRasWeOTVJVEZha7 LqIrqhaw9zV8lDgA4tIq8T6YNCutmOYe8sEIxByd+3pdQTH1gAdOxsReYYUvzfNGM9AQ xq3snctpV8jMIgFbOInRMWfNSc7sSWnaWVMVS8mRJe7/pVWN8+iLWrBAn+HPLQYD2IS2 qN6Bhuk+sjfnTOhGnWNEVMeSPoyHL+o+vFg5b5FDuNB8a1JuvCrAXa0fzO6mmL0ar4zZ iDFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716314374; x=1716919174; 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=vrfVlxH6/yrMp6Vv9D3jm93+yp0/ZPJ6N0ZTxwsTE5E=; b=mEm8fe8jd2g7xknqiAjL+oATzsRidLwpV3XKH+c3u0by7242aZu1eM7Nd1AUYHW3Pq 1IuNQ5/AJae7fAsuf8AehFCjZtRbQOobjrf1KzpTwi++b45h6X+2Lc5P3XaE5CtHYK/5 yVuH20U6na0RvUs5rWtO/0iY4mKkBBs9ksxrFrDlGXW2BkM9L5SMFnQylpp0dwY/00bF C/p5k/gLbwHkYmjELf6HLp/4C7OZL7iMqDcDpBTLwWGzu1mClUTAfNuJHqc/QzB/GMSj MC+dI28jDsW66JBRZQZoSQGuhaK9WDnCcWQhUjF62RzZbelYhzppV7grAysBiMaorlXQ iF1w== X-Gm-Message-State: AOJu0YwmcFMHLH5JKQiSgaCP2VqKa7ObJtw2iVU/vbjjty/Ke3MP/sIb wpK97AoKb9iQsnB/JUQ0Zc4L5iUT8JkPSqsIrI5gBYPbxO858gOPWkGIDNtC0IY= X-Google-Smtp-Source: AGHT+IH54wg5eRYpZnCkwQreGAMbgDD/WonVhjZ99mB7DacBqGVRwQ0mpsTZPZ18Q+815AsjuwwFeQ== X-Received: by 2002:a17:902:7845:b0:1e2:a807:7159 with SMTP id d9443c01a7336-1ef43c09602mr364690065ad.6.1716314374422; Tue, 21 May 2024 10:59:34 -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.30 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 21 May 2024 10:59:34 -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 , Trond Myklebust , Anna Schumaker , linux-nfs@vger.kernel.org Subject: [PATCH v6 07/11] nfs: drop usage of folio_file_pos Date: Wed, 22 May 2024 01:58:49 +0800 Message-ID: <20240521175854.96038-8-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-Stat-Signature: fqox6wmjp6jd6jnj1n657p5pbo9jbpey X-Rspamd-Queue-Id: E9ABA1C000F X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1716314375-578319 X-HE-Meta: U2FsdGVkX1/JB2jrr7JKCea9D32+WQJBvCO+Mx9WR05yrzAAWehhAgYdTCR0r0Rv91FgEexhoxNbNmbHX0twH7sazvHkhKq7LJbyoh9fBEXbG3Ye9421//JfdOYQ5tkhUZ7cUyFaz9T7+fliZb2PaNkeusy5vZ5NeSrsirhgf96/xU9S9kH91iRSgezbJ46OpDze4Dt8cNpSAbhrlE9of/w4S9lU3qv/HtcRSyJBaJER9YgQbmvwDbe4qeJw9tir0CyJtitBkXHtvqqVS0MJ9tkWOMDoH3FYw+DzOuKtvtBs8iKge/EEhGlq2PsmDEMKMZqcOSWk7HheRpOr7KaOZszEGQNmWb+zM0ZNT8kUkIMuvqB4JHvVIfEtJJYm66gbwoi7SlfOucxSOCD1Sgr1OuTiwGH4Uu4GXfj8ql+0TORCWBSUDR/ZK7OppDzQW7PtQzmL7F+rQ0hH3JtmMZFjSaUjs91D80dZd8Mr7dOiSzJmvoWmMZMHby4Vak0wj44ZLBO6tIAL07HeMc8ENa0FtoX6NVahGcjEUL8a4ntUAs5CNma3a87myuq+zbNb6O3I4rdAnOYy1Qwzi+2lD9vEDUeXbkpsG1roCUMp6jrDuL0UKw62gcVsX54v281JVbgXOKGpK87noEcX7lxjT5m4V7BXI2vyTGeWs5iUVEnRqWnD86PP2rQmyIlpKi1yy2fRMFz6WOB4q55/3IGIwKTpf3B3/Op+DEQn6a8thHmZNxT1s86s2UrjHZL0jzHKr6AHcI4VcFH5h8FFNROSdmxd9R88ADPMNc0ws20AVIoWk5NxostgP7OsYABA26xG3IL1PUs/XwPUNAfNeUqmk/bJm98dfDYwScYYbQG1u5NpXNCtRpVsmyA334v2LdJsz0FPfDZkrBmrvcY4kbpbZJ57/NY8ziYoPoElyiaMlBzvbD2g2Up066R9MHDtwRgJHmeNBIZzYzm9bEb7z4lzY3P W0gCviHq FI4ZKNJPvhL/+3g7Iqry7Eztobf7S04xwIokQqQqzTYaurkjRNbTahJb8WbrfFYpt+w9tEYrSoKnCCEFMHaTDlHQb+Gxry2Ti5Ys2u12nLZZYg+tC3DcA2QmqE1hEtV/9HWLqdrNtTdIXvTSLhUb8mxhLwS2AP+ruxunPAWiP3zcJaT+SixZkwrOnODrpcWulNQmsxfCSFxhpiFdRhXTF4T5ZoTZXsSDY2Q+gMzG3l2ct29/O1xbgZQq4TUIqfIZzGp02AoLHo0M7YaQdC3G8ARkGJGU177ckvqmWv75wmjm9CttiK869hCNdlGOzWTh7yYOx57mUa/t0VyacvPYSfVYxQD9VA/Ns8/UVGDDYE52hRI4rm3nn9Ir+cWrl/Vzn/vx825OMyXXAY6XGSRaOMTC2EbWzNFfgZYmYhb47EnlHWWYKcDRbOb/8+wCXdv9J8+xD5YUxHjIY7CwO1cABuWDtpE6P6u1JWXU85wj32uD9wqbrb9GXaSiEoZVjYG9NlLYOvB/aRLBirMTow481kmFZzeb2MGne3cIIuM2EAgqkrjAZnHevak2paieMuM6sArIvP20Od0YJ+xcnkIK/cTyLjXO3lViHbrjk6e4v5dmXOAS43VzHVlSNiOBUmbGtVfY/kuXwHLdVQ/ZEUT3yXfU4U2HlwiXVeQzU1t0EqgTYAjw6Fuw6ela9ky4Hmr+R+bYDMIrvmwgOdzfkjKFYdEpMUVAHyk6diix5Upea7iSESnl2ojvChZYsxEeI0vn6a0ArsOHW2WmHXghoF8bf2iCJtv1zEEcAwTMONVZ8SMNldx9B6kEQSuW9KqHGV37e6CCHedJ/yxEIdUiZnURgENI4AE6vU3VvXU7vg+w7RDNoHMJhladja8aLUJSNh6PbVSwm/KiZe7ZGGWBUODtl4l9PtOY4dXmjoatPF22dmKIMVEAWL+48NIaZZw== 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 folio_file_pos is only needed for mixed usage of page cache and swap cache, for pure page cache usage, the caller can just use folio_pos instead. After commit e1209d3a7a67 ("mm: introduce ->swap_rw and use it for reads from SWP_FS_OPS swap-space"), swap cache should never be exposed to nfs. So remove the usage of folio_file_pos in following NFS functions / helpers: - nfs_vm_page_mkwrite It's only used by nfs_file_vm_ops.page_mkwrite - trace event helper: nfs_folio_event - trace event helper: nfs_folio_event_done These two are used through DEFINE_NFS_FOLIO_EVENT and DEFINE_NFS_FOLIO_EVENT_DONE, which defined following events: - trace_nfs_aop_readpage{_done}: only called by nfs_read_folio - trace_nfs_writeback_folio: only called by nfs_wb_folio - trace_nfs_invalidate_folio: only called by nfs_invalidate_folio - trace_nfs_launder_folio_done: only called by nfs_launder_folio None of them could possibly be used on swap cache folio, nfs_read_folio only called by: .write_begin -> nfs_read_folio .read_folio nfs_wb_folio only called by nfs mapping: .release_folio -> nfs_wb_folio .launder_folio -> nfs_wb_folio .write_begin -> nfs_read_folio -> nfs_wb_folio .read_folio -> nfs_wb_folio .write_end -> nfs_update_folio -> nfs_writepage_setup -> nfs_setup_write_request -> nfs_try_to_update_request -> nfs_wb_folio .page_mkwrite -> nfs_update_folio -> nfs_writepage_setup -> nfs_setup_write_request -> nfs_try_to_update_request -> nfs_wb_folio .write_begin -> nfs_flush_incompatible -> nfs_wb_folio .page_mkwrite -> nfs_vm_page_mkwrite -> nfs_flush_incompatible -> nfs_wb_folio nfs_invalidate_folio is only called by .invalidate_folio. nfs_launder_folio is only called by .launder_folio - nfs_grow_file - nfs_update_folio nfs_grow_file is only called by nfs_update_folio, and all possible callers of them are: .write_end -> nfs_update_folio .page_mkwrite -> nfs_update_folio - nfs_wb_folio_cancel .invalidate_folio -> nfs_wb_folio_cancel Also, seeing from the swap side, swap_rw is now the only interface calling into fs, the offset info is always in iocb.ki_pos now. So we can remove all these folio_file_pos call safely. Signed-off-by: Kairui Song Cc: Trond Myklebust Cc: Anna Schumaker Cc: linux-nfs@vger.kernel.org --- fs/nfs/file.c | 2 +- fs/nfs/nfstrace.h | 4 ++-- fs/nfs/write.c | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/nfs/file.c b/fs/nfs/file.c index 6bd127e6683d..cebddf36b923 100644 --- a/fs/nfs/file.c +++ b/fs/nfs/file.c @@ -588,7 +588,7 @@ static vm_fault_t nfs_vm_page_mkwrite(struct vm_fault *vmf) dfprintk(PAGECACHE, "NFS: vm_page_mkwrite(%pD2(%lu), offset %lld)\n", filp, filp->f_mapping->host->i_ino, - (long long)folio_file_pos(folio)); + (long long)folio_pos(folio)); sb_start_pagefault(inode->i_sb); diff --git a/fs/nfs/nfstrace.h b/fs/nfs/nfstrace.h index afedb449b54f..d249741452e1 100644 --- a/fs/nfs/nfstrace.h +++ b/fs/nfs/nfstrace.h @@ -960,7 +960,7 @@ DECLARE_EVENT_CLASS(nfs_folio_event, __entry->fileid = nfsi->fileid; __entry->fhandle = nfs_fhandle_hash(&nfsi->fh); __entry->version = inode_peek_iversion_raw(inode); - __entry->offset = folio_file_pos(folio); + __entry->offset = folio_pos(folio); __entry->count = nfs_folio_length(folio); ), @@ -1008,7 +1008,7 @@ DECLARE_EVENT_CLASS(nfs_folio_event_done, __entry->fileid = nfsi->fileid; __entry->fhandle = nfs_fhandle_hash(&nfsi->fh); __entry->version = inode_peek_iversion_raw(inode); - __entry->offset = folio_file_pos(folio); + __entry->offset = folio_pos(folio); __entry->count = nfs_folio_length(folio); __entry->ret = ret; ), diff --git a/fs/nfs/write.c b/fs/nfs/write.c index 2329cbb0e446..3573cdc4b28f 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c @@ -281,7 +281,7 @@ static void nfs_grow_file(struct folio *folio, unsigned int offset, end_index = ((i_size - 1) >> folio_shift(folio)) << folio_order(folio); if (i_size > 0 && folio_index(folio) < end_index) goto out; - end = folio_file_pos(folio) + (loff_t)offset + (loff_t)count; + end = folio_pos(folio) + (loff_t)offset + (loff_t)count; if (i_size >= end) goto out; trace_nfs_size_grow(inode, end); @@ -1362,7 +1362,7 @@ int nfs_update_folio(struct file *file, struct folio *folio, nfs_inc_stats(inode, NFSIOS_VFSUPDATEPAGE); dprintk("NFS: nfs_update_folio(%pD2 %d@%lld)\n", file, count, - (long long)(folio_file_pos(folio) + offset)); + (long long)(folio_pos(folio) + offset)); if (!count) goto out; @@ -2073,7 +2073,7 @@ int nfs_wb_folio_cancel(struct inode *inode, struct folio *folio) */ int nfs_wb_folio(struct inode *inode, struct folio *folio) { - loff_t range_start = folio_file_pos(folio); + loff_t range_start = folio_pos(folio); loff_t range_end = range_start + (loff_t)folio_size(folio) - 1; struct writeback_control wbc = { .sync_mode = WB_SYNC_ALL, From patchwork Tue May 21 17:58:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13669616 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 C9498C25B74 for ; Tue, 21 May 2024 17:59:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 68D356B009E; Tue, 21 May 2024 13:59:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 63DEC6B009F; Tue, 21 May 2024 13:59:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4B7E16B00A0; Tue, 21 May 2024 13:59:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 29F8D6B009E for ; Tue, 21 May 2024 13:59:42 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id D02A8A1310 for ; Tue, 21 May 2024 17:59:41 +0000 (UTC) X-FDA: 82143165762.14.0C34E48 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by imf26.hostedemail.com (Postfix) with ESMTP id F3CEF140005 for ; Tue, 21 May 2024 17:59:39 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=nglIiw6c; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf26.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.214.171 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=1716314380; 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=D1huxSjfPNpI2elfAn7WJAQ+EPp79T3Zke3qFamrARc=; b=ze7N/SUt2vS6BAT5WKNK2a9PQkraelaXE6eXJfXcid1OgT6hZthNesrb5J7ROYOc5jyH2t ts9oATJvGRguzkmKzi48VjgOdWR85dtkafgqJscPr7bOPbntN2WkT281jm0CrDqzZoybZp 5B/DzQCJtsCJPGKC/KES3gFv3MZhpFg= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=nglIiw6c; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf26.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.214.171 as permitted sender) smtp.mailfrom=ryncsn@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716314380; a=rsa-sha256; cv=none; b=ZAJ1KpQY5vrjgi9E++4smUjG1ksgdTfkIOeYlC9dDbw3kNF3gPh7/kHKx9YDJGEDCbBn3K 55aVgOFr+0ohr2c1BcwfXTwmserSq7+VDXGJ5YI9XX+xjXDTl6y2j5uffxPMdx6OZeh76m 95ZF7It2Un/p9XbOzpNN1zopufjbkos= Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-1f0537e39b3so3292045ad.3 for ; Tue, 21 May 2024 10:59:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716314378; x=1716919178; 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=D1huxSjfPNpI2elfAn7WJAQ+EPp79T3Zke3qFamrARc=; b=nglIiw6c6EtynG1XKslFcxFaFdlv//4Ry34k2bGy7G0wI39YHVXSOjSexUHKnzKUPl h0NKn8GLnoD7R08py0SnbwPpjZy4EDNNxYnOjX/eufEEvTV3Cjvn+LTWr/Rvly7MOEAx HZJUox7F/ZCPLX0fDLdup9YGaBJqvwYKNKF2lVJofXImx27glH8NsI3y57v80J10DQFc 69EnH6/sQUP57xvZOlhHN//y8loQqjkUUfP1HXSVJJGfLNWBBxbmJsBQRTJ9sOxnh0xI xcmElMA5QnoJ7oRooHTGpPXPmQXYcvZPS5DtWroQae6O+XsYo0Iob9ME5IVvAAFhiiGH 5SkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716314378; x=1716919178; 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=D1huxSjfPNpI2elfAn7WJAQ+EPp79T3Zke3qFamrARc=; b=txenX6iwWzOWeNtjWmlYwyEzM11+xthANTGWXKU5YRqqkCeMv/UqV4uFsozxQUYyrw xTvoPgpLnjdKn355lSgO7JsxSexG6AMBoJyL5Etkidv296hjN7NYIPt2qalm5EOcwXqs sYccFa3r4idi1MHL6jbD6k6h+TvHRhr5WSN5X6b8kgXQoysLH4jmXhBvi5CIDTx+eHA9 Bcnxp436jE9lmaKlmGLdOLw0rdxAYAdg24XmlSgUysUrx5bkKULi2gmApJM1+gUc8a/k 952Di4eDJe2Rp8aWhtKpkr/QWDfyj/RxM6NqafLAc0w2AUoFIqjVD4eUngP3+vo5RaQg ZKzg== X-Gm-Message-State: AOJu0YybJnoGo0JhFI1cua+jCtxQtEhA3cf/4v3N3oVa6BlZQTQzN/6I H6G6hJZik4PJhLyVP5WFj2oRjxbdtI/IJy0ea7pMAHVo1HLfidp4t/SzkP6NcOg= X-Google-Smtp-Source: AGHT+IFhWVOawISt67dDcpWfcLwWNuJAcHjeZXZi5aR2zc9zllf3tQdQzGB28iJi3njxKzYTcZWE2A== X-Received: by 2002:a17:902:db09:b0:1f3:1026:2750 with SMTP id d9443c01a7336-1f310262acfmr25409265ad.61.1716314378510; Tue, 21 May 2024 10:59:38 -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.34 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 21 May 2024 10:59:38 -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 Subject: [PATCH v6 08/11] mm/swap: get the swap device offset directly Date: Wed, 22 May 2024 01:58:50 +0800 Message-ID: <20240521175854.96038-9-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: F3CEF140005 X-Stat-Signature: bdywuzed7wxm8ssxi89qihnfdhwnh3sz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9eMeWXUOgrVBXGazDTu7Lp4VYX43pK6kDrQF5swRgdy45NQPY9QBv+fimSumlQm7F73un5WCgySgttaKYdhVVUGQpOcrLZl2Lu/GL7+Wsg4Do/8zWd28kjBRXlcGcrf/EHwgz0uFVgCaKPQbaaP/QMAUAecx7zIuAfGRyPDpfqQwt5dzvUFanL9ZkfgJcvrkZ27P9fTXRO9elbFXf+vOLvTnIwvt+J2bP+OSJtjnNmIbJ12k3N7ACZAzwoitRu/6J1NkyydQLms2fOXt1kqQK5w+uKejFNEjS8haNHAea/KBTxJMzbTlidjzdBkGA3nOtSG7ExlzDfUkkBGPAfe2OhUjuUnhp0sLfchCLNtUpgP7r53zfycMgjIMvEkJ92qQf2QqTqYIZQvLsl2Ggv7SdIbDccqHjxRwlTKx0E9r5t4jz7aWQV6fNYn4+72H1/73bztIqDWjxtMcd07WuapaJIZFzHv0Dh43nv+D/EXDdlzGQijF6rNQKmWum++0TItPl5Zj/6R04AXDumqeJkhR45/n4HBTg+1K5AKqsYsSTwEjOQ7fBDLjLi/Lh7B+kLUmTv4jonDEX3pS6+9nnc70H6jO8byNiaUvxfoJH3y4gw/kjjUaaG2nT3XJhmFcCRb1pTnTV9S7gK1zzmIvGbCzEL1UoPaAyliP4SB21BD/5X1ryKY4I9J56Eg== 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 folio_file_pos and page_file_offset are for mixed usage of swap cache and page cache, it can't be page cache here, so introduce a new helper to get the swap offset in swap device directly. Need to include swapops.h in mm/swap.h to ensure swp_offset is always defined before use. Signed-off-by: Kairui Song Reviewed-by: "Huang, Ying" --- mm/page_io.c | 6 +++--- mm/swap.h | 9 +++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/mm/page_io.c b/mm/page_io.c index 46c603dddf04..a360857cf75d 100644 --- a/mm/page_io.c +++ b/mm/page_io.c @@ -280,7 +280,7 @@ static void sio_write_complete(struct kiocb *iocb, long ret) * be temporary. */ pr_err_ratelimited("Write error %ld on dio swapfile (%llu)\n", - ret, page_file_offset(page)); + ret, swap_dev_pos(page_swap_entry(page))); for (p = 0; p < sio->pages; p++) { page = sio->bvec[p].bv_page; set_page_dirty(page); @@ -299,7 +299,7 @@ static void swap_writepage_fs(struct folio *folio, struct writeback_control *wbc struct swap_iocb *sio = NULL; struct swap_info_struct *sis = swp_swap_info(folio->swap); struct file *swap_file = sis->swap_file; - loff_t pos = folio_file_pos(folio); + loff_t pos = swap_dev_pos(folio->swap); count_swpout_vm_event(folio); folio_start_writeback(folio); @@ -430,7 +430,7 @@ static void swap_read_folio_fs(struct folio *folio, struct swap_iocb **plug) { struct swap_info_struct *sis = swp_swap_info(folio->swap); struct swap_iocb *sio = NULL; - loff_t pos = folio_file_pos(folio); + loff_t pos = swap_dev_pos(folio->swap); if (plug) sio = *plug; diff --git a/mm/swap.h b/mm/swap.h index fc2f6ade7f80..82023ab93205 100644 --- a/mm/swap.h +++ b/mm/swap.h @@ -5,6 +5,7 @@ struct mempolicy; #ifdef CONFIG_SWAP +#include /* for swp_offset */ #include /* for bio_end_io_t */ /* linux/mm/page_io.c */ @@ -31,6 +32,14 @@ extern struct address_space *swapper_spaces[]; (&swapper_spaces[swp_type(entry)][swp_offset(entry) \ >> SWAP_ADDRESS_SPACE_SHIFT]) +/* + * Return the swap device position of the swap entry. + */ +static inline loff_t swap_dev_pos(swp_entry_t entry) +{ + return ((loff_t)swp_offset(entry)) << PAGE_SHIFT; +} + void show_swap_cache_info(void); bool add_to_swap(struct folio *folio); void *get_shadow_from_swap_cache(swp_entry_t entry); From patchwork Tue May 21 17:58:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13669617 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 3FF57C25B74 for ; Tue, 21 May 2024 17:59:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CF6AB6B00A0; Tue, 21 May 2024 13:59:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CA6A56B00A1; Tue, 21 May 2024 13:59:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B22D16B00A2; Tue, 21 May 2024 13:59:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 92AA46B00A0 for ; Tue, 21 May 2024 13:59:46 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 33018161170 for ; Tue, 21 May 2024 17:59:46 +0000 (UTC) X-FDA: 82143165972.06.D330875 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by imf30.hostedemail.com (Postfix) with ESMTP id 5919780008 for ; Tue, 21 May 2024 17:59:44 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=EafNYapJ; spf=pass (imf30.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.214.178 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=1716314384; a=rsa-sha256; cv=none; b=zGjxj1m7T0OOy2PBXXpa9gKl4rK/TIa+DDlb5gxwF2KzLJyBHlr7DRypK5Q+kHehB6Sslx NsmT8vLSSTWhhcw4izXfy52aYoo4E+fAkEQnymkEzO0G2swckUaSgMQYLdBHvV22d9ScNV usCpDu6obOk6K7tNGNOVE2S03QsrmyA= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=EafNYapJ; spf=pass (imf30.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.214.178 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=1716314384; 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=PHrzc7CPuMjcf8HiikXMyTuP6q46A9jLQj3ikc6Mh0Q=; b=VEdf41CY0YZLJYBkzAPNPhLX4Lewzn/q+HVsFLsKR6F3CvLIKT6Hde6GhIgoj4Ceb9wOga Kdf/+pFt2nq5KVogRrKXeHFQiAFH7mWTqIRJcj2DvAZUAqdkFi73fOL5M5g/n6QToZPUGr P5v0en0QwYAlu3oKV9wBDc53ZWeXxk0= Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-1f2ecea41deso100450445ad.1 for ; Tue, 21 May 2024 10:59:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716314383; x=1716919183; 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=PHrzc7CPuMjcf8HiikXMyTuP6q46A9jLQj3ikc6Mh0Q=; b=EafNYapJRX64vrCeixjGag85M3Um4goSqppuWL6AUnhFNx9DefmUXBUxrrylSBm3jm NKjWweg1EqujUX0F7HkRBo1FbosjAerqdUbERYU4vQbZAFFqH1HYpRaaLF6WFfak2hDB LG3RHqmxKQE2HUxZFW+EOk0kdsPng2VtdY0kRAsh3PwG8b8Uu7t+d7ebwC24FnGFWB+8 RBSIYvBZ/tEdtDsy0zaGfxe0zao9ZKN1Mti8U6wY/kRqdkl+i8Yc1a5k9SwwMzyB/MQR HubfXqXavhlNNIH/uQRQIyBpEMWzhREuEjPxaX5X/vfvhxy0Ug5FzRavUS/tp2niYiFr laag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716314383; x=1716919183; 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=PHrzc7CPuMjcf8HiikXMyTuP6q46A9jLQj3ikc6Mh0Q=; b=UrUxOQccjxvr5nH+vPGct5R6U1XITTw6DnMURikzZAZShHFRSigIG84JDvyhy76a6/ l35I8CnvXHVrT1BlK1K6UlAo0OxRn+Opy7uyvwx16hpTjoJzHARIAWu+kueCM3DjO2JS VRLPnKQuqga/hffqkvR50W3cDKNh9HuXDzpWARxvHHW3702L/NSm6+JsV86JpIx5tQCo OAXSJH2Ez2mjkUaPszxFTA25aFLsGSykSyKkGRRmocw4GwuGDbv4T0vMBvkwHC2PH4xd ybX/mtZ4LLQ9+8WJ6V4c/DaQjt3dIm3g3PjyyVZurghXaYEzty6D9lp2FpmLoVgZU3kz sMLg== X-Gm-Message-State: AOJu0YxTOO90v8SQV358LT+U9VkVSvvCDtx/9AbTKFkBC8pl8lsuEohx 7F5bFNioE9mKabiK38tW64cHOI4LAP03HvqfRHLEdXsowHmqKg6MZcJM8jYUgqA= X-Google-Smtp-Source: AGHT+IEqeNhAh7ppNHI9aB2X1JvWm56eouCLIcYDXiomK1yXxCwOtcxJysWQ/3ie5h+P2MMqSoR/GA== X-Received: by 2002:a17:903:2287:b0:1f2:f512:7a5f with SMTP id d9443c01a7336-1f2f5127d48mr99268225ad.42.1716314382853; Tue, 21 May 2024 10:59:42 -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.38 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 21 May 2024 10:59:42 -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 Subject: [PATCH v6 09/11] mm: remove page_file_offset and folio_file_pos Date: Wed, 22 May 2024 01:58:51 +0800 Message-ID: <20240521175854.96038-10-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: 5919780008 X-Rspam-User: X-Rspamd-Server: rspam12 X-Stat-Signature: x6rxu13mjutfrferyk8ttk9mm1aa4c46 X-HE-Tag: 1716314384-726407 X-HE-Meta: U2FsdGVkX1+va7sr87ETRHmqP32wG5LnfH4lvZJg493VD4IMaWFF2BZt1bAEUGpISLq2H0Ol+oV1vQ5MTdQu9INVyZxldob6bOKSyX8DO0X/tf/xyz6KjAzaOqmA0ZAQnK9Ai0ngKLOrUsd1n9g3eS5xyQ1OpDAp8yvZ9WnnLpMKz/8+3nF7U5BzWkxZKfnOyW9+LL+zRQR21m9Vwnf4sV88vFyC050oZJtizjUbQPPc05YotSzcDEunA9fm/8rS4Wsbod3GxkgfOVZZdLNBwJlf6h+zic2s916ki47oMcNoqLe/2eTAJPVF9ffvKU4Xrc8by3l/TSYCYXb/glqnqChDl2o0MlETfITjo2Ts9Zl+72KpY3OqB15wVl29lxAeB7PxIPY7WyOUNefJ1EhAKIYxJ7DY1vm4NDzjYQZ4prL6bqOkg08jAsy9h27BmXlOGqTy6kKN2iTh5e07XWhuDUxGsat9NoRONGP2iWdaST7+oV9hTG/Mx0nQpx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IThZZilo/+4ckb1AIHJmdmFbNSfNkmtD4Q0VXZ3o+/LvhZRukyxN0c5DJWHrRABAJ7MtFj2QSy8EI68DDrFV2t3kZYt9aqwYJMfXYIwor/xDOFu3eXvFODq3sp5eYpwWpgo8mcSY6vCHdsJjMytux1RA/K6cGijUFwkT5O1Htq5+lVs= 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 These two helpers were useful for mixed usage of swap cache and page cache, which help retrieve the corresponding file or swap device offset of a page or folio. They were introduced in commit f981c5950fa8 ("mm: methods for teaching filesystems about PG_swapcache pages") and used in commit d56b4ddf7781 ("nfs: teach the NFS client how to treat PG_swapcache pages"), suppose to be used with direct_IO for swap over fs. But after commit e1209d3a7a67 ("mm: introduce ->swap_rw and use it for reads from SWP_FS_OPS swap-space"), swap with direct_IO is no more, and swap cache mapping is never exposed to fs. Now we have dropped all users of page_file_offset and folio_file_pos, so they can be deleted. Signed-off-by: Kairui Song Reviewed-by: "Huang, Ying" --- include/linux/pagemap.h | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 3d69589c00a4..010ce7340244 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -920,11 +920,6 @@ static inline loff_t page_offset(struct page *page) return ((loff_t)page->index) << PAGE_SHIFT; } -static inline loff_t page_file_offset(struct page *page) -{ - return ((loff_t)page_index(page)) << PAGE_SHIFT; -} - /** * folio_pos - Returns the byte position of this folio in its file. * @folio: The folio. @@ -934,18 +929,6 @@ static inline loff_t folio_pos(struct folio *folio) return page_offset(&folio->page); } -/** - * folio_file_pos - Returns the byte position of this folio in its file. - * @folio: The folio. - * - * This differs from folio_pos() for folios which belong to a swap file. - * NFS is the only filesystem today which needs to use folio_file_pos(). - */ -static inline loff_t folio_file_pos(struct folio *folio) -{ - return page_file_offset(&folio->page); -} - /* * Get the offset in PAGE_SIZE (even for hugetlb folios). */ From patchwork Tue May 21 17:58:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13669618 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 EA2F0C25B74 for ; Tue, 21 May 2024 17:59:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 815876B00A2; Tue, 21 May 2024 13:59:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7CECC6B00A3; Tue, 21 May 2024 13:59:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 63E1D6B00A4; Tue, 21 May 2024 13:59:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 4748F6B00A2 for ; Tue, 21 May 2024 13:59:51 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id BCD4F80773 for ; Tue, 21 May 2024 17:59:50 +0000 (UTC) X-FDA: 82143166140.21.0530C84 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by imf10.hostedemail.com (Postfix) with ESMTP id BD951C0011 for ; Tue, 21 May 2024 17:59:48 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Bo1NgC1U; spf=pass (imf10.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.214.171 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=1716314388; 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=7qQgvaLUE9M4rws6iEQt+/SaZKzeTop758mxKe3fzns=; b=M1DqFc55M99GmF7rpJg9fGn2U/iCMgNEYnwq6/9HKFJoerXxR/LSIi9NI/BNx/mXisZf+K js1lTiomiSAHKFGEKH90www5l7KQ8lAz0N+/pBVkibpaw3wfV7Rnee/+qhwUOEzfWxz7x0 acZ8SDrnfz1CC7oBbqm3gcj1uLDJb/g= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Bo1NgC1U; spf=pass (imf10.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.214.171 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=1716314388; a=rsa-sha256; cv=none; b=LTwdZq7btzXyJg7e9pKHw6gXQZQHE6Gf0Kj3/saD2NmwmZVuOacVJegiz0GVC+wyGKskIp vgCopjz0XITO8LZvVFtoupWQKdvdXdOKqArEZ/IfblSW4zFc3bBbCOal8E5RRIL2WrDQvm cvVxux8flYm0GazKhridWFAXupxdC9Y= Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-1ecd3867556so3833325ad.0 for ; Tue, 21 May 2024 10:59:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716314387; x=1716919187; 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=7qQgvaLUE9M4rws6iEQt+/SaZKzeTop758mxKe3fzns=; b=Bo1NgC1UMDxPBSozU1KWD4aepsdJ5mFVlLe9XPAtk/cMmgioxCdgb6mTwLybS4lAxD xdBfgV9VL2bO5RZ7J5kJTmADReRHhe0oDIPyzyV+0VHyaKlKoVmEMJw2VPQisT+E6c2y 2IhayjxdcBZVxFUaKkvejM4tmBgF9mvLlIw/b3N/qpnj2n1J7eP71Vo8ozTH0DDUm26N 9cSwilhyrHKuOBmByVpwZ7t43jpficQcTZEsAtyFpIAeAv+aowzAQZV4AFFK+T4m+oTa n4gUvBsnnwMzQgUeZmWLTJ7JX5N9PLEOeQRE5YIRAItVSirgekpEh16ciVrxdVvEr6nD 45jA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716314387; x=1716919187; 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=7qQgvaLUE9M4rws6iEQt+/SaZKzeTop758mxKe3fzns=; b=NOEt4j6SAYk2hqao8rJwv5JKQDLl0I9bCaH97kUb60FEUh5whjxhry8QsKxP/3DTQb /DZkWeAv+yAF3c+Z9KFWAcO22fzPBrhxoinuJCWP4SM0YZ8K7vW6Fc6SPl5lSqUHLCfc xwhfFSYQSrCz/zsQ2Ehl/fzTaS8IsxzqP/P9rIr49FaO2t9CuBdIiGdn21sY3Ko3PNx9 ASFJytD29uj/kpKfCec+z6o+OIfU1XnfmjCPAkkPE1QJBueWbYTzg7owuLspBi36hwiI aBSb6aXtjCy0679zThR7aahLxC5sZt1QI6Pm90qkrjrfokLBdConJnneInWIkx31A2x6 BIQQ== X-Gm-Message-State: AOJu0Ywa44tO4rRzI8DV4Bvvh1HmHFK9nakWmDkwHad0jqlEwUbc2cTR eICLS1NBuOhNkXEk6Tb7PmR+ixrgy00XOGQjTGZJcj0SXHw5bwLbMU55tuyCCEo= X-Google-Smtp-Source: AGHT+IEZakWrbVxlRp22N1fNkpJSK0qMF00Dd6C/77G4znr2CuE4Uf3FXSSlP5KZRo8UMc08FAqQKQ== X-Received: by 2002:a17:902:dac1:b0:1f3:3ab:a4fb with SMTP id d9443c01a7336-1f303aba649mr57889605ad.10.1716314387027; Tue, 21 May 2024 10:59:47 -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.43 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 21 May 2024 10:59:46 -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 Subject: [PATCH v6 10/11] mm: drop page_index and simplify folio_index Date: Wed, 22 May 2024 01:58:52 +0800 Message-ID: <20240521175854.96038-11-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-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: BD951C0011 X-Stat-Signature: k16wesut6i6wg5bn9x1ntx5d6k6cziy9 X-HE-Tag: 1716314388-161280 X-HE-Meta: U2FsdGVkX18bp+T6TDmfSwffD6Lojs8d1jkFINCKoN5AyG5DSk7DIjFjYXrnvy7CfTdrO25jiK25oaB7JsrB2H2rzAxZWCv3xfLC2wOT5KyYCMG8dfN05DLGN/WOBToe9a8I8S77igiEnLLPq+5LiBsw1bRv90nHlCcYzVr/uX3JzXLRac3qLkv9+igU/+wEFEJfi/X5Wyu6SWvnBfn/OfL/ovhcbecULldJrTlCnXJNkICYz6NYwYOVOeBVxuf10KMelD4ZVZhhDuNFnMcZaj8DW8EiFMVglExGXRQmrnyeNmtuS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NFhuQcUcxDCgeEcgPXyFwyze7w3rgjydSjP89zJlRGUmj+O9Ip80hfHQVEgxErGgqCB6/OnAADt4nWpfJyo6RcWD3N13jqkrHX0nDwc/AfF+8Ss9OfowThigKB7/jp28k6RvhQBWU8eLS/x5IBcbNreHiPgIHCKUF9sw60zq2S6MiwlS2RzDI+kQtplszVeEP4v22wlldf38BPvx0UnyJLrIQAXsNC3U1lQzosGwgQbtZtefOgwLvECW3V/Mam2xvsrDLOJz6fl26vje4Y5mzybh1cgCVa9SFMlGzEpQhrFy2NoW/eVsjXKEGxWp+RQxRiTiowUCPDiLvxnxNbBq9YQVfPB7NGfBSbtbaM7uH9s33HIjrgfAuHuHr0FiS+q55tFlPjdmaPUONRMlG1dykH51eMlsF4ogDpdtaJh2Q== 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 There are two helpers for retrieving the index within address space for mixed usage of swap cache and page cache: - page_index - folio_index This commit drops page_index, as we have eliminated all users, and converts folio_index's helper __page_file_index to use folio to avoid the page conversion. Signed-off-by: Kairui Song Reviewed-by: "Huang, Ying" --- include/linux/mm.h | 13 ------------- include/linux/pagemap.h | 8 ++++---- mm/swapfile.c | 7 +++---- 3 files changed, 7 insertions(+), 21 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 9849dfda44d4..e2718cac0fda 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2290,19 +2290,6 @@ static inline void *folio_address(const struct folio *folio) return page_address(&folio->page); } -extern pgoff_t __page_file_index(struct page *page); - -/* - * Return the pagecache index of the passed page. Regular pagecache pages - * use ->index whereas swapcache pages use swp_offset(->private) - */ -static inline pgoff_t page_index(struct page *page) -{ - if (unlikely(PageSwapCache(page))) - return __page_file_index(page); - return page->index; -} - /* * Return true only if the page has been allocated with * ALLOC_NO_WATERMARKS and the low watermark was not diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 010ce7340244..7fd67edc0bcf 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -780,7 +780,7 @@ static inline struct page *grab_cache_page_nowait(struct address_space *mapping, mapping_gfp_mask(mapping)); } -#define swapcache_index(folio) __page_file_index(&(folio)->page) +extern pgoff_t __folio_swap_cache_index(struct folio *folio); /** * folio_index - File index of a folio. @@ -795,9 +795,9 @@ static inline struct page *grab_cache_page_nowait(struct address_space *mapping, */ static inline pgoff_t folio_index(struct folio *folio) { - if (unlikely(folio_test_swapcache(folio))) - return swapcache_index(folio); - return folio->index; + if (unlikely(folio_test_swapcache(folio))) + return __folio_swap_cache_index(folio); + return folio->index; } /** diff --git a/mm/swapfile.c b/mm/swapfile.c index f6ca215fb92f..0b0ae6e8c764 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -3474,12 +3474,11 @@ struct address_space *swapcache_mapping(struct folio *folio) } EXPORT_SYMBOL_GPL(swapcache_mapping); -pgoff_t __page_file_index(struct page *page) +pgoff_t __folio_swap_cache_index(struct folio *folio) { - swp_entry_t swap = page_swap_entry(page); - return swp_offset(swap); + return swp_offset(folio->swap); } -EXPORT_SYMBOL_GPL(__page_file_index); +EXPORT_SYMBOL_GPL(__folio_swap_cache_index); /* * add_swap_count_continuation - called when a swap count is duplicated From patchwork Tue May 21 17:58:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13669619 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 054C7C25B74 for ; Tue, 21 May 2024 17:59:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8D83B6B00A4; Tue, 21 May 2024 13:59:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 887396B00A5; Tue, 21 May 2024 13:59:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 702816B00A6; Tue, 21 May 2024 13:59:55 -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 53BF86B00A4 for ; Tue, 21 May 2024 13:59:55 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id CB463412E4 for ; Tue, 21 May 2024 17:59:54 +0000 (UTC) X-FDA: 82143166308.16.B9BF591 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) by imf27.hostedemail.com (Postfix) with ESMTP id E2FDE4000C for ; Tue, 21 May 2024 17:59:52 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=mBczl0OZ; spf=pass (imf27.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.214.172 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=1716314393; 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=jX6zUCloIMLeC0AtUUIo54oV7OGNQUUzaEpWo4Ucc+8=; b=27MZIviQYpKVeQIq9PGE8eMiHNB393TaHbDD3uTtPWgF8AuE7xW/A72Uiir90QqJ6d6HPB 3b/qa2sKFZ+Jysbw81RoA9vJpQzizfzVebsa8iV8i7PVIL9Ykczky7Ru+WWSD7i/0Mq3pP 5QbxIMnmbzXWRoOFKImLhC2Ld3TpKb8= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=mBczl0OZ; spf=pass (imf27.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.214.172 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=1716314393; a=rsa-sha256; cv=none; b=wgSm8BE1g+VvFtgk24sbSU9izR7KJhDqGv8bwVAASyO/iDsl38kJPPmfFFvtznUktZ7HTL //G9aK2PQKU0vXZ1TgjZrupbAWupDo6j6cT66cRFFdawGT/4IqlT+NsUZ5IqsJaAGEZ3lL kA1qgMEBR6SsqGSBJiTUS3nYhWkbU0Q= Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-1ed904c2280so3304375ad.2 for ; Tue, 21 May 2024 10:59:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716314391; x=1716919191; 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=jX6zUCloIMLeC0AtUUIo54oV7OGNQUUzaEpWo4Ucc+8=; b=mBczl0OZm4E2NWN2QnubO3rfD1f4Qhf18/TbZMnYE3Tv722GPSwniqFT3fyS0nJ/mk +aUJqhgPSDAsOUE/ooI+N6AfX8XZdbM6uJ1yP0EDN6E1IWFFWNshUgKNVnFQt+oLuTpK Ex4yDy+rGX4T941ddEg9N30r1Y9OOIyIxoGpyjwWntcMHarbw8maajH9MLmraKEvbb2d OFafPWG6PiiW8U9r4YZtEol+NW2Fj1//xhj8N4AiKt1v3mZRAB4BtH1H35bkMQPKBjHh 1aa6OlXcRXWBJpU6znu0QFliiwbgiCI+Nfy0d8mNZMaBjVR5zZ7ZWKlLs8GIyXZ0xTd8 cWUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716314391; x=1716919191; 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=jX6zUCloIMLeC0AtUUIo54oV7OGNQUUzaEpWo4Ucc+8=; b=jXOjA4TUAnAO+rCCXgRp1KgKoKZiY8ja4X92DEy7roxl5ZXvEutMqkei16+9zkqaea sz1HJ8uPzIh4t5DAdVtcMnihOh7x5UroUAsGaj0vyK1DDvg1Dab7q1hagwr8EldPtJNc UnOvdZ3jSR5MDATdLcK45HBAd1/dPuALaVpZFP9eSnvPPQhESvt+WltqrLomxjh/qykl pApFx5XDZKsRjaKyj4h/loCRYFVd2IxpcNxP9PHomjMDmFkxdzJgwU7Lv/6otYClDnt4 HyYmD0a5QudQd0NfZRqXyn3P3D4c+QTAdfQJVq+S4ND+t4DNQDcm9IL0zOIhS6fIZOVZ TXgg== X-Gm-Message-State: AOJu0YyhVA7ZqQr0YBamzDos/3CdD+rPYMnJ5KY9efnFsDN6cg+I51qv eQ+daAEOsjueqTMjakhJWs4bSpNeVtL7AMYoR04vlH/ZVgvy+cODoXIkAI4RT68= X-Google-Smtp-Source: AGHT+IExAfgsIwWGDABBN/J81IQxzi7Xmus1MnTq7EO1h5SpSUKVtCl9UBUAT3KpqGVr3jZT+Cbd4w== X-Received: by 2002:a17:902:bb17:b0:1e0:115c:e03c with SMTP id d9443c01a7336-1ef43f4ce9fmr320876095ad.53.1716314391332; Tue, 21 May 2024 10:59:51 -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.47 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 21 May 2024 10:59:50 -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 Subject: [PATCH v6 11/11] mm/swap: reduce swap cache search space Date: Wed, 22 May 2024 01:58:53 +0800 Message-ID: <20240521175854.96038-12-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-Stat-Signature: 4quwukba9n3idmcuz1uh5oktqghgx36e X-Rspamd-Queue-Id: E2FDE4000C X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1716314392-827219 X-HE-Meta: U2FsdGVkX18SFns+pIJkh3m2nYOd3lu4QLo7zG9lpU93Mi/ag/NOe4tA8Ss5w0Zx+trgLco8z3aBrxSzfo/MwcxCtrnlRkJD6B5fq6U9U8RjeXVvpIfomAyab+z9htL6Y7pctWCn/cx+jc+lCHkRqdbYsEvuDvPcc3zC3EbuN4RoefKjDlBjMhF6lfPr9Ny8CszYCG88Dlo7zyUgl0vuLTsxKhXgmgeQxbC/+4TqPJWoGG0QA10tn71pX+Gh+IablnovNWfFqAV4oMep6bEs6NDMrlAPSEhGeYViYbWi/6TrIgPhfLOmJH901mX8D+RloFE6nvU6dan+PB4MVVC3vf2bbkb2U2qnQMN4yMgosuNeKCc/nvCuIOXr1xpt7FhvsFabC/E+h/mia6Grmm9qiBnF352xZyGWOn1IM3jh1IlyCmoRbGZgffXzcTen5y4MWyd9mzLqdfBtcsVb6J7drUtKL1M9WHBT0tBDqNk7jLVV0j1c3ANcW+y0VEXK1nUrC/D/kuj/7RoGhb4NaYCHBXvS2AhcJRg2ancKGPQTLeZ5qqPDkhzieVl5xTGDBrxWveqnb0jFW5L5ppwixlqAur3S3HTXKggTkAYnqQwCATYoUFeIA8Gz+Ecr+zNihbiGY0c2YJNBj8WEkaB2sT07NutHUB/KX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Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Kairui Song Currently we use one swap_address_space for every 64M chunk to reduce lock contention, this is like having a set of smaller swap files inside one swap device. But when doing swap cache look up or insert, we are still using the offset of the whole large swap device. This is OK for correctness, as the offset (key) is unique. But Xarray is specially optimized for small indexes, it creates the radix tree levels lazily to be just enough to fit the largest key stored in one Xarray. So we are wasting tree nodes unnecessarily. For 64M chunk it should only take at most 3 levels to contain everything. But if we are using the offset from the whole swap device, the offset (key) value will be way beyond 64M, and so will the tree level. Optimize this by using a new helper swap_cache_index to get a swap entry's unique offset in its own 64M swap_address_space. I see a ~1% performance gain in benchmark and actual workload with high memory pressure. Test with `time memhog 128G` inside a 8G memcg using 128G swap (ramdisk with SWP_SYNCHRONOUS_IO dropped, tested 3 times, results are stable. The test result is similar but the improvement is smaller if SWP_SYNCHRONOUS_IO is enabled, as swap out path can never skip swap cache): Before: 6.07user 250.74system 4:17.26elapsed 99%CPU (0avgtext+0avgdata 8373376maxresident)k 0inputs+0outputs (55major+33555018minor)pagefaults 0swaps After (1.8% faster): 6.08user 246.09system 4:12.58elapsed 99%CPU (0avgtext+0avgdata 8373248maxresident)k 0inputs+0outputs (54major+33555027minor)pagefaults 0swaps Similar result with MySQL and sysbench using swap: Before: 94055.61 qps After (0.8% faster): 94834.91 qps Radix tree slab usage is also very slightly lower. Signed-off-by: Kairui Song Reviewed-by: "Huang, Ying" --- mm/huge_memory.c | 2 +- mm/memcontrol.c | 2 +- mm/mincore.c | 2 +- mm/shmem.c | 2 +- mm/swap.h | 15 +++++++++++++++ mm/swap_state.c | 17 +++++++++-------- mm/swapfile.c | 6 +++--- 7 files changed, 31 insertions(+), 15 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 317de2afd371..fcc0e86a2589 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2838,7 +2838,7 @@ static void __split_huge_page(struct page *page, struct list_head *list, split_page_memcg(head, order, new_order); if (folio_test_anon(folio) && folio_test_swapcache(folio)) { - offset = swp_offset(folio->swap); + offset = swap_cache_index(folio->swap); swap_cache = swap_address_space(folio->swap); xa_lock(&swap_cache->i_pages); } diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 7fad15b2290c..cee66c30d31e 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -6148,7 +6148,7 @@ static struct page *mc_handle_swap_pte(struct vm_area_struct *vma, * Because swap_cache_get_folio() updates some statistics counter, * we call find_get_page() with swapper_space directly. */ - page = find_get_page(swap_address_space(ent), swp_offset(ent)); + page = find_get_page(swap_address_space(ent), swap_cache_index(ent)); entry->val = ent.val; return page; diff --git a/mm/mincore.c b/mm/mincore.c index dad3622cc963..e31cf1bde614 100644 --- a/mm/mincore.c +++ b/mm/mincore.c @@ -139,7 +139,7 @@ static int mincore_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end, } else { #ifdef CONFIG_SWAP *vec = mincore_page(swap_address_space(entry), - swp_offset(entry)); + swap_cache_index(entry)); #else WARN_ON(1); *vec = 1; diff --git a/mm/shmem.c b/mm/shmem.c index f5d60436b604..f9b0c34c435a 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1756,7 +1756,7 @@ static int shmem_replace_folio(struct folio **foliop, gfp_t gfp, old = *foliop; entry = old->swap; - swap_index = swp_offset(entry); + swap_index = swap_cache_index(entry); swap_mapping = swap_address_space(entry); /* diff --git a/mm/swap.h b/mm/swap.h index 82023ab93205..2c0e96272d49 100644 --- a/mm/swap.h +++ b/mm/swap.h @@ -27,6 +27,7 @@ void __swap_writepage(struct folio *folio, struct writeback_control *wbc); /* One swap address space for each 64M swap space */ #define SWAP_ADDRESS_SPACE_SHIFT 14 #define SWAP_ADDRESS_SPACE_PAGES (1 << SWAP_ADDRESS_SPACE_SHIFT) +#define SWAP_ADDRESS_SPACE_MASK (SWAP_ADDRESS_SPACE_PAGES - 1) extern struct address_space *swapper_spaces[]; #define swap_address_space(entry) \ (&swapper_spaces[swp_type(entry)][swp_offset(entry) \ @@ -40,6 +41,15 @@ static inline loff_t swap_dev_pos(swp_entry_t entry) return ((loff_t)swp_offset(entry)) << PAGE_SHIFT; } +/* + * Return the swap cache index of the swap entry. + */ +static inline pgoff_t swap_cache_index(swp_entry_t entry) +{ + BUILD_BUG_ON((SWP_OFFSET_MASK | SWAP_ADDRESS_SPACE_MASK) != SWP_OFFSET_MASK); + return swp_offset(entry) & SWAP_ADDRESS_SPACE_MASK; +} + void show_swap_cache_info(void); bool add_to_swap(struct folio *folio); void *get_shadow_from_swap_cache(swp_entry_t entry); @@ -86,6 +96,11 @@ static inline struct address_space *swap_address_space(swp_entry_t entry) return NULL; } +static inline pgoff_t swap_cache_index(swp_entry_t entry) +{ + return 0; +} + static inline void show_swap_cache_info(void) { } diff --git a/mm/swap_state.c b/mm/swap_state.c index 642c30d8376c..6e86c759dc1d 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -72,7 +72,7 @@ void show_swap_cache_info(void) void *get_shadow_from_swap_cache(swp_entry_t entry) { struct address_space *address_space = swap_address_space(entry); - pgoff_t idx = swp_offset(entry); + pgoff_t idx = swap_cache_index(entry); void *shadow; shadow = xa_load(&address_space->i_pages, idx); @@ -89,7 +89,7 @@ int add_to_swap_cache(struct folio *folio, swp_entry_t entry, gfp_t gfp, void **shadowp) { struct address_space *address_space = swap_address_space(entry); - pgoff_t idx = swp_offset(entry); + pgoff_t idx = swap_cache_index(entry); XA_STATE_ORDER(xas, &address_space->i_pages, idx, folio_order(folio)); unsigned long i, nr = folio_nr_pages(folio); void *old; @@ -144,7 +144,7 @@ void __delete_from_swap_cache(struct folio *folio, struct address_space *address_space = swap_address_space(entry); int i; long nr = folio_nr_pages(folio); - pgoff_t idx = swp_offset(entry); + pgoff_t idx = swap_cache_index(entry); XA_STATE(xas, &address_space->i_pages, idx); xas_set_update(&xas, workingset_update_node); @@ -253,13 +253,14 @@ void clear_shadow_from_swap_cache(int type, unsigned long begin, for (;;) { swp_entry_t entry = swp_entry(type, curr); + unsigned long index = curr & SWAP_ADDRESS_SPACE_MASK; struct address_space *address_space = swap_address_space(entry); - XA_STATE(xas, &address_space->i_pages, curr); + XA_STATE(xas, &address_space->i_pages, index); xas_set_update(&xas, workingset_update_node); xa_lock_irq(&address_space->i_pages); - xas_for_each(&xas, old, end) { + xas_for_each(&xas, old, min(index + (end - curr), SWAP_ADDRESS_SPACE_PAGES)) { if (!xa_is_value(old)) continue; xas_store(&xas, NULL); @@ -350,7 +351,7 @@ struct folio *swap_cache_get_folio(swp_entry_t entry, { struct folio *folio; - folio = filemap_get_folio(swap_address_space(entry), swp_offset(entry)); + folio = filemap_get_folio(swap_address_space(entry), swap_cache_index(entry)); if (!IS_ERR(folio)) { bool vma_ra = swap_use_vma_readahead(); bool readahead; @@ -420,7 +421,7 @@ struct folio *filemap_get_incore_folio(struct address_space *mapping, si = get_swap_device(swp); if (!si) return ERR_PTR(-ENOENT); - index = swp_offset(swp); + index = swap_cache_index(swp); folio = filemap_get_folio(swap_address_space(swp), index); put_swap_device(si); return folio; @@ -447,7 +448,7 @@ struct folio *__read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask, * that would confuse statistics. */ folio = filemap_get_folio(swap_address_space(entry), - swp_offset(entry)); + swap_cache_index(entry)); if (!IS_ERR(folio)) goto got_folio; diff --git a/mm/swapfile.c b/mm/swapfile.c index 0b0ae6e8c764..4f0e8b2ac8aa 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -142,7 +142,7 @@ static int __try_to_reclaim_swap(struct swap_info_struct *si, struct folio *folio; int ret = 0; - folio = filemap_get_folio(swap_address_space(entry), offset); + folio = filemap_get_folio(swap_address_space(entry), swap_cache_index(entry)); if (IS_ERR(folio)) return 0; /* @@ -2158,7 +2158,7 @@ static int try_to_unuse(unsigned int type) (i = find_next_to_unuse(si, i)) != 0) { entry = swp_entry(type, i); - folio = filemap_get_folio(swap_address_space(entry), i); + folio = filemap_get_folio(swap_address_space(entry), swap_cache_index(entry)); if (IS_ERR(folio)) continue; @@ -3476,7 +3476,7 @@ EXPORT_SYMBOL_GPL(swapcache_mapping); pgoff_t __folio_swap_cache_index(struct folio *folio) { - return swp_offset(folio->swap); + return swap_cache_index(folio->swap); } EXPORT_SYMBOL_GPL(__folio_swap_cache_index);