summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Wilcox (Oracle) <willy@infradead.org>2024-07-08 15:23:35 -0400
committerChristian Brauner <brauner@kernel.org>2024-08-07 11:31:52 +0200
commit597697c5adf8ac16e8e8a5d55a572a19f2282b88 (patch)
tree0b18ab1c2caf98f9662129cc7dc03e35c4860021
parente95d2754458a6a0a1c8a5dc1d593d80f6940fbdc (diff)
ufs: Convert ufs_set_link() and ufss_dotdot() to take a folio
This matches ext2 and removes a few hidden calls to compound_head(). Reviewed-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Signed-off-by: Christian Brauner <brauner@kernel.org>
-rw-r--r--fs/ufs/dir.c26
-rw-r--r--fs/ufs/namei.c16
-rw-r--r--fs/ufs/ufs.h4
3 files changed, 21 insertions, 25 deletions
diff --git a/fs/ufs/dir.c b/fs/ufs/dir.c
index fb56a00b622c..6fcca4dd064a 100644
--- a/fs/ufs/dir.c
+++ b/fs/ufs/dir.c
@@ -89,23 +89,22 @@ ino_t ufs_inode_by_name(struct inode *dir, const struct qstr *qstr)
/* Releases the page */
void ufs_set_link(struct inode *dir, struct ufs_dir_entry *de,
- struct page *page, struct inode *inode,
+ struct folio *folio, struct inode *inode,
bool update_times)
{
- loff_t pos = page_offset(page) +
- (char *) de - (char *) page_address(page);
+ loff_t pos = folio_pos(folio) + offset_in_folio(folio, de);
unsigned len = fs16_to_cpu(dir->i_sb, de->d_reclen);
int err;
- lock_page(page);
- err = ufs_prepare_chunk(page, pos, len);
+ folio_lock(folio);
+ err = ufs_prepare_chunk(&folio->page, pos, len);
BUG_ON(err);
de->d_ino = cpu_to_fs32(dir->i_sb, inode->i_ino);
ufs_set_de_type(dir->i_sb, de, inode->i_mode);
- ufs_commit_chunk(page, pos, len);
- ufs_put_page(page);
+ ufs_commit_chunk(&folio->page, pos, len);
+ ufs_put_page(&folio->page);
if (update_times)
inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir));
mark_inode_dirty(dir);
@@ -233,17 +232,14 @@ ufs_next_entry(struct super_block *sb, struct ufs_dir_entry *p)
fs16_to_cpu(sb, p->d_reclen));
}
-struct ufs_dir_entry *ufs_dotdot(struct inode *dir, struct page **p)
+struct ufs_dir_entry *ufs_dotdot(struct inode *dir, struct folio **foliop)
{
- struct folio *folio;
- struct ufs_dir_entry *de = ufs_get_folio(dir, 0, &folio);
+ struct ufs_dir_entry *de = ufs_get_folio(dir, 0, foliop);
- if (IS_ERR(de))
- return NULL;
- de = ufs_next_entry(dir->i_sb, de);
- *p = &folio->page;
+ if (!IS_ERR(de))
+ return ufs_next_entry(dir->i_sb, de);
- return de;
+ return NULL;
}
/*
diff --git a/fs/ufs/namei.c b/fs/ufs/namei.c
index 53e9bfad54df..1759b710d831 100644
--- a/fs/ufs/namei.c
+++ b/fs/ufs/namei.c
@@ -249,7 +249,7 @@ static int ufs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
{
struct inode *old_inode = d_inode(old_dentry);
struct inode *new_inode = d_inode(new_dentry);
- struct page *dir_page = NULL;
+ struct folio *dir_folio = NULL;
struct ufs_dir_entry * dir_de = NULL;
struct folio *old_folio;
struct ufs_dir_entry *old_de;
@@ -264,7 +264,7 @@ static int ufs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
if (S_ISDIR(old_inode->i_mode)) {
err = -EIO;
- dir_de = ufs_dotdot(old_inode, &dir_page);
+ dir_de = ufs_dotdot(old_inode, &dir_folio);
if (!dir_de)
goto out_old;
}
@@ -281,7 +281,7 @@ static int ufs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
new_de = ufs_find_entry(new_dir, &new_dentry->d_name, &new_folio);
if (!new_de)
goto out_dir;
- ufs_set_link(new_dir, new_de, &new_folio->page, old_inode, 1);
+ ufs_set_link(new_dir, new_de, new_folio, old_inode, 1);
inode_set_ctime_current(new_inode);
if (dir_de)
drop_nlink(new_inode);
@@ -305,10 +305,10 @@ static int ufs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
if (dir_de) {
if (old_dir != new_dir)
- ufs_set_link(old_inode, dir_de, dir_page, new_dir, 0);
+ ufs_set_link(old_inode, dir_de, dir_folio, new_dir, 0);
else {
- kunmap(dir_page);
- put_page(dir_page);
+ kunmap(&dir_folio->page);
+ folio_put(dir_folio);
}
inode_dec_link_count(old_dir);
}
@@ -317,8 +317,8 @@ static int ufs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
out_dir:
if (dir_de) {
- kunmap(dir_page);
- put_page(dir_page);
+ kunmap(&dir_folio->page);
+ folio_put(dir_folio);
}
out_old:
kunmap(&old_folio->page);
diff --git a/fs/ufs/ufs.h b/fs/ufs/ufs.h
index 161fe0bb6fd1..1ad992ab2855 100644
--- a/fs/ufs/ufs.h
+++ b/fs/ufs/ufs.h
@@ -107,9 +107,9 @@ 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_empty_dir(struct inode *);
-struct ufs_dir_entry *ufs_dotdot(struct inode *, struct page **);
+struct ufs_dir_entry *ufs_dotdot(struct inode *, struct folio **);
void ufs_set_link(struct inode *dir, struct ufs_dir_entry *de,
- struct page *page, struct inode *inode, bool update_times);
+ struct folio *folio, struct inode *inode, bool update_times);
/* file.c */
extern const struct inode_operations ufs_file_inode_operations;