Patch "ext4: handle the rest of ext4_mb_load_buddy() ENOMEM errors" has been added to the 4.4-stable tree
Subsystems (2)
This is a note to let you know that I've just added the patch titled
ext4: handle the rest of ext4_mb_load_buddy() ENOMEM errors
to the 4.4-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
ext4-handle-the-rest-of-ext4_mb_load_buddy-enomem-errors.patch
and it can be found in the queue-4.4 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From foo@baz Tue Apr 10 10:31:53 CEST 2018
From: Konstantin Khlebnikov <[email protected]>
Date: Sun, 21 May 2017 22:35:23 -0400
Subject: ext4: handle the rest of ext4_mb_load_buddy() ENOMEM errors
From: Konstantin Khlebnikov <[email protected]>
[ Upstream commit 9651e6b2e20648d04d5e1fe6479a3056047e8781 ]
I've got another report about breaking ext4 by ENOMEM error returned from ext4_mb_load_buddy() caused by memory shortage in memory cgroup. This time inside ext4_discard_preallocations().
This patch replaces ext4_error() with ext4_warning() where errors returned from ext4_mb_load_buddy() are not fatal and handled by caller:
* ext4_mb_discard_group_preallocations() - called before generating ENOSPC, we'll try to discard other group or return ENOSPC into user-space.
* ext4_trim_all_free() - just stop trimming and return ENOMEM from ioctl.
Some callers cannot handle errors, thus __GFP_NOFAIL is used for them:
* ext4_discard_preallocations()
* ext4_mb_discard_lg_preallocations()
--- fs/ext4/mballoc.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-)
fs/ext4/mballoc.c +14 -9
@@ -3874,7 +3874,8 @@ ext4_mb_discard_group_preallocations(str err =ext4_mb_load_buddy (sb, group, &e4b);if (err) { -ext4_error (sb,"Error loading buddy information for %u" , group); +ext4_warning (sb,"Error %d loading buddy information for %u" , + err, group);put_bh (bitmap_bh);return 0 ; }
@@ -4031,10 +4032,11 @@ repeat:BUG_ON (pa->pa_type !=MB_INODE_PA ); group =ext4_get_group_number (sb, pa->pa_pstart); - err =ext4_mb_load_buddy (sb, group, &e4b); + err =ext4_mb_load_buddy_gfp (sb, group, &e4b, +GFP_NOFS |__GFP_NOFAIL);if (err) { -ext4_error (sb,"Error loading buddy information for %u" , - group); +ext4_error (sb,"Error %d loading buddy information for %u" , + err, group);continue ; }
@@ -4290,11 +4292,14 @@ ext4_mb_discard_lg_preallocations(structspin_unlock (&lg->lg_prealloc_lock);list_for_each_entry_safe (pa, tmp, &discard_list, u.pa_tmp_list) { +int err; group =ext4_get_group_number (sb, pa->pa_pstart); -if (ext4_mb_load_buddy (sb, group, &e4b)) { -ext4_error (sb,"Error loading buddy information for %u" , - group); + err =ext4_mb_load_buddy_gfp (sb, group, &e4b, +GFP_NOFS |__GFP_NOFAIL); +if (err) { +ext4_error (sb,"Error %d loading buddy information for %u" , + err, group);continue ; }ext4_lock_group (sb, group);
@@ -5116,8 +5121,8 @@ ext4_trim_all_free(struct super_block *s ret =ext4_mb_load_buddy (sb, group, &e4b);if (ret) { -ext4_error (sb,"Error in loading buddy " -"information for %u" , group); +ext4_warning (sb,"Error %d loading buddy information for %u" , + ret, group);return ret; } bitmap = e4b.bd_bitmap;
Patches currently in stable-queue which might be from [email protected] are
queue-4.4/ext4-handle-the-rest-of-ext4_mb_load_buddy-enomem-errors.patch