linux-nilfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ryusuke Konishi <konishi.ryusuke@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-nilfs@vger.kernel.org, Matthew Wilcox <willy@infradead.org>,
	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	[thread overview]
Message-ID: <20231127143036.2425-14-konishi.ryusuke@gmail.com> (raw)
In-Reply-To: <20231127143036.2425-1-konishi.ryusuke@gmail.com>

From: "Matthew Wilcox (Oracle)" <willy@infradead.org>

Remove six calls to compound_head() by using the folio API.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
---
 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 inode *inode)
 	unsigned int chunk_size = nilfs_chunk_size(dir);
 	unsigned int reclen = NILFS_DIR_REC_LEN(namelen);
 	unsigned short rec_len, name_len;
-	struct page *page = NULL;
+	struct folio *folio = NULL;
 	struct nilfs_dir_entry *de;
 	unsigned long npages = dir_pages(dir);
 	unsigned long n;
-	char *kaddr;
-	unsigned int from, to;
+	size_t from, to;
 	int err;
 
 	/*
 	 * 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 = 0; n <= npages; n++) {
+		char *kaddr = nilfs_get_folio(dir, n, &folio);
 		char *dir_end;
 
-		kaddr = nilfs_get_page(dir, n, &page);
-		err = PTR_ERR(kaddr);
 		if (IS_ERR(kaddr))
-			goto out;
-		lock_page(page);
+			return PTR_ERR(kaddr);
+		folio_lock(folio);
 		dir_end = kaddr + nilfs_last_byte(dir, n);
 		de = (struct nilfs_dir_entry *)kaddr;
-		kaddr += PAGE_SIZE - reclen;
+		kaddr += folio_size(folio) - reclen;
 		while ((char *)de <= kaddr) {
 			if ((char *)de == dir_end) {
 				/* We hit i_size */
@@ -489,16 +487,16 @@ int nilfs_add_link(struct dentry *dentry, struct inode *inode)
 				goto got_it;
 			de = (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;
 
 got_it:
-	from = offset_in_page(de);
+	from = offset_in_folio(folio, de);
 	to = from + rec_len;
-	err = nilfs_prepare_chunk(page, from, to);
+	err = 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 inode *inode)
 	memcpy(de->name, name, namelen);
 	de->inode = 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;
 }
 
-- 
2.34.1


  parent reply	other threads:[~2023-11-27 14:31 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-27 14:30 [PATCH 00/17] nilfs2: Folio conversions for directory paths Ryusuke Konishi
2023-11-27 14:30 ` [PATCH 01/17] nilfs2: move page release outside of nilfs_delete_entry and nilfs_set_link Ryusuke Konishi
2023-11-27 17:08   ` Matthew Wilcox
2023-11-27 14:30 ` [PATCH 02/17] nilfs2: eliminate staggered calls to kunmap in nilfs_rename Ryusuke Konishi
2023-11-27 17:08   ` Matthew Wilcox
2023-11-27 14:30 ` [PATCH 03/17] nilfs2: Remove page_address() from nilfs_set_link Ryusuke Konishi
2023-11-27 14:30 ` [PATCH 04/17] nilfs2: Remove page_address() from nilfs_add_link Ryusuke Konishi
2023-11-27 14:30 ` [PATCH 05/17] nilfs2: Remove page_address() from nilfs_delete_entry Ryusuke Konishi
2023-11-27 14:30 ` [PATCH 06/17] nilfs2: Return the mapped address from nilfs_get_page() Ryusuke Konishi
2023-11-27 14:30 ` [PATCH 07/17] nilfs2: Pass the mapped address to nilfs_check_page() Ryusuke Konishi
2023-11-27 14:30 ` [PATCH 08/17] nilfs2: Switch to kmap_local for directory handling Ryusuke Konishi
2023-11-27 14:30 ` [PATCH 09/17] nilfs2: Add nilfs_get_folio() Ryusuke Konishi
2023-11-27 14:30 ` [PATCH 10/17] nilfs2: Convert nilfs_readdir to use a folio Ryusuke Konishi
2023-11-27 14:30 ` [PATCH 11/17] nilfs2: Convert nilfs_find_entry " Ryusuke Konishi
2023-11-27 14:30 ` [PATCH 12/17] nilfs2: Convert nilfs_rename() to use folios Ryusuke Konishi
2023-11-27 14:30 ` Ryusuke Konishi [this message]
2023-11-27 14:30 ` [PATCH 14/17] nilfs2: Convert nilfs_empty_dir() to use a folio Ryusuke Konishi
2023-11-27 14:30 ` [PATCH 15/17] nilfs2: Convert nilfs_make_empty() " Ryusuke Konishi
2023-11-27 14:30 ` [PATCH 16/17] nilfs2: Convert nilfs_prepare_chunk() and nilfs_commit_chunk() to folios Ryusuke Konishi
2023-11-27 14:30 ` [PATCH 17/17] nilfs2: Convert nilfs_page_bug() to nilfs_folio_bug() Ryusuke Konishi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231127143036.2425-14-konishi.ryusuke@gmail.com \
    --to=konishi.ryusuke@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nilfs@vger.kernel.org \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).