From nobody Wed Dec 17 12:17:23 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B8C36C4167B for ; Mon, 27 Nov 2023 14:31:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233758AbjK0Obn (ORCPT ); Mon, 27 Nov 2023 09:31:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233469AbjK0ObP (ORCPT ); Mon, 27 Nov 2023 09:31:15 -0500 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 379DC10D2; Mon, 27 Nov 2023 06:30:46 -0800 (PST) Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1cfc1512df1so8689815ad.2; Mon, 27 Nov 2023 06:30:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701095445; x=1701700245; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gJ/vM3XQ9Xzn38++4z91sUsmQpG2Xapck6PJLaG5SCE=; b=Y1GSpM2LkZobFg3DhhQEurZNU5tUlLLV8CMxAIMjeVoeIuzFdwGdbSKuoArwzzksVO jL+hRd2IS7MmR0Ox1a6ZD4X5IvcMNNIrjIGN5oJlEKN0B+fqihw/mYVyi7fqnf3nPG8K KvZQi4vOErbD+EDEt9Mo+WchWfWmiVNpmoxnzebbbdGsKBDXv22ut3eqr3C/azfQ6A3t 9AMdY7yQWvbZfqldjwUF/GKveBsCjDNlTV+mpIFt7TaYovr4v9NZ0seV8PC0tt5qIFyW i3JBpc098xFkH2WDGXTPsVD7DUQXwS1r1ErCFJEoWqQ4iqf6YxholXqifrFLuAalkC0w TknQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701095445; x=1701700245; h=content-transfer-encoding:mime-version: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=gJ/vM3XQ9Xzn38++4z91sUsmQpG2Xapck6PJLaG5SCE=; b=DujTGdlSQOv5dHl9tLQ32L8L6gTbVuMSheyrVgGPLQ84KdkgwO6KyQ0MGS0JvIsmbK xdlvNjlKwp9JfEaUxY+3ae1hI6KZZ+phX0yuTxzLWcycNKub2penN0dVB89Stt7XBaMF F+JR5t4dNG44AWthbWSHxyAS8nPuXrqhi9a0CcxfZDi71RHuQ1+Lgj21geRxe0UP31pi YhlW9iX2R2En7yd+xMvZX4YQ5DzM7dRWMKdNvkdKpUz42s+y7AEtZ/a3MBEGBQoLdfYN Ek4XwneQ9YS3HtH5GKaKFpIYzcFoUV0KqC/Craxmq1RWKfDyqb7BVT3VgQgty55OiMDE gZDg== X-Gm-Message-State: AOJu0Ywd1ilxoBb7yfvY5jofu8xZaAn1YSe2VOEzIwe9cjzV9wqg+xSg D3v0Ifmhm2ub061e3RBz7SruC8Y7PlE= X-Google-Smtp-Source: AGHT+IFy5VE+vtEgemkre65ANI2Q1mcBjoivTg3gEz1BU1CGEIwKQ7nLOEdhMaUTK1QeSN1tKTCFZg== X-Received: by 2002:a17:902:c144:b0:1cf:bf7b:ae07 with SMTP id 4-20020a170902c14400b001cfbf7bae07mr4772809plj.7.1701095445321; Mon, 27 Nov 2023 06:30:45 -0800 (PST) Received: from carrot.. (i60-34-119-11.s42.a014.ap.plala.or.jp. [60.34.119.11]) by smtp.gmail.com with ESMTPSA id a5-20020a170902ee8500b001cf51972586sm8302784pld.292.2023.11.27.06.30.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 06:30:44 -0800 (PST) From: Ryusuke Konishi To: Andrew Morton Cc: linux-nilfs@vger.kernel.org, Matthew Wilcox , linux-kernel@vger.kernel.org Subject: [PATCH 01/17] nilfs2: move page release outside of nilfs_delete_entry and nilfs_set_link Date: Mon, 27 Nov 2023 23:30:20 +0900 Message-Id: <20231127143036.2425-2-konishi.ryusuke@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231127143036.2425-1-konishi.ryusuke@gmail.com> References: <20231127143036.2425-1-konishi.ryusuke@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" In a few directory operations, the call to nilfs_put_page() for a page obtained using nilfs_find_entry() or nilfs_dotdot() is hidden in nilfs_set_link() and nilfs_delete_entry(), making it difficult to track page release and preventing change of its call position. By moving nilfs_put_page() out of these functions, this makes the page get/put correspondence clearer and makes it easier to swap nilfs_put_page() calls (and kunmap calls within them) when modifying multiple directory entries simultaneously in nilfs_rename(). Also, update comments for nilfs_set_link() and nilfs_delete_entry() to reflect changes in their behavior. To make nilfs_put_page() visible from namei.c, this moves its definition to nilfs.h and replaces existing equivalents to use it, but the exposure of that definition is temporary and will be removed on a later kmap -> kmap_local conversion. Signed-off-by: Ryusuke Konishi Cc: Matthew Wilcox (Oracle) Reviewed-by: Matthew Wilcox (Oracle) --- fs/nilfs2/dir.c | 11 +---------- fs/nilfs2/namei.c | 13 +++++++------ fs/nilfs2/nilfs.h | 6 ++++++ 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c index de2073c47651..b9f13bdf8fba 100644 --- a/fs/nilfs2/dir.c +++ b/fs/nilfs2/dir.c @@ -64,12 +64,6 @@ static inline unsigned int nilfs_chunk_size(struct inode= *inode) return inode->i_sb->s_blocksize; } =20 -static inline void nilfs_put_page(struct page *page) -{ - kunmap(page); - put_page(page); -} - /* * Return the offset into page `page_nr' of the last valid * byte in that page, plus one. @@ -413,7 +407,6 @@ ino_t nilfs_inode_by_name(struct inode *dir, const stru= ct qstr *qstr) return res; } =20 -/* Releases the page */ void nilfs_set_link(struct inode *dir, struct nilfs_dir_entry *de, struct page *page, struct inode *inode) { @@ -428,7 +421,6 @@ void nilfs_set_link(struct inode *dir, struct nilfs_dir= _entry *de, de->inode =3D cpu_to_le64(inode->i_ino); nilfs_set_de_type(de, inode); nilfs_commit_chunk(page, mapping, from, to); - nilfs_put_page(page); inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); } =20 @@ -533,7 +525,7 @@ int nilfs_add_link(struct dentry *dentry, struct inode = *inode) =20 /* * nilfs_delete_entry deletes a directory entry by merging it with the - * previous entry. Page is up-to-date. Releases the page. + * previous entry. Page is up-to-date. */ int nilfs_delete_entry(struct nilfs_dir_entry *dir, struct page *page) { @@ -569,7 +561,6 @@ int nilfs_delete_entry(struct nilfs_dir_entry *dir, str= uct page *page) nilfs_commit_chunk(page, mapping, from, to); inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode)); out: - nilfs_put_page(page); return err; } =20 diff --git a/fs/nilfs2/namei.c b/fs/nilfs2/namei.c index 2a4e7f4a8102..99255694cbe9 100644 --- a/fs/nilfs2/namei.c +++ b/fs/nilfs2/namei.c @@ -280,6 +280,7 @@ static int nilfs_do_unlink(struct inode *dir, struct de= ntry *dentry) set_nlink(inode, 1); } err =3D nilfs_delete_entry(de, page); + nilfs_put_page(page); if (err) goto out; =20 @@ -386,6 +387,7 @@ static int nilfs_rename(struct mnt_idmap *idmap, if (!new_de) goto out_dir; nilfs_set_link(new_dir, new_de, new_page, old_inode); + nilfs_put_page(new_page); nilfs_mark_inode_dirty(new_dir); inode_set_ctime_current(new_inode); if (dir_de) @@ -409,9 +411,11 @@ static int nilfs_rename(struct mnt_idmap *idmap, inode_set_ctime_current(old_inode); =20 nilfs_delete_entry(old_de, old_page); + nilfs_put_page(old_page); =20 if (dir_de) { nilfs_set_link(old_inode, dir_de, dir_page, new_dir); + nilfs_put_page(dir_page); drop_nlink(old_dir); } nilfs_mark_inode_dirty(old_dir); @@ -421,13 +425,10 @@ static int nilfs_rename(struct mnt_idmap *idmap, return err; =20 out_dir: - if (dir_de) { - kunmap(dir_page); - put_page(dir_page); - } + if (dir_de) + nilfs_put_page(dir_page); out_old: - kunmap(old_page); - put_page(old_page); + nilfs_put_page(old_page); out: nilfs_transaction_abort(old_dir->i_sb); return err; diff --git a/fs/nilfs2/nilfs.h b/fs/nilfs2/nilfs.h index 8046490cd7fe..afd700f5dc4e 100644 --- a/fs/nilfs2/nilfs.h +++ b/fs/nilfs2/nilfs.h @@ -237,6 +237,12 @@ extern struct nilfs_dir_entry *nilfs_dotdot(struct ino= de *, struct page **); extern void nilfs_set_link(struct inode *, struct nilfs_dir_entry *, struct page *, struct inode *); =20 +static inline void nilfs_put_page(struct page *page) +{ + kunmap(page); + put_page(page); +} + /* file.c */ extern int nilfs_sync_file(struct file *, loff_t, loff_t, int); =20 --=20 2.34.1 From nobody Wed Dec 17 12:17:23 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3168BC0755A for ; Mon, 27 Nov 2023 14:31:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233777AbjK0Obq (ORCPT ); Mon, 27 Nov 2023 09:31:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233640AbjK0ObS (ORCPT ); Mon, 27 Nov 2023 09:31:18 -0500 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36CFB10FB; Mon, 27 Nov 2023 06:30:49 -0800 (PST) Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1cfa8f7c356so16970345ad.2; Mon, 27 Nov 2023 06:30:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701095448; x=1701700248; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=79oq+dAh3gxJRpbXVK4oY+eeQB5JyiO6FF7VLXAwv3Y=; b=gGQfITpu/0IEPQBSVWUfVKLM+qaUMf7s6Ux6aq8lIXab74oai3ZVJT2nUU1uXWIEB5 Xb06vD9km71cQqzGE6OU+W5cOuLfMOU/B3X81ES7bYg4rlzV45uEGqMgeE83ShUVJABL evvEsO4/+B23bdFsUCoAzNwY6EdTd7Gl9lK5uIMQOhm3EFwQRQb35dWnwp6i5ej1+5HE EOhOcW6Da4wYF2bCqsv9svv7RA/f9pChmPgm7GndIBqsrZlJnq0xkduUAdl1vWaNexQw Gcs9+m7RJDFXBCGJpNPCnXK/lcpJdzG1ZEG5EfdKS8WQTjfE7idC/LRugik2oDmgNmoP gnVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701095448; x=1701700248; h=content-transfer-encoding:mime-version: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=79oq+dAh3gxJRpbXVK4oY+eeQB5JyiO6FF7VLXAwv3Y=; b=R88hVyIIRcO1RKNvrabvKjN/JgFcKQgYSI7JTiWXdHlrWKJIO2ETdd+oAtaIjCBj6T QL+az+Wte0W2yxCnE6nMGs7yk3F63OVH9gTD5BXyWbdupFLSVwQCyfrSsV2XWEea2xJN D0PpMeWQUgbgWPnlWWo+2WqUZ9ecyOHhZ8vDWXdL7V2UFiFtJY4KcEYrcq58/QHNDzY8 Y/NXe2BmOkxUUmjV3flsBspdFb9Y4Yu7DZUUOHNqxJkMPwPmBtSP+YB6Cx5Yv3P6Lt9H E1FYptpkO3WvlsRTzSQ+m+8jvZ6rRytkFAljK7JhWr2QN1IE1TppmXGJ+Hi9dyOUFByr 9HjA== X-Gm-Message-State: AOJu0YyMvf/z3GneU2pKRsFlI9jBmhu/MXztXcx84yvf2b3WhcHS46q2 3Nyodr85UtK8/b8heRJIzjLhtlYsLT4= X-Google-Smtp-Source: AGHT+IFCcGQTenNTKXAWPxXEVGofHh+r5H3pUIB/LHFak8FW5Q+MGjQ4jb9EIEow3dxg4VrJyStGBg== X-Received: by 2002:a17:902:f541:b0:1cf:d648:31e3 with SMTP id h1-20020a170902f54100b001cfd64831e3mr2215302plf.65.1701095448328; Mon, 27 Nov 2023 06:30:48 -0800 (PST) Received: from carrot.. (i60-34-119-11.s42.a014.ap.plala.or.jp. [60.34.119.11]) by smtp.gmail.com with ESMTPSA id a5-20020a170902ee8500b001cf51972586sm8302784pld.292.2023.11.27.06.30.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 06:30:47 -0800 (PST) From: Ryusuke Konishi To: Andrew Morton Cc: linux-nilfs@vger.kernel.org, Matthew Wilcox , linux-kernel@vger.kernel.org Subject: [PATCH 02/17] nilfs2: eliminate staggered calls to kunmap in nilfs_rename Date: Mon, 27 Nov 2023 23:30:21 +0900 Message-Id: <20231127143036.2425-3-konishi.ryusuke@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231127143036.2425-1-konishi.ryusuke@gmail.com> References: <20231127143036.2425-1-konishi.ryusuke@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" In nilfs_rename(), calls to nilfs_put_page() to release pages obtained with nilfs_find_entry() or nilfs_dotdot() are alternated in the normal path. When replacing the kernel memory mapping method from kmap to kmap_local_{page,folio}, this violates the constraint on the calling order of kunmap_local(). Swap the order of nilfs_put_page calls where the kmap sections of multiple pages overlap so that they are nested, allowing direct replacement of nilfs_put_page() -> unmap_and_put_page(). Without this reordering, that replacement will cause a kernel WARNING in kunmap_local_indexed() on architectures with high memory mapping. Signed-off-by: Ryusuke Konishi Cc: Matthew Wilcox (Oracle) Reviewed-by: Matthew Wilcox (Oracle) --- fs/nilfs2/namei.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/nilfs2/namei.c b/fs/nilfs2/namei.c index 99255694cbe9..d179db8074c2 100644 --- a/fs/nilfs2/namei.c +++ b/fs/nilfs2/namei.c @@ -411,13 +411,14 @@ static int nilfs_rename(struct mnt_idmap *idmap, inode_set_ctime_current(old_inode); =20 nilfs_delete_entry(old_de, old_page); - nilfs_put_page(old_page); =20 if (dir_de) { nilfs_set_link(old_inode, dir_de, dir_page, new_dir); nilfs_put_page(dir_page); drop_nlink(old_dir); } + nilfs_put_page(old_page); + nilfs_mark_inode_dirty(old_dir); nilfs_mark_inode_dirty(old_inode); =20 --=20 2.34.1 From nobody Wed Dec 17 12:17:23 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E1B4C4167B for ; Mon, 27 Nov 2023 14:31:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233851AbjK0Obt (ORCPT ); Mon, 27 Nov 2023 09:31:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233766AbjK0ObT (ORCPT ); Mon, 27 Nov 2023 09:31:19 -0500 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C151A1707; Mon, 27 Nov 2023 06:30:52 -0800 (PST) Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1ce627400f6so32881405ad.2; Mon, 27 Nov 2023 06:30:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701095452; x=1701700252; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DCM3sUYAk/tlBLIzo2SaDQBBpHgsnzA0anQsHtnDawg=; b=ExiDDPRoA0/zQHstCPV5m9COgyMsE1YPuklgiFPgFWE6RT4+cOV8WmkswESSFX/Jce 7loF4QvMA8TxX/hqbjkLzvhXwtTSgMTefammgk9nkEC2Ylbtfk6te6J7VkU1AM8MTFWN 1TT4v/c2jtEgd3ZTA9AApwx3MQhm4nKyCRIbesLDGvYKJvmhPvV8GGMQx3+ly66WHhHs AivmTasjb/efSxd5PMdU0JdqQAbt9BdHC6RCAnUsgT7ONtoGGvL8W6X4Cn6oWlq36QIh bDSQm2nLZqJN0nB8B5ASWYYKA/j+OPEc7IhSil13V6W/x3TNGNvN8Klt82DMTEX5eHl7 TbdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701095452; x=1701700252; h=content-transfer-encoding:mime-version: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=DCM3sUYAk/tlBLIzo2SaDQBBpHgsnzA0anQsHtnDawg=; b=TBY9/dwEE94xkf3atuZOjEVJIl583gIpXrDTOmSIgWvBytA5ZVRF5delUsQtHSkM61 kQRkixZVv3K4JQQCkB3beGPCZz/CLnVbfpHJZQuXsjfuLnwgWYgXljCxeJHzU8eTHAPi EQ9DdyrjLeQ4xIID9P0GPwJAR3al+XwD+ewc/3cOSo7DDKgdmz9YM0pLslQTzYFDOe19 oLEX1KS5wJkYhsvpE56B5ddY5FeCMKRvuzyNZM3lqcmtp3qdIBvF0JhNy7XsOo/zesgv Xhvl7Cn7aDU8y5TtwDbs2Pnd/gQOV0aha3nE65eZgpdFGnWJtpIVUs6JHieefwk8LsEH PFOA== X-Gm-Message-State: AOJu0Yyy6fOllCkc91//ALWad7qGspfWPUO1iD59uxMzuUMA3Gk5ZBjK ZTrsWWJMGX+uuBOCI1+kOGNGYQW8Ryg= X-Google-Smtp-Source: AGHT+IGqs2p9AUmWg40Aa1szxvE9St37rUQlPzhh9gXKXTySpFbUaY+bo4T4WR14yruHNtlzdD7hHw== X-Received: by 2002:a17:902:a589:b0:1cf:e880:cb8f with SMTP id az9-20020a170902a58900b001cfe880cb8fmr487203plb.55.1701095451896; Mon, 27 Nov 2023 06:30:51 -0800 (PST) Received: from carrot.. (i60-34-119-11.s42.a014.ap.plala.or.jp. [60.34.119.11]) by smtp.gmail.com with ESMTPSA id a5-20020a170902ee8500b001cf51972586sm8302784pld.292.2023.11.27.06.30.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 06:30:51 -0800 (PST) From: Ryusuke Konishi To: Andrew Morton Cc: linux-nilfs@vger.kernel.org, Matthew Wilcox , linux-kernel@vger.kernel.org Subject: [PATCH 03/17] nilfs2: Remove page_address() from nilfs_set_link Date: Mon, 27 Nov 2023 23:30:22 +0900 Message-Id: <20231127143036.2425-4-konishi.ryusuke@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231127143036.2425-1-konishi.ryusuke@gmail.com> References: <20231127143036.2425-1-konishi.ryusuke@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: "Matthew Wilcox (Oracle)" In preparation for removing kmap from directory handling, use offset_in_page() to calculate 'from'. Matches ext2. Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Ryusuke Konishi --- fs/nilfs2/dir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c index b9f13bdf8fba..9c0513245a3b 100644 --- a/fs/nilfs2/dir.c +++ b/fs/nilfs2/dir.c @@ -410,7 +410,7 @@ ino_t nilfs_inode_by_name(struct inode *dir, const stru= ct qstr *qstr) void nilfs_set_link(struct inode *dir, struct nilfs_dir_entry *de, struct page *page, struct inode *inode) { - unsigned int from =3D (char *)de - (char *)page_address(page); + unsigned int from =3D offset_in_page(de); unsigned int to =3D from + nilfs_rec_len_from_disk(de->rec_len); struct address_space *mapping =3D page->mapping; int err; --=20 2.34.1 From nobody Wed Dec 17 12:17:23 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21450C4167B for ; Mon, 27 Nov 2023 14:32:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233679AbjK0Oby (ORCPT ); Mon, 27 Nov 2023 09:31:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233770AbjK0ObT (ORCPT ); Mon, 27 Nov 2023 09:31:19 -0500 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EDCAC1727; Mon, 27 Nov 2023 06:30:54 -0800 (PST) Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1cfb3ee8bc7so16408785ad.1; Mon, 27 Nov 2023 06:30:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701095454; x=1701700254; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tAEplWTuwzV3S4Z2ct3K3DPtCcwmnpKgJHolez0b9mo=; b=AkbRcCdpMnJz6h1t2matzBF5QSpTK3pmu9wyG7yHu4ncsw2vz/XBy7pWyXm/b9LjUu /TEImCkSFQ07sSQgQcB1SGGsBX6sD1YK1/ayNuhDTTpYQoVPV2ygz5wYf3ShvHLPrWO7 P2BKcKjGVSBM4Noqaxe26jK9E0iP+LSsTNCAxgoxEbddjCURvvAoVkfVfqYzeQmSH8sW NI9B5m5gv5UK5GI4sCMdl+pGxQQxex3BuCViltDAMl1/wODHoAWwsnWqlI+gk9zhLJIJ 3iqpSAhAFr5QyLNo0NxIps3PkI921YzegJ8FHqOHYMPvSWFuWDu6I+Hu0fewNBX1DiDU JUKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701095454; x=1701700254; h=content-transfer-encoding:mime-version: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=tAEplWTuwzV3S4Z2ct3K3DPtCcwmnpKgJHolez0b9mo=; b=vSocXQ96ePbLad3ztrbMe8du0CfNVCOeYfR+zGXcqCyfYX2nVJs6q6xv9bNPXYFl4s EYS3ccHjEULPYXxLneFjU+R9D+cPN0J/uelTOdekF7VSFWXcBKJEyfKjHcI7swsuH6dZ M+8Ulih3lZCWTh6Wh5Wfih1OGBmpUFhiWK9rKcb9L5SzFGfICob9f7zc7YPh1Skt/Ymc n95o9KvZ1iPr6J48kepQ4XESpuqysFFxYQ46FLaScaQitPMfANx0AmBrBC4it9Vc+kPa sRfIVu18TyXvcmTbUWJZ5DJGDEFYEKcrXKU6lQ8ZfFvgG//1gS57yFlvVMCww6csZrm0 TQuQ== X-Gm-Message-State: AOJu0YwTeAJ+RmzGL5HBbB1bMWWWtOqVtE6p5RVl7Trs5x2y814tT3gu 5H5yKeUZ3YRACP9/UxWXvUQ= X-Google-Smtp-Source: AGHT+IGkuxW60EYL+gq1SIyBsyBmh6Q7OwG2p/ZfHDeGRvdPHXj7OfN95Big1qkF0cBkoYJ49tfBrg== X-Received: by 2002:a17:902:dac8:b0:1cd:fce2:d702 with SMTP id q8-20020a170902dac800b001cdfce2d702mr15945223plx.15.1701095454348; Mon, 27 Nov 2023 06:30:54 -0800 (PST) Received: from carrot.. (i60-34-119-11.s42.a014.ap.plala.or.jp. [60.34.119.11]) by smtp.gmail.com with ESMTPSA id a5-20020a170902ee8500b001cf51972586sm8302784pld.292.2023.11.27.06.30.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 06:30:53 -0800 (PST) From: Ryusuke Konishi To: Andrew Morton Cc: linux-nilfs@vger.kernel.org, Matthew Wilcox , linux-kernel@vger.kernel.org Subject: [PATCH 04/17] nilfs2: Remove page_address() from nilfs_add_link Date: Mon, 27 Nov 2023 23:30:23 +0900 Message-Id: <20231127143036.2425-5-konishi.ryusuke@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231127143036.2425-1-konishi.ryusuke@gmail.com> References: <20231127143036.2425-1-konishi.ryusuke@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: "Matthew Wilcox (Oracle)" In preparation for removing kmap from directory handling, use offset_in_page() to calculate 'from'. Matches ext2. Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Ryusuke Konishi --- fs/nilfs2/dir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c index 9c0513245a3b..73f135290288 100644 --- a/fs/nilfs2/dir.c +++ b/fs/nilfs2/dir.c @@ -493,7 +493,7 @@ int nilfs_add_link(struct dentry *dentry, struct inode = *inode) return -EINVAL; =20 got_it: - from =3D (char *)de - (char *)page_address(page); + from =3D offset_in_page(de); to =3D from + rec_len; err =3D nilfs_prepare_chunk(page, from, to); if (err) --=20 2.34.1 From nobody Wed Dec 17 12:17:23 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0CF29C4167B for ; Mon, 27 Nov 2023 14:32:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233653AbjK0Ob6 (ORCPT ); Mon, 27 Nov 2023 09:31:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233775AbjK0ObT (ORCPT ); Mon, 27 Nov 2023 09:31:19 -0500 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2DBF710EC; Mon, 27 Nov 2023 06:30:58 -0800 (PST) Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1cfc2d03b3aso8079815ad.1; Mon, 27 Nov 2023 06:30:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701095457; x=1701700257; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TtusoM3dpH6zj86rZ9DcGWfb2vtJ7UeLgS5shm5pfGs=; b=TpoRDYsQk+HkejkDtsfCnnX2/Y57W4+bi3HBYG7762HYYwi7NP1TQNQlkqvWW6OS02 gMdAXtMDAY6irCSAoeIpRnNxRb98ykmlUd8do/WfqD1j2kgNavHL53mC93v8BVvALCVw WUPlHS/MQpGfA8XxATi2HVjXx/qYQ7ka87HqIy7bbENUVeDPHPCabd146GOdarrsZhOe xTlWC5S8oFxNfHO3z11KuB+WAgu49rZFgUxAlkIQj5uQZUaYQ4hEJuBUx6v1e4iXfFIW ppDwWpyaBOVXzzK2HkGzfBKZeYM/EzTgzLSFby1UWLSEOopw6UGFYGIE7VO26KlivQ1z Xikw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701095457; x=1701700257; h=content-transfer-encoding:mime-version: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=TtusoM3dpH6zj86rZ9DcGWfb2vtJ7UeLgS5shm5pfGs=; b=qjsLhpcuZlJ+v3N0RoGnJuOMiKrsigW3H39rr98O5oncj4jxOZkNZH2SulAPd4guSw fP2EcL8DrbJHsa7UsEUjiKv/TnuO9Xa8H+LXLC9/C0i+qE0mNZr9NZU8muE2jwJstrPN jyZZMzFC3m+Qm5MYHVRmAgJfYVY88seas7qkXvgUvZKEjSrxFWo+hKLmextq8zveQEy1 5ojA9P2Qkx33Skrk69UyGN1IaY0Y0zeo4FeL0dD7dEHTyzle6DIrlGxL3FlpbwEZ/lCI /RgfR8gsHIIq0zimPSxyWY1y+NpVYjkR2QeTC/ZVooFFc6GjugtH1y80tOipGBs2f+Uq NfoA== X-Gm-Message-State: AOJu0YxtVRqCstcwWGfNRLpkbMTa6NI4gwbfnbkQeXhA2fqhqCQSCx6h dPNMZrtqsorzHC8NROHz+2D2gM6VBVE= X-Google-Smtp-Source: AGHT+IE5lM6J+NZSydRaySA557HC3cJyq5847etNUFGAlE9tx4q0L/cSdLamUjeGFIshgx1ecCrTZw== X-Received: by 2002:a17:903:11c8:b0:1cf:5760:43f9 with SMTP id q8-20020a17090311c800b001cf576043f9mr12554020plh.64.1701095457548; Mon, 27 Nov 2023 06:30:57 -0800 (PST) Received: from carrot.. (i60-34-119-11.s42.a014.ap.plala.or.jp. [60.34.119.11]) by smtp.gmail.com with ESMTPSA id a5-20020a170902ee8500b001cf51972586sm8302784pld.292.2023.11.27.06.30.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 06:30:56 -0800 (PST) From: Ryusuke Konishi To: Andrew Morton Cc: linux-nilfs@vger.kernel.org, Matthew Wilcox , linux-kernel@vger.kernel.org Subject: [PATCH 05/17] nilfs2: Remove page_address() from nilfs_delete_entry Date: Mon, 27 Nov 2023 23:30:24 +0900 Message-Id: <20231127143036.2425-6-konishi.ryusuke@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231127143036.2425-1-konishi.ryusuke@gmail.com> References: <20231127143036.2425-1-konishi.ryusuke@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: "Matthew Wilcox (Oracle)" In preparation for removing kmap from directory handling, mask the directory entry pointer to discover the start address of the page. Matches ext2. Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Ryusuke Konishi --- fs/nilfs2/dir.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c index 73f135290288..385e47eda99f 100644 --- a/fs/nilfs2/dir.c +++ b/fs/nilfs2/dir.c @@ -531,7 +531,7 @@ int nilfs_delete_entry(struct nilfs_dir_entry *dir, str= uct page *page) { struct address_space *mapping =3D page->mapping; struct inode *inode =3D mapping->host; - char *kaddr =3D page_address(page); + char *kaddr =3D (char *)((unsigned long)dir & PAGE_MASK); unsigned int from, to; struct nilfs_dir_entry *de, *pde =3D NULL; int err; @@ -551,7 +551,7 @@ int nilfs_delete_entry(struct nilfs_dir_entry *dir, str= uct page *page) de =3D nilfs_next_entry(de); } if (pde) - from =3D (char *)pde - (char *)page_address(page); + from =3D (char *)pde - kaddr; lock_page(page); err =3D nilfs_prepare_chunk(page, from, to); BUG_ON(err); --=20 2.34.1 From nobody Wed Dec 17 12:17:23 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93603C4167B for ; Mon, 27 Nov 2023 14:32:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233903AbjK0OcB (ORCPT ); Mon, 27 Nov 2023 09:32:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233780AbjK0ObU (ORCPT ); Mon, 27 Nov 2023 09:31:20 -0500 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B71D19AB; Mon, 27 Nov 2023 06:31:00 -0800 (PST) Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1cfa5840db3so23163715ad.2; Mon, 27 Nov 2023 06:31:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701095460; x=1701700260; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LSD6FwTVggzrZpf2kEN+3oSDCrGK42JmxcGcmXQsxww=; b=KLJx8QvmCPcubfTBNhQxVX0gSf3HddAJQa6MM86PMg781f5bWHIEXWR9ya2pRWqB7+ 9oWo4d/dsLZsiM/Y3iOVhi43VNcRtpVLG+sd7jMLWj/sKiLoNF8S63NLf3KkLcXVgfMJ TnZJIiD9tSNMk8kYQ0l02SxGOnIY6PZR/IOV6ByHcz7xCOt5RetIzXkdG1WgoSEZq/FS o0EZjK2snzpAtyfxfaFEcSkUxr3ZcVhMsoZFuNtOpEmB/T8d2f1w8cg8hzgViAiA3osE RjYG6uuduTC0xu65OzT1gO8gIKaJDI7R31AAOb1RLyguuSi6b+zAX4kfgoDhXrV2Adbk jINw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701095460; x=1701700260; h=content-transfer-encoding:mime-version: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=LSD6FwTVggzrZpf2kEN+3oSDCrGK42JmxcGcmXQsxww=; b=u80Z09Kv5SmFAuw7ITVf8WkbfcwLJOzZLudXU7t3m3dmLljAKD3OKC4zqMzRVkfwvs CQfmSz7ggwU+5nO/qrW76XY9Ay1l+eKyIWQH1dFUXFMttSYS6Q9Htdcv0QB9miCFGcwf DBT7eoV8JzFwo2dk1mIyz3l8SVH0hqLQLrQ6iklE1AsACEns0aLk+Hs1QbgKikR4k3g5 CoUNn9Yitkz7OfkZ/yT9kCWz9d394NScTXtD/8ysR+e3N1Bm75Vq/q+8CTT1ydb9PT74 HSDTYsiOtFl8hOV0AXG5yicbFnGn9fW6+IM0ZCo96Na8Sz1Ap/4/ORpgrjgHpvAMFoQK kPgQ== X-Gm-Message-State: AOJu0YwvnsaYzaTZO2tfk9QFuzKTW9YlHQh3B6G9QKofskHry9cTpaV8 P6DxrQ0N+DTwwTSZNO3rLac= X-Google-Smtp-Source: AGHT+IEF1Kj/8FJ+iVLoJfprjT4ji3uBhZlsosiVNxX3G5wSdQYnZ7HKAlwVCQ4nJEIhRGgGIPeS3A== X-Received: by 2002:a17:903:41ce:b0:1cf:c3fb:a982 with SMTP id u14-20020a17090341ce00b001cfc3fba982mr5966951ple.63.1701095459732; Mon, 27 Nov 2023 06:30:59 -0800 (PST) Received: from carrot.. (i60-34-119-11.s42.a014.ap.plala.or.jp. [60.34.119.11]) by smtp.gmail.com with ESMTPSA id a5-20020a170902ee8500b001cf51972586sm8302784pld.292.2023.11.27.06.30.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 06:30:59 -0800 (PST) From: Ryusuke Konishi To: Andrew Morton Cc: linux-nilfs@vger.kernel.org, Matthew Wilcox , linux-kernel@vger.kernel.org Subject: [PATCH 06/17] nilfs2: Return the mapped address from nilfs_get_page() Date: Mon, 27 Nov 2023 23:30:25 +0900 Message-Id: <20231127143036.2425-7-konishi.ryusuke@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231127143036.2425-1-konishi.ryusuke@gmail.com> References: <20231127143036.2425-1-konishi.ryusuke@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: "Matthew Wilcox (Oracle)" In prepartion for switching from kmap() to kmap_local(), return the kmap address from nilfs_get_page() instead of having the caller look up page_address(). [ konishi.ryusuke: fixed a missing blank line after declaration ] Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Ryusuke Konishi --- fs/nilfs2/dir.c | 57 +++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c index 385e47eda99f..45f75d4c4522 100644 --- a/fs/nilfs2/dir.c +++ b/fs/nilfs2/dir.c @@ -180,19 +180,24 @@ static bool nilfs_check_page(struct page *page) return false; } =20 -static struct page *nilfs_get_page(struct inode *dir, unsigned long n) +static void *nilfs_get_page(struct inode *dir, unsigned long n, + struct page **pagep) { struct address_space *mapping =3D dir->i_mapping; struct page *page =3D read_mapping_page(mapping, n, NULL); + void *kaddr; =20 - if (!IS_ERR(page)) { - kmap(page); - if (unlikely(!PageChecked(page))) { - if (!nilfs_check_page(page)) - goto fail; - } + if (IS_ERR(page)) + return page; + + kaddr =3D kmap(page); + if (unlikely(!PageChecked(page))) { + if (!nilfs_check_page(page)) + goto fail; } - return page; + + *pagep =3D page; + return kaddr; =20 fail: nilfs_put_page(page); @@ -269,14 +274,14 @@ static int nilfs_readdir(struct file *file, struct di= r_context *ctx) for ( ; n < npages; n++, offset =3D 0) { char *kaddr, *limit; struct nilfs_dir_entry *de; - struct page *page =3D nilfs_get_page(inode, n); + struct page *page; =20 - if (IS_ERR(page)) { + kaddr =3D nilfs_get_page(inode, n, &page); + if (IS_ERR(kaddr)) { nilfs_error(sb, "bad page in #%lu", inode->i_ino); ctx->pos +=3D PAGE_SIZE - offset; return -EIO; } - kaddr =3D page_address(page); de =3D (struct nilfs_dir_entry *)(kaddr + offset); limit =3D kaddr + nilfs_last_byte(inode, n) - NILFS_DIR_REC_LEN(1); @@ -339,11 +344,9 @@ nilfs_find_entry(struct inode *dir, const struct qstr = *qstr, start =3D 0; n =3D start; do { - char *kaddr; + char *kaddr =3D nilfs_get_page(dir, n, &page); =20 - page =3D nilfs_get_page(dir, n); - if (!IS_ERR(page)) { - kaddr =3D page_address(page); + if (!IS_ERR(kaddr)) { de =3D (struct nilfs_dir_entry *)kaddr; kaddr +=3D nilfs_last_byte(dir, n) - reclen; while ((char *) de <=3D kaddr) { @@ -381,15 +384,11 @@ nilfs_find_entry(struct inode *dir, const struct qstr= *qstr, =20 struct nilfs_dir_entry *nilfs_dotdot(struct inode *dir, struct page **p) { - struct page *page =3D nilfs_get_page(dir, 0); - struct nilfs_dir_entry *de =3D NULL; + struct nilfs_dir_entry *de =3D nilfs_get_page(dir, 0, p); =20 - if (!IS_ERR(page)) { - de =3D nilfs_next_entry( - (struct nilfs_dir_entry *)page_address(page)); - *p =3D page; - } - return de; + if (IS_ERR(de)) + return NULL; + return nilfs_next_entry(de); } =20 ino_t nilfs_inode_by_name(struct inode *dir, const struct qstr *qstr) @@ -451,12 +450,11 @@ int nilfs_add_link(struct dentry *dentry, struct inod= e *inode) for (n =3D 0; n <=3D npages; n++) { char *dir_end; =20 - page =3D nilfs_get_page(dir, n); - err =3D PTR_ERR(page); - if (IS_ERR(page)) + kaddr =3D nilfs_get_page(dir, n, &page); + err =3D PTR_ERR(kaddr); + if (IS_ERR(kaddr)) goto out; lock_page(page); - kaddr =3D page_address(page); dir_end =3D kaddr + nilfs_last_byte(dir, n); de =3D (struct nilfs_dir_entry *)kaddr; kaddr +=3D PAGE_SIZE - reclen; @@ -618,11 +616,10 @@ int nilfs_empty_dir(struct inode *inode) char *kaddr; struct nilfs_dir_entry *de; =20 - page =3D nilfs_get_page(inode, i); - if (IS_ERR(page)) + kaddr =3D nilfs_get_page(inode, i, &page); + if (IS_ERR(kaddr)) continue; =20 - kaddr =3D page_address(page); de =3D (struct nilfs_dir_entry *)kaddr; kaddr +=3D nilfs_last_byte(inode, i) - NILFS_DIR_REC_LEN(1); =20 --=20 2.34.1 From nobody Wed Dec 17 12:17:23 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D153FC4167B for ; Mon, 27 Nov 2023 14:32:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233909AbjK0OcF (ORCPT ); Mon, 27 Nov 2023 09:32:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233783AbjK0ObU (ORCPT ); Mon, 27 Nov 2023 09:31:20 -0500 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F56BD4E; Mon, 27 Nov 2023 06:31:02 -0800 (PST) Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1cfb3ee8bc7so16410645ad.1; Mon, 27 Nov 2023 06:31:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701095462; x=1701700262; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/d7tcqdMYU+NIu4RxF41sEaUndQSw2DoYo4hopYEA8w=; b=Lw9jDzfcO5WwCkgN8ONaCbNWVhsbAvekvVKZcIjQoUiE9FfYcOONuKZY056OKpW3v7 IENEfEnMsccKUatjG3AVzMoLcf4DuLB+dGl5jmehqCEdksCsaxdC86yqCUuJtVrqxxU0 XpyPbkEDI9/ouSGWUoVd1IRIMONx8ym1OAOfErcPddirgQLUKXinbxiTyHDHpByCJ4MD V949yjyvlAoy4rflSebQSjPAep3aOq6MyE03ayPQpvxFFTLNu2aldc8Vfs76velUn5X8 ll77DRrNuaOROQkK70zeKV7l+6gcSBhvzy2b/BHDg5rnAFd54+ZYHt7lsmAgzReMHlX+ +Ymw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701095462; x=1701700262; h=content-transfer-encoding:mime-version: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=/d7tcqdMYU+NIu4RxF41sEaUndQSw2DoYo4hopYEA8w=; b=N6//HMVubi3AMG7UxR1mnew+a0glSA+9biatiE6HHlWfEf/yRV7N0sOHmMaK9w8wx4 VHApIwVcMl+LbWtmcctWOp5U7razjWh38uwj7180upve70D6VOzfovBHlmkKSoETsSZv PkMWFsAT992bRkIA1LigDEKwr6JLcTMtABQspdtvs1boKZLkOYnKeJKEdwocwpNG7Cps U9eo0LrdKIQsD4Y47rqHA/1dqHvNl8iivEyM9r/4tzfCen7E1hQbLo0X3Ik8T0xfyaiX nSZFG8J0MzmjN39Pdh5LDyzcV8oG7DQ2oX9SOUgPxBqWlq2/Ece2rYE+NSr7Gn6+7H7W AKKg== X-Gm-Message-State: AOJu0Yzvd2iG2yFgDesm7pvsaV+im4GL66xddB20e0PvPElEyd8RYX6/ MKobZD7Yf6rYYLmv4v+C9z8= X-Google-Smtp-Source: AGHT+IFR9IdkflmhovRvGJ8Y/cHbW9Gy8VWxRdd3Uuf+6+6Epad+/hFOJoL1wuvJ8+WH5OSI/7gvDQ== X-Received: by 2002:a17:902:b282:b0:1cf:b190:ea09 with SMTP id u2-20020a170902b28200b001cfb190ea09mr9899906plr.42.1701095461923; Mon, 27 Nov 2023 06:31:01 -0800 (PST) Received: from carrot.. (i60-34-119-11.s42.a014.ap.plala.or.jp. [60.34.119.11]) by smtp.gmail.com with ESMTPSA id a5-20020a170902ee8500b001cf51972586sm8302784pld.292.2023.11.27.06.31.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 06:31:01 -0800 (PST) From: Ryusuke Konishi To: Andrew Morton Cc: linux-nilfs@vger.kernel.org, Matthew Wilcox , linux-kernel@vger.kernel.org Subject: [PATCH 07/17] nilfs2: Pass the mapped address to nilfs_check_page() Date: Mon, 27 Nov 2023 23:30:26 +0900 Message-Id: <20231127143036.2425-8-konishi.ryusuke@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231127143036.2425-1-konishi.ryusuke@gmail.com> References: <20231127143036.2425-1-konishi.ryusuke@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: "Matthew Wilcox (Oracle)" Remove another use of page_address() as part of preparing for the kmap to kmap_local transition. Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Ryusuke Konishi --- fs/nilfs2/dir.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c index 45f75d4c4522..01900e84bddf 100644 --- a/fs/nilfs2/dir.c +++ b/fs/nilfs2/dir.c @@ -107,12 +107,11 @@ static void nilfs_commit_chunk(struct page *page, unlock_page(page); } =20 -static bool nilfs_check_page(struct page *page) +static bool nilfs_check_page(struct page *page, char *kaddr) { struct inode *dir =3D page->mapping->host; struct super_block *sb =3D dir->i_sb; unsigned int chunk_size =3D nilfs_chunk_size(dir); - char *kaddr =3D page_address(page); unsigned int offs, rec_len; unsigned int limit =3D PAGE_SIZE; struct nilfs_dir_entry *p; @@ -192,7 +191,7 @@ static void *nilfs_get_page(struct inode *dir, unsigned= long n, =20 kaddr =3D kmap(page); if (unlikely(!PageChecked(page))) { - if (!nilfs_check_page(page)) + if (!nilfs_check_page(page, kaddr)) goto fail; } =20 --=20 2.34.1 From nobody Wed Dec 17 12:17:23 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E80BC4167B for ; Mon, 27 Nov 2023 14:32:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233930AbjK0OcW (ORCPT ); Mon, 27 Nov 2023 09:32:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233787AbjK0ObV (ORCPT ); Mon, 27 Nov 2023 09:31:21 -0500 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3758B19B1; Mon, 27 Nov 2023 06:31:06 -0800 (PST) Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1ce627400f6so32884815ad.2; Mon, 27 Nov 2023 06:31:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701095465; x=1701700265; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fmlHMlCcVNl+9QQ+HEZAWjQ4Dk/nWbrv44XxJPOCOUs=; b=H9sYfuiUkCJajY1vgdV0dnhNlCGa2WbNjtM11m7CoGDv16DRzn/2u+7U/9ueD4j5Cz Dwgc9KEap7Pkx2T7vB6db/7z4DABRH56gEz1dLZE3Ptnlo0oeO0yyVednFz89+FLV4HM H4U4tRCIP+4r6ie2u6PqP/Y0tLELo7Tt7xRDnodyYkYTELAyOUf2fx/GRYL6VVlAGPRw 5khczgHmj6y/fgBgX/XU+qcv4Azo4VnqgerdbdkUzHwLU22aZDl2veEs0kBreHgN1E1i /yXxm9HFgcguGUQeM8Ch6K1M3SK63xumqDw7OPgx6OAj0hUUyFDWmVkd3qH857fMEzKv EUBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701095465; x=1701700265; h=content-transfer-encoding:mime-version: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=fmlHMlCcVNl+9QQ+HEZAWjQ4Dk/nWbrv44XxJPOCOUs=; b=okN9sbmf4qS92ZQ93Lj3GeuApsM2ROPUVYtMy1hvv1iCqqqomgY5SGq4qd8ttGzWRu ANuRCnM9HEcxnR2rrV2e2IFWZXGGHK30FbQBPXF/+pR0CmqDkTbpiMlGvgisKVDlAgc+ 5E98/wGF0pM9PTm/LghCAEcnMro/8+uTAxFI1L9kb1dTlWbmiyyVKJcUQ9SQZVeQnsvk ptN3CldN3we0r3X+6Bf6+8MVVUnxflekyyzxwpyBuHU7yHQ4msQVF/PdI23DYFycs4fm 5M9Kwlyxe/BvgXpwOE8X0ytMyB1dWsZoOBr+paipKBqXMyPOd7N3M3df7MEA+S+TGoFx 4rdA== X-Gm-Message-State: AOJu0YzgtcP/pB/l18u6RkvQDXXR+yHBCgihA1JgFDz07Zs/KXEDyoVL hxWNM79vUevNUn0tfjIRF5d2C6cAaeo= X-Google-Smtp-Source: AGHT+IHcpLQCX7P2fe+VGevVjZMn1ka13x6syqzxnJZTvu2H8fyqHRlIQNkUFJgid2J3N2ExEOyPvA== X-Received: by 2002:a17:903:41c6:b0:1cf:c2ad:7f43 with SMTP id u6-20020a17090341c600b001cfc2ad7f43mr4877366ple.23.1701095465169; Mon, 27 Nov 2023 06:31:05 -0800 (PST) Received: from carrot.. (i60-34-119-11.s42.a014.ap.plala.or.jp. [60.34.119.11]) by smtp.gmail.com with ESMTPSA id a5-20020a170902ee8500b001cf51972586sm8302784pld.292.2023.11.27.06.31.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 06:31:04 -0800 (PST) From: Ryusuke Konishi To: Andrew Morton Cc: linux-nilfs@vger.kernel.org, Matthew Wilcox , linux-kernel@vger.kernel.org Subject: [PATCH 08/17] nilfs2: Switch to kmap_local for directory handling Date: Mon, 27 Nov 2023 23:30:27 +0900 Message-Id: <20231127143036.2425-9-konishi.ryusuke@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231127143036.2425-1-konishi.ryusuke@gmail.com> References: <20231127143036.2425-1-konishi.ryusuke@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: "Matthew Wilcox (Oracle)" Match ext2 by using kmap_local() instead of kmap(). This is more efficient. Also use unmap_and_put_page() instead of duplicating it as a nilfs function. [ konishi.ryusuke: followed the change of page release helper call sites ] Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Ryusuke Konishi --- fs/nilfs2/dir.c | 27 +++++++++++++-------------- fs/nilfs2/namei.c | 12 ++++++------ fs/nilfs2/nilfs.h | 6 ------ 3 files changed, 19 insertions(+), 26 deletions(-) diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c index 01900e84bddf..89e8a248e571 100644 --- a/fs/nilfs2/dir.c +++ b/fs/nilfs2/dir.c @@ -189,7 +189,7 @@ static void *nilfs_get_page(struct inode *dir, unsigned= long n, if (IS_ERR(page)) return page; =20 - kaddr =3D kmap(page); + kaddr =3D kmap_local_page(page); if (unlikely(!PageChecked(page))) { if (!nilfs_check_page(page, kaddr)) goto fail; @@ -199,7 +199,7 @@ static void *nilfs_get_page(struct inode *dir, unsigned= long n, return kaddr; =20 fail: - nilfs_put_page(page); + unmap_and_put_page(page, kaddr); return ERR_PTR(-EIO); } =20 @@ -287,7 +287,7 @@ static int nilfs_readdir(struct file *file, struct dir_= context *ctx) for ( ; (char *)de <=3D limit; de =3D nilfs_next_entry(de)) { if (de->rec_len =3D=3D 0) { nilfs_error(sb, "zero-length directory entry"); - nilfs_put_page(page); + unmap_and_put_page(page, kaddr); return -EIO; } if (de->inode) { @@ -300,13 +300,13 @@ static int nilfs_readdir(struct file *file, struct di= r_context *ctx) =20 if (!dir_emit(ctx, de->name, de->name_len, le64_to_cpu(de->inode), t)) { - nilfs_put_page(page); + unmap_and_put_page(page, kaddr); return 0; } } ctx->pos +=3D nilfs_rec_len_from_disk(de->rec_len); } - nilfs_put_page(page); + unmap_and_put_page(page, kaddr); } return 0; } @@ -352,14 +352,14 @@ nilfs_find_entry(struct inode *dir, const struct qstr= *qstr, if (de->rec_len =3D=3D 0) { nilfs_error(dir->i_sb, "zero-length directory entry"); - nilfs_put_page(page); + unmap_and_put_page(page, kaddr); goto out; } if (nilfs_match(namelen, name, de)) goto found; de =3D nilfs_next_entry(de); } - nilfs_put_page(page); + unmap_and_put_page(page, kaddr); } if (++n >=3D npages) n =3D 0; @@ -399,8 +399,7 @@ ino_t nilfs_inode_by_name(struct inode *dir, const stru= ct qstr *qstr) de =3D nilfs_find_entry(dir, qstr, &page); if (de) { res =3D le64_to_cpu(de->inode); - kunmap(page); - put_page(page); + unmap_and_put_page(page, de); } return res; } @@ -484,7 +483,7 @@ int nilfs_add_link(struct dentry *dentry, struct inode = *inode) de =3D (struct nilfs_dir_entry *)((char *)de + rec_len); } unlock_page(page); - nilfs_put_page(page); + unmap_and_put_page(page, kaddr); } BUG(); return -EINVAL; @@ -512,7 +511,7 @@ int nilfs_add_link(struct dentry *dentry, struct inode = *inode) nilfs_mark_inode_dirty(dir); /* OFFSET_CACHE */ out_put: - nilfs_put_page(page); + unmap_and_put_page(page, de); out: return err; out_unlock: @@ -609,10 +608,10 @@ int nilfs_make_empty(struct inode *inode, struct inod= e *parent) int nilfs_empty_dir(struct inode *inode) { struct page *page =3D NULL; + char *kaddr; unsigned long i, npages =3D dir_pages(inode); =20 for (i =3D 0; i < npages; i++) { - char *kaddr; struct nilfs_dir_entry *de; =20 kaddr =3D nilfs_get_page(inode, i, &page); @@ -644,12 +643,12 @@ int nilfs_empty_dir(struct inode *inode) } de =3D nilfs_next_entry(de); } - nilfs_put_page(page); + unmap_and_put_page(page, kaddr); } return 1; =20 not_empty: - nilfs_put_page(page); + unmap_and_put_page(page, kaddr); return 0; } =20 diff --git a/fs/nilfs2/namei.c b/fs/nilfs2/namei.c index d179db8074c2..c08b1bf9fa7b 100644 --- a/fs/nilfs2/namei.c +++ b/fs/nilfs2/namei.c @@ -280,7 +280,7 @@ static int nilfs_do_unlink(struct inode *dir, struct de= ntry *dentry) set_nlink(inode, 1); } err =3D nilfs_delete_entry(de, page); - nilfs_put_page(page); + unmap_and_put_page(page, de); if (err) goto out; =20 @@ -387,7 +387,7 @@ static int nilfs_rename(struct mnt_idmap *idmap, if (!new_de) goto out_dir; nilfs_set_link(new_dir, new_de, new_page, old_inode); - nilfs_put_page(new_page); + unmap_and_put_page(new_page, new_de); nilfs_mark_inode_dirty(new_dir); inode_set_ctime_current(new_inode); if (dir_de) @@ -414,10 +414,10 @@ static int nilfs_rename(struct mnt_idmap *idmap, =20 if (dir_de) { nilfs_set_link(old_inode, dir_de, dir_page, new_dir); - nilfs_put_page(dir_page); + unmap_and_put_page(dir_page, dir_de); drop_nlink(old_dir); } - nilfs_put_page(old_page); + unmap_and_put_page(old_page, old_de); =20 nilfs_mark_inode_dirty(old_dir); nilfs_mark_inode_dirty(old_inode); @@ -427,9 +427,9 @@ static int nilfs_rename(struct mnt_idmap *idmap, =20 out_dir: if (dir_de) - nilfs_put_page(dir_page); + unmap_and_put_page(dir_page, dir_de); out_old: - nilfs_put_page(old_page); + unmap_and_put_page(old_page, old_de); out: nilfs_transaction_abort(old_dir->i_sb); return err; diff --git a/fs/nilfs2/nilfs.h b/fs/nilfs2/nilfs.h index afd700f5dc4e..8046490cd7fe 100644 --- a/fs/nilfs2/nilfs.h +++ b/fs/nilfs2/nilfs.h @@ -237,12 +237,6 @@ extern struct nilfs_dir_entry *nilfs_dotdot(struct ino= de *, struct page **); extern void nilfs_set_link(struct inode *, struct nilfs_dir_entry *, struct page *, struct inode *); =20 -static inline void nilfs_put_page(struct page *page) -{ - kunmap(page); - put_page(page); -} - /* file.c */ extern int nilfs_sync_file(struct file *, loff_t, loff_t, int); =20 --=20 2.34.1 From nobody Wed Dec 17 12:17:23 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A6CB3C4167B for ; Mon, 27 Nov 2023 14:32:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233807AbjK0OcI (ORCPT ); Mon, 27 Nov 2023 09:32:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233788AbjK0ObV (ORCPT ); Mon, 27 Nov 2023 09:31:21 -0500 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C399B136; Mon, 27 Nov 2023 06:31:09 -0800 (PST) Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1cfb30ce241so17250435ad.0; Mon, 27 Nov 2023 06:31:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701095469; x=1701700269; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TBt5qqEXcIxLlVq5mn6Mu1pF2TRKVo2Ss4zaqApVgBQ=; b=YtOsSu6w/+/1n8ZYa7O2o087Suja++niiFuL1c8/2I3TtgIDj9fy2GiINUA3+5SCW6 tWc/NgxXmgh6g4iMLvpAtDLU153BjMLnqyFkSNVIEQjcVsAY9lYZGO1Xrg99U5ZJyWPX 1ktI3EjUd5M/d8blAYicuwAE0FBMFRjt3VTK945cKP5qM0iZSBohy76l7QNI3B+hnSi1 NTJqz3q29uaEXy0eZf3JfpHedOHB4CJPaEJU1g0rlFi2VJ6TA2gkME0tjpN8TYiAzdmO x/VkQgz1zzlgtDfwWRmSptsEta2wFBBckSZUW0cSAfuoDsnVugNS6vrjXTDQKyo9Dkst rWrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701095469; x=1701700269; h=content-transfer-encoding:mime-version: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=TBt5qqEXcIxLlVq5mn6Mu1pF2TRKVo2Ss4zaqApVgBQ=; b=jdB8aP3athxq9eZ48ce655Y/WZMKFuLGOKIqIHLZWfJuotHsjPE1SOIQG7fifGk+bT BaTo5OG8fdhmkkc2knFvc/YCoE/XQFjVYvSv9f429Cq59Oa71eEybHoJoXkAYqUUf1Zm QmuICddnNJEiAmIaY9lwpT6UZOKmC8Hk0zbaqc5O/OhM8qoCkat1zvug4TTqhtfzobHG SOaObdwP4pl2X3XTknZuky5MO1cWTJzndIzC8jDysdLkzhefFopog01Yl8HG1kMY5J/u KSWkzeBpKTCcjfpao9dRp1QJ7t/kBwtDHPYq+P021/iC9z1ZSOVLoJS6VM/z5Q4OTZXM 2j3g== X-Gm-Message-State: AOJu0Yw2c4tMMUhaqRS/7b2NI1sN3QFFy2HeRbqUtj9hbYFZz59KXiIb ZvjCL6F+QLrvwNOpEztRYSg= X-Google-Smtp-Source: AGHT+IGGggnKsTbQDYtZGZyl5Gak4PUXvkGjS5Ry3Cc0on0EINCc1SQWs6MdPJJxFiz/20o0jk6y+w== X-Received: by 2002:a17:903:120b:b0:1cc:bf63:929 with SMTP id l11-20020a170903120b00b001ccbf630929mr15110401plh.64.1701095469174; Mon, 27 Nov 2023 06:31:09 -0800 (PST) Received: from carrot.. (i60-34-119-11.s42.a014.ap.plala.or.jp. [60.34.119.11]) by smtp.gmail.com with ESMTPSA id a5-20020a170902ee8500b001cf51972586sm8302784pld.292.2023.11.27.06.31.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 06:31:08 -0800 (PST) From: Ryusuke Konishi To: Andrew Morton Cc: linux-nilfs@vger.kernel.org, Matthew Wilcox , linux-kernel@vger.kernel.org Subject: [PATCH 09/17] nilfs2: Add nilfs_get_folio() Date: Mon, 27 Nov 2023 23:30:28 +0900 Message-Id: <20231127143036.2425-10-konishi.ryusuke@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231127143036.2425-1-konishi.ryusuke@gmail.com> References: <20231127143036.2425-1-konishi.ryusuke@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: "Matthew Wilcox (Oracle)" Convert nilfs_get_page() to be a wrapper. Also convert nilfs_check_page() to nilfs_check_folio(). Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Ryusuke Konishi --- fs/nilfs2/dir.c | 53 +++++++++++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c index 89e8a248e571..5c9ca3f0d7f4 100644 --- a/fs/nilfs2/dir.c +++ b/fs/nilfs2/dir.c @@ -107,18 +107,18 @@ static void nilfs_commit_chunk(struct page *page, unlock_page(page); } =20 -static bool nilfs_check_page(struct page *page, char *kaddr) +static bool nilfs_check_folio(struct folio *folio, char *kaddr) { - struct inode *dir =3D page->mapping->host; + struct inode *dir =3D folio->mapping->host; struct super_block *sb =3D dir->i_sb; unsigned int chunk_size =3D nilfs_chunk_size(dir); - unsigned int offs, rec_len; - unsigned int limit =3D PAGE_SIZE; + size_t offs, rec_len; + size_t limit =3D folio_size(folio); struct nilfs_dir_entry *p; char *error; =20 - if ((dir->i_size >> PAGE_SHIFT) =3D=3D page->index) { - limit =3D dir->i_size & ~PAGE_MASK; + if (dir->i_size < folio_pos(folio) + limit) { + limit =3D dir->i_size - folio_pos(folio); if (limit & (chunk_size - 1)) goto Ebadsize; if (!limit) @@ -140,7 +140,7 @@ static bool nilfs_check_page(struct page *page, char *k= addr) if (offs !=3D limit) goto Eend; out: - SetPageChecked(page); + folio_set_checked(folio); return true; =20 /* Too bad, we had an error */ @@ -163,8 +163,8 @@ static bool nilfs_check_page(struct page *page, char *k= addr) error =3D "directory entry across blocks"; bad_entry: nilfs_error(sb, - "bad entry in directory #%lu: %s - offset=3D%lu, inode=3D%lu, rec_le= n=3D%d, name_len=3D%d", - dir->i_ino, error, (page->index << PAGE_SHIFT) + offs, + "bad entry in directory #%lu: %s - offset=3D%lu, inode=3D%lu, rec_le= n=3D%zd, name_len=3D%d", + dir->i_ino, error, (folio->index << PAGE_SHIFT) + offs, (unsigned long)le64_to_cpu(p->inode), rec_len, p->name_len); goto fail; @@ -172,37 +172,48 @@ static bool nilfs_check_page(struct page *page, char = *kaddr) p =3D (struct nilfs_dir_entry *)(kaddr + offs); nilfs_error(sb, "entry in directory #%lu spans the page boundary offset=3D%lu, inode= =3D%lu", - dir->i_ino, (page->index << PAGE_SHIFT) + offs, + dir->i_ino, (folio->index << PAGE_SHIFT) + offs, (unsigned long)le64_to_cpu(p->inode)); fail: - SetPageError(page); + folio_set_error(folio); return false; } =20 -static void *nilfs_get_page(struct inode *dir, unsigned long n, - struct page **pagep) +static void *nilfs_get_folio(struct inode *dir, unsigned long n, + struct folio **foliop) { struct address_space *mapping =3D dir->i_mapping; - struct page *page =3D read_mapping_page(mapping, n, NULL); + struct folio *folio =3D read_mapping_folio(mapping, n, NULL); void *kaddr; =20 - if (IS_ERR(page)) - return page; + if (IS_ERR(folio)) + return folio; =20 - kaddr =3D kmap_local_page(page); - if (unlikely(!PageChecked(page))) { - if (!nilfs_check_page(page, kaddr)) + kaddr =3D kmap_local_folio(folio, 0); + if (unlikely(!folio_test_checked(folio))) { + if (!nilfs_check_folio(folio, kaddr)) goto fail; } =20 - *pagep =3D page; + *foliop =3D folio; return kaddr; =20 fail: - unmap_and_put_page(page, kaddr); + folio_release_kmap(folio, kaddr); return ERR_PTR(-EIO); } =20 +static void *nilfs_get_page(struct inode *dir, unsigned long n, + struct page **pagep) +{ + struct folio *folio; + void *kaddr =3D nilfs_get_folio(dir, n, &folio); + + if (!IS_ERR(kaddr)) + *pagep =3D &folio->page; + return kaddr; +} + /* * NOTE! unlike strncmp, nilfs_match returns 1 for success, 0 for failure. * --=20 2.34.1 From nobody Wed Dec 17 12:17:23 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7EB5FC4167B for ; Mon, 27 Nov 2023 14:32:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233820AbjK0OcN (ORCPT ); Mon, 27 Nov 2023 09:32:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233793AbjK0ObV (ORCPT ); Mon, 27 Nov 2023 09:31:21 -0500 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E461010F6; Mon, 27 Nov 2023 06:31:11 -0800 (PST) Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1cc9b626a96so30352245ad.2; Mon, 27 Nov 2023 06:31:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701095471; x=1701700271; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fZIiUDywASZ5qLtxZqnaVnT8sxb13W9YOdsItG5ysDI=; b=ddpL/kveJht9XsO36Dpv4ydrFVF2gHZn0max1hT/qbuwk/6k/w9296jrSQLS4TzBLo jYR5Q+pcFZ4zegz5l9N5uIuc2DphizKoQ+5JrSrUHltDhW0I22PYgcGEDaicqvZXSatC WowotQRskAF7ezxA6U2X+WRqlx+k4oEWC539tvo9UHS34vHb/A7WlaJbB7hReeL9EKzR wex/gETBXGFhmQDeFWsk0RuVJipNqbCP8wkR6iWfAoxSI4PVCJJvP0ijQHTHrrgB9fAJ CgFklZL+wjFK+XWv9DDQpDz5QARud0hGZp4Adim8/UHIiZ1LcPc0qEZ9hsuL0ua7CBUZ tJfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701095471; x=1701700271; h=content-transfer-encoding:mime-version: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=fZIiUDywASZ5qLtxZqnaVnT8sxb13W9YOdsItG5ysDI=; b=FL5FzhSpbBkojd6cigJ6jvnhqUQCk4fFUBUUlJvEaDDf+5rd5hf4F48zkU93XDWJMj 033GLDAPdthkFw2plP8PE50ZvzqHEZflq9fmTGJR5zEeQarkKmA8J2H24vUARj9rhDGP FCPTCqs1VH4TQ5r/u14Mu3583VGiITbaLgBMwU260qFwFCEy0G5OdaLGW7PPYRDUC2rk dU1IDkpTeQ/EzGb3koMh3FiPamuw8Sw9jVy2iPgN2HRmZ2Jo6eME38bmccKywmE3yPW9 rdJojqyfCG/ywtcTSkiack0leKVKydZRglyluY/uASZSEsuZd2xvq82idyN4CmoAwXx2 SE+A== X-Gm-Message-State: AOJu0YxHzBkR7BADpvdaiMsB+S7LbSpBY3GEd5Rcry1zTN/5oQz9Es7t s3xRqqsQpnvIrWDulr7xGBlzs/wQsP8= X-Google-Smtp-Source: AGHT+IFC6kljr/OxSGZeYSj1/XgvOHN9fwAW1Ops/Yklp4y0OXGn1HDHydCquS+o6vgWef+Lkm+O6Q== X-Received: by 2002:a17:902:c411:b0:1cf:a0b1:ec06 with SMTP id k17-20020a170902c41100b001cfa0b1ec06mr13415865plk.55.1701095471403; Mon, 27 Nov 2023 06:31:11 -0800 (PST) Received: from carrot.. (i60-34-119-11.s42.a014.ap.plala.or.jp. [60.34.119.11]) by smtp.gmail.com with ESMTPSA id a5-20020a170902ee8500b001cf51972586sm8302784pld.292.2023.11.27.06.31.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 06:31:10 -0800 (PST) From: Ryusuke Konishi To: Andrew Morton Cc: linux-nilfs@vger.kernel.org, Matthew Wilcox , linux-kernel@vger.kernel.org Subject: [PATCH 10/17] nilfs2: Convert nilfs_readdir to use a folio Date: Mon, 27 Nov 2023 23:30:29 +0900 Message-Id: <20231127143036.2425-11-konishi.ryusuke@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231127143036.2425-1-konishi.ryusuke@gmail.com> References: <20231127143036.2425-1-konishi.ryusuke@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: "Matthew Wilcox (Oracle)" Use the new folio APIs to remove calls to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Ryusuke Konishi --- fs/nilfs2/dir.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c index 5c9ca3f0d7f4..c7b046589877 100644 --- a/fs/nilfs2/dir.c +++ b/fs/nilfs2/dir.c @@ -284,9 +284,9 @@ static int nilfs_readdir(struct file *file, struct dir_= context *ctx) for ( ; n < npages; n++, offset =3D 0) { char *kaddr, *limit; struct nilfs_dir_entry *de; - struct page *page; + struct folio *folio; =20 - kaddr =3D nilfs_get_page(inode, n, &page); + kaddr =3D nilfs_get_folio(inode, n, &folio); if (IS_ERR(kaddr)) { nilfs_error(sb, "bad page in #%lu", inode->i_ino); ctx->pos +=3D PAGE_SIZE - offset; @@ -298,7 +298,7 @@ static int nilfs_readdir(struct file *file, struct dir_= context *ctx) for ( ; (char *)de <=3D limit; de =3D nilfs_next_entry(de)) { if (de->rec_len =3D=3D 0) { nilfs_error(sb, "zero-length directory entry"); - unmap_and_put_page(page, kaddr); + folio_release_kmap(folio, kaddr); return -EIO; } if (de->inode) { @@ -311,13 +311,13 @@ static int nilfs_readdir(struct file *file, struct di= r_context *ctx) =20 if (!dir_emit(ctx, de->name, de->name_len, le64_to_cpu(de->inode), t)) { - unmap_and_put_page(page, kaddr); + folio_release_kmap(folio, kaddr); return 0; } } ctx->pos +=3D nilfs_rec_len_from_disk(de->rec_len); } - unmap_and_put_page(page, kaddr); + folio_release_kmap(folio, kaddr); } return 0; } --=20 2.34.1 From nobody Wed Dec 17 12:17:23 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B3195C4167B for ; Mon, 27 Nov 2023 14:32:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233751AbjK0Oc2 (ORCPT ); Mon, 27 Nov 2023 09:32:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233796AbjK0ObV (ORCPT ); Mon, 27 Nov 2023 09:31:21 -0500 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08077191; Mon, 27 Nov 2023 06:31:17 -0800 (PST) Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1cfa5840db3so23169205ad.2; Mon, 27 Nov 2023 06:31:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701095476; x=1701700276; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UePQJ8QOPzkPSmphS7Y8EH5bntY87+qPN2cJVMHHYV8=; b=Q1VImZ3Z0PfW3BSdro6+l02BZpM3g3Sj2yvSRbjUlBrQUjQ9eWSZgRvNjX0HSD/a8p /w8GM0QFzI0LMPWMng8NNwfX+VS46CgN484hrfZjDE7cxiwnfkJK0hZm5pLbIPqdI0LG AuU/O8vly+gUiGceNCrbKXSv/LEngfljXCjo9BTfgDubm9AT5YIbyYUnowjL6R+1666b aqvj4PLdnem2ESft+m2lQKCcLL3CLL3xyGCU/HFcVoB4Z7tQZmaWsX7U8zkIMpmtyfBy KUEDqZt9nb/9xtgdGeCttc0SlbsU2k4MTbIgN5Sru3LNWtqNffy3bp2zboPtWzenQCNd VwRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701095476; x=1701700276; h=content-transfer-encoding:mime-version: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=UePQJ8QOPzkPSmphS7Y8EH5bntY87+qPN2cJVMHHYV8=; b=OghfEdhRUL7QCSBgoUSt6k/2eQ3MG3x5t9QIlqq/FHnIGss22I23HQnZsqbKir/y4r Nm0v/msonJKpIqBaezvuxlZ44Ml238Oev1Lfe/KFd7+7NNZceLiBusfT8el07t8dGGSY ldCjh7B7SEBlwWSegv8+gAfOuCpejE2pTRfMzbm8NjNmPy2iWGFJPvq1XLVe9084n6TF 0G8j5o6+LGyPyw6L/0+xB2maW153RNv+oc9xFo2/X7UXqsf3zdbgA24ajsq/DhrbM2vw ipvAq4Y+XBIYyR83U03SJxr1tWbU4fJ9My0ds81rCPiaHZktpqddqB5qskJfT8ccIsFW h0ww== X-Gm-Message-State: AOJu0YxgfBEtf238AM8ovYYkbMvVPMQWKBLGUqe3ucXhB4PB7M0yXYZL ivQts4A2uyXhsWrORweFXfv9tltHxKY= X-Google-Smtp-Source: AGHT+IG1oBcIbGFxOiv8HFXh2KXYeqUMLpETj8DkwwqAzEdYp0e8p+/K4INzAIOXJXChKJ28IWBbAg== X-Received: by 2002:a17:902:724a:b0:1cf:d2c3:2865 with SMTP id c10-20020a170902724a00b001cfd2c32865mr2634338pll.40.1701095476436; Mon, 27 Nov 2023 06:31:16 -0800 (PST) Received: from carrot.. (i60-34-119-11.s42.a014.ap.plala.or.jp. [60.34.119.11]) by smtp.gmail.com with ESMTPSA id a5-20020a170902ee8500b001cf51972586sm8302784pld.292.2023.11.27.06.31.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 06:31:15 -0800 (PST) From: Ryusuke Konishi To: Andrew Morton Cc: linux-nilfs@vger.kernel.org, Matthew Wilcox , linux-kernel@vger.kernel.org Subject: [PATCH 11/17] nilfs2: Convert nilfs_find_entry to use a folio Date: Mon, 27 Nov 2023 23:30:30 +0900 Message-Id: <20231127143036.2425-12-konishi.ryusuke@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231127143036.2425-1-konishi.ryusuke@gmail.com> References: <20231127143036.2425-1-konishi.ryusuke@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: "Matthew Wilcox (Oracle)" Use the new folio APIs to remove calls to compound_head(). [ konishi.ryusuke: resolved a conflict due to style warning correction ] Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Ryusuke Konishi --- fs/nilfs2/dir.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c index c7b046589877..a79726182867 100644 --- a/fs/nilfs2/dir.c +++ b/fs/nilfs2/dir.c @@ -339,7 +339,7 @@ nilfs_find_entry(struct inode *dir, const struct qstr *= qstr, unsigned int reclen =3D NILFS_DIR_REC_LEN(namelen); unsigned long start, n; unsigned long npages =3D dir_pages(dir); - struct page *page =3D NULL; + struct folio *folio =3D NULL; struct nilfs_inode_info *ei =3D NILFS_I(dir); struct nilfs_dir_entry *de; =20 @@ -354,7 +354,7 @@ nilfs_find_entry(struct inode *dir, const struct qstr *= qstr, start =3D 0; n =3D start; do { - char *kaddr =3D nilfs_get_page(dir, n, &page); + char *kaddr =3D nilfs_get_folio(dir, n, &folio); =20 if (!IS_ERR(kaddr)) { de =3D (struct nilfs_dir_entry *)kaddr; @@ -363,18 +363,18 @@ nilfs_find_entry(struct inode *dir, const struct qstr= *qstr, if (de->rec_len =3D=3D 0) { nilfs_error(dir->i_sb, "zero-length directory entry"); - unmap_and_put_page(page, kaddr); + folio_release_kmap(folio, kaddr); goto out; } if (nilfs_match(namelen, name, de)) goto found; de =3D nilfs_next_entry(de); } - unmap_and_put_page(page, kaddr); + folio_release_kmap(folio, kaddr); } if (++n >=3D npages) n =3D 0; - /* next page is past the blocks we've got */ + /* next folio is past the blocks we've got */ if (unlikely(n > (dir->i_blocks >> (PAGE_SHIFT - 9)))) { nilfs_error(dir->i_sb, "dir %lu size %lld exceeds block count %llu", @@ -387,7 +387,7 @@ nilfs_find_entry(struct inode *dir, const struct qstr *= qstr, return NULL; =20 found: - *res_page =3D page; + *res_page =3D &folio->page; ei->i_dir_start_lookup =3D n; return de; } --=20 2.34.1 From nobody Wed Dec 17 12:17:23 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8DAB7C4167B for ; Mon, 27 Nov 2023 14:32:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233954AbjK0Oci (ORCPT ); Mon, 27 Nov 2023 09:32:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233797AbjK0ObV (ORCPT ); Mon, 27 Nov 2023 09:31:21 -0500 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FDD41B5; Mon, 27 Nov 2023 06:31:19 -0800 (PST) Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1cfc2bcffc7so8815355ad.1; Mon, 27 Nov 2023 06:31:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701095479; x=1701700279; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TiorARWlp4qpkHsXWYNAOFHyrVXE8mudjiPl7CQm/78=; b=Qlj7ObEVkgGfo0F+ejgNcIffZ6OYUtkuFJcPjUEJt66z1LHX24NLuaBc1nL8P1gORx dxyRk9buSB+wFBmCBKtlrWUxjjTJT9rE/UB/SFvkMdixk0gdNsCgh5o8cOdj1TGPMEKs LNKtPTpOyZW7hzAfVJRaDfJz2Y6RK/c0HROQSeJpNiSNYR5bCTa+gevAGiP1uY6yFJS6 ts5TSOZ1mrpMuGUftnd/FFVB/h7u3zJLLqV+0nb1YRmPExp5XetDpqeXNne4TNPORLgS PeBt0n+P1qr8VQU9TSJX8l6Ywbnel6jrBydQ0scbfxSFHvTrzwo/Vcn5/xFhx0nSK5iP V6Xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701095479; x=1701700279; h=content-transfer-encoding:mime-version: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=TiorARWlp4qpkHsXWYNAOFHyrVXE8mudjiPl7CQm/78=; b=L+RFO2jMGd/qN+OxgTlMdawEn7Ouw3lOiBWjfpqZOX1pbl0EaC0aCyeaL4IwvKyTyn trhod/PvkshUosjdbkebMnfqhZGBUt1sLnVlBzje4rGIuTF4UlHiuBGJjGokfA9h2t2H KtyCEuVbDREQxwfEOFSyYth9OqrL1EQiNNZu4RBbN3gRmztipdVnfxELH603yDcdC1yf PyMQBTR0LUsn2/pps0FJ+8jciac+Ha/D6aplunW3mMGUKrFVqAW/Zw7bYtg0bJvVpaWu UH5GJasgvQWi6ejem2Ifpde7oZZARXoOSt8HdmWp2NX8VIxO6qJ6J5EYMrojkgEe6viW Lhvw== X-Gm-Message-State: AOJu0YyAruV+FY39JQDiyUuISG7ghZRfq02/UPGtQYmRt0X3wzGKEX3t wZ+53S+dY+OGdqja4hsCFFZDPemarK8= X-Google-Smtp-Source: AGHT+IFarF66RG3004ITpjBR2ukq0GnNAI2kVE4RFG4Cg8APf1Ne6cbdYR5mOEbfTktjyDo/Uju42w== X-Received: by 2002:a17:902:6941:b0:1cf:ce79:88e8 with SMTP id k1-20020a170902694100b001cfce7988e8mr3776147plt.29.1701095478869; Mon, 27 Nov 2023 06:31:18 -0800 (PST) Received: from carrot.. (i60-34-119-11.s42.a014.ap.plala.or.jp. [60.34.119.11]) by smtp.gmail.com with ESMTPSA id a5-20020a170902ee8500b001cf51972586sm8302784pld.292.2023.11.27.06.31.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 06:31:18 -0800 (PST) From: Ryusuke Konishi To: Andrew Morton Cc: linux-nilfs@vger.kernel.org, Matthew Wilcox , linux-kernel@vger.kernel.org Subject: [PATCH 12/17] nilfs2: Convert nilfs_rename() to use folios Date: Mon, 27 Nov 2023 23:30:31 +0900 Message-Id: <20231127143036.2425-13-konishi.ryusuke@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231127143036.2425-1-konishi.ryusuke@gmail.com> References: <20231127143036.2425-1-konishi.ryusuke@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: "Matthew Wilcox (Oracle)" This involves converting nilfs_find_entry(), nilfs_dotdot(), nilfs_set_link(), nilfs_delete_entry() and nilfs_do_unlink() to use folios as well. [ konishi.ryusuke: followed the change of page release helper call sites ] Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Ryusuke Konishi --- fs/nilfs2/dir.c | 68 ++++++++++++++++++++++------------------------- fs/nilfs2/namei.c | 36 ++++++++++++------------- fs/nilfs2/nilfs.h | 20 +++++++------- 3 files changed, 60 insertions(+), 64 deletions(-) diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c index a79726182867..2a759598801b 100644 --- a/fs/nilfs2/dir.c +++ b/fs/nilfs2/dir.c @@ -323,38 +323,35 @@ static int nilfs_readdir(struct file *file, struct di= r_context *ctx) } =20 /* - * nilfs_find_entry() + * nilfs_find_entry() * - * finds an entry in the specified directory with the wanted name. It - * returns the page in which the entry was found, and the entry itself - * (as a parameter - res_dir). Page is returned mapped and unlocked. - * Entry is guaranteed to be valid. + * Finds an entry in the specified directory with the wanted name. It + * returns the folio in which the entry was found, and the entry itself. + * The folio is mapped and unlocked. When the caller is finished with + * the entry, it should call folio_release_kmap(). + * + * On failure, returns NULL and the caller should ignore foliop. */ -struct nilfs_dir_entry * -nilfs_find_entry(struct inode *dir, const struct qstr *qstr, - struct page **res_page) +struct nilfs_dir_entry *nilfs_find_entry(struct inode *dir, + const struct qstr *qstr, struct folio **foliop) { const unsigned char *name =3D qstr->name; int namelen =3D qstr->len; unsigned int reclen =3D NILFS_DIR_REC_LEN(namelen); unsigned long start, n; unsigned long npages =3D dir_pages(dir); - struct folio *folio =3D NULL; struct nilfs_inode_info *ei =3D NILFS_I(dir); struct nilfs_dir_entry *de; =20 if (npages =3D=3D 0) goto out; =20 - /* OFFSET_CACHE */ - *res_page =3D NULL; - start =3D ei->i_dir_start_lookup; if (start >=3D npages) start =3D 0; n =3D start; do { - char *kaddr =3D nilfs_get_folio(dir, n, &folio); + char *kaddr =3D nilfs_get_folio(dir, n, foliop); =20 if (!IS_ERR(kaddr)) { de =3D (struct nilfs_dir_entry *)kaddr; @@ -363,14 +360,14 @@ nilfs_find_entry(struct inode *dir, const struct qstr= *qstr, if (de->rec_len =3D=3D 0) { nilfs_error(dir->i_sb, "zero-length directory entry"); - folio_release_kmap(folio, kaddr); + folio_release_kmap(*foliop, kaddr); goto out; } if (nilfs_match(namelen, name, de)) goto found; de =3D nilfs_next_entry(de); } - folio_release_kmap(folio, kaddr); + folio_release_kmap(*foliop, kaddr); } if (++n >=3D npages) n =3D 0; @@ -387,14 +384,13 @@ nilfs_find_entry(struct inode *dir, const struct qstr= *qstr, return NULL; =20 found: - *res_page =3D &folio->page; ei->i_dir_start_lookup =3D n; return de; } =20 -struct nilfs_dir_entry *nilfs_dotdot(struct inode *dir, struct page **p) +struct nilfs_dir_entry *nilfs_dotdot(struct inode *dir, struct folio **fol= iop) { - struct nilfs_dir_entry *de =3D nilfs_get_page(dir, 0, p); + struct nilfs_dir_entry *de =3D nilfs_get_folio(dir, 0, foliop); =20 if (IS_ERR(de)) return NULL; @@ -405,30 +401,30 @@ ino_t nilfs_inode_by_name(struct inode *dir, const st= ruct qstr *qstr) { ino_t res =3D 0; struct nilfs_dir_entry *de; - struct page *page; + struct folio *folio; =20 - de =3D nilfs_find_entry(dir, qstr, &page); + de =3D nilfs_find_entry(dir, qstr, &folio); if (de) { res =3D le64_to_cpu(de->inode); - unmap_and_put_page(page, de); + folio_release_kmap(folio, de); } return res; } =20 void nilfs_set_link(struct inode *dir, struct nilfs_dir_entry *de, - struct page *page, struct inode *inode) + struct folio *folio, struct inode *inode) { - unsigned int from =3D offset_in_page(de); - unsigned int to =3D from + nilfs_rec_len_from_disk(de->rec_len); - struct address_space *mapping =3D page->mapping; + size_t from =3D offset_in_folio(folio, de); + size_t to =3D from + nilfs_rec_len_from_disk(de->rec_len); + struct address_space *mapping =3D folio->mapping; int err; =20 - lock_page(page); - err =3D nilfs_prepare_chunk(page, from, to); + folio_lock(folio); + err =3D nilfs_prepare_chunk(&folio->page, from, to); BUG_ON(err); de->inode =3D cpu_to_le64(inode->i_ino); nilfs_set_de_type(de, inode); - nilfs_commit_chunk(page, mapping, from, to); + nilfs_commit_chunk(&folio->page, mapping, from, to); inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); } =20 @@ -532,14 +528,14 @@ int nilfs_add_link(struct dentry *dentry, struct inod= e *inode) =20 /* * nilfs_delete_entry deletes a directory entry by merging it with the - * previous entry. Page is up-to-date. + * previous entry. Folio is up-to-date. */ -int nilfs_delete_entry(struct nilfs_dir_entry *dir, struct page *page) +int nilfs_delete_entry(struct nilfs_dir_entry *dir, struct folio *folio) { - struct address_space *mapping =3D page->mapping; + struct address_space *mapping =3D folio->mapping; struct inode *inode =3D mapping->host; - char *kaddr =3D (char *)((unsigned long)dir & PAGE_MASK); - unsigned int from, to; + char *kaddr =3D (char *)((unsigned long)dir & ~(folio_size(folio) - 1)); + size_t from, to; struct nilfs_dir_entry *de, *pde =3D NULL; int err; =20 @@ -559,13 +555,13 @@ int nilfs_delete_entry(struct nilfs_dir_entry *dir, s= truct page *page) } if (pde) from =3D (char *)pde - kaddr; - lock_page(page); - err =3D nilfs_prepare_chunk(page, from, to); + folio_lock(folio); + err =3D nilfs_prepare_chunk(&folio->page, from, to); BUG_ON(err); if (pde) pde->rec_len =3D nilfs_rec_len_to_disk(to - from); dir->inode =3D 0; - nilfs_commit_chunk(page, mapping, from, to); + nilfs_commit_chunk(&folio->page, mapping, from, to); inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode)); out: return err; diff --git a/fs/nilfs2/namei.c b/fs/nilfs2/namei.c index c08b1bf9fa7b..959bd9fb3d81 100644 --- a/fs/nilfs2/namei.c +++ b/fs/nilfs2/namei.c @@ -260,11 +260,11 @@ static int nilfs_do_unlink(struct inode *dir, struct = dentry *dentry) { struct inode *inode; struct nilfs_dir_entry *de; - struct page *page; + struct folio *folio; int err; =20 err =3D -ENOENT; - de =3D nilfs_find_entry(dir, &dentry->d_name, &page); + de =3D nilfs_find_entry(dir, &dentry->d_name, &folio); if (!de) goto out; =20 @@ -279,8 +279,8 @@ static int nilfs_do_unlink(struct inode *dir, struct de= ntry *dentry) inode->i_ino, inode->i_nlink); set_nlink(inode, 1); } - err =3D nilfs_delete_entry(de, page); - unmap_and_put_page(page, de); + err =3D nilfs_delete_entry(de, folio); + folio_release_kmap(folio, de); if (err) goto out; =20 @@ -348,9 +348,9 @@ static int nilfs_rename(struct mnt_idmap *idmap, { struct inode *old_inode =3D d_inode(old_dentry); struct inode *new_inode =3D d_inode(new_dentry); - struct page *dir_page =3D NULL; + struct folio *dir_folio =3D NULL; struct nilfs_dir_entry *dir_de =3D NULL; - struct page *old_page; + struct folio *old_folio; struct nilfs_dir_entry *old_de; struct nilfs_transaction_info ti; int err; @@ -363,19 +363,19 @@ static int nilfs_rename(struct mnt_idmap *idmap, return err; =20 err =3D -ENOENT; - old_de =3D nilfs_find_entry(old_dir, &old_dentry->d_name, &old_page); + old_de =3D nilfs_find_entry(old_dir, &old_dentry->d_name, &old_folio); if (!old_de) goto out; =20 if (S_ISDIR(old_inode->i_mode)) { err =3D -EIO; - dir_de =3D nilfs_dotdot(old_inode, &dir_page); + dir_de =3D nilfs_dotdot(old_inode, &dir_folio); if (!dir_de) goto out_old; } =20 if (new_inode) { - struct page *new_page; + struct folio *new_folio; struct nilfs_dir_entry *new_de; =20 err =3D -ENOTEMPTY; @@ -383,11 +383,11 @@ static int nilfs_rename(struct mnt_idmap *idmap, goto out_dir; =20 err =3D -ENOENT; - new_de =3D nilfs_find_entry(new_dir, &new_dentry->d_name, &new_page); + new_de =3D nilfs_find_entry(new_dir, &new_dentry->d_name, &new_folio); if (!new_de) goto out_dir; - nilfs_set_link(new_dir, new_de, new_page, old_inode); - unmap_and_put_page(new_page, new_de); + nilfs_set_link(new_dir, new_de, new_folio, old_inode); + folio_release_kmap(new_folio, new_de); nilfs_mark_inode_dirty(new_dir); inode_set_ctime_current(new_inode); if (dir_de) @@ -410,14 +410,14 @@ static int nilfs_rename(struct mnt_idmap *idmap, */ inode_set_ctime_current(old_inode); =20 - nilfs_delete_entry(old_de, old_page); + nilfs_delete_entry(old_de, old_folio); =20 if (dir_de) { - nilfs_set_link(old_inode, dir_de, dir_page, new_dir); - unmap_and_put_page(dir_page, dir_de); + nilfs_set_link(old_inode, dir_de, dir_folio, new_dir); + folio_release_kmap(dir_folio, dir_de); drop_nlink(old_dir); } - unmap_and_put_page(old_page, old_de); + folio_release_kmap(old_folio, old_de); =20 nilfs_mark_inode_dirty(old_dir); nilfs_mark_inode_dirty(old_inode); @@ -427,9 +427,9 @@ static int nilfs_rename(struct mnt_idmap *idmap, =20 out_dir: if (dir_de) - unmap_and_put_page(dir_page, dir_de); + folio_release_kmap(dir_folio, dir_de); out_old: - unmap_and_put_page(old_page, old_de); + folio_release_kmap(old_folio, old_de); out: nilfs_transaction_abort(old_dir->i_sb); return err; diff --git a/fs/nilfs2/nilfs.h b/fs/nilfs2/nilfs.h index 8046490cd7fe..98cffaf0ac12 100644 --- a/fs/nilfs2/nilfs.h +++ b/fs/nilfs2/nilfs.h @@ -226,16 +226,16 @@ static inline __u32 nilfs_mask_flags(umode_t mode, __= u32 flags) } =20 /* dir.c */ -extern int nilfs_add_link(struct dentry *, struct inode *); -extern ino_t nilfs_inode_by_name(struct inode *, const struct qstr *); -extern int nilfs_make_empty(struct inode *, struct inode *); -extern struct nilfs_dir_entry * -nilfs_find_entry(struct inode *, const struct qstr *, struct page **); -extern int nilfs_delete_entry(struct nilfs_dir_entry *, struct page *); -extern int nilfs_empty_dir(struct inode *); -extern struct nilfs_dir_entry *nilfs_dotdot(struct inode *, struct page **= ); -extern void nilfs_set_link(struct inode *, struct nilfs_dir_entry *, - struct page *, struct inode *); +int nilfs_add_link(struct dentry *, struct inode *); +ino_t nilfs_inode_by_name(struct inode *, const struct qstr *); +int nilfs_make_empty(struct inode *, struct inode *); +struct nilfs_dir_entry *nilfs_find_entry(struct inode *, const struct qstr= *, + struct folio **); +int nilfs_delete_entry(struct nilfs_dir_entry *, struct folio *); +int nilfs_empty_dir(struct inode *); +struct nilfs_dir_entry *nilfs_dotdot(struct inode *, struct folio **); +void nilfs_set_link(struct inode *, struct nilfs_dir_entry *, + struct folio *, struct inode *); =20 /* file.c */ extern int nilfs_sync_file(struct file *, loff_t, loff_t, int); --=20 2.34.1 From nobody Wed Dec 17 12:17:23 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1959C4167B for ; Mon, 27 Nov 2023 14:32:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233784AbjK0Oce (ORCPT ); Mon, 27 Nov 2023 09:32:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233798AbjK0ObV (ORCPT ); Mon, 27 Nov 2023 09:31:21 -0500 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4213D1A7; Mon, 27 Nov 2023 06:31:22 -0800 (PST) Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1cfd78f8a12so5374665ad.2; Mon, 27 Nov 2023 06:31:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701095482; x=1701700282; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=sYhxtv86BtK/w/7d1AHNEGaD3rJv/iHyqgFD4qVbk18=; b=SbhbYCgdRRJLY580S8COCvn54sLEVfwmMgo0d7JdRY2xOyN7Ff9fn5WCO8o+FwW0oZ /sclR8OD0JmkN6aTv/bBwD2A90IDWQvhJCSNguOMZ2V4Iah5SR/c99zjCH+x4w41C3Hz 63qjI8LND+2hYDLmCgsmLKTS+ONS5v75+/BNRU087DzoadWlksUJ9UjuKbz8/I1bxWR+ 3j3Okrqj4W0d2YkvUZ+FwguBM7xOUerK9pQFHZ4zxFN7gq/dy6aRdwihMY8UMMpw/jqx 2W2MUWiuJV9HJxeN0NPrY94W+sP+wBCnjo2Exw7PTuzc65EYhfZJ30Rbyvz4KNBsJ9E+ q05Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701095482; x=1701700282; h=content-transfer-encoding:mime-version: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=sYhxtv86BtK/w/7d1AHNEGaD3rJv/iHyqgFD4qVbk18=; b=TgwXaetQeSUsuRXVlnCe3zjKb8bjd/6cRxhNhhcR51xnNe++4UX3Gf1+VqkyV5MfDk 0AReYKRIaPxQNMvkcsbcwxCgPMpDOM4xccNK2Og7H9ZLksL2OVl7DFb/zJm9hGyorfht JxRTUWKUNvrgKmkV06ipG4zOBlZHlA7Xk+8PAwgTRdRQU/DnHeIj8QlIW636apeHoJG3 gFmELsLf2jzZdT9FCKeZ/pmzHHZVYpiwDjdnos6QOp0MGsuV+OF97KbK3bb445bTWJjv F5Ar4EWjj4UJcbF1AgVKdQ8U2tYXseyxpnLG2JoEuGUrWuLpiqJiRvNU7nRG1imcDK+9 47/w== X-Gm-Message-State: AOJu0YxRTc2s7ssLOzeNrR6ZZlkAFUG+GTHgV3Lcvctv6Oh1ar80yGIM iruV6jK5ig2goSArll91ybbitet4CUM= X-Google-Smtp-Source: AGHT+IEPqbn3qSwDis9foPC4G7E12/KJ/W/nZq0LekG/FKWFcjYE//iyh9890Ft07kCpA+JyjG6YlQ== X-Received: by 2002:a17:902:d2c6:b0:1cf:cf34:d4fa with SMTP id n6-20020a170902d2c600b001cfcf34d4famr4051225plc.28.1701095481683; Mon, 27 Nov 2023 06:31:21 -0800 (PST) Received: from carrot.. (i60-34-119-11.s42.a014.ap.plala.or.jp. [60.34.119.11]) by smtp.gmail.com with ESMTPSA id a5-20020a170902ee8500b001cf51972586sm8302784pld.292.2023.11.27.06.31.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 06:31:21 -0800 (PST) From: Ryusuke Konishi To: Andrew Morton Cc: linux-nilfs@vger.kernel.org, Matthew Wilcox , linux-kernel@vger.kernel.org Subject: [PATCH 13/17] nilfs2: Convert nilfs_add_link() to use a folio Date: Mon, 27 Nov 2023 23:30:32 +0900 Message-Id: <20231127143036.2425-14-konishi.ryusuke@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231127143036.2425-1-konishi.ryusuke@gmail.com> References: <20231127143036.2425-1-konishi.ryusuke@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: "Matthew Wilcox (Oracle)" Remove six calls to compound_head() by using the folio API. Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Ryusuke Konishi --- fs/nilfs2/dir.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c index 2a759598801b..8d8c42e34148 100644 --- a/fs/nilfs2/dir.c +++ b/fs/nilfs2/dir.c @@ -439,30 +439,28 @@ int nilfs_add_link(struct dentry *dentry, struct inod= e *inode) unsigned int chunk_size =3D nilfs_chunk_size(dir); unsigned int reclen =3D NILFS_DIR_REC_LEN(namelen); unsigned short rec_len, name_len; - struct page *page =3D NULL; + struct folio *folio =3D NULL; struct nilfs_dir_entry *de; unsigned long npages =3D dir_pages(dir); unsigned long n; - char *kaddr; - unsigned int from, to; + size_t from, to; int err; =20 /* * We take care of directory expansion in the same loop. - * This code plays outside i_size, so it locks the page + * This code plays outside i_size, so it locks the folio * to protect that region. */ for (n =3D 0; n <=3D npages; n++) { + char *kaddr =3D nilfs_get_folio(dir, n, &folio); char *dir_end; =20 - kaddr =3D nilfs_get_page(dir, n, &page); - err =3D PTR_ERR(kaddr); if (IS_ERR(kaddr)) - goto out; - lock_page(page); + return PTR_ERR(kaddr); + folio_lock(folio); dir_end =3D kaddr + nilfs_last_byte(dir, n); de =3D (struct nilfs_dir_entry *)kaddr; - kaddr +=3D PAGE_SIZE - reclen; + kaddr +=3D folio_size(folio) - reclen; while ((char *)de <=3D kaddr) { if ((char *)de =3D=3D dir_end) { /* We hit i_size */ @@ -489,16 +487,16 @@ int nilfs_add_link(struct dentry *dentry, struct inod= e *inode) goto got_it; de =3D (struct nilfs_dir_entry *)((char *)de + rec_len); } - unlock_page(page); - unmap_and_put_page(page, kaddr); + folio_unlock(folio); + folio_release_kmap(folio, kaddr); } BUG(); return -EINVAL; =20 got_it: - from =3D offset_in_page(de); + from =3D offset_in_folio(folio, de); to =3D from + rec_len; - err =3D nilfs_prepare_chunk(page, from, to); + err =3D nilfs_prepare_chunk(&folio->page, from, to); if (err) goto out_unlock; if (de->inode) { @@ -513,16 +511,15 @@ int nilfs_add_link(struct dentry *dentry, struct inod= e *inode) memcpy(de->name, name, namelen); de->inode =3D cpu_to_le64(inode->i_ino); nilfs_set_de_type(de, inode); - nilfs_commit_chunk(page, page->mapping, from, to); + nilfs_commit_chunk(&folio->page, folio->mapping, from, to); inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); nilfs_mark_inode_dirty(dir); /* OFFSET_CACHE */ out_put: - unmap_and_put_page(page, de); -out: + folio_release_kmap(folio, de); return err; out_unlock: - unlock_page(page); + folio_unlock(folio); goto out_put; } =20 --=20 2.34.1 From nobody Wed Dec 17 12:17:23 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 18012C4167B for ; Mon, 27 Nov 2023 14:32:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233815AbjK0Ock (ORCPT ); Mon, 27 Nov 2023 09:32:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233799AbjK0ObW (ORCPT ); Mon, 27 Nov 2023 09:31:22 -0500 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8711C1AD; Mon, 27 Nov 2023 06:31:25 -0800 (PST) Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1cf89df1eecso27319505ad.3; Mon, 27 Nov 2023 06:31:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701095485; x=1701700285; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LQ0hTMNOO2rQEY/dpZit98zV3CambmsVJR+t1rZ7hqw=; b=lvFBsreHk2zBB4k3PxfvUiSWpHMqxYMoxPpfUbGsWPzafdGKfV9jpTYqrtJtgbMJr0 YLQ5fZl+e6CMCbDY+1aGMrqmtXUGHrwj0F8bQJJF5RY/XHhdxxQ7j99AZWHcfRntw+FT 3dtMoaiUrQ3vSNhMf3CRCDNIKozNsXaE+7lLATjUgzIu3+9afC+r3PNfq9yG26mrEuj2 KBtmM2wJp38mRb1irXA3GEyo3CxwrurWtr2o2CiloHIiKVP/jbzg7Q0zPdsBZWba2arb XtpXPHGl8/OQMNnGqRuED2NqSeqTfr6w++2yuqLkT/SQUrcuZ3wT5sZa1slrV7MN1nc6 zpng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701095485; x=1701700285; h=content-transfer-encoding:mime-version: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=LQ0hTMNOO2rQEY/dpZit98zV3CambmsVJR+t1rZ7hqw=; b=oE72ZTJXknOkhAjo3J3fxy49gThjWmVuykMy8N94IEOPx6zQ61MukmGAHxCSyZNTBf ks0GJYEJOTgg9iDzzmPVSj/+U0I9HZ1Wi0/KH7MC4sV4x7REkBYraYcupaIau8zFvX3f yzm3uny6w4gDXVOyN1O+URquzUEzx/UpkRaUtVB5CVIax9k3FYPldLMVOkpcaR3xvpPV 1o6fCJ8FCOPvWzfSJ1fsFu6Voq0/XRCHXCZSv8Ibf0PPNaaFKpnQJDkoyfCz69cZi6GW Cs3/NSH9Lwje7HJUwcBEA+Ui0rumqDU4TX+YnLG9PIzM18h5VMLjuFl0WISgwQH+bDsX 1efQ== X-Gm-Message-State: AOJu0YxjHT9idnkKOUUp8H3D2koxfUuEF1wYakmvTIB3XmvB41Ru4njk DKFSFCUmltCSxWNU8iZTRsA= X-Google-Smtp-Source: AGHT+IGy/CYDGZVItVW7R8O6dqj5gmUXwm0OW1c2CXsygrOfqAP0Is/gJQa5ZYWaF7N2qjYgEcMYuw== X-Received: by 2002:a17:902:e843:b0:1cf:d24c:7b6c with SMTP id t3-20020a170902e84300b001cfd24c7b6cmr2485252plg.59.1701095484950; Mon, 27 Nov 2023 06:31:24 -0800 (PST) Received: from carrot.. (i60-34-119-11.s42.a014.ap.plala.or.jp. [60.34.119.11]) by smtp.gmail.com with ESMTPSA id a5-20020a170902ee8500b001cf51972586sm8302784pld.292.2023.11.27.06.31.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 06:31:24 -0800 (PST) From: Ryusuke Konishi To: Andrew Morton Cc: linux-nilfs@vger.kernel.org, Matthew Wilcox , linux-kernel@vger.kernel.org Subject: [PATCH 14/17] nilfs2: Convert nilfs_empty_dir() to use a folio Date: Mon, 27 Nov 2023 23:30:33 +0900 Message-Id: <20231127143036.2425-15-konishi.ryusuke@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231127143036.2425-1-konishi.ryusuke@gmail.com> References: <20231127143036.2425-1-konishi.ryusuke@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: "Matthew Wilcox (Oracle)" Remove three calls to compound_head() by using the folio API. Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Ryusuke Konishi --- fs/nilfs2/dir.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c index 8d8c42e34148..919936d9ec27 100644 --- a/fs/nilfs2/dir.c +++ b/fs/nilfs2/dir.c @@ -203,17 +203,6 @@ static void *nilfs_get_folio(struct inode *dir, unsign= ed long n, return ERR_PTR(-EIO); } =20 -static void *nilfs_get_page(struct inode *dir, unsigned long n, - struct page **pagep) -{ - struct folio *folio; - void *kaddr =3D nilfs_get_folio(dir, n, &folio); - - if (!IS_ERR(kaddr)) - *pagep =3D &folio->page; - return kaddr; -} - /* * NOTE! unlike strncmp, nilfs_match returns 1 for success, 0 for failure. * @@ -611,14 +600,14 @@ int nilfs_make_empty(struct inode *inode, struct inod= e *parent) */ int nilfs_empty_dir(struct inode *inode) { - struct page *page =3D NULL; + struct folio *folio =3D NULL; char *kaddr; unsigned long i, npages =3D dir_pages(inode); =20 for (i =3D 0; i < npages; i++) { struct nilfs_dir_entry *de; =20 - kaddr =3D nilfs_get_page(inode, i, &page); + kaddr =3D nilfs_get_folio(inode, i, &folio); if (IS_ERR(kaddr)) continue; =20 @@ -647,12 +636,12 @@ int nilfs_empty_dir(struct inode *inode) } de =3D nilfs_next_entry(de); } - unmap_and_put_page(page, kaddr); + folio_release_kmap(folio, kaddr); } return 1; =20 not_empty: - unmap_and_put_page(page, kaddr); + folio_release_kmap(folio, kaddr); return 0; } =20 --=20 2.34.1 From nobody Wed Dec 17 12:17:23 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D6617C07CB1 for ; Mon, 27 Nov 2023 14:32:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233966AbjK0Ocn (ORCPT ); Mon, 27 Nov 2023 09:32:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233800AbjK0ObW (ORCPT ); Mon, 27 Nov 2023 09:31:22 -0500 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81687C0; Mon, 27 Nov 2023 06:31:27 -0800 (PST) Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1cfbce92362so10659765ad.1; Mon, 27 Nov 2023 06:31:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701095487; x=1701700287; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fUxnds+HPQEGrIJRV5viCfLrna/cjmgtYIVib94o7Eo=; b=RdivvAYF6eVZLGArJIlnuuoF0pUYPM9OlLjbM4qrsAKAPIXYjfXqM5ghNnG2vb3Pzw LPsY4RKvQJ+bvFT2Of0zQ946I1gD9DktveSyBD0Z31l8Kh4KuwJwovLZlKETeeauP2rp K9OhMy0w1No0B0xbDCucDS+e8Ooptsz38qxxoCF+TBLr5iNgLHgOH266Wx/wdgWfscoi CZYSrclNcNNhBBEGFtI7rLxdgRwe7k5c+tR8NITJZHdLUlzZI3JiAkpWKMAnC2QbSOrh 1k/VRJVEgO9JLNd4QaGU0svDJKyKIWvv//+hpdypeWz8OVdgCwsgmhVvUUD7go99Ximu Lg8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701095487; x=1701700287; h=content-transfer-encoding:mime-version: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=fUxnds+HPQEGrIJRV5viCfLrna/cjmgtYIVib94o7Eo=; b=F2Z6KJidmnrLtW1YRpGiaYylkMaQ72cbmjR0u3EGMNNRYDwYT6w6qQ1OCx6nfFmgDO AG92lOUDFEKtXTj+59F2tj9RJIF/Bw22WoyUpJ/yKm6k8o4BFSoK74aPSr8CXmwEUeva RFdoZd/a5mSVI42t95mnRTpmHvEj7jqfu0xykrg0KIt3w5aw8HAQpr9zcc3W2eBGjUbz 0gwD5Qi+XDn0Ap4UgtJl/3R7TDbgIhcoHWZZlkn34YNwunZT1GGT1RIVg1pQJ1RM4d1j dcMY4OLrXyT3zGGJ86iIlleA/v6gIybh/uAB55c215oCHUUYxDqKiUiNhblxB8MCJkTP ppug== X-Gm-Message-State: AOJu0YwDkJLEVtfSk4fgdn+7ReOqBg3wW2aHpZ6LkLoqG2GgaMHajLXN 7Aw8+7ELbXQi/GJsB6WP6qA= X-Google-Smtp-Source: AGHT+IGHFOd7bkC9a/RJlftGaScnufs5iWcmZxUJy8v4aDrD5/NusvSFtuGBLdVVyQMFR2YKEOy64w== X-Received: by 2002:a17:902:f544:b0:1cf:ca7b:8ef3 with SMTP id h4-20020a170902f54400b001cfca7b8ef3mr5192081plf.11.1701095486878; Mon, 27 Nov 2023 06:31:26 -0800 (PST) Received: from carrot.. (i60-34-119-11.s42.a014.ap.plala.or.jp. [60.34.119.11]) by smtp.gmail.com with ESMTPSA id a5-20020a170902ee8500b001cf51972586sm8302784pld.292.2023.11.27.06.31.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 06:31:26 -0800 (PST) From: Ryusuke Konishi To: Andrew Morton Cc: linux-nilfs@vger.kernel.org, Matthew Wilcox , linux-kernel@vger.kernel.org Subject: [PATCH 15/17] nilfs2: Convert nilfs_make_empty() to use a folio Date: Mon, 27 Nov 2023 23:30:34 +0900 Message-Id: <20231127143036.2425-16-konishi.ryusuke@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231127143036.2425-1-konishi.ryusuke@gmail.com> References: <20231127143036.2425-1-konishi.ryusuke@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: "Matthew Wilcox (Oracle)" Remove two calls to compound_head() and switch from kmap_atomic to kmap_local. Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Ryusuke Konishi --- fs/nilfs2/dir.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c index 919936d9ec27..ff0a009a292f 100644 --- a/fs/nilfs2/dir.c +++ b/fs/nilfs2/dir.c @@ -559,21 +559,21 @@ int nilfs_delete_entry(struct nilfs_dir_entry *dir, s= truct folio *folio) int nilfs_make_empty(struct inode *inode, struct inode *parent) { struct address_space *mapping =3D inode->i_mapping; - struct page *page =3D grab_cache_page(mapping, 0); + struct folio *folio =3D filemap_grab_folio(mapping, 0); unsigned int chunk_size =3D nilfs_chunk_size(inode); struct nilfs_dir_entry *de; int err; void *kaddr; =20 - if (!page) - return -ENOMEM; + if (IS_ERR(folio)) + return PTR_ERR(folio); =20 - err =3D nilfs_prepare_chunk(page, 0, chunk_size); + err =3D nilfs_prepare_chunk(&folio->page, 0, chunk_size); if (unlikely(err)) { - unlock_page(page); + folio_unlock(folio); goto fail; } - kaddr =3D kmap_atomic(page); + kaddr =3D kmap_local_folio(folio, 0); memset(kaddr, 0, chunk_size); de =3D (struct nilfs_dir_entry *)kaddr; de->name_len =3D 1; @@ -588,10 +588,10 @@ int nilfs_make_empty(struct inode *inode, struct inod= e *parent) de->inode =3D cpu_to_le64(parent->i_ino); memcpy(de->name, "..\0", 4); nilfs_set_de_type(de, inode); - kunmap_atomic(kaddr); - nilfs_commit_chunk(page, mapping, 0, chunk_size); + kunmap_local(kaddr); + nilfs_commit_chunk(&folio->page, mapping, 0, chunk_size); fail: - put_page(page); + folio_put(folio); return err; } =20 --=20 2.34.1 From nobody Wed Dec 17 12:17:23 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 99803C4167B for ; Mon, 27 Nov 2023 14:33:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233974AbjK0Ocv (ORCPT ); Mon, 27 Nov 2023 09:32:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233802AbjK0ObX (ORCPT ); Mon, 27 Nov 2023 09:31:23 -0500 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C4701BC; Mon, 27 Nov 2023 06:31:29 -0800 (PST) Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1cfaaa79766so21654435ad.3; Mon, 27 Nov 2023 06:31:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701095489; x=1701700289; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=A/T4u+44sUSgL7jMIOqkqh2vRw9RREOIECbOfKqfV6Q=; b=JlJmnaVhDJtwC5aYAOxjyqPsxqI719U3yl9x5xaC2n0QSoO+MVNvTp2OyP60ql31+t bPMLCFpTpHA5zgyc8t/nwOP6A1iFxb6GyNW6/XJ4axqzFuwXNePfLJXQdo6UTHeqWqPN gIMRg4QDyGf8jOh3q8RQh1OdZpDRW5+DNoejCmzSaVtAUhd9FF3xlc4CIKhYXP057UWB ITYdVubedInsQb7itxGK70omHTDz7e5AvCUFWANPBEwMJUUIhqZV9cnSUW+2iC39lEnt bZBXYedwmlzF7SlmQw6eWc50OXd9FE5PIij5HhX6WWLLc33nCeIdYGMBOs0KpFpRE/vB sUxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701095489; x=1701700289; h=content-transfer-encoding:mime-version: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=A/T4u+44sUSgL7jMIOqkqh2vRw9RREOIECbOfKqfV6Q=; b=aHlbfrDmgRc5slkWA+az1NAv1nBjGs2Qk0sSk7GQTfivz1bqzO0fzjQxqsNK5wmQzh ormzmtOnXSEgdHfsERvfVsauInDfCSH2rSS2BYe2hzLhvC/ycn8DsXJrHGgBL4+ExM6p +8i08FDx8Ft3Bk4eg2uPKxpsm5MiH4Jo5Oi+nGdB90a983F3kdEhV0Gpa5La52Ek81sU 2Fk9FNFCuJo4Z2wJ2p8cW9CYy1/tP1fq7JVMywzLiYBGnThmhFaWz7sdtOb4kOGAHLFG wLBDrsSFcXhJIS9MWmHAkGbpO58PftQKcMBOOFVE8eMObnWBUHpZqjVyRs69jZW3D2C1 lpoA== X-Gm-Message-State: AOJu0YyydEsL5D9Lie0RQv0fjQOP5pZhsak5LVqrQo8zO+hDX909htMg X0BzOC/4SU3321FHXoZa+a7f8XgJ58U= X-Google-Smtp-Source: AGHT+IEfeLVUq+ehWCvhqGM9q4W7M00oiClsnZ2lTmK6F//m+CHsj83PQYWmGYbYHdUEfX8OUHq1IQ== X-Received: by 2002:a17:902:ce84:b0:1cf:b7ea:fea with SMTP id f4-20020a170902ce8400b001cfb7ea0feamr8629251plg.1.1701095488835; Mon, 27 Nov 2023 06:31:28 -0800 (PST) Received: from carrot.. (i60-34-119-11.s42.a014.ap.plala.or.jp. [60.34.119.11]) by smtp.gmail.com with ESMTPSA id a5-20020a170902ee8500b001cf51972586sm8302784pld.292.2023.11.27.06.31.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 06:31:28 -0800 (PST) From: Ryusuke Konishi To: Andrew Morton Cc: linux-nilfs@vger.kernel.org, Matthew Wilcox , linux-kernel@vger.kernel.org Subject: [PATCH 16/17] nilfs2: Convert nilfs_prepare_chunk() and nilfs_commit_chunk() to folios Date: Mon, 27 Nov 2023 23:30:35 +0900 Message-Id: <20231127143036.2425-17-konishi.ryusuke@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231127143036.2425-1-konishi.ryusuke@gmail.com> References: <20231127143036.2425-1-konishi.ryusuke@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: "Matthew Wilcox (Oracle)" All callers now have a folio, so convert these two functions. Saves one call to compound_head() in unlock_page(). [ konishi.ryusuke: resolved conflicts in nilfs_{set_link,delete_entry} ] Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Ryusuke Konishi --- fs/nilfs2/dir.c | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c index ff0a009a292f..bc846b904b68 100644 --- a/fs/nilfs2/dir.c +++ b/fs/nilfs2/dir.c @@ -78,33 +78,32 @@ static unsigned int nilfs_last_byte(struct inode *inode= , unsigned long page_nr) return last_byte; } =20 -static int nilfs_prepare_chunk(struct page *page, unsigned int from, +static int nilfs_prepare_chunk(struct folio *folio, unsigned int from, unsigned int to) { - loff_t pos =3D page_offset(page) + from; + loff_t pos =3D folio_pos(folio) + from; =20 - return __block_write_begin(page, pos, to - from, nilfs_get_block); + return __block_write_begin(&folio->page, pos, to - from, nilfs_get_block); } =20 -static void nilfs_commit_chunk(struct page *page, - struct address_space *mapping, - unsigned int from, unsigned int to) +static void nilfs_commit_chunk(struct folio *folio, + struct address_space *mapping, size_t from, size_t to) { struct inode *dir =3D mapping->host; - loff_t pos =3D page_offset(page) + from; - unsigned int len =3D to - from; - unsigned int nr_dirty, copied; + loff_t pos =3D folio_pos(folio) + from; + size_t copied, len =3D to - from; + unsigned int nr_dirty; int err; =20 - nr_dirty =3D nilfs_page_count_clean_buffers(page, from, to); - copied =3D block_write_end(NULL, mapping, pos, len, len, page, NULL); + nr_dirty =3D nilfs_page_count_clean_buffers(&folio->page, from, to); + copied =3D block_write_end(NULL, mapping, pos, len, len, &folio->page, NU= LL); if (pos + copied > dir->i_size) i_size_write(dir, pos + copied); if (IS_DIRSYNC(dir)) nilfs_set_transaction_flag(NILFS_TI_SYNC); err =3D nilfs_set_file_dirty(dir, nr_dirty); WARN_ON(err); /* do not happen */ - unlock_page(page); + folio_unlock(folio); } =20 static bool nilfs_check_folio(struct folio *folio, char *kaddr) @@ -409,11 +408,11 @@ void nilfs_set_link(struct inode *dir, struct nilfs_d= ir_entry *de, int err; =20 folio_lock(folio); - err =3D nilfs_prepare_chunk(&folio->page, from, to); + err =3D nilfs_prepare_chunk(folio, from, to); BUG_ON(err); de->inode =3D cpu_to_le64(inode->i_ino); nilfs_set_de_type(de, inode); - nilfs_commit_chunk(&folio->page, mapping, from, to); + nilfs_commit_chunk(folio, mapping, from, to); inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); } =20 @@ -485,7 +484,7 @@ int nilfs_add_link(struct dentry *dentry, struct inode = *inode) got_it: from =3D offset_in_folio(folio, de); to =3D from + rec_len; - err =3D nilfs_prepare_chunk(&folio->page, from, to); + err =3D nilfs_prepare_chunk(folio, from, to); if (err) goto out_unlock; if (de->inode) { @@ -500,7 +499,7 @@ int nilfs_add_link(struct dentry *dentry, struct inode = *inode) memcpy(de->name, name, namelen); de->inode =3D cpu_to_le64(inode->i_ino); nilfs_set_de_type(de, inode); - nilfs_commit_chunk(&folio->page, folio->mapping, from, to); + nilfs_commit_chunk(folio, folio->mapping, from, to); inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); nilfs_mark_inode_dirty(dir); /* OFFSET_CACHE */ @@ -542,12 +541,12 @@ int nilfs_delete_entry(struct nilfs_dir_entry *dir, s= truct folio *folio) if (pde) from =3D (char *)pde - kaddr; folio_lock(folio); - err =3D nilfs_prepare_chunk(&folio->page, from, to); + err =3D nilfs_prepare_chunk(folio, from, to); BUG_ON(err); if (pde) pde->rec_len =3D nilfs_rec_len_to_disk(to - from); dir->inode =3D 0; - nilfs_commit_chunk(&folio->page, mapping, from, to); + nilfs_commit_chunk(folio, mapping, from, to); inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode)); out: return err; @@ -568,7 +567,7 @@ int nilfs_make_empty(struct inode *inode, struct inode = *parent) if (IS_ERR(folio)) return PTR_ERR(folio); =20 - err =3D nilfs_prepare_chunk(&folio->page, 0, chunk_size); + err =3D nilfs_prepare_chunk(folio, 0, chunk_size); if (unlikely(err)) { folio_unlock(folio); goto fail; @@ -589,7 +588,7 @@ int nilfs_make_empty(struct inode *inode, struct inode = *parent) memcpy(de->name, "..\0", 4); nilfs_set_de_type(de, inode); kunmap_local(kaddr); - nilfs_commit_chunk(&folio->page, mapping, 0, chunk_size); + nilfs_commit_chunk(folio, mapping, 0, chunk_size); fail: folio_put(folio); return err; --=20 2.34.1 From nobody Wed Dec 17 12:17:23 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 701B2C4167B for ; Mon, 27 Nov 2023 14:32:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233746AbjK0Ocs (ORCPT ); Mon, 27 Nov 2023 09:32:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233287AbjK0Ob0 (ORCPT ); Mon, 27 Nov 2023 09:31:26 -0500 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5F53D41; Mon, 27 Nov 2023 06:31:32 -0800 (PST) Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1cfaaa79766so21655055ad.3; Mon, 27 Nov 2023 06:31:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701095492; x=1701700292; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YzhEI8PX9uWduVePnYqK/AxUKd745WWyGgZ0XvSFp+U=; b=ji9j8nAxQqzvOX147sKXHx8lju59AiZvFm2DRBZy5RZt+0E3kSqwVWewBIRsgq8ZMT kiTG+8c7oKmYUlCsjSgLp3wuAgmCwW0XYnrR/oH/XDE6IkKhtBB9HiE+KEn8jAyqBa8M 4I4uYsLhWln4bLTz7GSXZhWJ1oAmAwBNv5Pcl5rdL/NVGVZfaYYCOQlCrjeC2AwfYxWG mopkjg0D/30Rs+9TLz76fa4ny+3tta/NPKSS6uZv+yUTlzszvD68M2Tlg/JgKheBfj8c enEt0gGRUfLMQnHwqDonU2W2337qnpng2obHbzej3vZ/h9vTcUMzQODk8lBSJ3W/Sz5T vD2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701095492; x=1701700292; h=content-transfer-encoding:mime-version: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=YzhEI8PX9uWduVePnYqK/AxUKd745WWyGgZ0XvSFp+U=; b=RQjQcbVayqGyAjrHsdM5phnE5j+cs4g6rdkJn7sfoqZ+Oxp1Kc4ATBRQlfpj/Vf4zi vK00Q5TekXL9F2qTEzNcFDngvYOoDVZmkMlkJnXCG/ge6fTEc6OZVkMUa+6OFzVAB13Y yYE1HGHPkdyo58gPWRStpoj0MLEfkbbt+ZBnQubvTMmppQCeWaGxDX2tRCD45F+2Ez27 FDi976WAdo4P+Q1ub4yjgNeqER7iHQGhLnq9uZsxoBZgFJy1LlNXKTiyxhM26MnBCDDq bZbAWK1US8duVNX1+E3T5g97WgE4AwR3rknBg1nhkAdqinE4w+1/pM1uhZ/Mrakz9M1s HrlA== X-Gm-Message-State: AOJu0YxVZ1SqzNolxGkToyrEttziZaeq2YM1U5FN3tbC8NVCeTEe0N06 jAskTaDxA2iTfaYV+F0hgMU= X-Google-Smtp-Source: AGHT+IFSnoQkHprY5znYQP1Yyq2eAnrGNVx2gV7UFL5mKqSq8bKNzLTdIL+Y3iv/zkWHLVYX8l1KgQ== X-Received: by 2002:a17:902:ced0:b0:1cc:ae1a:b0b8 with SMTP id d16-20020a170902ced000b001ccae1ab0b8mr15658483plg.44.1701095492166; Mon, 27 Nov 2023 06:31:32 -0800 (PST) Received: from carrot.. (i60-34-119-11.s42.a014.ap.plala.or.jp. [60.34.119.11]) by smtp.gmail.com with ESMTPSA id a5-20020a170902ee8500b001cf51972586sm8302784pld.292.2023.11.27.06.31.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 06:31:31 -0800 (PST) From: Ryusuke Konishi To: Andrew Morton Cc: linux-nilfs@vger.kernel.org, Matthew Wilcox , linux-kernel@vger.kernel.org Subject: [PATCH 17/17] nilfs2: Convert nilfs_page_bug() to nilfs_folio_bug() Date: Mon, 27 Nov 2023 23:30:36 +0900 Message-Id: <20231127143036.2425-18-konishi.ryusuke@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231127143036.2425-1-konishi.ryusuke@gmail.com> References: <20231127143036.2425-1-konishi.ryusuke@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: "Matthew Wilcox (Oracle)" All callers have a folio now, so convert it. Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Ryusuke Konishi --- fs/nilfs2/btnode.c | 4 ++-- fs/nilfs2/page.c | 25 +++++++++++++------------ fs/nilfs2/page.h | 6 +++--- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/fs/nilfs2/btnode.c b/fs/nilfs2/btnode.c index 1204dd06ead8..0131d83b912d 100644 --- a/fs/nilfs2/btnode.c +++ b/fs/nilfs2/btnode.c @@ -190,7 +190,7 @@ int nilfs_btnode_prepare_change_key(struct address_spac= e *btnc, retry: /* BUG_ON(oldkey !=3D obh->b_folio->index); */ if (unlikely(oldkey !=3D ofolio->index)) - NILFS_PAGE_BUG(&ofolio->page, + NILFS_FOLIO_BUG(ofolio, "invalid oldkey %lld (newkey=3D%lld)", (unsigned long long)oldkey, (unsigned long long)newkey); @@ -246,7 +246,7 @@ void nilfs_btnode_commit_change_key(struct address_spac= e *btnc, if (nbh =3D=3D NULL) { /* blocksize =3D=3D pagesize */ ofolio =3D obh->b_folio; if (unlikely(oldkey !=3D ofolio->index)) - NILFS_PAGE_BUG(&ofolio->page, + NILFS_FOLIO_BUG(ofolio, "invalid oldkey %lld (newkey=3D%lld)", (unsigned long long)oldkey, (unsigned long long)newkey); diff --git a/fs/nilfs2/page.c b/fs/nilfs2/page.c index 94e11bcee05b..5c2eba1987bd 100644 --- a/fs/nilfs2/page.c +++ b/fs/nilfs2/page.c @@ -150,29 +150,30 @@ bool nilfs_folio_buffers_clean(struct folio *folio) return true; } =20 -void nilfs_page_bug(struct page *page) +void nilfs_folio_bug(struct folio *folio) { + struct buffer_head *bh, *head; struct address_space *m; unsigned long ino; =20 - if (unlikely(!page)) { - printk(KERN_CRIT "NILFS_PAGE_BUG(NULL)\n"); + if (unlikely(!folio)) { + printk(KERN_CRIT "NILFS_FOLIO_BUG(NULL)\n"); return; } =20 - m =3D page->mapping; + m =3D folio->mapping; ino =3D m ? m->host->i_ino : 0; =20 - printk(KERN_CRIT "NILFS_PAGE_BUG(%p): cnt=3D%d index#=3D%llu flags=3D0x%l= x " + printk(KERN_CRIT "NILFS_FOLIO_BUG(%p): cnt=3D%d index#=3D%llu flags=3D0x%= lx " "mapping=3D%p ino=3D%lu\n", - page, page_ref_count(page), - (unsigned long long)page->index, page->flags, m, ino); + folio, folio_ref_count(folio), + (unsigned long long)folio->index, folio->flags, m, ino); =20 - if (page_has_buffers(page)) { - struct buffer_head *bh, *head; + head =3D folio_buffers(folio); + if (head) { int i =3D 0; =20 - bh =3D head =3D page_buffers(page); + bh =3D head; do { printk(KERN_CRIT " BH[%d] %p: cnt=3D%d block#=3D%llu state=3D0x%lx\n", @@ -258,7 +259,7 @@ int nilfs_copy_dirty_pages(struct address_space *dmap, =20 folio_lock(folio); if (unlikely(!folio_test_dirty(folio))) - NILFS_PAGE_BUG(&folio->page, "inconsistent dirty state"); + NILFS_FOLIO_BUG(folio, "inconsistent dirty state"); =20 dfolio =3D filemap_grab_folio(dmap, folio->index); if (unlikely(IS_ERR(dfolio))) { @@ -268,7 +269,7 @@ int nilfs_copy_dirty_pages(struct address_space *dmap, break; } if (unlikely(!folio_buffers(folio))) - NILFS_PAGE_BUG(&folio->page, + NILFS_FOLIO_BUG(folio, "found empty page in dat page cache"); =20 nilfs_copy_folio(dfolio, folio, true); diff --git a/fs/nilfs2/page.h b/fs/nilfs2/page.h index 968b311d265b..7e1a2c455a10 100644 --- a/fs/nilfs2/page.h +++ b/fs/nilfs2/page.h @@ -37,7 +37,7 @@ struct buffer_head *nilfs_grab_buffer(struct inode *, str= uct address_space *, void nilfs_forget_buffer(struct buffer_head *); void nilfs_copy_buffer(struct buffer_head *, struct buffer_head *); bool nilfs_folio_buffers_clean(struct folio *); -void nilfs_page_bug(struct page *); +void nilfs_folio_bug(struct folio *); =20 int nilfs_copy_dirty_pages(struct address_space *, struct address_space *); void nilfs_copy_back_pages(struct address_space *, struct address_space *); @@ -49,7 +49,7 @@ unsigned long nilfs_find_uncommitted_extent(struct inode = *inode, sector_t start_blk, sector_t *blkoff); =20 -#define NILFS_PAGE_BUG(page, m, a...) \ - do { nilfs_page_bug(page); BUG(); } while (0) +#define NILFS_FOLIO_BUG(folio, m, a...) \ + do { nilfs_folio_bug(folio); BUG(); } while (0) =20 #endif /* _NILFS_PAGE_H */ --=20 2.34.1