* [PATCH 00/20] nilfs2: Folio conversions for file paths
@ 2023-11-14 8:44 Ryusuke Konishi
2023-11-14 8:44 ` [PATCH 01/20] nilfs2: Add nilfs_end_folio_io() Ryusuke Konishi
` (19 more replies)
0 siblings, 20 replies; 21+ messages in thread
From: Ryusuke Konishi @ 2023-11-14 8:44 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-nilfs, Matthew Wilcox, linux-kernel
Hi Andrew, please queue this series for the next merge window.
This series advances page->folio conversions for a wide range of
nilfs2, including its file operations, block routines, and the log
writer's writeback routines. It doesn't cover large folios support,
but it saves a lot of hidden compound_head() calls while preserving
the existing support range behavior.
The original series in post [1] also covered directory-related
page->folio conversions, but that was put on hold because a regression
was found in testing, so this is an excerpt from the first half of the
original post.
[1] https://lkml.kernel.org/r/20231106173903.1734114-1-willy@infradead.org
I tested this series in both 32-bit and 64-bit environments, switching
between normal and small block sizes. I also reviewed all changes in
all patches to ensure they do not break existing behavior.
There were no problems, so I'm sending this part first because I would
like you to keep it in the -mm tree at an early stage.
Thanks,
Ryusuke Konishi
Matthew Wilcox (Oracle) (20):
nilfs2: Add nilfs_end_folio_io()
nilfs2: Convert nilfs_abort_logs to use folios
nilfs2: Convert nilfs_segctor_complete_write to use folios
nilfs2: Convert nilfs_forget_buffer to use a folio
nilfs2: Convert to nilfs_folio_buffers_clean()
nilfs2: Convert nilfs_writepage() to use a folio
nilfs2: Convert nilfs_mdt_write_page() to use a folio
nilfs2: Convert to nilfs_clear_folio_dirty()
nilfs2: Convert to __nilfs_clear_folio_dirty()
nilfs2: Convert nilfs_segctor_prepare_write to use folios
nilfs2: Convert nilfs_page_mkwrite() to use a folio
nilfs2: Convert nilfs_mdt_create_block to use a folio
nilfs2: Convert nilfs_mdt_submit_block to use a folio
nilfs2: Convert nilfs_gccache_submit_read_data to use a folio
nilfs2: Convert nilfs_btnode_create_block to use a folio
nilfs2: Convert nilfs_btnode_submit_block to use a folio
nilfs2: Convert nilfs_btnode_delete to use a folio
nilfs2: Convert nilfs_btnode_prepare_change_key to use a folio
nilfs2: Convert nilfs_btnode_commit_change_key to use a folio
nilfs2: Convert nilfs_btnode_abort_change_key to use a folio
fs/nilfs2/btnode.c | 62 ++++++++---------
fs/nilfs2/file.c | 28 ++++----
fs/nilfs2/gcinode.c | 4 +-
fs/nilfs2/inode.c | 11 ++--
fs/nilfs2/mdt.c | 23 +++----
fs/nilfs2/page.c | 68 +++++++++----------
fs/nilfs2/page.h | 6 +-
fs/nilfs2/segment.c | 157 ++++++++++++++++++++++----------------------
8 files changed, 183 insertions(+), 176 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 01/20] nilfs2: Add nilfs_end_folio_io()
2023-11-14 8:44 [PATCH 00/20] nilfs2: Folio conversions for file paths Ryusuke Konishi
@ 2023-11-14 8:44 ` Ryusuke Konishi
2023-11-14 8:44 ` [PATCH 02/20] nilfs2: Convert nilfs_abort_logs to use folios Ryusuke Konishi
` (18 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Ryusuke Konishi @ 2023-11-14 8:44 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-nilfs, Matthew Wilcox, linux-kernel
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
This is the folio counterpart of the existing nilfs_end_page_io()
which is retained as a wrapper of nilfs_end_folio_io(). Replaces
nine hidden calls to compound_head() with one.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
---
fs/nilfs2/segment.c | 36 ++++++++++++++++++++++--------------
1 file changed, 22 insertions(+), 14 deletions(-)
diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c
index 55e31cc903d1..1df03d0895be 100644
--- a/fs/nilfs2/segment.c
+++ b/fs/nilfs2/segment.c
@@ -1739,17 +1739,18 @@ static int nilfs_segctor_write(struct nilfs_sc_info *sci,
return ret;
}
-static void nilfs_end_page_io(struct page *page, int err)
+static void nilfs_end_folio_io(struct folio *folio, int err)
{
- if (!page)
+ if (!folio)
return;
- if (buffer_nilfs_node(page_buffers(page)) && !PageWriteback(page)) {
+ if (buffer_nilfs_node(folio_buffers(folio)) &&
+ !folio_test_writeback(folio)) {
/*
* For b-tree node pages, this function may be called twice
* or more because they might be split in a segment.
*/
- if (PageDirty(page)) {
+ if (folio_test_dirty(folio)) {
/*
* For pages holding split b-tree node buffers, dirty
* flag on the buffers may be cleared discretely.
@@ -1757,24 +1758,31 @@ static void nilfs_end_page_io(struct page *page, int err)
* remaining buffers, and it must be cancelled if
* all the buffers get cleaned later.
*/
- lock_page(page);
- if (nilfs_page_buffers_clean(page))
- __nilfs_clear_page_dirty(page);
- unlock_page(page);
+ folio_lock(folio);
+ if (nilfs_page_buffers_clean(&folio->page))
+ __nilfs_clear_page_dirty(&folio->page);
+ folio_unlock(folio);
}
return;
}
if (!err) {
- if (!nilfs_page_buffers_clean(page))
- __set_page_dirty_nobuffers(page);
- ClearPageError(page);
+ if (!nilfs_page_buffers_clean(&folio->page))
+ filemap_dirty_folio(folio->mapping, folio);
+ folio_clear_error(folio);
} else {
- __set_page_dirty_nobuffers(page);
- SetPageError(page);
+ filemap_dirty_folio(folio->mapping, folio);
+ folio_set_error(folio);
}
- end_page_writeback(page);
+ folio_end_writeback(folio);
+}
+
+static void nilfs_end_page_io(struct page *page, int err)
+{
+ if (!page)
+ return;
+ nilfs_end_folio_io(page_folio(page), err);
}
static void nilfs_abort_logs(struct list_head *logs, int err)
--
2.34.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 02/20] nilfs2: Convert nilfs_abort_logs to use folios
2023-11-14 8:44 [PATCH 00/20] nilfs2: Folio conversions for file paths Ryusuke Konishi
2023-11-14 8:44 ` [PATCH 01/20] nilfs2: Add nilfs_end_folio_io() Ryusuke Konishi
@ 2023-11-14 8:44 ` Ryusuke Konishi
2023-11-14 8:44 ` [PATCH 03/20] nilfs2: Convert nilfs_segctor_complete_write " Ryusuke Konishi
` (17 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Ryusuke Konishi @ 2023-11-14 8:44 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-nilfs, Matthew Wilcox, linux-kernel
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Use the new folio APIs, saving five hidden calls to compound_head().
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
---
fs/nilfs2/segment.c | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c
index 1df03d0895be..730062e79bfc 100644
--- a/fs/nilfs2/segment.c
+++ b/fs/nilfs2/segment.c
@@ -1788,7 +1788,7 @@ static void nilfs_end_page_io(struct page *page, int err)
static void nilfs_abort_logs(struct list_head *logs, int err)
{
struct nilfs_segment_buffer *segbuf;
- struct page *bd_page = NULL, *fs_page = NULL;
+ struct folio *bd_folio = NULL, *fs_folio = NULL;
struct buffer_head *bh;
if (list_empty(logs))
@@ -1798,10 +1798,10 @@ static void nilfs_abort_logs(struct list_head *logs, int err)
list_for_each_entry(bh, &segbuf->sb_segsum_buffers,
b_assoc_buffers) {
clear_buffer_uptodate(bh);
- if (bh->b_page != bd_page) {
- if (bd_page)
- end_page_writeback(bd_page);
- bd_page = bh->b_page;
+ if (bh->b_folio != bd_folio) {
+ if (bd_folio)
+ folio_end_writeback(bd_folio);
+ bd_folio = bh->b_folio;
}
}
@@ -1810,22 +1810,22 @@ static void nilfs_abort_logs(struct list_head *logs, int err)
clear_buffer_async_write(bh);
if (bh == segbuf->sb_super_root) {
clear_buffer_uptodate(bh);
- if (bh->b_page != bd_page) {
- end_page_writeback(bd_page);
- bd_page = bh->b_page;
+ if (bh->b_folio != bd_folio) {
+ folio_end_writeback(bd_folio);
+ bd_folio = bh->b_folio;
}
break;
}
- if (bh->b_page != fs_page) {
- nilfs_end_page_io(fs_page, err);
- fs_page = bh->b_page;
+ if (bh->b_folio != fs_folio) {
+ nilfs_end_folio_io(fs_folio, err);
+ fs_folio = bh->b_folio;
}
}
}
- if (bd_page)
- end_page_writeback(bd_page);
+ if (bd_folio)
+ folio_end_writeback(bd_folio);
- nilfs_end_page_io(fs_page, err);
+ nilfs_end_folio_io(fs_folio, err);
}
static void nilfs_segctor_abort_construction(struct nilfs_sc_info *sci,
--
2.34.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 03/20] nilfs2: Convert nilfs_segctor_complete_write to use folios
2023-11-14 8:44 [PATCH 00/20] nilfs2: Folio conversions for file paths Ryusuke Konishi
2023-11-14 8:44 ` [PATCH 01/20] nilfs2: Add nilfs_end_folio_io() Ryusuke Konishi
2023-11-14 8:44 ` [PATCH 02/20] nilfs2: Convert nilfs_abort_logs to use folios Ryusuke Konishi
@ 2023-11-14 8:44 ` Ryusuke Konishi
2023-11-14 8:44 ` [PATCH 04/20] nilfs2: Convert nilfs_forget_buffer to use a folio Ryusuke Konishi
` (16 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Ryusuke Konishi @ 2023-11-14 8:44 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-nilfs, Matthew Wilcox, linux-kernel
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Use the new folio APIs, saving five calls to compound_head().
This includes the last callers of nilfs_end_page_io(), so
remove that too.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
---
fs/nilfs2/segment.c | 49 +++++++++++++++++++--------------------------
1 file changed, 21 insertions(+), 28 deletions(-)
diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c
index 730062e79bfc..2a058aad5c2d 100644
--- a/fs/nilfs2/segment.c
+++ b/fs/nilfs2/segment.c
@@ -1778,13 +1778,6 @@ static void nilfs_end_folio_io(struct folio *folio, int err)
folio_end_writeback(folio);
}
-static void nilfs_end_page_io(struct page *page, int err)
-{
- if (!page)
- return;
- nilfs_end_folio_io(page_folio(page), err);
-}
-
static void nilfs_abort_logs(struct list_head *logs, int err)
{
struct nilfs_segment_buffer *segbuf;
@@ -1867,7 +1860,7 @@ static void nilfs_set_next_segment(struct the_nilfs *nilfs,
static void nilfs_segctor_complete_write(struct nilfs_sc_info *sci)
{
struct nilfs_segment_buffer *segbuf;
- struct page *bd_page = NULL, *fs_page = NULL;
+ struct folio *bd_folio = NULL, *fs_folio = NULL;
struct the_nilfs *nilfs = sci->sc_super->s_fs_info;
int update_sr = false;
@@ -1878,21 +1871,21 @@ static void nilfs_segctor_complete_write(struct nilfs_sc_info *sci)
b_assoc_buffers) {
set_buffer_uptodate(bh);
clear_buffer_dirty(bh);
- if (bh->b_page != bd_page) {
- if (bd_page)
- end_page_writeback(bd_page);
- bd_page = bh->b_page;
+ if (bh->b_folio != bd_folio) {
+ if (bd_folio)
+ folio_end_writeback(bd_folio);
+ bd_folio = bh->b_folio;
}
}
/*
- * We assume that the buffers which belong to the same page
+ * We assume that the buffers which belong to the same folio
* continue over the buffer list.
- * Under this assumption, the last BHs of pages is
- * identifiable by the discontinuity of bh->b_page
- * (page != fs_page).
+ * Under this assumption, the last BHs of folios is
+ * identifiable by the discontinuity of bh->b_folio
+ * (folio != fs_folio).
*
* For B-tree node blocks, however, this assumption is not
- * guaranteed. The cleanup code of B-tree node pages needs
+ * guaranteed. The cleanup code of B-tree node folios needs
* special care.
*/
list_for_each_entry(bh, &segbuf->sb_payload_buffers,
@@ -1905,16 +1898,16 @@ static void nilfs_segctor_complete_write(struct nilfs_sc_info *sci)
set_mask_bits(&bh->b_state, clear_bits, set_bits);
if (bh == segbuf->sb_super_root) {
- if (bh->b_page != bd_page) {
- end_page_writeback(bd_page);
- bd_page = bh->b_page;
+ if (bh->b_folio != bd_folio) {
+ folio_end_writeback(bd_folio);
+ bd_folio = bh->b_folio;
}
update_sr = true;
break;
}
- if (bh->b_page != fs_page) {
- nilfs_end_page_io(fs_page, 0);
- fs_page = bh->b_page;
+ if (bh->b_folio != fs_folio) {
+ nilfs_end_folio_io(fs_folio, 0);
+ fs_folio = bh->b_folio;
}
}
@@ -1928,13 +1921,13 @@ static void nilfs_segctor_complete_write(struct nilfs_sc_info *sci)
}
}
/*
- * Since pages may continue over multiple segment buffers,
- * end of the last page must be checked outside of the loop.
+ * Since folios may continue over multiple segment buffers,
+ * end of the last folio must be checked outside of the loop.
*/
- if (bd_page)
- end_page_writeback(bd_page);
+ if (bd_folio)
+ folio_end_writeback(bd_folio);
- nilfs_end_page_io(fs_page, 0);
+ nilfs_end_folio_io(fs_folio, 0);
nilfs_drop_collected_inodes(&sci->sc_dirty_files);
--
2.34.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 04/20] nilfs2: Convert nilfs_forget_buffer to use a folio
2023-11-14 8:44 [PATCH 00/20] nilfs2: Folio conversions for file paths Ryusuke Konishi
` (2 preceding siblings ...)
2023-11-14 8:44 ` [PATCH 03/20] nilfs2: Convert nilfs_segctor_complete_write " Ryusuke Konishi
@ 2023-11-14 8:44 ` Ryusuke Konishi
2023-11-14 8:44 ` [PATCH 05/20] nilfs2: Convert to nilfs_folio_buffers_clean() Ryusuke Konishi
` (15 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Ryusuke Konishi @ 2023-11-14 8:44 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-nilfs, Matthew Wilcox, linux-kernel
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Save two hidden calls to compound_head().
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
---
fs/nilfs2/page.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/fs/nilfs2/page.c b/fs/nilfs2/page.c
index 06b04758f289..3882acde1b3e 100644
--- a/fs/nilfs2/page.c
+++ b/fs/nilfs2/page.c
@@ -73,7 +73,7 @@ struct buffer_head *nilfs_grab_buffer(struct inode *inode,
*/
void nilfs_forget_buffer(struct buffer_head *bh)
{
- struct page *page = bh->b_page;
+ struct folio *folio = bh->b_folio;
const unsigned long clear_bits =
(BIT(BH_Uptodate) | BIT(BH_Dirty) | BIT(BH_Mapped) |
BIT(BH_Async_Write) | BIT(BH_NILFS_Volatile) |
@@ -81,12 +81,12 @@ void nilfs_forget_buffer(struct buffer_head *bh)
lock_buffer(bh);
set_mask_bits(&bh->b_state, clear_bits, 0);
- if (nilfs_page_buffers_clean(page))
- __nilfs_clear_page_dirty(page);
+ if (nilfs_page_buffers_clean(&folio->page))
+ __nilfs_clear_page_dirty(&folio->page);
bh->b_blocknr = -1;
- ClearPageUptodate(page);
- ClearPageMappedToDisk(page);
+ folio_clear_uptodate(folio);
+ folio_clear_mappedtodisk(folio);
unlock_buffer(bh);
brelse(bh);
}
--
2.34.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 05/20] nilfs2: Convert to nilfs_folio_buffers_clean()
2023-11-14 8:44 [PATCH 00/20] nilfs2: Folio conversions for file paths Ryusuke Konishi
` (3 preceding siblings ...)
2023-11-14 8:44 ` [PATCH 04/20] nilfs2: Convert nilfs_forget_buffer to use a folio Ryusuke Konishi
@ 2023-11-14 8:44 ` Ryusuke Konishi
2023-11-14 8:44 ` [PATCH 06/20] nilfs2: Convert nilfs_writepage() to use a folio Ryusuke Konishi
` (14 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Ryusuke Konishi @ 2023-11-14 8:44 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-nilfs, Matthew Wilcox, linux-kernel
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
All callers of nilfs_page_buffers_clean() now have a folio, so convert
it to take a folio. While I'm at it, make it return a bool.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
---
fs/nilfs2/page.c | 18 +++++++++---------
fs/nilfs2/page.h | 2 +-
fs/nilfs2/segment.c | 4 ++--
3 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/fs/nilfs2/page.c b/fs/nilfs2/page.c
index 3882acde1b3e..29799a49c234 100644
--- a/fs/nilfs2/page.c
+++ b/fs/nilfs2/page.c
@@ -81,7 +81,7 @@ void nilfs_forget_buffer(struct buffer_head *bh)
lock_buffer(bh);
set_mask_bits(&bh->b_state, clear_bits, 0);
- if (nilfs_page_buffers_clean(&folio->page))
+ if (nilfs_folio_buffers_clean(folio))
__nilfs_clear_page_dirty(&folio->page);
bh->b_blocknr = -1;
@@ -131,23 +131,23 @@ void nilfs_copy_buffer(struct buffer_head *dbh, struct buffer_head *sbh)
}
/**
- * nilfs_page_buffers_clean - check if a page has dirty buffers or not.
- * @page: page to be checked
+ * nilfs_folio_buffers_clean - Check if a folio has dirty buffers or not.
+ * @folio: Folio to be checked.
*
- * nilfs_page_buffers_clean() returns zero if the page has dirty buffers.
- * Otherwise, it returns non-zero value.
+ * nilfs_folio_buffers_clean() returns false if the folio has dirty buffers.
+ * Otherwise, it returns true.
*/
-int nilfs_page_buffers_clean(struct page *page)
+bool nilfs_folio_buffers_clean(struct folio *folio)
{
struct buffer_head *bh, *head;
- bh = head = page_buffers(page);
+ bh = head = folio_buffers(folio);
do {
if (buffer_dirty(bh))
- return 0;
+ return false;
bh = bh->b_this_page;
} while (bh != head);
- return 1;
+ return true;
}
void nilfs_page_bug(struct page *page)
diff --git a/fs/nilfs2/page.h b/fs/nilfs2/page.h
index d249ea1cefff..a8ab800e689c 100644
--- a/fs/nilfs2/page.h
+++ b/fs/nilfs2/page.h
@@ -36,7 +36,7 @@ struct buffer_head *nilfs_grab_buffer(struct inode *, struct address_space *,
unsigned long, unsigned long);
void nilfs_forget_buffer(struct buffer_head *);
void nilfs_copy_buffer(struct buffer_head *, struct buffer_head *);
-int nilfs_page_buffers_clean(struct page *);
+bool nilfs_folio_buffers_clean(struct folio *);
void nilfs_page_bug(struct page *);
int nilfs_copy_dirty_pages(struct address_space *, struct address_space *);
diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c
index 2a058aad5c2d..888b8606a1e8 100644
--- a/fs/nilfs2/segment.c
+++ b/fs/nilfs2/segment.c
@@ -1759,7 +1759,7 @@ static void nilfs_end_folio_io(struct folio *folio, int err)
* all the buffers get cleaned later.
*/
folio_lock(folio);
- if (nilfs_page_buffers_clean(&folio->page))
+ if (nilfs_folio_buffers_clean(folio))
__nilfs_clear_page_dirty(&folio->page);
folio_unlock(folio);
}
@@ -1767,7 +1767,7 @@ static void nilfs_end_folio_io(struct folio *folio, int err)
}
if (!err) {
- if (!nilfs_page_buffers_clean(&folio->page))
+ if (!nilfs_folio_buffers_clean(folio))
filemap_dirty_folio(folio->mapping, folio);
folio_clear_error(folio);
} else {
--
2.34.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 06/20] nilfs2: Convert nilfs_writepage() to use a folio
2023-11-14 8:44 [PATCH 00/20] nilfs2: Folio conversions for file paths Ryusuke Konishi
` (4 preceding siblings ...)
2023-11-14 8:44 ` [PATCH 05/20] nilfs2: Convert to nilfs_folio_buffers_clean() Ryusuke Konishi
@ 2023-11-14 8:44 ` Ryusuke Konishi
2023-11-14 8:44 ` [PATCH 07/20] nilfs2: Convert nilfs_mdt_write_page() " Ryusuke Konishi
` (13 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Ryusuke Konishi @ 2023-11-14 8:44 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-nilfs, Matthew Wilcox, linux-kernel
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Convert the incoming page to a folio. Replaces three calls to
compound_head() with one.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
---
fs/nilfs2/inode.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c
index f861f3a0bf5c..c7ec56358a79 100644
--- a/fs/nilfs2/inode.c
+++ b/fs/nilfs2/inode.c
@@ -175,7 +175,8 @@ static int nilfs_writepages(struct address_space *mapping,
static int nilfs_writepage(struct page *page, struct writeback_control *wbc)
{
- struct inode *inode = page->mapping->host;
+ struct folio *folio = page_folio(page);
+ struct inode *inode = folio->mapping->host;
int err;
if (sb_rdonly(inode->i_sb)) {
@@ -186,12 +187,12 @@ static int nilfs_writepage(struct page *page, struct writeback_control *wbc)
* So, here we simply discard this dirty page.
*/
nilfs_clear_dirty_page(page, false);
- unlock_page(page);
+ folio_unlock(folio);
return -EROFS;
}
- redirty_page_for_writepage(wbc, page);
- unlock_page(page);
+ folio_redirty_for_writepage(wbc, folio);
+ folio_unlock(folio);
if (wbc->sync_mode == WB_SYNC_ALL) {
err = nilfs_construct_segment(inode->i_sb);
--
2.34.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 07/20] nilfs2: Convert nilfs_mdt_write_page() to use a folio
2023-11-14 8:44 [PATCH 00/20] nilfs2: Folio conversions for file paths Ryusuke Konishi
` (5 preceding siblings ...)
2023-11-14 8:44 ` [PATCH 06/20] nilfs2: Convert nilfs_writepage() to use a folio Ryusuke Konishi
@ 2023-11-14 8:44 ` Ryusuke Konishi
2023-11-14 8:44 ` [PATCH 08/20] nilfs2: Convert to nilfs_clear_folio_dirty() Ryusuke Konishi
` (12 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Ryusuke Konishi @ 2023-11-14 8:44 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-nilfs, Matthew Wilcox, linux-kernel
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Convert the incoming page to a folio. Replaces three calls to
compound_head() with one.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
---
fs/nilfs2/mdt.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/fs/nilfs2/mdt.c b/fs/nilfs2/mdt.c
index c97c77a39668..327408512b86 100644
--- a/fs/nilfs2/mdt.c
+++ b/fs/nilfs2/mdt.c
@@ -399,7 +399,8 @@ int nilfs_mdt_fetch_dirty(struct inode *inode)
static int
nilfs_mdt_write_page(struct page *page, struct writeback_control *wbc)
{
- struct inode *inode = page->mapping->host;
+ struct folio *folio = page_folio(page);
+ struct inode *inode = folio->mapping->host;
struct super_block *sb;
int err = 0;
@@ -407,16 +408,16 @@ nilfs_mdt_write_page(struct page *page, struct writeback_control *wbc)
/*
* It means that filesystem was remounted in read-only
* mode because of error or metadata corruption. But we
- * have dirty pages that try to be flushed in background.
- * So, here we simply discard this dirty page.
+ * have dirty folios that try to be flushed in background.
+ * So, here we simply discard this dirty folio.
*/
nilfs_clear_dirty_page(page, false);
- unlock_page(page);
+ folio_unlock(folio);
return -EROFS;
}
- redirty_page_for_writepage(wbc, page);
- unlock_page(page);
+ folio_redirty_for_writepage(wbc, folio);
+ folio_unlock(folio);
if (!inode)
return 0;
--
2.34.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 08/20] nilfs2: Convert to nilfs_clear_folio_dirty()
2023-11-14 8:44 [PATCH 00/20] nilfs2: Folio conversions for file paths Ryusuke Konishi
` (6 preceding siblings ...)
2023-11-14 8:44 ` [PATCH 07/20] nilfs2: Convert nilfs_mdt_write_page() " Ryusuke Konishi
@ 2023-11-14 8:44 ` Ryusuke Konishi
2023-11-14 8:44 ` [PATCH 09/20] nilfs2: Convert to __nilfs_clear_folio_dirty() Ryusuke Konishi
` (11 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Ryusuke Konishi @ 2023-11-14 8:44 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-nilfs, Matthew Wilcox, linux-kernel
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
All callers of nilfs_clear_dirty_page() now have a folio, so rename
the function and pass in the folio. Saves three hidden calls to
compound_head().
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
---
fs/nilfs2/inode.c | 2 +-
fs/nilfs2/mdt.c | 2 +-
fs/nilfs2/page.c | 27 ++++++++++++++-------------
fs/nilfs2/page.h | 2 +-
4 files changed, 17 insertions(+), 16 deletions(-)
diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c
index c7ec56358a79..8fe784f62720 100644
--- a/fs/nilfs2/inode.c
+++ b/fs/nilfs2/inode.c
@@ -186,7 +186,7 @@ static int nilfs_writepage(struct page *page, struct writeback_control *wbc)
* have dirty pages that try to be flushed in background.
* So, here we simply discard this dirty page.
*/
- nilfs_clear_dirty_page(page, false);
+ nilfs_clear_folio_dirty(folio, false);
folio_unlock(folio);
return -EROFS;
}
diff --git a/fs/nilfs2/mdt.c b/fs/nilfs2/mdt.c
index 327408512b86..2e7952ac2f67 100644
--- a/fs/nilfs2/mdt.c
+++ b/fs/nilfs2/mdt.c
@@ -411,7 +411,7 @@ nilfs_mdt_write_page(struct page *page, struct writeback_control *wbc)
* have dirty folios that try to be flushed in background.
* So, here we simply discard this dirty folio.
*/
- nilfs_clear_dirty_page(page, false);
+ nilfs_clear_folio_dirty(folio, false);
folio_unlock(folio);
return -EROFS;
}
diff --git a/fs/nilfs2/page.c b/fs/nilfs2/page.c
index 29799a49c234..48a91ff059f5 100644
--- a/fs/nilfs2/page.c
+++ b/fs/nilfs2/page.c
@@ -379,7 +379,7 @@ void nilfs_clear_dirty_pages(struct address_space *mapping, bool silent)
* was acquired. Skip processing in that case.
*/
if (likely(folio->mapping == mapping))
- nilfs_clear_dirty_page(&folio->page, silent);
+ nilfs_clear_folio_dirty(folio, silent);
folio_unlock(folio);
}
@@ -389,32 +389,33 @@ void nilfs_clear_dirty_pages(struct address_space *mapping, bool silent)
}
/**
- * nilfs_clear_dirty_page - discard dirty page
- * @page: dirty page that will be discarded
+ * nilfs_clear_folio_dirty - discard dirty folio
+ * @folio: dirty folio that will be discarded
* @silent: suppress [true] or print [false] warning messages
*/
-void nilfs_clear_dirty_page(struct page *page, bool silent)
+void nilfs_clear_folio_dirty(struct folio *folio, bool silent)
{
- struct inode *inode = page->mapping->host;
+ struct inode *inode = folio->mapping->host;
struct super_block *sb = inode->i_sb;
+ struct buffer_head *bh, *head;
- BUG_ON(!PageLocked(page));
+ BUG_ON(!folio_test_locked(folio));
if (!silent)
nilfs_warn(sb, "discard dirty page: offset=%lld, ino=%lu",
- page_offset(page), inode->i_ino);
+ folio_pos(folio), inode->i_ino);
- ClearPageUptodate(page);
- ClearPageMappedToDisk(page);
+ folio_clear_uptodate(folio);
+ folio_clear_mappedtodisk(folio);
- if (page_has_buffers(page)) {
- struct buffer_head *bh, *head;
+ head = folio_buffers(folio);
+ if (head) {
const unsigned long clear_bits =
(BIT(BH_Uptodate) | BIT(BH_Dirty) | BIT(BH_Mapped) |
BIT(BH_Async_Write) | BIT(BH_NILFS_Volatile) |
BIT(BH_NILFS_Checked) | BIT(BH_NILFS_Redirected));
- bh = head = page_buffers(page);
+ bh = head;
do {
lock_buffer(bh);
if (!silent)
@@ -427,7 +428,7 @@ void nilfs_clear_dirty_page(struct page *page, bool silent)
} while (bh = bh->b_this_page, bh != head);
}
- __nilfs_clear_page_dirty(page);
+ __nilfs_clear_page_dirty(&folio->page);
}
unsigned int nilfs_page_count_clean_buffers(struct page *page,
diff --git a/fs/nilfs2/page.h b/fs/nilfs2/page.h
index a8ab800e689c..c419bb1f5b7d 100644
--- a/fs/nilfs2/page.h
+++ b/fs/nilfs2/page.h
@@ -41,7 +41,7 @@ void nilfs_page_bug(struct page *);
int nilfs_copy_dirty_pages(struct address_space *, struct address_space *);
void nilfs_copy_back_pages(struct address_space *, struct address_space *);
-void nilfs_clear_dirty_page(struct page *, bool);
+void nilfs_clear_folio_dirty(struct folio *, bool);
void nilfs_clear_dirty_pages(struct address_space *, bool);
unsigned int nilfs_page_count_clean_buffers(struct page *, unsigned int,
unsigned int);
--
2.34.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 09/20] nilfs2: Convert to __nilfs_clear_folio_dirty()
2023-11-14 8:44 [PATCH 00/20] nilfs2: Folio conversions for file paths Ryusuke Konishi
` (7 preceding siblings ...)
2023-11-14 8:44 ` [PATCH 08/20] nilfs2: Convert to nilfs_clear_folio_dirty() Ryusuke Konishi
@ 2023-11-14 8:44 ` Ryusuke Konishi
2023-11-14 8:44 ` [PATCH 10/20] nilfs2: Convert nilfs_segctor_prepare_write to use folios Ryusuke Konishi
` (10 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Ryusuke Konishi @ 2023-11-14 8:44 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-nilfs, Matthew Wilcox, linux-kernel
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
All callers now have a folio, so convert to pass a folio. No caller
uses the return value, so make it return void. Removes a couple of
hidden calls to compound_head().
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
---
fs/nilfs2/page.c | 19 ++++++++++---------
fs/nilfs2/page.h | 2 +-
fs/nilfs2/segment.c | 2 +-
3 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/fs/nilfs2/page.c b/fs/nilfs2/page.c
index 48a91ff059f5..94e11bcee05b 100644
--- a/fs/nilfs2/page.c
+++ b/fs/nilfs2/page.c
@@ -82,7 +82,7 @@ void nilfs_forget_buffer(struct buffer_head *bh)
lock_buffer(bh);
set_mask_bits(&bh->b_state, clear_bits, 0);
if (nilfs_folio_buffers_clean(folio))
- __nilfs_clear_page_dirty(&folio->page);
+ __nilfs_clear_folio_dirty(folio);
bh->b_blocknr = -1;
folio_clear_uptodate(folio);
@@ -428,7 +428,7 @@ void nilfs_clear_folio_dirty(struct folio *folio, bool silent)
} while (bh = bh->b_this_page, bh != head);
}
- __nilfs_clear_page_dirty(&folio->page);
+ __nilfs_clear_folio_dirty(folio);
}
unsigned int nilfs_page_count_clean_buffers(struct page *page,
@@ -458,22 +458,23 @@ unsigned int nilfs_page_count_clean_buffers(struct page *page,
* 2) Some B-tree operations like insertion or deletion may dispose buffers
* in dirty state, and this needs to cancel the dirty state of their pages.
*/
-int __nilfs_clear_page_dirty(struct page *page)
+void __nilfs_clear_folio_dirty(struct folio *folio)
{
- struct address_space *mapping = page->mapping;
+ struct address_space *mapping = folio->mapping;
if (mapping) {
xa_lock_irq(&mapping->i_pages);
- if (test_bit(PG_dirty, &page->flags)) {
- __xa_clear_mark(&mapping->i_pages, page_index(page),
+ if (folio_test_dirty(folio)) {
+ __xa_clear_mark(&mapping->i_pages, folio->index,
PAGECACHE_TAG_DIRTY);
xa_unlock_irq(&mapping->i_pages);
- return clear_page_dirty_for_io(page);
+ folio_clear_dirty_for_io(folio);
+ return;
}
xa_unlock_irq(&mapping->i_pages);
- return 0;
+ return;
}
- return TestClearPageDirty(page);
+ folio_clear_dirty(folio);
}
/**
diff --git a/fs/nilfs2/page.h b/fs/nilfs2/page.h
index c419bb1f5b7d..968b311d265b 100644
--- a/fs/nilfs2/page.h
+++ b/fs/nilfs2/page.h
@@ -30,7 +30,7 @@ BUFFER_FNS(NILFS_Checked, nilfs_checked) /* buffer is verified */
BUFFER_FNS(NILFS_Redirected, nilfs_redirected) /* redirected to a copy */
-int __nilfs_clear_page_dirty(struct page *);
+void __nilfs_clear_folio_dirty(struct folio *);
struct buffer_head *nilfs_grab_buffer(struct inode *, struct address_space *,
unsigned long, unsigned long);
diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c
index 888b8606a1e8..8c675c118c66 100644
--- a/fs/nilfs2/segment.c
+++ b/fs/nilfs2/segment.c
@@ -1760,7 +1760,7 @@ static void nilfs_end_folio_io(struct folio *folio, int err)
*/
folio_lock(folio);
if (nilfs_folio_buffers_clean(folio))
- __nilfs_clear_page_dirty(&folio->page);
+ __nilfs_clear_folio_dirty(folio);
folio_unlock(folio);
}
return;
--
2.34.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 10/20] nilfs2: Convert nilfs_segctor_prepare_write to use folios
2023-11-14 8:44 [PATCH 00/20] nilfs2: Folio conversions for file paths Ryusuke Konishi
` (8 preceding siblings ...)
2023-11-14 8:44 ` [PATCH 09/20] nilfs2: Convert to __nilfs_clear_folio_dirty() Ryusuke Konishi
@ 2023-11-14 8:44 ` Ryusuke Konishi
2023-11-14 8:44 ` [PATCH 11/20] nilfs2: Convert nilfs_page_mkwrite() to use a folio Ryusuke Konishi
` (9 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Ryusuke Konishi @ 2023-11-14 8:44 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-nilfs, Matthew Wilcox, linux-kernel
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Use the new folio APIs, saving 17 hidden calls to compound_head().
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
---
fs/nilfs2/segment.c | 58 ++++++++++++++++++++++-----------------------
1 file changed, 29 insertions(+), 29 deletions(-)
diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c
index 8c675c118c66..52995838f2de 100644
--- a/fs/nilfs2/segment.c
+++ b/fs/nilfs2/segment.c
@@ -1665,39 +1665,39 @@ static int nilfs_segctor_assign(struct nilfs_sc_info *sci, int mode)
return 0;
}
-static void nilfs_begin_page_io(struct page *page)
+static void nilfs_begin_folio_io(struct folio *folio)
{
- if (!page || PageWriteback(page))
+ if (!folio || folio_test_writeback(folio))
/*
* For split b-tree node pages, this function may be called
* twice. We ignore the 2nd or later calls by this check.
*/
return;
- lock_page(page);
- clear_page_dirty_for_io(page);
- set_page_writeback(page);
- unlock_page(page);
+ folio_lock(folio);
+ folio_clear_dirty_for_io(folio);
+ folio_start_writeback(folio);
+ folio_unlock(folio);
}
static void nilfs_segctor_prepare_write(struct nilfs_sc_info *sci)
{
struct nilfs_segment_buffer *segbuf;
- struct page *bd_page = NULL, *fs_page = NULL;
+ struct folio *bd_folio = NULL, *fs_folio = NULL;
list_for_each_entry(segbuf, &sci->sc_segbufs, sb_list) {
struct buffer_head *bh;
list_for_each_entry(bh, &segbuf->sb_segsum_buffers,
b_assoc_buffers) {
- if (bh->b_page != bd_page) {
- if (bd_page) {
- lock_page(bd_page);
- clear_page_dirty_for_io(bd_page);
- set_page_writeback(bd_page);
- unlock_page(bd_page);
+ if (bh->b_folio != bd_folio) {
+ if (bd_folio) {
+ folio_lock(bd_folio);
+ folio_clear_dirty_for_io(bd_folio);
+ folio_start_writeback(bd_folio);
+ folio_unlock(bd_folio);
}
- bd_page = bh->b_page;
+ bd_folio = bh->b_folio;
}
}
@@ -1705,28 +1705,28 @@ static void nilfs_segctor_prepare_write(struct nilfs_sc_info *sci)
b_assoc_buffers) {
set_buffer_async_write(bh);
if (bh == segbuf->sb_super_root) {
- if (bh->b_page != bd_page) {
- lock_page(bd_page);
- clear_page_dirty_for_io(bd_page);
- set_page_writeback(bd_page);
- unlock_page(bd_page);
- bd_page = bh->b_page;
+ if (bh->b_folio != bd_folio) {
+ folio_lock(bd_folio);
+ folio_clear_dirty_for_io(bd_folio);
+ folio_start_writeback(bd_folio);
+ folio_unlock(bd_folio);
+ bd_folio = bh->b_folio;
}
break;
}
- if (bh->b_page != fs_page) {
- nilfs_begin_page_io(fs_page);
- fs_page = bh->b_page;
+ if (bh->b_folio != fs_folio) {
+ nilfs_begin_folio_io(fs_folio);
+ fs_folio = bh->b_folio;
}
}
}
- if (bd_page) {
- lock_page(bd_page);
- clear_page_dirty_for_io(bd_page);
- set_page_writeback(bd_page);
- unlock_page(bd_page);
+ if (bd_folio) {
+ folio_lock(bd_folio);
+ folio_clear_dirty_for_io(bd_folio);
+ folio_start_writeback(bd_folio);
+ folio_unlock(bd_folio);
}
- nilfs_begin_page_io(fs_page);
+ nilfs_begin_folio_io(fs_folio);
}
static int nilfs_segctor_write(struct nilfs_sc_info *sci,
--
2.34.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 11/20] nilfs2: Convert nilfs_page_mkwrite() to use a folio
2023-11-14 8:44 [PATCH 00/20] nilfs2: Folio conversions for file paths Ryusuke Konishi
` (9 preceding siblings ...)
2023-11-14 8:44 ` [PATCH 10/20] nilfs2: Convert nilfs_segctor_prepare_write to use folios Ryusuke Konishi
@ 2023-11-14 8:44 ` Ryusuke Konishi
2023-11-14 8:44 ` [PATCH 12/20] nilfs2: Convert nilfs_mdt_create_block " Ryusuke Konishi
` (8 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Ryusuke Konishi @ 2023-11-14 8:44 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-nilfs, Matthew Wilcox, linux-kernel
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Using the new folio APIs saves seven hidden calls to compound_head().
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
---
fs/nilfs2/file.c | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/fs/nilfs2/file.c b/fs/nilfs2/file.c
index 740ce26d1e76..bec33b89a075 100644
--- a/fs/nilfs2/file.c
+++ b/fs/nilfs2/file.c
@@ -45,34 +45,36 @@ int nilfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
static vm_fault_t nilfs_page_mkwrite(struct vm_fault *vmf)
{
struct vm_area_struct *vma = vmf->vma;
- struct page *page = vmf->page;
+ struct folio *folio = page_folio(vmf->page);
struct inode *inode = file_inode(vma->vm_file);
struct nilfs_transaction_info ti;
+ struct buffer_head *bh, *head;
int ret = 0;
if (unlikely(nilfs_near_disk_full(inode->i_sb->s_fs_info)))
return VM_FAULT_SIGBUS; /* -ENOSPC */
sb_start_pagefault(inode->i_sb);
- lock_page(page);
- if (page->mapping != inode->i_mapping ||
- page_offset(page) >= i_size_read(inode) || !PageUptodate(page)) {
- unlock_page(page);
+ folio_lock(folio);
+ if (folio->mapping != inode->i_mapping ||
+ folio_pos(folio) >= i_size_read(inode) ||
+ !folio_test_uptodate(folio)) {
+ folio_unlock(folio);
ret = -EFAULT; /* make the VM retry the fault */
goto out;
}
/*
- * check to see if the page is mapped already (no holes)
+ * check to see if the folio is mapped already (no holes)
*/
- if (PageMappedToDisk(page))
+ if (folio_test_mappedtodisk(folio))
goto mapped;
- if (page_has_buffers(page)) {
- struct buffer_head *bh, *head;
+ head = folio_buffers(folio);
+ if (head) {
int fully_mapped = 1;
- bh = head = page_buffers(page);
+ bh = head;
do {
if (!buffer_mapped(bh)) {
fully_mapped = 0;
@@ -81,11 +83,11 @@ static vm_fault_t nilfs_page_mkwrite(struct vm_fault *vmf)
} while (bh = bh->b_this_page, bh != head);
if (fully_mapped) {
- SetPageMappedToDisk(page);
+ folio_set_mappedtodisk(folio);
goto mapped;
}
}
- unlock_page(page);
+ folio_unlock(folio);
/*
* fill hole blocks
@@ -105,7 +107,7 @@ static vm_fault_t nilfs_page_mkwrite(struct vm_fault *vmf)
nilfs_transaction_commit(inode->i_sb);
mapped:
- wait_for_stable_page(page);
+ folio_wait_stable(folio);
out:
sb_end_pagefault(inode->i_sb);
return vmf_fs_error(ret);
--
2.34.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 12/20] nilfs2: Convert nilfs_mdt_create_block to use a folio
2023-11-14 8:44 [PATCH 00/20] nilfs2: Folio conversions for file paths Ryusuke Konishi
` (10 preceding siblings ...)
2023-11-14 8:44 ` [PATCH 11/20] nilfs2: Convert nilfs_page_mkwrite() to use a folio Ryusuke Konishi
@ 2023-11-14 8:44 ` Ryusuke Konishi
2023-11-14 8:44 ` [PATCH 13/20] nilfs2: Convert nilfs_mdt_submit_block " Ryusuke Konishi
` (7 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Ryusuke Konishi @ 2023-11-14 8:44 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-nilfs, Matthew Wilcox, linux-kernel
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Saves two calls to compound_head().
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
---
fs/nilfs2/mdt.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/nilfs2/mdt.c b/fs/nilfs2/mdt.c
index 2e7952ac2f67..7e4dcff2c94b 100644
--- a/fs/nilfs2/mdt.c
+++ b/fs/nilfs2/mdt.c
@@ -97,8 +97,8 @@ static int nilfs_mdt_create_block(struct inode *inode, unsigned long block,
}
failed_bh:
- unlock_page(bh->b_page);
- put_page(bh->b_page);
+ folio_unlock(bh->b_folio);
+ folio_put(bh->b_folio);
brelse(bh);
failed_unlock:
--
2.34.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 13/20] nilfs2: Convert nilfs_mdt_submit_block to use a folio
2023-11-14 8:44 [PATCH 00/20] nilfs2: Folio conversions for file paths Ryusuke Konishi
` (11 preceding siblings ...)
2023-11-14 8:44 ` [PATCH 12/20] nilfs2: Convert nilfs_mdt_create_block " Ryusuke Konishi
@ 2023-11-14 8:44 ` Ryusuke Konishi
2023-11-14 8:44 ` [PATCH 14/20] nilfs2: Convert nilfs_gccache_submit_read_data " Ryusuke Konishi
` (6 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Ryusuke Konishi @ 2023-11-14 8:44 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-nilfs, Matthew Wilcox, linux-kernel
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Saves two calls to compound_head().
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
---
fs/nilfs2/mdt.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/nilfs2/mdt.c b/fs/nilfs2/mdt.c
index 7e4dcff2c94b..e45c01a559c0 100644
--- a/fs/nilfs2/mdt.c
+++ b/fs/nilfs2/mdt.c
@@ -158,8 +158,8 @@ nilfs_mdt_submit_block(struct inode *inode, unsigned long blkoff, blk_opf_t opf,
*out_bh = bh;
failed_bh:
- unlock_page(bh->b_page);
- put_page(bh->b_page);
+ folio_unlock(bh->b_folio);
+ folio_put(bh->b_folio);
brelse(bh);
failed:
return ret;
--
2.34.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 14/20] nilfs2: Convert nilfs_gccache_submit_read_data to use a folio
2023-11-14 8:44 [PATCH 00/20] nilfs2: Folio conversions for file paths Ryusuke Konishi
` (12 preceding siblings ...)
2023-11-14 8:44 ` [PATCH 13/20] nilfs2: Convert nilfs_mdt_submit_block " Ryusuke Konishi
@ 2023-11-14 8:44 ` Ryusuke Konishi
2023-11-14 8:44 ` [PATCH 15/20] nilfs2: Convert nilfs_btnode_create_block " Ryusuke Konishi
` (5 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Ryusuke Konishi @ 2023-11-14 8:44 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-nilfs, Matthew Wilcox, linux-kernel
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Saves two calls to compound_head().
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
---
fs/nilfs2/gcinode.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/nilfs2/gcinode.c b/fs/nilfs2/gcinode.c
index 8beb2730929d..bf9a11d58817 100644
--- a/fs/nilfs2/gcinode.c
+++ b/fs/nilfs2/gcinode.c
@@ -98,8 +98,8 @@ int nilfs_gccache_submit_read_data(struct inode *inode, sector_t blkoff,
*out_bh = bh;
failed:
- unlock_page(bh->b_page);
- put_page(bh->b_page);
+ folio_unlock(bh->b_folio);
+ folio_put(bh->b_folio);
if (unlikely(err))
brelse(bh);
return err;
--
2.34.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 15/20] nilfs2: Convert nilfs_btnode_create_block to use a folio
2023-11-14 8:44 [PATCH 00/20] nilfs2: Folio conversions for file paths Ryusuke Konishi
` (13 preceding siblings ...)
2023-11-14 8:44 ` [PATCH 14/20] nilfs2: Convert nilfs_gccache_submit_read_data " Ryusuke Konishi
@ 2023-11-14 8:44 ` Ryusuke Konishi
2023-11-14 8:44 ` [PATCH 16/20] nilfs2: Convert nilfs_btnode_submit_block " Ryusuke Konishi
` (4 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Ryusuke Konishi @ 2023-11-14 8:44 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-nilfs, Matthew Wilcox, linux-kernel
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Saves two calls to compound_head().
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
---
fs/nilfs2/btnode.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/nilfs2/btnode.c b/fs/nilfs2/btnode.c
index 5710833ac1cc..691a50410ea9 100644
--- a/fs/nilfs2/btnode.c
+++ b/fs/nilfs2/btnode.c
@@ -64,8 +64,8 @@ nilfs_btnode_create_block(struct address_space *btnc, __u64 blocknr)
set_buffer_mapped(bh);
set_buffer_uptodate(bh);
- unlock_page(bh->b_page);
- put_page(bh->b_page);
+ folio_unlock(bh->b_folio);
+ folio_put(bh->b_folio);
return bh;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 16/20] nilfs2: Convert nilfs_btnode_submit_block to use a folio
2023-11-14 8:44 [PATCH 00/20] nilfs2: Folio conversions for file paths Ryusuke Konishi
` (14 preceding siblings ...)
2023-11-14 8:44 ` [PATCH 15/20] nilfs2: Convert nilfs_btnode_create_block " Ryusuke Konishi
@ 2023-11-14 8:44 ` Ryusuke Konishi
2023-11-14 8:44 ` [PATCH 17/20] nilfs2: Convert nilfs_btnode_delete " Ryusuke Konishi
` (3 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Ryusuke Konishi @ 2023-11-14 8:44 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-nilfs, Matthew Wilcox, linux-kernel
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Saves two calls to compound_head().
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
---
fs/nilfs2/btnode.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/fs/nilfs2/btnode.c b/fs/nilfs2/btnode.c
index 691a50410ea9..5ef9eebd8d2e 100644
--- a/fs/nilfs2/btnode.c
+++ b/fs/nilfs2/btnode.c
@@ -75,7 +75,7 @@ int nilfs_btnode_submit_block(struct address_space *btnc, __u64 blocknr,
{
struct buffer_head *bh;
struct inode *inode = btnc->host;
- struct page *page;
+ struct folio *folio;
int err;
bh = nilfs_grab_buffer(inode, btnc, blocknr, BIT(BH_NILFS_Node));
@@ -83,7 +83,7 @@ int nilfs_btnode_submit_block(struct address_space *btnc, __u64 blocknr,
return -ENOMEM;
err = -EEXIST; /* internal code */
- page = bh->b_page;
+ folio = bh->b_folio;
if (buffer_uptodate(bh) || buffer_dirty(bh))
goto found;
@@ -130,8 +130,8 @@ int nilfs_btnode_submit_block(struct address_space *btnc, __u64 blocknr,
*pbh = bh;
out_locked:
- unlock_page(page);
- put_page(page);
+ folio_unlock(folio);
+ folio_put(folio);
return err;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 17/20] nilfs2: Convert nilfs_btnode_delete to use a folio
2023-11-14 8:44 [PATCH 00/20] nilfs2: Folio conversions for file paths Ryusuke Konishi
` (15 preceding siblings ...)
2023-11-14 8:44 ` [PATCH 16/20] nilfs2: Convert nilfs_btnode_submit_block " Ryusuke Konishi
@ 2023-11-14 8:44 ` Ryusuke Konishi
2023-11-14 8:44 ` [PATCH 18/20] nilfs2: Convert nilfs_btnode_prepare_change_key " Ryusuke Konishi
` (2 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Ryusuke Konishi @ 2023-11-14 8:44 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-nilfs, Matthew Wilcox, linux-kernel
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Saves six calls to compound_head().
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
---
fs/nilfs2/btnode.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/fs/nilfs2/btnode.c b/fs/nilfs2/btnode.c
index 5ef9eebd8d2e..e077d4a7a11c 100644
--- a/fs/nilfs2/btnode.c
+++ b/fs/nilfs2/btnode.c
@@ -145,19 +145,19 @@ int nilfs_btnode_submit_block(struct address_space *btnc, __u64 blocknr,
void nilfs_btnode_delete(struct buffer_head *bh)
{
struct address_space *mapping;
- struct page *page = bh->b_page;
- pgoff_t index = page_index(page);
+ struct folio *folio = bh->b_folio;
+ pgoff_t index = folio->index;
int still_dirty;
- get_page(page);
- lock_page(page);
- wait_on_page_writeback(page);
+ folio_get(folio);
+ folio_lock(folio);
+ folio_wait_writeback(folio);
nilfs_forget_buffer(bh);
- still_dirty = PageDirty(page);
- mapping = page->mapping;
- unlock_page(page);
- put_page(page);
+ still_dirty = folio_test_dirty(folio);
+ mapping = folio->mapping;
+ folio_unlock(folio);
+ folio_put(folio);
if (!still_dirty && mapping)
invalidate_inode_pages2_range(mapping, index, index);
--
2.34.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 18/20] nilfs2: Convert nilfs_btnode_prepare_change_key to use a folio
2023-11-14 8:44 [PATCH 00/20] nilfs2: Folio conversions for file paths Ryusuke Konishi
` (16 preceding siblings ...)
2023-11-14 8:44 ` [PATCH 17/20] nilfs2: Convert nilfs_btnode_delete " Ryusuke Konishi
@ 2023-11-14 8:44 ` Ryusuke Konishi
2023-11-14 8:44 ` [PATCH 19/20] nilfs2: Convert nilfs_btnode_commit_change_key " Ryusuke Konishi
2023-11-14 8:44 ` [PATCH 20/20] nilfs2: Convert nilfs_btnode_abort_change_key " Ryusuke Konishi
19 siblings, 0 replies; 21+ messages in thread
From: Ryusuke Konishi @ 2023-11-14 8:44 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-nilfs, Matthew Wilcox, linux-kernel
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Saves three calls to compound_head().
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
---
fs/nilfs2/btnode.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/fs/nilfs2/btnode.c b/fs/nilfs2/btnode.c
index e077d4a7a11c..da3e4366625f 100644
--- a/fs/nilfs2/btnode.c
+++ b/fs/nilfs2/btnode.c
@@ -185,23 +185,23 @@ int nilfs_btnode_prepare_change_key(struct address_space *btnc,
ctxt->newbh = NULL;
if (inode->i_blkbits == PAGE_SHIFT) {
- struct page *opage = obh->b_page;
- lock_page(opage);
+ struct folio *ofolio = obh->b_folio;
+ folio_lock(ofolio);
retry:
/* BUG_ON(oldkey != obh->b_folio->index); */
- if (unlikely(oldkey != opage->index))
- NILFS_PAGE_BUG(opage,
+ if (unlikely(oldkey != ofolio->index))
+ NILFS_PAGE_BUG(&ofolio->page,
"invalid oldkey %lld (newkey=%lld)",
(unsigned long long)oldkey,
(unsigned long long)newkey);
xa_lock_irq(&btnc->i_pages);
- err = __xa_insert(&btnc->i_pages, newkey, opage, GFP_NOFS);
+ err = __xa_insert(&btnc->i_pages, newkey, ofolio, GFP_NOFS);
xa_unlock_irq(&btnc->i_pages);
/*
- * Note: page->index will not change to newkey until
+ * Note: folio->index will not change to newkey until
* nilfs_btnode_commit_change_key() will be called.
- * To protect the page in intermediate state, the page lock
+ * To protect the folio in intermediate state, the folio lock
* is held.
*/
if (!err)
@@ -213,7 +213,7 @@ int nilfs_btnode_prepare_change_key(struct address_space *btnc,
if (!err)
goto retry;
/* fallback to copy mode */
- unlock_page(opage);
+ folio_unlock(ofolio);
}
nbh = nilfs_btnode_create_block(btnc, newkey);
@@ -225,7 +225,7 @@ int nilfs_btnode_prepare_change_key(struct address_space *btnc,
return 0;
failed_unlock:
- unlock_page(obh->b_page);
+ folio_unlock(obh->b_folio);
return err;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 19/20] nilfs2: Convert nilfs_btnode_commit_change_key to use a folio
2023-11-14 8:44 [PATCH 00/20] nilfs2: Folio conversions for file paths Ryusuke Konishi
` (17 preceding siblings ...)
2023-11-14 8:44 ` [PATCH 18/20] nilfs2: Convert nilfs_btnode_prepare_change_key " Ryusuke Konishi
@ 2023-11-14 8:44 ` Ryusuke Konishi
2023-11-14 8:44 ` [PATCH 20/20] nilfs2: Convert nilfs_btnode_abort_change_key " Ryusuke Konishi
19 siblings, 0 replies; 21+ messages in thread
From: Ryusuke Konishi @ 2023-11-14 8:44 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-nilfs, Matthew Wilcox, linux-kernel
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Saves one call to compound_head().
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
---
fs/nilfs2/btnode.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/fs/nilfs2/btnode.c b/fs/nilfs2/btnode.c
index da3e4366625f..fb1638765d54 100644
--- a/fs/nilfs2/btnode.c
+++ b/fs/nilfs2/btnode.c
@@ -238,15 +238,15 @@ void nilfs_btnode_commit_change_key(struct address_space *btnc,
{
struct buffer_head *obh = ctxt->bh, *nbh = ctxt->newbh;
__u64 oldkey = ctxt->oldkey, newkey = ctxt->newkey;
- struct page *opage;
+ struct folio *ofolio;
if (oldkey == newkey)
return;
if (nbh == NULL) { /* blocksize == pagesize */
- opage = obh->b_page;
- if (unlikely(oldkey != opage->index))
- NILFS_PAGE_BUG(opage,
+ ofolio = obh->b_folio;
+ if (unlikely(oldkey != ofolio->index))
+ NILFS_PAGE_BUG(&ofolio->page,
"invalid oldkey %lld (newkey=%lld)",
(unsigned long long)oldkey,
(unsigned long long)newkey);
@@ -257,8 +257,8 @@ void nilfs_btnode_commit_change_key(struct address_space *btnc,
__xa_set_mark(&btnc->i_pages, newkey, PAGECACHE_TAG_DIRTY);
xa_unlock_irq(&btnc->i_pages);
- opage->index = obh->b_blocknr = newkey;
- unlock_page(opage);
+ ofolio->index = obh->b_blocknr = newkey;
+ folio_unlock(ofolio);
} else {
nilfs_copy_buffer(nbh, obh);
mark_buffer_dirty(nbh);
--
2.34.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 20/20] nilfs2: Convert nilfs_btnode_abort_change_key to use a folio
2023-11-14 8:44 [PATCH 00/20] nilfs2: Folio conversions for file paths Ryusuke Konishi
` (18 preceding siblings ...)
2023-11-14 8:44 ` [PATCH 19/20] nilfs2: Convert nilfs_btnode_commit_change_key " Ryusuke Konishi
@ 2023-11-14 8:44 ` Ryusuke Konishi
19 siblings, 0 replies; 21+ messages in thread
From: Ryusuke Konishi @ 2023-11-14 8:44 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-nilfs, Matthew Wilcox, linux-kernel
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Saves one call to compound_head().
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
---
fs/nilfs2/btnode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/nilfs2/btnode.c b/fs/nilfs2/btnode.c
index fb1638765d54..1204dd06ead8 100644
--- a/fs/nilfs2/btnode.c
+++ b/fs/nilfs2/btnode.c
@@ -284,7 +284,7 @@ void nilfs_btnode_abort_change_key(struct address_space *btnc,
if (nbh == NULL) { /* blocksize == pagesize */
xa_erase_irq(&btnc->i_pages, newkey);
- unlock_page(ctxt->bh->b_page);
+ folio_unlock(ctxt->bh->b_folio);
} else {
/*
* When canceling a buffer that a prepare operation has
--
2.34.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
end of thread, other threads:[~2023-11-14 8:47 UTC | newest]
Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-14 8:44 [PATCH 00/20] nilfs2: Folio conversions for file paths Ryusuke Konishi
2023-11-14 8:44 ` [PATCH 01/20] nilfs2: Add nilfs_end_folio_io() Ryusuke Konishi
2023-11-14 8:44 ` [PATCH 02/20] nilfs2: Convert nilfs_abort_logs to use folios Ryusuke Konishi
2023-11-14 8:44 ` [PATCH 03/20] nilfs2: Convert nilfs_segctor_complete_write " Ryusuke Konishi
2023-11-14 8:44 ` [PATCH 04/20] nilfs2: Convert nilfs_forget_buffer to use a folio Ryusuke Konishi
2023-11-14 8:44 ` [PATCH 05/20] nilfs2: Convert to nilfs_folio_buffers_clean() Ryusuke Konishi
2023-11-14 8:44 ` [PATCH 06/20] nilfs2: Convert nilfs_writepage() to use a folio Ryusuke Konishi
2023-11-14 8:44 ` [PATCH 07/20] nilfs2: Convert nilfs_mdt_write_page() " Ryusuke Konishi
2023-11-14 8:44 ` [PATCH 08/20] nilfs2: Convert to nilfs_clear_folio_dirty() Ryusuke Konishi
2023-11-14 8:44 ` [PATCH 09/20] nilfs2: Convert to __nilfs_clear_folio_dirty() Ryusuke Konishi
2023-11-14 8:44 ` [PATCH 10/20] nilfs2: Convert nilfs_segctor_prepare_write to use folios Ryusuke Konishi
2023-11-14 8:44 ` [PATCH 11/20] nilfs2: Convert nilfs_page_mkwrite() to use a folio Ryusuke Konishi
2023-11-14 8:44 ` [PATCH 12/20] nilfs2: Convert nilfs_mdt_create_block " Ryusuke Konishi
2023-11-14 8:44 ` [PATCH 13/20] nilfs2: Convert nilfs_mdt_submit_block " Ryusuke Konishi
2023-11-14 8:44 ` [PATCH 14/20] nilfs2: Convert nilfs_gccache_submit_read_data " Ryusuke Konishi
2023-11-14 8:44 ` [PATCH 15/20] nilfs2: Convert nilfs_btnode_create_block " Ryusuke Konishi
2023-11-14 8:44 ` [PATCH 16/20] nilfs2: Convert nilfs_btnode_submit_block " Ryusuke Konishi
2023-11-14 8:44 ` [PATCH 17/20] nilfs2: Convert nilfs_btnode_delete " Ryusuke Konishi
2023-11-14 8:44 ` [PATCH 18/20] nilfs2: Convert nilfs_btnode_prepare_change_key " Ryusuke Konishi
2023-11-14 8:44 ` [PATCH 19/20] nilfs2: Convert nilfs_btnode_commit_change_key " Ryusuke Konishi
2023-11-14 8:44 ` [PATCH 20/20] nilfs2: Convert nilfs_btnode_abort_change_key " Ryusuke Konishi
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 read-only IMAP folder(s) and NNTP newsgroup(s).