Make folio_start_writeback return void
Subsystems (7)
Matthew Wilcox (Oracle)
maintainercover Make folio_start_writeback return void
Most of the folio flag-setting functions return void. folio_start_writeback is gratuitously different; the only two filesystems that do anything with the return value emit debug messages if it's already set, and we can (and should) do that internally without bothering the filesystem to do it.
Matthew Wilcox (Oracle) (4):
mm: Remove test_set_page_writeback()
afs: Do not test the return value of folio_start_writeback()
smb: Do not test the return value of folio_start_writeback()
mm: Return void from folio_start_writeback() and related functions
fs/afs/write.c | 6 ++--- fs/smb/client/file.c | 6 ++--- include/linux/page-flags.h | 9 ++----- mm/folio-compat.c | 4 +-- mm/page-writeback.c | 54 ++++++++++++++++++-------------------- 5 files changed, 33 insertions(+), 46 deletions(-)
Signature · 1 line
2.42.0
Matthew Wilcox (Oracle)
maintainerPATCH 1/4 mm: Remove test_set_page_writeback()
There are no more callers of this wrapper.
--- include/linux/page-flags.h | 5 ----- 1 file changed, 5 deletions(-)
include/linux/page-flags.h +0 -5
@@ -780,11 +780,6 @@ bool set_page_writeback(struct page *page);#define folio_start_writeback_keepwrite (folio) \ __folio_start_writeback(folio, true) -static inline bool test_set_page_writeback (struct page *page) -{ -return set_page_writeback (page); -} - static __always_inline bool folio_test_head(struct folio *folio) {return test_bit (PG_head,folio_flags (folio,FOLIO_PF_ANY ));
Signature · 1 line
2.42.0
Matthew Wilcox (Oracle)
maintainerPATCH 2/4 afs: Do not test the return value of folio_start_writeback()
In reply to Matthew Wilcox (Oracle)In preparation for removing the return value entirely, stop testing it in afs.
--- fs/afs/write.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
fs/afs/write.c +2 -4
@@ -559,8 +559,7 @@ static void afs_extend_writeback(struct address_space *mapping,if (!folio_clear_dirty_for_io (folio))BUG (); -if (folio_start_writeback (folio)) -BUG (); +folio_start_writeback (folio);afs_folio_start_fscache (caching, folio); *_count -=folio_nr_pages (folio);
@@ -595,8 +594,7 @@ static ssize_t afs_write_back_from_locked_folio(struct address_space *mapping,_enter (",%lx,%llx-%llx" ,folio_index (folio), start, end); -if (folio_start_writeback (folio)) -BUG (); +folio_start_writeback (folio);afs_folio_start_fscache (caching, folio); count -=folio_nr_pages (folio);
Signature · 1 line
2.42.0
Matthew Wilcox (Oracle)
maintainerPATCH 3/4 smb: Do not test the return value of folio_start_writeback()
In reply to Matthew Wilcox (Oracle)In preparation for removing the return value entirely, stop testing it in smb.
--- fs/smb/client/file.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
fs/smb/client/file.c +2 -4
@@ -2706,8 +2706,7 @@ static void cifs_extend_writeback(struct address_space *mapping,*/ if (!folio_clear_dirty_for_io (folio))WARN_ON (1 ); -if (folio_start_writeback (folio)) -WARN_ON (1 ); +folio_start_writeback (folio); *_count -=folio_nr_pages (folio);folio_unlock (folio);
@@ -2742,8 +2741,7 @@ static ssize_t cifs_write_back_from_locked_folio(struct address_space *mapping,int rc;/* The folio should be locked, dirty and not undergoing writeback. */ -if (folio_start_writeback (folio)) -WARN_ON (1 ); +folio_start_writeback (folio); count -=folio_nr_pages (folio); len =folio_size (folio);
Signature · 1 line
2.42.0
Re: [PATCH 3/4] smb: Do not test the return value of folio_start_writeback()
Quoted 7 lines · Matthew Wilcox (Oracle)
In preparation for removing the return value entirely, stop testing it in smb.
Signed-off-by Matthew Wilcox (Oracle) <[email protected]>--- fs/smb/client/file.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
Steve French
Acked-byRe: [PATCH 3/4] smb: Do not test the return value of folio_start_writeback()
Quoted 13 lines · Paulo Alcantara
Quoted 7 lines · Matthew Wilcox (Oracle)
In preparation for removing the return value entirely, stop testing it in smb.
Signed-off-by Matthew Wilcox (Oracle) <[email protected]>--- fs/smb/client/file.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)Reviewed-by Paulo Alcantara (SUSE) <[email protected]>
Signature · 3 lines
Thanks, Steve
Matthew Wilcox (Oracle)
maintainerPATCH 4/4 mm: Return void from folio_start_writeback() and related functions
In reply to Matthew Wilcox (Oracle)Nobody now checks the return value from any of these functions, so add an assertion at the beginning of the function and return void.
--- include/linux/page-flags.h | 4 +-- mm/folio-compat.c | 4 +-- mm/page-writeback.c | 54 ++++++++++++++++++-------------------- 3 files changed, 29 insertions(+), 33 deletions(-)
include/linux/page-flags.h +2 -2
@@ -772,8 +772,8 @@ static __always_inline void SetPageUptodate(struct page *page) CLEARPAGEFLAG(Uptodate, uptodate, PF_NO_TAIL) -bool __folio_start_writeback (struct folio *folio,bool keep_write); -bool set_page_writeback (struct page *page); +void __folio_start_writeback (struct folio *folio,bool keep_write); +void set_page_writeback (struct page *page);#define folio_start_writeback (folio) \ __folio_start_writeback(folio, false)
mm/folio-compat.c +2 -2
@@ -46,9 +46,9 @@ void mark_page_accessed(struct page *page) }EXPORT_SYMBOL (mark_page_accessed); -bool set_page_writeback (struct page *page) +void set_page_writeback (struct page *page) { -return folio_start_writeback (page_folio (page)); +folio_start_writeback (page_folio (page)); }EXPORT_SYMBOL (set_page_writeback);
mm/page-writeback.c +25 -29
92 lines not on this page · raw message
Signature · 1 line
2.42.0
Re: [PATCH 4/4] mm: Return void from folio_start_writeback() and related functions
Quoted 49 lines · Matthew Wilcox (Oracle)
Nobody now checks the return value from any of these functions, so add an assertion at the beginning of the function and return void.
Signed-off-by Matthew Wilcox (Oracle) <[email protected]>--- include/linux/page-flags.h | 4 +-- mm/folio-compat.c | 4 +-- mm/page-writeback.c | 54 ++++++++++++++++++-------------------- 3 files changed, 29 insertions(+), 33 deletions(-)include/linux/page-flags.h +2
-2@@ -772,8 +772,8 @@ static __always_inline void SetPageUptodate(struct page *page) CLEARPAGEFLAG(Uptodate, uptodate, PF_NO_TAIL) -bool __folio_start_writeback (struct folio *folio,bool keep_write); -bool set_page_writeback (struct page *page); +void __folio_start_writeback (struct folio *folio,bool keep_write); +void set_page_writeback (struct page *page);#define folio_start_writeback (folio) \ __folio_start_writeback(folio, false)mm/folio-compat.c +2
-2@@ -46,9 +46,9 @@ void mark_page_accessed(struct page *page) }EXPORT_SYMBOL (mark_page_accessed); -bool set_page_writeback (struct page *page) +void set_page_writeback (struct page *page) { -return folio_start_writeback (page_folio (page)); +folio_start_writeback (page_folio (page)); }EXPORT_SYMBOL (set_page_writeback);mm/page-writeback.c +0
-0@@ -2982,67 +2982,63 @@ bool __folio_end_writeback(struct folio *folio)return ret; }
mm/page-writeback.c bool __folio_end_writeback(struct folio *folio) · line 2992
Quoted 10 lines
mm/page-writeback.c +3
-2-bool __folio_start_writeback (struct folio *folio,bool keep_write) +void __folio_start_writeback (struct folio *folio,bool keep_write) {long nr =folio_nr_pages (folio);struct address_space *mapping =folio_mapping (folio); -bool ret;int access_ret; +VM_BUG_ON_FOLIO (folio_test_writeback (folio), folio); +
At first I was writing a response asking why it was ok to expect that folio_test_set_writeback would always return true, but then I noticed this bit. And then I went looking around and it appears that we expect the folio to be locked when we call this function, so this is indeed safe. But I'm stupid and had to go read a bunch of code to make sure this was actually safe. Could you add a comment to that effect, or add a
VM_BUG_ON_FOLIO(!folio_test_locked(folio), folio);
here as well to make it clear what we expect? Otherwise the series looks good to me, you can add
Thanks,
Josef