ext4: Add missing brelse() in add_new_gdb_meta_bg()
PATCH v2 1/2 ext4: Add missing brelse() in add_new_gdb_meta_bg()
Currently in add_new_gdb_meta_bg() there is a missing brelse of gdb_bh in case ext4_journal_get_write_access() fails.
Additionally kvfree() is missing in the same error path. Fix it by moving the ext4_journal_get_write_access() before the ext4 sb update as Ted suggested and release n_group_desc and gdb_bh in case it fails.
---
v2: Mofe ext4_journal_get_write_access() before we update ext4 sb
fs/ext4/resize.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
fs/ext4/resize.c +9 -2
@@ -932,11 +932,18 @@ static int add_new_gdb_meta_bg(struct super_block *sb,memcpy (n_group_desc, o_group_desc,EXT4_SB (sb)->s_gdb_count *sizeof (struct buffer_head *)); n_group_desc[gdb_num] = gdb_bh; + +BUFFER_TRACE (gdb_bh,"get_write_access" ); + err =ext4_journal_get_write_access (handle, gdb_bh); +if (err) { +kvfree (n_group_desc); +brelse (gdb_bh); +return err; + } +EXT4_SB (sb)->s_group_desc = n_group_desc;EXT4_SB (sb)->s_gdb_count++;kvfree (o_group_desc); -BUFFER_TRACE (gdb_bh,"get_write_access" ); - err =ext4_journal_get_write_access (handle, gdb_bh);return err; }
Signature · 1 line
2.20.1
PATCH v2 2/2 ext4: Report real fs size after failed resize
Currently when the file system resize using ext4_resize_fs() fails it will report into log that "resized filesystem to <requested block count>". However this may not be true in the case of failure. Use the current block count as returned by ext4_blocks_count() to report the block count.
Additionally report to log that "error occurred during file system resize"
---
v2: this is actually the first version
fs/ext4/resize.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/ext4/resize.c +4 -1
@@ -2079,6 +2079,9 @@ int ext4_resize_fs(struct super_block *sb, ext4_fsblk_t n_blocks_count)free_flex_gd (flex_gd);if (resize_inode !=NULL )iput (resize_inode); -ext4_msg (sb,KERN_INFO ,"resized filesystem to %llu" , n_blocks_count); +if (err) +ext4_warning (sb,"error occurred during file system resize" ); +ext4_msg (sb,KERN_INFO ,"resized filesystem to %llu" , +ext4_blocks_count (es));return err; }
Signature · 1 line
2.20.1
Re: [PATCH v2 2/2] ext4: Report real fs size after failed resize
Quoted 9 lines · Lukas Czerner
Currently when the file system resize using
ext4_resize_fs()fails it will report into log that "resized filesystem to <requested block count>". However this may not be true in the case of failure. Use the current block count as returned byext4_blocks_count()to report the block count.
Additionally report to log that "error occurred during file system resize"Signed-off-by Lukas Czerner <[email protected]>
Thanks, applied with one minor change. In call to ext4_warning(), I changed it to include error code so the warning message will be more useful:
fs/ext4/resize.c int ext4_resize_fs(struct super_block *sb, ext4_fsblk_t n_blocks_count) · line 2083
Quoted 2 lines
fs/ext4/resize.c +2
-0+if (err) +ext4_warning (sb,"error occurred during file system resize" );
is now
+ if (err)
+ ext4_warning(sb, "error (%d) occurred during "
+ "file system resize", err);
- Ted
Re: [PATCH v2 2/2] ext4: Report real fs size after failed resize
Quoted 20 lines · Theodore Ts'o
Quoted 9 lines · Lukas Czerner
Currently when the file system resize using
ext4_resize_fs()fails it will report into log that "resized filesystem to <requested block count>". However this may not be true in the case of failure. Use the current block count as returned byext4_blocks_count()to report the block count.
Additionally report to log that "error occurred during file system resize"Signed-off-by Lukas Czerner <[email protected]>Thanks, applied with one minor change. In call to
ext4_warning(), I changed it to include error code so the warning message will be more useful:fs/ext4/resize.c int ext4_resize_fs(struct super_block *sb, ext4_fsblk_t n_blocks_count) · line 2083
Quoted 2 lines
fs/ext4/resize.c +2
-0+if (err) +ext4_warning (sb,"error occurred during file system resize" );is now
Review
Quoted 3 lines
(quoted diff) +3
-0+ if (err) + ext4_warning(sb, "error (%d) occurred during " + "file system resize", err);
Yeah, that's better.
Thanks!
-Lukas
Quoted 2 lines
- Ted
Quoted 8 lines · Lukas Czerner
Currently in
add_new_gdb_meta_bg()there is a missing brelse ofgdb_bhin caseext4_journal_get_write_access()fails.
Additionallykvfree()is missing in the same error path. Fix it by moving theext4_journal_get_write_access()before the ext4 sb update as Ted suggested and releasen_group_descandgdb_bhin case it fails.Fixes 61a9c11e5e7a ("ext4: add missing brelse() add_new_gdb_meta_bg()'s error path")Signed-off-by Lukas Czerner <[email protected]>
Thanks, applied.
- Ted