This matches ext2 and removes a few hidden calls to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx> --- fs/sysv/dir.c | 23 ++++++++++------------- fs/sysv/namei.c | 10 +++++----- fs/sysv/sysv.h | 4 ++-- 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/fs/sysv/dir.c b/fs/sysv/dir.c index 5b2e3c7c2971..ebccf7bb5b69 100644 --- a/fs/sysv/dir.c +++ b/fs/sysv/dir.c @@ -327,21 +327,21 @@ int sysv_empty_dir(struct inode * inode) } /* Releases the page */ -int sysv_set_link(struct sysv_dir_entry *de, struct page *page, - struct inode *inode) +int sysv_set_link(struct sysv_dir_entry *de, struct folio *folio, + struct inode *inode) { - struct inode *dir = page->mapping->host; - loff_t pos = page_offset(page) + offset_in_page(de); + struct inode *dir = folio->mapping->host; + loff_t pos = folio_pos(folio) + offset_in_folio(folio, de); int err; - lock_page(page); - err = sysv_prepare_chunk(page, pos, SYSV_DIRSIZE); + folio_lock(folio); + err = sysv_prepare_chunk(&folio->page, pos, SYSV_DIRSIZE); if (err) { - unlock_page(page); + folio_unlock(folio); return err; } de->inode = cpu_to_fs16(SYSV_SB(inode->i_sb), inode->i_ino); - dir_commit_chunk(page, pos, SYSV_DIRSIZE); + dir_commit_chunk(&folio->page, pos, SYSV_DIRSIZE); inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); mark_inode_dirty(dir); return sysv_handle_dirsync(inode); @@ -354,15 +354,12 @@ int sysv_set_link(struct sysv_dir_entry *de, struct page *page, * sysv_dotdot() acts as a call to dir_get_folio() and must be treated * accordingly for nesting purposes. */ -struct sysv_dir_entry *sysv_dotdot(struct inode *dir, struct page **p) +struct sysv_dir_entry *sysv_dotdot(struct inode *dir, struct folio **foliop) { - struct folio *folio; - - struct sysv_dir_entry *de = dir_get_folio(dir, 0, &folio); + struct sysv_dir_entry *de = dir_get_folio(dir, 0, foliop); if (IS_ERR(de)) return NULL; - *p = &folio->page; /* ".." is the second directory entry */ return de + 1; } diff --git a/fs/sysv/namei.c b/fs/sysv/namei.c index 970043fe49ee..ef4d91431225 100644 --- a/fs/sysv/namei.c +++ b/fs/sysv/namei.c @@ -194,7 +194,7 @@ static int sysv_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; struct sysv_dir_entry * dir_de = NULL; struct folio *old_folio; struct sysv_dir_entry * old_de; @@ -209,7 +209,7 @@ static int sysv_rename(struct mnt_idmap *idmap, struct inode *old_dir, if (S_ISDIR(old_inode->i_mode)) { err = -EIO; - dir_de = sysv_dotdot(old_inode, &dir_page); + dir_de = sysv_dotdot(old_inode, &dir_folio); if (!dir_de) goto out_old; } @@ -226,7 +226,7 @@ static int sysv_rename(struct mnt_idmap *idmap, struct inode *old_dir, new_de = sysv_find_entry(new_dentry, &new_folio); if (!new_de) goto out_dir; - err = sysv_set_link(new_de, &new_folio->page, old_inode); + err = sysv_set_link(new_de, new_folio, old_inode); folio_release_kmap(new_folio, new_de); if (err) goto out_dir; @@ -249,14 +249,14 @@ static int sysv_rename(struct mnt_idmap *idmap, struct inode *old_dir, mark_inode_dirty(old_inode); if (dir_de) { - err = sysv_set_link(dir_de, dir_page, new_dir); + err = sysv_set_link(dir_de, dir_folio, new_dir); if (!err) inode_dec_link_count(old_dir); } out_dir: if (dir_de) - unmap_and_put_page(dir_page, dir_de); + folio_release_kmap(dir_folio, dir_de); out_old: folio_release_kmap(old_folio, old_de); out: diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h index be15c659a027..ee90af7dbed9 100644 --- a/fs/sysv/sysv.h +++ b/fs/sysv/sysv.h @@ -153,9 +153,9 @@ int sysv_add_link(struct dentry *, struct inode *); int sysv_delete_entry(struct sysv_dir_entry *, struct page *); int sysv_make_empty(struct inode *, struct inode *); int sysv_empty_dir(struct inode *); -int sysv_set_link(struct sysv_dir_entry *, struct page *, +int sysv_set_link(struct sysv_dir_entry *, struct folio *, struct inode *); -struct sysv_dir_entry *sysv_dotdot(struct inode *, struct page **); +struct sysv_dir_entry *sysv_dotdot(struct inode *, struct folio **); ino_t sysv_inode_by_name(struct dentry *); -- 2.43.0