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/HtcRSyJBaJER9YgQbmvwDbe4qeJw9tir0CyJtitBkXHtvqqVS0MJ9tkWOMDoH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nn9Ir+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,