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 3/7] sysv: Convert sysv_set_link() and sysv_dotdot() to take a folio
Date: Tue, 9 Jul 2024 16:03:08 +0100 [thread overview]
Message-ID: <20240709150314.1906109-4-willy@infradead.org> (raw)
In-Reply-To: <20240709150314.1906109-1-willy@infradead.org>
This matches ext2 and removes a few hidden calls to compound_head().
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
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
next prev parent reply other threads:[~2024-07-09 15:03 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-09 15:03 [PATCH 0/7] Convert sysv directory handling to folios Matthew Wilcox (Oracle)
2024-07-09 15:03 ` [PATCH 1/7] sysv: Convert dir_get_page() to dir_get_folio() Matthew Wilcox (Oracle)
2024-07-09 15:03 ` [PATCH 2/7] sysv: Convert sysv_find_entry() to take a folio Matthew Wilcox (Oracle)
2024-07-09 15:03 ` Matthew Wilcox (Oracle) [this message]
2024-07-09 15:03 ` [PATCH 4/7] sysv: Convert sysv_delete_entry() to work on " Matthew Wilcox (Oracle)
2024-07-09 15:03 ` [PATCH 5/7] sysv: Convert sysv_make_empty() to use " Matthew Wilcox (Oracle)
2024-07-09 15:03 ` [PATCH 6/7] sysv: Convert sysv_prepare_chunk() to take " Matthew Wilcox (Oracle)
2024-07-09 15:03 ` [PATCH 7/7] sysv: Convert dir_commit_chunk() " Matthew Wilcox (Oracle)
2024-07-16 8:17 ` [PATCH 0/7] Convert sysv directory handling to folios Christian Brauner
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=20240709150314.1906109-4-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).