linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
To: linux-fsdevel@vger.kernel.org
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
	Al Viro <viro@zeniv.linux.org.uk>, Christoph Hellwig <hch@lst.de>
Subject: [PATCH 06/10] ufs: Convert ufs_delete_entry() to work on a folio
Date: Tue,  9 Jul 2024 04:30:23 +0100	[thread overview]
Message-ID: <20240709033029.1769992-7-willy@infradead.org> (raw)
In-Reply-To: <20240709033029.1769992-1-willy@infradead.org>

Match ext2 and remove a few hidden calls to compound_head().

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/ufs/dir.c   | 29 ++++++++++++++++-------------
 fs/ufs/namei.c |  4 ++--
 fs/ufs/ufs.h   |  2 +-
 3 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/fs/ufs/dir.c b/fs/ufs/dir.c
index 6fcca4dd064a..945fff87b385 100644
--- a/fs/ufs/dir.c
+++ b/fs/ufs/dir.c
@@ -485,19 +485,23 @@ ufs_readdir(struct file *file, struct dir_context *ctx)
  * previous entry.
  */
 int ufs_delete_entry(struct inode *inode, struct ufs_dir_entry *dir,
-		     struct page * page)
+		     struct folio *folio)
 {
 	struct super_block *sb = inode->i_sb;
-	char *kaddr = page_address(page);
-	unsigned from = ((char*)dir - kaddr) & ~(UFS_SB(sb)->s_uspi->s_dirblksize - 1);
-	unsigned to = ((char*)dir - kaddr) + fs16_to_cpu(sb, dir->d_reclen);
+	size_t from, to;
+	char *kaddr;
 	loff_t pos;
-	struct ufs_dir_entry *pde = NULL;
-	struct ufs_dir_entry *de = (struct ufs_dir_entry *) (kaddr + from);
+	struct ufs_dir_entry *de, *pde = NULL;
 	int err;
 
 	UFSD("ENTER\n");
 
+	from = offset_in_folio(folio, dir);
+	to = from + fs16_to_cpu(sb, dir->d_reclen);
+	kaddr = (char *)dir - from;
+	from &= ~(UFS_SB(sb)->s_uspi->s_dirblksize - 1);
+	de = (struct ufs_dir_entry *) (kaddr + from);
+
 	UFSD("ino %u, reclen %u, namlen %u, name %s\n",
 	      fs32_to_cpu(sb, de->d_ino),
 	      fs16_to_cpu(sb, de->d_reclen),
@@ -514,21 +518,20 @@ int ufs_delete_entry(struct inode *inode, struct ufs_dir_entry *dir,
 		de = ufs_next_entry(sb, de);
 	}
 	if (pde)
-		from = (char*)pde - (char*)page_address(page);
-
-	pos = page_offset(page) + from;
-	lock_page(page);
-	err = ufs_prepare_chunk(page, pos, to - from);
+		from = offset_in_folio(folio, pde);
+	pos = folio_pos(folio) + from;
+	folio_lock(folio);
+	err = ufs_prepare_chunk(&folio->page, pos, to - from);
 	BUG_ON(err);
 	if (pde)
 		pde->d_reclen = cpu_to_fs16(sb, to - from);
 	dir->d_ino = 0;
-	ufs_commit_chunk(page, pos, to - from);
+	ufs_commit_chunk(&folio->page, pos, to - from);
 	inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
 	mark_inode_dirty(inode);
 	err = ufs_handle_dirsync(inode);
 out:
-	ufs_put_page(page);
+	ufs_put_page(&folio->page);
 	UFSD("EXIT\n");
 	return err;
 }
diff --git a/fs/ufs/namei.c b/fs/ufs/namei.c
index 1759b710d831..a9b0c15de067 100644
--- a/fs/ufs/namei.c
+++ b/fs/ufs/namei.c
@@ -216,7 +216,7 @@ static int ufs_unlink(struct inode *dir, struct dentry *dentry)
 	if (!de)
 		goto out;
 
-	err = ufs_delete_entry(dir, de, &folio->page);
+	err = ufs_delete_entry(dir, de, folio);
 	if (err)
 		goto out;
 
@@ -300,7 +300,7 @@ static int ufs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
 	 */
 	inode_set_ctime_current(old_inode);
 
-	ufs_delete_entry(old_dir, old_de, &old_folio->page);
+	ufs_delete_entry(old_dir, old_de, old_folio);
 	mark_inode_dirty(old_inode);
 
 	if (dir_de) {
diff --git a/fs/ufs/ufs.h b/fs/ufs/ufs.h
index 1ad992ab2855..a2c762cb65a0 100644
--- a/fs/ufs/ufs.h
+++ b/fs/ufs/ufs.h
@@ -105,7 +105,7 @@ ino_t ufs_inode_by_name(struct inode *, const struct qstr *);
 int ufs_make_empty(struct inode *, struct inode *);
 struct ufs_dir_entry *ufs_find_entry(struct inode *, const struct qstr *,
 		struct folio **);
-int ufs_delete_entry(struct inode *, struct ufs_dir_entry *, struct page *);
+int ufs_delete_entry(struct inode *, struct ufs_dir_entry *, struct folio *);
 int ufs_empty_dir(struct inode *);
 struct ufs_dir_entry *ufs_dotdot(struct inode *, struct folio **);
 void ufs_set_link(struct inode *dir, struct ufs_dir_entry *de,
-- 
2.43.0


  parent reply	other threads:[~2024-07-09  3:30 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-09  3:30 [PATCH 00/10] Convert UFS directory handling to folios Matthew Wilcox (Oracle)
2024-07-09  3:30 ` [PATCH 01/10] ufs: Convert ufs_get_page() to use a folio Matthew Wilcox (Oracle)
2024-07-16 22:31   ` Al Viro
2024-07-09  3:30 ` [PATCH 02/10] ufs: Convert ufs_get_page() to ufs_get_folio() Matthew Wilcox (Oracle)
2024-07-09  3:30 ` [PATCH 03/10] ufs: Convert ufs_check_page() to ufs_check_folio() Matthew Wilcox (Oracle)
2024-07-09  3:30 ` [PATCH 04/10] ufs: Convert ufs_find_entry() to take a folio Matthew Wilcox (Oracle)
2024-07-09  3:30 ` [PATCH 05/10] ufs: Convert ufs_set_link() and ufss_dotdot() " Matthew Wilcox (Oracle)
2024-07-09  3:30 ` Matthew Wilcox (Oracle) [this message]
2024-07-09  3:30 ` [PATCH 07/10] ufs: Convert ufs_make_empty() to use " Matthew Wilcox (Oracle)
2024-07-09  3:30 ` [PATCH 08/10] ufs: Convert ufs_prepare_chunk() to take " Matthew Wilcox (Oracle)
2024-07-09  3:30 ` [PATCH 09/10] ufs; Convert ufs_commit_chunk() " Matthew Wilcox (Oracle)
2024-07-09  3:30 ` [PATCH 10/10] ufs: Convert directory handling to kmap_local Matthew Wilcox (Oracle)
2024-07-16 22:46 ` [PATCH 00/10] Convert UFS directory handling to folios Al Viro

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=20240709033029.1769992-7-willy@infradead.org \
    --to=willy@infradead.org \
    --cc=hch@lst.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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).