fs: drop GFP_NOFAIL mode from alloc_page_buffers
PATCH 1/1 fs: drop GFP_NOFAIL mode from alloc_page_buffers
From: Michal Hocko <[email protected]>
There is only one called of alloc_page_buffers and it doesn't require __GFP_NOFAIL so drop this allocation mode.
--- drivers/md/md-bitmap.c | 2 +- fs/buffer.c | 5 +---- include/linux/buffer_head.h | 3 +-- 3 files changed, 3 insertions(+), 7 deletions(-)
while looking at GFP_NOFAIL users I have encountered this left over.
drivers/md/md-bitmap.c +1 -1
@@ -360,7 +360,7 @@ static int read_file_page(struct file *file, unsigned long index,pr_debug ("read bitmap file (%dB @ %llu)\n" , (int )PAGE_SIZE , (unsigned long long )index <<PAGE_SHIFT ); - bh =alloc_page_buffers (page, blocksize, false); + bh =alloc_page_buffers (page, blocksize);if (!bh) { ret = -ENOMEM ; goto out;
fs/buffer.c +1 -4
@@ -958,12 +958,9 @@ struct buffer_head *folio_alloc_buffers(struct folio *folio, unsigned long size, }EXPORT_SYMBOL_GPL (folio_alloc_buffers); -struct buffer_head *alloc_page_buffers (struct page *page,unsigned long size, -bool retry) +struct buffer_head *alloc_page_buffers (struct page *page,unsigned long size) {gfp_t gfp =GFP_NOFS | __GFP_ACCOUNT; -if (retry) - gfp |= __GFP_NOFAIL;return folio_alloc_buffers (page_folio (page), size, gfp); }
include/linux/buffer_head.h +1 -2
@@ -199,8 +199,7 @@ void folio_set_bh(struct buffer_head *bh, struct folio *folio, unsigned long offset);struct buffer_head *folio_alloc_buffers (struct folio *folio,unsigned long size,gfp_t gfp); -struct buffer_head *alloc_page_buffers (struct page *page,unsigned long size, -bool retry); +struct buffer_head *alloc_page_buffers (struct page *page,unsigned long size);struct buffer_head *create_empty_buffers (struct folio *folio,unsigned long blocksize,unsigned long b_state);void end_buffer_read_sync (struct buffer_head *bh,int uptodate);
Signature · 1 line
2.46.0
Quoted 7 lines · Michal Hocko
From: Michal Hocko <[email protected]>
There is only one called of
alloc_page_buffersand it doesn't require__GFP_NOFAILso drop this allocation mode.Signed-off-by Michal Hocko <[email protected]>
Thanks for the cleanup!
I guess we will take this via the fs tree. So
Quoted 6 lines · Michal Hocko
From: Michal Hocko <[email protected]>
There is only one called of
alloc_page_buffersand it doesn't require__GFP_NOFAILso drop this allocation mode.Signed-off-by Michal Hocko <[email protected]>
Looks good. Feel free to add:
Although even better fix would be to convert the last remaining caller of alloc_page_buffers() to folio_alloc_buffers()... But that may be more difficult.
Honza
Quoted 56 lines
--- drivers/md/md-bitmap.c | 2 +- fs/buffer.c | 5 +---- include/linux/buffer_head.h | 3 +-- 3 files changed, 3 insertions(+), 7 deletions(-)while looking at
GFP_NOFAILusers I have encountered this left over.drivers/md/md-bitmap.c +1
-1@@ -360,7 +360,7 @@ static int read_file_page(struct file *file, unsigned long index,pr_debug ("read bitmap file (%dB @ %llu)\n" , (int )PAGE_SIZE , (unsigned long long )index <<PAGE_SHIFT ); - bh =alloc_page_buffers (page, blocksize, false); + bh =alloc_page_buffers (page, blocksize);if (!bh) { ret = -ENOMEM ; goto out;fs/buffer.c +1
-4@@ -958,12 +958,9 @@ struct buffer_head *folio_alloc_buffers(struct folio *folio, unsigned long size, }EXPORT_SYMBOL_GPL (folio_alloc_buffers); -struct buffer_head *alloc_page_buffers (struct page *page,unsigned long size, -bool retry) +struct buffer_head *alloc_page_buffers (struct page *page,unsigned long size) {gfp_t gfp =GFP_NOFS | __GFP_ACCOUNT; -if (retry) - gfp |= __GFP_NOFAIL;return folio_alloc_buffers (page_folio (page), size, gfp); }include/linux/buffer_head.h +1
-2@@ -199,8 +199,7 @@ void folio_set_bh(struct buffer_head *bh, struct folio *folio, unsigned long offset);struct buffer_head *folio_alloc_buffers (struct folio *folio,unsigned long size,gfp_t gfp); -struct buffer_head *alloc_page_buffers (struct page *page,unsigned long size, -bool retry); +struct buffer_head *alloc_page_buffers (struct page *page,unsigned long size);struct buffer_head *create_empty_buffers (struct folio *folio,unsigned long blocksize,unsigned long b_state);void end_buffer_read_sync (struct buffer_head *bh,int uptodate);Signature · 1 line
2.46.0
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Quoted 8 lines · Jan Kara
Quoted 6 lines · Michal Hocko
From: Michal Hocko <[email protected]>
There is only one called of
alloc_page_buffersand it doesn't require__GFP_NOFAILso drop this allocation mode.Signed-off-by Michal Hocko <[email protected]>
Quoted 8 lines
Looks good. Feel free to add:
Reviewed-by Jan Kara <[email protected]>Although even better fix would be to convert the last remaining caller of
alloc_page_buffers()tofolio_alloc_buffers()... But that may be more difficult.
Already done by Pankajs large-block patchset, currently staged in vfs.git.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Quoted 11 lines · Hannes Reinecke
Quoted 10 lines · Jan Kara
Quoted 6 lines · Michal Hocko
From: Michal Hocko <[email protected]>
There is only one called of
alloc_page_buffersand it doesn't require__GFP_NOFAILso drop this allocation mode.Signed-off-by Michal Hocko <[email protected]>Looks good. Feel free to add:
Quoted 7 lines
Quoted 6 lines
Reviewed-by Jan Kara <[email protected]>Although even better fix would be to convert the last remaining caller of
alloc_page_buffers()tofolio_alloc_buffers()... But that may be more difficult.Already done by Pankajs large-block patchset, currently staged in vfs.git.
Which branch should I be looking at?
Signature · 2 lines
Michal Hocko SUSE Labs
Christian Brauner
maintainerQuoted 14 lines · Michal Hocko
Quoted 13 lines · Hannes Reinecke
Quoted 12 lines · Jan Kara
Quoted 6 lines · Michal Hocko
From: Michal Hocko <[email protected]>
There is only one called of
alloc_page_buffersand it doesn't require__GFP_NOFAILso drop this allocation mode.Signed-off-by Michal Hocko <[email protected]>Looks good. Feel free to add:
Reviewed-by Jan Kara <[email protected]>
Quoted 7 lines
Quoted 5 lines
Quoted 4 lines
Although even better fix would be to convert the last remaining caller of
alloc_page_buffers()tofolio_alloc_buffers()... But that may be more difficult.Already done by Pankajs large-block patchset, currently staged in vfs.git.
Which branch should I be looking at?
Hi Michal, Hannes should be referring to:
https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git/log/?h=vfs.blocksize
Quoted 19 lines · Christian Brauner
Quoted 18 lines · Michal Hocko
Quoted 17 lines · Hannes Reinecke
Quoted 16 lines · Jan Kara
Quoted 6 lines · Michal Hocko
From: Michal Hocko <[email protected]>
There is only one called of
alloc_page_buffersand it doesn't require__GFP_NOFAILso drop this allocation mode.Signed-off-by Michal Hocko <[email protected]>Looks good. Feel free to add:
Reviewed-by Jan Kara <[email protected]>Although even better fix would be to convert the last remaining caller of
alloc_page_buffers()tofolio_alloc_buffers()... But that may be more difficult.
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Already done by Pankajs large-block patchset, currently staged in vfs.git.
Which branch should I be looking at?
Hi Michal, Hannes should be referring to:
https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git/log/?h=vfs.blocksize
OK, but that branch seems to still have alloc_page_buffers user. Maybe I am just misunderstanding what am I supposed to do here. Anyway, I won't have much time to spend refactoring this so if there are more changes required then I will likely not get to that. Sorry.
Signature · 2 lines
Michal Hocko SUSE Labs
Quoted 4 lines · Michal Hocko
There is only one called of
alloc_page_buffersand it doesn't require__GFP_NOFAILso drop this allocation mode.
Applied to the vfs.misc branch of the vfs/vfs.git tree. Patches in the vfs.misc 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.misc
[1/1] fs: drop GFP_NOFAIL mode from alloc_page_buffers
https://git.kernel.org/vfs/vfs/c/bf72320f8348