2024-01-17 11:56:11

by yangerkun

[permalink] [raw]
Subject: [PATCH 2/2] ext4: distinguish different error in ext4_mb_seq_groups_show

While cat mb_groups for a mounted ext4 image which has some corrupted
group, the string return to userspace was just "I/O error" which confuse
me a lot. Use ext4_decode_error to help distinguish different error.

Signed-off-by: yangerkun <[email protected]>
---
fs/ext4/mballoc.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 139f232bdbb5..77d6113e2822 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -2991,6 +2991,7 @@ static int ext4_mb_seq_groups_show(struct seq_file *seq, void *v)
struct super_block *sb = pde_data(file_inode(seq->file));
ext4_group_t group = (ext4_group_t) ((unsigned long) v);
int i, err;
+ char nbuf[16];
struct ext4_buddy e4b;
struct ext4_group_info *grinfo;
unsigned char blocksize_bits = min_t(unsigned char,
@@ -3017,7 +3018,7 @@ static int ext4_mb_seq_groups_show(struct seq_file *seq, void *v)
if (unlikely(EXT4_MB_GRP_NEED_INIT(grinfo))) {
err = ext4_mb_load_buddy(sb, group, &e4b);
if (err) {
- seq_printf(seq, "#%-5u: I/O error\n", group);
+ seq_printf(seq, "#%-5u: %s\n", group, ext4_decode_error(NULL, err, nbuf));
return 0;
}
ext4_mb_unload_buddy(&e4b);
--
2.39.2



2024-01-17 12:58:34

by Jan Kara

[permalink] [raw]
Subject: Re: [PATCH 2/2] ext4: distinguish different error in ext4_mb_seq_groups_show

On Wed 17-01-24 19:52:23, yangerkun wrote:
> While cat mb_groups for a mounted ext4 image which has some corrupted
> group, the string return to userspace was just "I/O error" which confuse
> me a lot. Use ext4_decode_error to help distinguish different error.
>
> Signed-off-by: yangerkun <[email protected]>

I guess this is an improvement :). Feel free to add:

Reviewed-by: Jan Kara <[email protected]>

Honza

> ---
> fs/ext4/mballoc.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
> index 139f232bdbb5..77d6113e2822 100644
> --- a/fs/ext4/mballoc.c
> +++ b/fs/ext4/mballoc.c
> @@ -2991,6 +2991,7 @@ static int ext4_mb_seq_groups_show(struct seq_file *seq, void *v)
> struct super_block *sb = pde_data(file_inode(seq->file));
> ext4_group_t group = (ext4_group_t) ((unsigned long) v);
> int i, err;
> + char nbuf[16];
> struct ext4_buddy e4b;
> struct ext4_group_info *grinfo;
> unsigned char blocksize_bits = min_t(unsigned char,
> @@ -3017,7 +3018,7 @@ static int ext4_mb_seq_groups_show(struct seq_file *seq, void *v)
> if (unlikely(EXT4_MB_GRP_NEED_INIT(grinfo))) {
> err = ext4_mb_load_buddy(sb, group, &e4b);
> if (err) {
> - seq_printf(seq, "#%-5u: I/O error\n", group);
> + seq_printf(seq, "#%-5u: %s\n", group, ext4_decode_error(NULL, err, nbuf));
> return 0;
> }
> ext4_mb_unload_buddy(&e4b);
> --
> 2.39.2
>
--
Jan Kara <[email protected]>
SUSE Labs, CR