From patchwork Fri May 10 11:47: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: 13661471 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 A0B97C25B5F for ; Fri, 10 May 2024 11:50:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 393B86B00CE; Fri, 10 May 2024 07:50:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 343AA6B00CF; Fri, 10 May 2024 07:50:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 20C166B00D0; Fri, 10 May 2024 07:50:30 -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 018DA6B00CE for ; Fri, 10 May 2024 07:50:29 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id AC16A41760 for ; Fri, 10 May 2024 11:50:29 +0000 (UTC) X-FDA: 82102318578.21.5C1F4FD Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) by imf11.hostedemail.com (Postfix) with ESMTP id E09E540003 for ; Fri, 10 May 2024 11:50:27 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=AkhXWOPO; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf11.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.214.177 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=1715341827; 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=mIIbTsUqC47TgpII0qMr2P678NC38ZS92LaHNxc/VvU=; b=TsNJAbbtTvt520kHx4o9VwLa6qxtOVfAEOtPuJWAIM7ljhfA9BwLBkgAddM1432urVkTcZ 5HfdEF+sRMaG8Rwlt9wBwL8DoJvQDQtdftAcHE8oL7nCjb2fiu/oaooOISqMorF7XO/Ee3 4TwTn/RyLTaEK3OHKRpIReugq3YZ7tQ= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=AkhXWOPO; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf11.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.214.177 as permitted sender) smtp.mailfrom=ryncsn@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1715341827; a=rsa-sha256; cv=none; b=5by2VShj8KkzGyj1Q53HtYk4CLA4bfbUa4fEUM7E/Q3JkPKt0LmIDn98iEI33VH1nv3nQC 1xDarsKeh4PuXiYUU4MCuHksWfHmIEbVf/BYWYSR96/77DusDjpOMxu+3nLCDnluQ/7MZB 0VtutS0pLGhaqSPc6N0y7DK2YICQix8= Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-1ee42b97b32so15507075ad.2 for ; Fri, 10 May 2024 04:50:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715341826; x=1715946626; 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=mIIbTsUqC47TgpII0qMr2P678NC38ZS92LaHNxc/VvU=; b=AkhXWOPOL7PwHidx4pZsfZU8XYmkhziUWwmmAEyKzg/gydF/XzaNszgDFrlayHPAMd yQNnQw+ZOch/FmiazlkvinSyJBw42DIjVF6/J26W7osHMKeiE53j6vrumT0vV3GuhGBz /VGoPukJYDRCj6K1mFV3xecbnfBSzj002abBfiAsvBo91yiTkl+68YItUT5Xy5FpYoAj 5gG8fHh/P3wsdj99n2ZypfZH/PLBmJ6L9Vi6IUrwkRULzlWOeKeqjpq7XGLk1APkslPb 33J9K6jG4EaLPkiKmqlWinpI/Rj4l1/6cB4Ad9r+Oxy2Yvn6L6kkSMW4ahIvyggls/Mi sc1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715341826; x=1715946626; 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=mIIbTsUqC47TgpII0qMr2P678NC38ZS92LaHNxc/VvU=; b=W0Z+0o2qaa9xW4SeW7SzVp/sFHgoCj/WrUs+c8T/4PLmj0ZirSrWIGxshHOSTq8byW KdFnMHm0qKJkBTH/coLpbF3VZ6+ILSmYBry+zRBAx7Ool3EG4o2WBUbR2ARGEqIaubr/ cECYPV45swpQMG4vF8jgxc0P1eq4wOQL10j6jH81H1b79ruQU3Z+jNrdYkthvJBfaex0 QtUl43brk2K30cg5UibPhuYopPZVNEOhnHVlg2rOXq4CBOFwskRayFEGfbevIDwh80CV xO4p+6saw461nc0fcn8E3YDzhIAm+DS2KKZBvtU3ngUX0FJCOI/UX97YNuOQoIqcNJ2p /HjA== X-Gm-Message-State: AOJu0YzAd68G0jr+N8W5Azllx6vkybzGPvQk2tLwm7OeeuuuGAociUsL Lp0OzQ2yFNt0WHTy6O3EkIqRLjj9u8amBRpsnHr5nvS2yNkvK4ByoGPKIPWYVkbBmQ== X-Google-Smtp-Source: AGHT+IEqWWlYE0LaQa+qtHe47sVQ58jjdkZuIoCJG8MKrxdZVoUXsASGJ68twijEqsRcGHoHUXZc2w== X-Received: by 2002:a17:902:d4c4:b0:1eb:7ba:a4bc with SMTP id d9443c01a7336-1ef43f43106mr25708225ad.51.1715341826460; Fri, 10 May 2024 04:50:26 -0700 (PDT) Received: from KASONG-MC4.tencent.com ([43.132.141.20]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1ef0c134155sm30183825ad.231.2024.05.10.04.50.22 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 10 May 2024 04:50:26 -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 v5 08/12] nfs: drop usage of folio_file_pos Date: Fri, 10 May 2024 19:47:43 +0800 Message-ID: <20240510114747.21548-9-ryncsn@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240510114747.21548-1-ryncsn@gmail.com> References: <20240510114747.21548-1-ryncsn@gmail.com> Reply-To: Kairui Song MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: E09E540003 X-Stat-Signature: bx8p4qs1d6883o4u6cptdjaio311uw3k X-Rspam-User: X-HE-Tag: 1715341827-713891 X-HE-Meta: U2FsdGVkX1+h6uXHp4HkRwMaCrYTHUQR+nlEPyI4G6LHOoCyMF2zqINjXn2NSDlbWeeKSz2eceMqFGACcGq31I5hybN+n+Upg2t0zQHqZb5ERybiP+sXKBtMPcbC7jy6a3r094E+PDRvxNEpkUGfOVCuAdcUxiRo1jVLf7Xe8IeSJClUorSNH9PpFpLBhuyMsu2QKUSVW1v1oRK9odQAG6JJULNWF+jf8czW2f7SWttkOUVRKVflm6iYkfirIczVcs3ArYldTUfbcUd4WBm8lkDeMPGh7tXeUW+c9euN7O1mq1IrdJ4SeW0RRJNKy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cUgLdIelDMl/81iJpxNjhWM6VlEo7wK6LE4WpkmDekZOdTq4i3fH8xpXeJwv7HNn3RcVwsCk0q9RQHqR2MggAd6AIqH4qgRRauULEKTUkCiYUPZfH02JmEjSVDJ2OUk8mw1spSglBJxCdAPmg83Wfc5iyCCZIqI4CoO3zGTgqxZ4p7JF/ORek1kgT8tznWgAm3KVf9abE92Q5RZWIqCZUyFIBh1lKIO08547pkD1PNtJjVPpL6e490kUa6CkZckfKqcYaMDYmKLyC5AEXjdKaWPOnqs36uhtjrUG9Z8Z7hIfa0yzitDUl0vdG8j9sSGae/p/BpKRen8qCjMetGRUwd0SRl/YxzLN4WNS+ge99YVO1Htwv5zAKEMqlE4RjbdAbuA 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 407c6e15afe2..02741c32e114 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 5de85d725fb9..fc782d889449 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,