* [PATCH 0/7] Convert sysv directory handling to folios
@ 2024-07-09 15:03 Matthew Wilcox (Oracle)
2024-07-09 15:03 ` [PATCH 1/7] sysv: Convert dir_get_page() to dir_get_folio() Matthew Wilcox (Oracle)
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-07-09 15:03 UTC (permalink / raw)
To: linux-fsdevel; +Cc: Matthew Wilcox (Oracle), Al Viro, Christoph Hellwig
This patch series mirrors the changes to ext2 directory handling.
It's a bit simpler than the UFS one from yesterday as sysv was already
converted to kmap_local. Again, compile tested only.
Matthew Wilcox (Oracle) (7):
sysv: Convert dir_get_page() to dir_get_folio()
sysv: Convert sysv_find_entry() to take a folio
sysv: Convert sysv_set_link() and sysv_dotdot() to take a folio
sysv: Convert sysv_delete_entry() to work on a folio
sysv: Convert sysv_make_empty() to use a folio
sysv: Convert sysv_prepare_chunk() to take a folio
sysv: Convert dir_commit_chunk() to take a folio
fs/sysv/dir.c | 158 +++++++++++++++++++++++-------------------------
fs/sysv/itree.c | 4 +-
fs/sysv/namei.c | 32 +++++-----
fs/sysv/sysv.h | 20 +++---
4 files changed, 105 insertions(+), 109 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/7] sysv: Convert dir_get_page() to dir_get_folio()
2024-07-09 15:03 [PATCH 0/7] Convert sysv directory handling to folios Matthew Wilcox (Oracle)
@ 2024-07-09 15:03 ` Matthew Wilcox (Oracle)
2024-07-09 15:03 ` [PATCH 2/7] sysv: Convert sysv_find_entry() to take a folio Matthew Wilcox (Oracle)
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-07-09 15:03 UTC (permalink / raw)
To: linux-fsdevel; +Cc: Matthew Wilcox (Oracle), Al Viro, Christoph Hellwig
Remove a few conversions between page and folio.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
fs/sysv/dir.c | 80 +++++++++++++++++++++++++++------------------------
1 file changed, 42 insertions(+), 38 deletions(-)
diff --git a/fs/sysv/dir.c b/fs/sysv/dir.c
index 2e126d72d619..1f95f82f8941 100644
--- a/fs/sysv/dir.c
+++ b/fs/sysv/dir.c
@@ -52,20 +52,21 @@ static int sysv_handle_dirsync(struct inode *dir)
}
/*
- * Calls to dir_get_page()/unmap_and_put_page() must be nested according to the
+ * Calls to dir_get_folio()/folio_release_kmap() must be nested according to the
* rules documented in mm/highmem.rst.
*
- * NOTE: sysv_find_entry() and sysv_dotdot() act as calls to dir_get_page()
+ * NOTE: sysv_find_entry() and sysv_dotdot() act as calls to dir_get_folio()
* and must be treated accordingly for nesting purposes.
*/
-static void *dir_get_page(struct inode *dir, unsigned long n, struct page **p)
+static void *dir_get_folio(struct inode *dir, unsigned long n,
+ struct folio **foliop)
{
- struct address_space *mapping = dir->i_mapping;
- struct page *page = read_mapping_page(mapping, n, NULL);
- if (IS_ERR(page))
- return ERR_CAST(page);
- *p = page;
- return kmap_local_page(page);
+ struct folio *folio = read_mapping_folio(dir->i_mapping, n, NULL);
+
+ if (IS_ERR(folio))
+ return ERR_CAST(folio);
+ *foliop = folio;
+ return kmap_local_folio(folio, 0);
}
static int sysv_readdir(struct file *file, struct dir_context *ctx)
@@ -87,9 +88,9 @@ static int sysv_readdir(struct file *file, struct dir_context *ctx)
for ( ; n < npages; n++, offset = 0) {
char *kaddr, *limit;
struct sysv_dir_entry *de;
- struct page *page;
+ struct folio *folio;
- kaddr = dir_get_page(inode, n, &page);
+ kaddr = dir_get_folio(inode, n, &folio);
if (IS_ERR(kaddr))
continue;
de = (struct sysv_dir_entry *)(kaddr+offset);
@@ -103,11 +104,11 @@ static int sysv_readdir(struct file *file, struct dir_context *ctx)
if (!dir_emit(ctx, name, strnlen(name,SYSV_NAMELEN),
fs16_to_cpu(SYSV_SB(sb), de->inode),
DT_UNKNOWN)) {
- unmap_and_put_page(page, kaddr);
+ folio_release_kmap(folio, kaddr);
return 0;
}
}
- unmap_and_put_page(page, kaddr);
+ folio_release_kmap(folio, kaddr);
}
return 0;
}
@@ -133,7 +134,7 @@ static inline int namecompare(int len, int maxlen,
*
* On Success unmap_and_put_page() should be called on *res_page.
*
- * sysv_find_entry() acts as a call to dir_get_page() and must be treated
+ * sysv_find_entry() acts as a call to dir_get_folio() and must be treated
* accordingly for nesting purposes.
*/
struct sysv_dir_entry *sysv_find_entry(struct dentry *dentry, struct page **res_page)
@@ -143,7 +144,7 @@ struct sysv_dir_entry *sysv_find_entry(struct dentry *dentry, struct page **res_
struct inode * dir = d_inode(dentry->d_parent);
unsigned long start, n;
unsigned long npages = dir_pages(dir);
- struct page *page = NULL;
+ struct folio *folio = NULL;
struct sysv_dir_entry *de;
*res_page = NULL;
@@ -154,7 +155,7 @@ struct sysv_dir_entry *sysv_find_entry(struct dentry *dentry, struct page **res_
n = start;
do {
- char *kaddr = dir_get_page(dir, n, &page);
+ char *kaddr = dir_get_folio(dir, n, &folio);
if (!IS_ERR(kaddr)) {
de = (struct sysv_dir_entry *)kaddr;
@@ -166,7 +167,7 @@ struct sysv_dir_entry *sysv_find_entry(struct dentry *dentry, struct page **res_
name, de->name))
goto found;
}
- unmap_and_put_page(page, kaddr);
+ folio_release_kmap(folio, kaddr);
}
if (++n >= npages)
@@ -177,7 +178,7 @@ struct sysv_dir_entry *sysv_find_entry(struct dentry *dentry, struct page **res_
found:
SYSV_I(dir)->i_dir_start_lookup = n;
- *res_page = page;
+ *res_page = &folio->page;
return de;
}
@@ -186,7 +187,7 @@ int sysv_add_link(struct dentry *dentry, struct inode *inode)
struct inode *dir = d_inode(dentry->d_parent);
const char * name = dentry->d_name.name;
int namelen = dentry->d_name.len;
- struct page *page = NULL;
+ struct folio *folio = NULL;
struct sysv_dir_entry * de;
unsigned long npages = dir_pages(dir);
unsigned long n;
@@ -196,7 +197,7 @@ int sysv_add_link(struct dentry *dentry, struct inode *inode)
/* We take care of directory expansion in the same loop */
for (n = 0; n <= npages; n++) {
- kaddr = dir_get_page(dir, n, &page);
+ kaddr = dir_get_folio(dir, n, &folio);
if (IS_ERR(kaddr))
return PTR_ERR(kaddr);
de = (struct sysv_dir_entry *)kaddr;
@@ -206,33 +207,33 @@ int sysv_add_link(struct dentry *dentry, struct inode *inode)
goto got_it;
err = -EEXIST;
if (namecompare(namelen, SYSV_NAMELEN, name, de->name))
- goto out_page;
+ goto out_folio;
de++;
}
- unmap_and_put_page(page, kaddr);
+ folio_release_kmap(folio, kaddr);
}
BUG();
return -EINVAL;
got_it:
- pos = page_offset(page) + offset_in_page(de);
- lock_page(page);
- err = sysv_prepare_chunk(page, pos, SYSV_DIRSIZE);
+ pos = folio_pos(folio) + offset_in_folio(folio, de);
+ folio_lock(folio);
+ err = sysv_prepare_chunk(&folio->page, pos, SYSV_DIRSIZE);
if (err)
goto out_unlock;
memcpy (de->name, name, namelen);
memset (de->name + namelen, 0, SYSV_DIRSIZE - namelen - 2);
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);
err = sysv_handle_dirsync(dir);
-out_page:
- unmap_and_put_page(page, kaddr);
+out_folio:
+ folio_release_kmap(folio, kaddr);
return err;
out_unlock:
- unlock_page(page);
- goto out_page;
+ folio_unlock(folio);
+ goto out_folio;
}
int sysv_delete_entry(struct sysv_dir_entry *de, struct page *page)
@@ -292,19 +293,19 @@ int sysv_make_empty(struct inode *inode, struct inode *dir)
int sysv_empty_dir(struct inode * inode)
{
struct super_block *sb = inode->i_sb;
- struct page *page = NULL;
+ struct folio *folio = NULL;
unsigned long i, npages = dir_pages(inode);
char *kaddr;
for (i = 0; i < npages; i++) {
struct sysv_dir_entry *de;
- kaddr = dir_get_page(inode, i, &page);
+ kaddr = dir_get_folio(inode, i, &folio);
if (IS_ERR(kaddr))
continue;
de = (struct sysv_dir_entry *)kaddr;
- kaddr += PAGE_SIZE-SYSV_DIRSIZE;
+ kaddr += folio_size(folio) - SYSV_DIRSIZE;
for ( ;(char *)de <= kaddr; de++) {
if (!de->inode)
@@ -321,12 +322,12 @@ int sysv_empty_dir(struct inode * inode)
if (de->name[1] != '.' || de->name[2])
goto not_empty;
}
- unmap_and_put_page(page, kaddr);
+ folio_release_kmap(folio, kaddr);
}
return 1;
not_empty:
- unmap_and_put_page(page, kaddr);
+ folio_release_kmap(folio, kaddr);
return 0;
}
@@ -352,18 +353,21 @@ int sysv_set_link(struct sysv_dir_entry *de, struct page *page,
}
/*
- * Calls to dir_get_page()/unmap_and_put_page() must be nested according to the
+ * Calls to dir_get_folio()/folio_release_kmap() must be nested according to the
* rules documented in mm/highmem.rst.
*
- * sysv_dotdot() acts as a call to dir_get_page() and must be treated
+ * 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 *de = dir_get_page(dir, 0, p);
+ struct folio *folio;
+
+ struct sysv_dir_entry *de = dir_get_folio(dir, 0, &folio);
if (IS_ERR(de))
return NULL;
+ *p = &folio->page;
/* ".." is the second directory entry */
return de + 1;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/7] sysv: Convert sysv_find_entry() to take a folio
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 ` Matthew Wilcox (Oracle)
2024-07-09 15:03 ` [PATCH 3/7] sysv: Convert sysv_set_link() and sysv_dotdot() " Matthew Wilcox (Oracle)
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-07-09 15:03 UTC (permalink / raw)
To: linux-fsdevel; +Cc: Matthew Wilcox (Oracle), Al Viro, Christoph Hellwig
Remove a few hidden calls to compound_head().
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
fs/sysv/dir.c | 25 ++++++++++---------------
fs/sysv/namei.c | 24 ++++++++++++------------
fs/sysv/sysv.h | 16 ++++++++--------
3 files changed, 30 insertions(+), 35 deletions(-)
diff --git a/fs/sysv/dir.c b/fs/sysv/dir.c
index 1f95f82f8941..5b2e3c7c2971 100644
--- a/fs/sysv/dir.c
+++ b/fs/sysv/dir.c
@@ -127,39 +127,35 @@ static inline int namecompare(int len, int maxlen,
/*
* sysv_find_entry()
*
- * finds an entry in the specified directory with the wanted name. It
- * returns the cache buffer in which the entry was found, and the entry
- * itself (as a parameter - res_dir). It does NOT read the inode of the
+ * finds an entry in the specified directory with the wanted name.
+ * It does NOT read the inode of the
* entry - you'll have to do that yourself if you want to.
*
- * On Success unmap_and_put_page() should be called on *res_page.
+ * On Success folio_release_kmap() should be called on *foliop.
*
* sysv_find_entry() acts as a call to dir_get_folio() and must be treated
* accordingly for nesting purposes.
*/
-struct sysv_dir_entry *sysv_find_entry(struct dentry *dentry, struct page **res_page)
+struct sysv_dir_entry *sysv_find_entry(struct dentry *dentry, struct folio **foliop)
{
const char * name = dentry->d_name.name;
int namelen = dentry->d_name.len;
struct inode * dir = d_inode(dentry->d_parent);
unsigned long start, n;
unsigned long npages = dir_pages(dir);
- struct folio *folio = NULL;
struct sysv_dir_entry *de;
- *res_page = NULL;
-
start = SYSV_I(dir)->i_dir_start_lookup;
if (start >= npages)
start = 0;
n = start;
do {
- char *kaddr = dir_get_folio(dir, n, &folio);
+ char *kaddr = dir_get_folio(dir, n, foliop);
if (!IS_ERR(kaddr)) {
de = (struct sysv_dir_entry *)kaddr;
- kaddr += PAGE_SIZE - SYSV_DIRSIZE;
+ kaddr += folio_size(*foliop) - SYSV_DIRSIZE;
for ( ; (char *) de <= kaddr ; de++) {
if (!de->inode)
continue;
@@ -167,7 +163,7 @@ struct sysv_dir_entry *sysv_find_entry(struct dentry *dentry, struct page **res_
name, de->name))
goto found;
}
- folio_release_kmap(folio, kaddr);
+ folio_release_kmap(*foliop, kaddr);
}
if (++n >= npages)
@@ -178,7 +174,6 @@ struct sysv_dir_entry *sysv_find_entry(struct dentry *dentry, struct page **res_
found:
SYSV_I(dir)->i_dir_start_lookup = n;
- *res_page = &folio->page;
return de;
}
@@ -374,13 +369,13 @@ struct sysv_dir_entry *sysv_dotdot(struct inode *dir, struct page **p)
ino_t sysv_inode_by_name(struct dentry *dentry)
{
- struct page *page;
- struct sysv_dir_entry *de = sysv_find_entry (dentry, &page);
+ struct folio *folio;
+ struct sysv_dir_entry *de = sysv_find_entry (dentry, &folio);
ino_t res = 0;
if (de) {
res = fs16_to_cpu(SYSV_SB(dentry->d_sb), de->inode);
- unmap_and_put_page(page, de);
+ folio_release_kmap(folio, de);
}
return res;
}
diff --git a/fs/sysv/namei.c b/fs/sysv/namei.c
index d6b73798071b..970043fe49ee 100644
--- a/fs/sysv/namei.c
+++ b/fs/sysv/namei.c
@@ -151,20 +151,20 @@ static int sysv_mkdir(struct mnt_idmap *idmap, struct inode *dir,
static int sysv_unlink(struct inode * dir, struct dentry * dentry)
{
struct inode * inode = d_inode(dentry);
- struct page * page;
+ struct folio *folio;
struct sysv_dir_entry * de;
int err;
- de = sysv_find_entry(dentry, &page);
+ de = sysv_find_entry(dentry, &folio);
if (!de)
return -ENOENT;
- err = sysv_delete_entry(de, page);
+ err = sysv_delete_entry(de, &folio->page);
if (!err) {
inode_set_ctime_to_ts(inode, inode_get_ctime(dir));
inode_dec_link_count(inode);
}
- unmap_and_put_page(page, de);
+ folio_release_kmap(folio, de);
return err;
}
@@ -196,14 +196,14 @@ static int sysv_rename(struct mnt_idmap *idmap, struct inode *old_dir,
struct inode * new_inode = d_inode(new_dentry);
struct page * dir_page = NULL;
struct sysv_dir_entry * dir_de = NULL;
- struct page * old_page;
+ struct folio *old_folio;
struct sysv_dir_entry * old_de;
int err = -ENOENT;
if (flags & ~RENAME_NOREPLACE)
return -EINVAL;
- old_de = sysv_find_entry(old_dentry, &old_page);
+ old_de = sysv_find_entry(old_dentry, &old_folio);
if (!old_de)
goto out;
@@ -215,7 +215,7 @@ static int sysv_rename(struct mnt_idmap *idmap, struct inode *old_dir,
}
if (new_inode) {
- struct page * new_page;
+ struct folio *new_folio;
struct sysv_dir_entry * new_de;
err = -ENOTEMPTY;
@@ -223,11 +223,11 @@ static int sysv_rename(struct mnt_idmap *idmap, struct inode *old_dir,
goto out_dir;
err = -ENOENT;
- new_de = sysv_find_entry(new_dentry, &new_page);
+ new_de = sysv_find_entry(new_dentry, &new_folio);
if (!new_de)
goto out_dir;
- err = sysv_set_link(new_de, new_page, old_inode);
- unmap_and_put_page(new_page, new_de);
+ err = sysv_set_link(new_de, &new_folio->page, old_inode);
+ folio_release_kmap(new_folio, new_de);
if (err)
goto out_dir;
inode_set_ctime_current(new_inode);
@@ -242,7 +242,7 @@ static int sysv_rename(struct mnt_idmap *idmap, struct inode *old_dir,
inode_inc_link_count(new_dir);
}
- err = sysv_delete_entry(old_de, old_page);
+ err = sysv_delete_entry(old_de, &old_folio->page);
if (err)
goto out_dir;
@@ -258,7 +258,7 @@ static int sysv_rename(struct mnt_idmap *idmap, struct inode *old_dir,
if (dir_de)
unmap_and_put_page(dir_page, dir_de);
out_old:
- unmap_and_put_page(old_page, old_de);
+ folio_release_kmap(old_folio, old_de);
out:
return err;
}
diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
index e3f988b469ee..be15c659a027 100644
--- a/fs/sysv/sysv.h
+++ b/fs/sysv/sysv.h
@@ -148,15 +148,15 @@ extern void sysv_destroy_icache(void);
/* dir.c */
-extern struct sysv_dir_entry *sysv_find_entry(struct dentry *, struct page **);
-extern int sysv_add_link(struct dentry *, struct inode *);
-extern int sysv_delete_entry(struct sysv_dir_entry *, struct page *);
-extern int sysv_make_empty(struct inode *, struct inode *);
-extern int sysv_empty_dir(struct inode *);
-extern int sysv_set_link(struct sysv_dir_entry *, struct page *,
+struct sysv_dir_entry *sysv_find_entry(struct dentry *, struct folio **);
+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 *,
struct inode *);
-extern struct sysv_dir_entry *sysv_dotdot(struct inode *, struct page **);
-extern ino_t sysv_inode_by_name(struct dentry *);
+struct sysv_dir_entry *sysv_dotdot(struct inode *, struct page **);
+ino_t sysv_inode_by_name(struct dentry *);
extern const struct inode_operations sysv_file_inode_operations;
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 3/7] sysv: Convert sysv_set_link() and sysv_dotdot() to take a folio
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)
2024-07-09 15:03 ` [PATCH 4/7] sysv: Convert sysv_delete_entry() to work on " Matthew Wilcox (Oracle)
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-07-09 15:03 UTC (permalink / raw)
To: linux-fsdevel; +Cc: Matthew Wilcox (Oracle), Al Viro, Christoph Hellwig
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
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 4/7] sysv: Convert sysv_delete_entry() to work on a folio
2024-07-09 15:03 [PATCH 0/7] Convert sysv directory handling to folios Matthew Wilcox (Oracle)
` (2 preceding siblings ...)
2024-07-09 15:03 ` [PATCH 3/7] sysv: Convert sysv_set_link() and sysv_dotdot() " Matthew Wilcox (Oracle)
@ 2024-07-09 15:03 ` Matthew Wilcox (Oracle)
2024-07-09 15:03 ` [PATCH 5/7] sysv: Convert sysv_make_empty() to use " Matthew Wilcox (Oracle)
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-07-09 15:03 UTC (permalink / raw)
To: linux-fsdevel; +Cc: Matthew Wilcox (Oracle), Al Viro, Christoph Hellwig
Match ext2 and remove a few hidden calls to compound_head().
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
fs/sysv/dir.c | 14 +++++++-------
fs/sysv/namei.c | 4 ++--
fs/sysv/sysv.h | 2 +-
3 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/fs/sysv/dir.c b/fs/sysv/dir.c
index ebccf7bb5b69..0b5727510bdd 100644
--- a/fs/sysv/dir.c
+++ b/fs/sysv/dir.c
@@ -231,20 +231,20 @@ int sysv_add_link(struct dentry *dentry, struct inode *inode)
goto out_folio;
}
-int sysv_delete_entry(struct sysv_dir_entry *de, struct page *page)
+int sysv_delete_entry(struct sysv_dir_entry *de, struct folio *folio)
{
- struct inode *inode = page->mapping->host;
- loff_t pos = page_offset(page) + offset_in_page(de);
+ struct inode *inode = 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 = 0;
- dir_commit_chunk(page, pos, SYSV_DIRSIZE);
+ dir_commit_chunk(&folio->page, pos, SYSV_DIRSIZE);
inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
mark_inode_dirty(inode);
return sysv_handle_dirsync(inode);
diff --git a/fs/sysv/namei.c b/fs/sysv/namei.c
index ef4d91431225..fb8bd8437872 100644
--- a/fs/sysv/namei.c
+++ b/fs/sysv/namei.c
@@ -159,7 +159,7 @@ static int sysv_unlink(struct inode * dir, struct dentry * dentry)
if (!de)
return -ENOENT;
- err = sysv_delete_entry(de, &folio->page);
+ err = sysv_delete_entry(de, folio);
if (!err) {
inode_set_ctime_to_ts(inode, inode_get_ctime(dir));
inode_dec_link_count(inode);
@@ -242,7 +242,7 @@ static int sysv_rename(struct mnt_idmap *idmap, struct inode *old_dir,
inode_inc_link_count(new_dir);
}
- err = sysv_delete_entry(old_de, &old_folio->page);
+ err = sysv_delete_entry(old_de, old_folio);
if (err)
goto out_dir;
diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
index ee90af7dbed9..fec9f6b883d5 100644
--- a/fs/sysv/sysv.h
+++ b/fs/sysv/sysv.h
@@ -150,7 +150,7 @@ extern void sysv_destroy_icache(void);
/* dir.c */
struct sysv_dir_entry *sysv_find_entry(struct dentry *, struct folio **);
int sysv_add_link(struct dentry *, struct inode *);
-int sysv_delete_entry(struct sysv_dir_entry *, struct page *);
+int sysv_delete_entry(struct sysv_dir_entry *, struct folio *);
int sysv_make_empty(struct inode *, struct inode *);
int sysv_empty_dir(struct inode *);
int sysv_set_link(struct sysv_dir_entry *, struct folio *,
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 5/7] sysv: Convert sysv_make_empty() to use a folio
2024-07-09 15:03 [PATCH 0/7] Convert sysv directory handling to folios Matthew Wilcox (Oracle)
` (3 preceding siblings ...)
2024-07-09 15:03 ` [PATCH 4/7] sysv: Convert sysv_delete_entry() to work on " Matthew Wilcox (Oracle)
@ 2024-07-09 15:03 ` Matthew Wilcox (Oracle)
2024-07-09 15:03 ` [PATCH 6/7] sysv: Convert sysv_prepare_chunk() to take " Matthew Wilcox (Oracle)
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-07-09 15:03 UTC (permalink / raw)
To: linux-fsdevel; +Cc: Matthew Wilcox (Oracle), Al Viro, Christoph Hellwig
Removes a few hidden calls to compound_head().
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
fs/sysv/dir.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/fs/sysv/dir.c b/fs/sysv/dir.c
index 0b5727510bdd..5f91a82a2966 100644
--- a/fs/sysv/dir.c
+++ b/fs/sysv/dir.c
@@ -252,33 +252,33 @@ int sysv_delete_entry(struct sysv_dir_entry *de, struct folio *folio)
int sysv_make_empty(struct inode *inode, struct inode *dir)
{
- struct page *page = grab_cache_page(inode->i_mapping, 0);
+ struct folio *folio = filemap_grab_folio(inode->i_mapping, 0);
struct sysv_dir_entry * de;
- char *base;
+ char *kaddr;
int err;
- if (!page)
- return -ENOMEM;
- err = sysv_prepare_chunk(page, 0, 2 * SYSV_DIRSIZE);
+ if (IS_ERR(folio))
+ return PTR_ERR(folio);
+ err = sysv_prepare_chunk(&folio->page, 0, 2 * SYSV_DIRSIZE);
if (err) {
- unlock_page(page);
+ folio_unlock(folio);
goto fail;
}
- base = kmap_local_page(page);
- memset(base, 0, PAGE_SIZE);
+ kaddr = kmap_local_folio(folio, 0);
+ memset(kaddr, 0, folio_size(folio));
- de = (struct sysv_dir_entry *) base;
+ de = (struct sysv_dir_entry *)kaddr;
de->inode = cpu_to_fs16(SYSV_SB(inode->i_sb), inode->i_ino);
strcpy(de->name,".");
de++;
de->inode = cpu_to_fs16(SYSV_SB(inode->i_sb), dir->i_ino);
strcpy(de->name,"..");
- kunmap_local(base);
- dir_commit_chunk(page, 0, 2 * SYSV_DIRSIZE);
+ kunmap_local(kaddr);
+ dir_commit_chunk(&folio->page, 0, 2 * SYSV_DIRSIZE);
err = sysv_handle_dirsync(inode);
fail:
- put_page(page);
+ folio_put(folio);
return err;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 6/7] sysv: Convert sysv_prepare_chunk() to take a folio
2024-07-09 15:03 [PATCH 0/7] Convert sysv directory handling to folios Matthew Wilcox (Oracle)
` (4 preceding siblings ...)
2024-07-09 15:03 ` [PATCH 5/7] sysv: Convert sysv_make_empty() to use " Matthew Wilcox (Oracle)
@ 2024-07-09 15:03 ` 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
7 siblings, 0 replies; 9+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-07-09 15:03 UTC (permalink / raw)
To: linux-fsdevel; +Cc: Matthew Wilcox (Oracle), Al Viro, Christoph Hellwig
All callers now have a folio, so convert ufs_prepare_chunk() to take one.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
fs/sysv/dir.c | 8 ++++----
fs/sysv/itree.c | 4 ++--
fs/sysv/sysv.h | 4 ++--
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/fs/sysv/dir.c b/fs/sysv/dir.c
index 5f91a82a2966..43615b803fee 100644
--- a/fs/sysv/dir.c
+++ b/fs/sysv/dir.c
@@ -213,7 +213,7 @@ int sysv_add_link(struct dentry *dentry, struct inode *inode)
got_it:
pos = folio_pos(folio) + offset_in_folio(folio, de);
folio_lock(folio);
- err = sysv_prepare_chunk(&folio->page, pos, SYSV_DIRSIZE);
+ err = sysv_prepare_chunk(folio, pos, SYSV_DIRSIZE);
if (err)
goto out_unlock;
memcpy (de->name, name, namelen);
@@ -238,7 +238,7 @@ int sysv_delete_entry(struct sysv_dir_entry *de, struct folio *folio)
int err;
folio_lock(folio);
- err = sysv_prepare_chunk(&folio->page, pos, SYSV_DIRSIZE);
+ err = sysv_prepare_chunk(folio, pos, SYSV_DIRSIZE);
if (err) {
folio_unlock(folio);
return err;
@@ -259,7 +259,7 @@ int sysv_make_empty(struct inode *inode, struct inode *dir)
if (IS_ERR(folio))
return PTR_ERR(folio);
- err = sysv_prepare_chunk(&folio->page, 0, 2 * SYSV_DIRSIZE);
+ err = sysv_prepare_chunk(folio, 0, 2 * SYSV_DIRSIZE);
if (err) {
folio_unlock(folio);
goto fail;
@@ -335,7 +335,7 @@ int sysv_set_link(struct sysv_dir_entry *de, struct folio *folio,
int err;
folio_lock(folio);
- err = sysv_prepare_chunk(&folio->page, pos, SYSV_DIRSIZE);
+ err = sysv_prepare_chunk(folio, pos, SYSV_DIRSIZE);
if (err) {
folio_unlock(folio);
return err;
diff --git a/fs/sysv/itree.c b/fs/sysv/itree.c
index 19bcb51a2203..c8511e286673 100644
--- a/fs/sysv/itree.c
+++ b/fs/sysv/itree.c
@@ -466,9 +466,9 @@ static int sysv_read_folio(struct file *file, struct folio *folio)
return block_read_full_folio(folio, get_block);
}
-int sysv_prepare_chunk(struct page *page, loff_t pos, unsigned len)
+int sysv_prepare_chunk(struct folio *folio, loff_t pos, unsigned len)
{
- return __block_write_begin(page, pos, len, get_block);
+ return __block_write_begin(&folio->page, pos, len, get_block);
}
static void sysv_write_failed(struct address_space *mapping, loff_t to)
diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
index fec9f6b883d5..0a48b2e7edb1 100644
--- a/fs/sysv/sysv.h
+++ b/fs/sysv/sysv.h
@@ -133,8 +133,8 @@ extern void sysv_free_block(struct super_block *, sysv_zone_t);
extern unsigned long sysv_count_free_blocks(struct super_block *);
/* itree.c */
-extern void sysv_truncate(struct inode *);
-extern int sysv_prepare_chunk(struct page *page, loff_t pos, unsigned len);
+void sysv_truncate(struct inode *);
+int sysv_prepare_chunk(struct folio *folio, loff_t pos, unsigned len);
/* inode.c */
extern struct inode *sysv_iget(struct super_block *, unsigned int);
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 7/7] sysv: Convert dir_commit_chunk() to take a folio
2024-07-09 15:03 [PATCH 0/7] Convert sysv directory handling to folios Matthew Wilcox (Oracle)
` (5 preceding siblings ...)
2024-07-09 15:03 ` [PATCH 6/7] sysv: Convert sysv_prepare_chunk() to take " Matthew Wilcox (Oracle)
@ 2024-07-09 15:03 ` Matthew Wilcox (Oracle)
2024-07-16 8:17 ` [PATCH 0/7] Convert sysv directory handling to folios Christian Brauner
7 siblings, 0 replies; 9+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-07-09 15:03 UTC (permalink / raw)
To: linux-fsdevel; +Cc: Matthew Wilcox (Oracle), Al Viro, Christoph Hellwig
All callers now have a folio, so pass it in. Saves a call to
compound_head().
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
fs/sysv/dir.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/fs/sysv/dir.c b/fs/sysv/dir.c
index 43615b803fee..27eaa5273ba7 100644
--- a/fs/sysv/dir.c
+++ b/fs/sysv/dir.c
@@ -28,17 +28,17 @@ const struct file_operations sysv_dir_operations = {
.fsync = generic_file_fsync,
};
-static void dir_commit_chunk(struct page *page, loff_t pos, unsigned len)
+static void dir_commit_chunk(struct folio *folio, loff_t pos, unsigned len)
{
- struct address_space *mapping = page->mapping;
+ struct address_space *mapping = folio->mapping;
struct inode *dir = mapping->host;
- block_write_end(NULL, mapping, pos, len, len, page, NULL);
+ block_write_end(NULL, mapping, pos, len, len, &folio->page, NULL);
if (pos+len > dir->i_size) {
i_size_write(dir, pos+len);
mark_inode_dirty(dir);
}
- unlock_page(page);
+ folio_unlock(folio);
}
static int sysv_handle_dirsync(struct inode *dir)
@@ -219,7 +219,7 @@ int sysv_add_link(struct dentry *dentry, struct inode *inode)
memcpy (de->name, name, namelen);
memset (de->name + namelen, 0, SYSV_DIRSIZE - namelen - 2);
de->inode = cpu_to_fs16(SYSV_SB(inode->i_sb), inode->i_ino);
- dir_commit_chunk(&folio->page, pos, SYSV_DIRSIZE);
+ dir_commit_chunk(folio, pos, SYSV_DIRSIZE);
inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir));
mark_inode_dirty(dir);
err = sysv_handle_dirsync(dir);
@@ -244,7 +244,7 @@ int sysv_delete_entry(struct sysv_dir_entry *de, struct folio *folio)
return err;
}
de->inode = 0;
- dir_commit_chunk(&folio->page, pos, SYSV_DIRSIZE);
+ dir_commit_chunk(folio, pos, SYSV_DIRSIZE);
inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
mark_inode_dirty(inode);
return sysv_handle_dirsync(inode);
@@ -275,7 +275,7 @@ int sysv_make_empty(struct inode *inode, struct inode *dir)
strcpy(de->name,"..");
kunmap_local(kaddr);
- dir_commit_chunk(&folio->page, 0, 2 * SYSV_DIRSIZE);
+ dir_commit_chunk(folio, 0, 2 * SYSV_DIRSIZE);
err = sysv_handle_dirsync(inode);
fail:
folio_put(folio);
@@ -341,7 +341,7 @@ int sysv_set_link(struct sysv_dir_entry *de, struct folio *folio,
return err;
}
de->inode = cpu_to_fs16(SYSV_SB(inode->i_sb), inode->i_ino);
- dir_commit_chunk(&folio->page, pos, SYSV_DIRSIZE);
+ dir_commit_chunk(folio, pos, SYSV_DIRSIZE);
inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir));
mark_inode_dirty(dir);
return sysv_handle_dirsync(inode);
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 0/7] Convert sysv directory handling to folios
2024-07-09 15:03 [PATCH 0/7] Convert sysv directory handling to folios Matthew Wilcox (Oracle)
` (6 preceding siblings ...)
2024-07-09 15:03 ` [PATCH 7/7] sysv: Convert dir_commit_chunk() " Matthew Wilcox (Oracle)
@ 2024-07-16 8:17 ` Christian Brauner
7 siblings, 0 replies; 9+ messages in thread
From: Christian Brauner @ 2024-07-16 8:17 UTC (permalink / raw)
To: linux-fsdevel, Matthew Wilcox (Oracle)
Cc: Christian Brauner, Al Viro, Christoph Hellwig
On Tue, 09 Jul 2024 16:03:05 +0100, Matthew Wilcox (Oracle) wrote:
> This patch series mirrors the changes to ext2 directory handling.
> It's a bit simpler than the UFS one from yesterday as sysv was already
> converted to kmap_local. Again, compile tested only.
>
> Matthew Wilcox (Oracle) (7):
> sysv: Convert dir_get_page() to dir_get_folio()
> sysv: Convert sysv_find_entry() to take a folio
> sysv: Convert sysv_set_link() and sysv_dotdot() to take a folio
> sysv: Convert sysv_delete_entry() to work on a folio
> sysv: Convert sysv_make_empty() to use a folio
> sysv: Convert sysv_prepare_chunk() to take a folio
> sysv: Convert dir_commit_chunk() to take a folio
>
> [...]
Applied to the vfs.sysv branch of the vfs/vfs.git tree.
Patches in the vfs.sysv branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs.sysv
[1/7] sysv: Convert dir_get_page() to dir_get_folio()
https://git.kernel.org/vfs/vfs/c/b4e73a41d327
[2/7] sysv: Convert sysv_find_entry() to take a folio
https://git.kernel.org/vfs/vfs/c/1f1099c58539
[3/7] sysv: Convert sysv_set_link() and sysv_dotdot() to take a folio
https://git.kernel.org/vfs/vfs/c/14ee02c67a40
[4/7] sysv: Convert sysv_delete_entry() to work on a folio
https://git.kernel.org/vfs/vfs/c/8e71393b2017
[5/7] sysv: Convert sysv_make_empty() to use a folio
https://git.kernel.org/vfs/vfs/c/ff6dcbb30cc1
[6/7] sysv: Convert sysv_prepare_chunk() to take a folio
https://git.kernel.org/vfs/vfs/c/aedfd2c0a3cf
[7/7] sysv: Convert dir_commit_chunk() to take a folio
https://git.kernel.org/vfs/vfs/c/6adec8dae1bc
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2024-07-16 8:17 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH 3/7] sysv: Convert sysv_set_link() and sysv_dotdot() " Matthew Wilcox (Oracle)
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
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).