[2/2] ext2: dump current reservation window info before BUG

Message ID 20230811033857.1800578-3-yebin10@huawei.com
State New
Headers
Series fix race between setxattr and write back |

Commit Message

Ye Bin Aug. 11, 2023, 3:38 a.m. UTC
  There's report BUG in 'ext2_try_to_allocate_with_rsv()', although there's
now dump of all reservation windows information. But there's unknown which
window is being processed.So this is not helpful for locating the issue.
To better analyze the problem, dump the information about reservation window
that is being processed.

Signed-off-by: Ye Bin <yebin10@huawei.com>
---
 fs/ext2/balloc.c | 5 +++++
 1 file changed, 5 insertions(+)
  

Comments

Jan Kara Aug. 14, 2023, 1:08 p.m. UTC | #1
On Fri 11-08-23 11:38:57, Ye Bin wrote:
> There's report BUG in 'ext2_try_to_allocate_with_rsv()', although there's
> now dump of all reservation windows information. But there's unknown which
> window is being processed.So this is not helpful for locating the issue.
> To better analyze the problem, dump the information about reservation window
> that is being processed.
> 
> Signed-off-by: Ye Bin <yebin10@huawei.com>
> ---
>  fs/ext2/balloc.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
> index 039f655febfd..0132b8af546e 100644
> --- a/fs/ext2/balloc.c
> +++ b/fs/ext2/balloc.c
> @@ -1131,6 +1131,11 @@ ext2_try_to_allocate_with_rsv(struct super_block *sb, unsigned int group,
>  
>  		if ((my_rsv->rsv_start > group_last_block) ||
>  				(my_rsv->rsv_end < group_first_block)) {
> +			ext2_error(sb, __func__,
> +				   "Out of group %u range goal %d fsb[%lu,%lu] rsv[%lu, %lu]",
                                   ^^^ "Reservation out of group ...."

> +				   group, grp_goal, group_first_block,
> +				   group_last_block, my_rsv->rsv_start,
> +				   my_rsv->rsv_end);
>  			rsv_window_dump(&EXT2_SB(sb)->s_rsv_window_root, 1);
>  			BUG();
>  		}

And we could just bail with error instead of BUG here when we are already
changing the code...

								Honza
  

Patch

diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
index 039f655febfd..0132b8af546e 100644
--- a/fs/ext2/balloc.c
+++ b/fs/ext2/balloc.c
@@ -1131,6 +1131,11 @@  ext2_try_to_allocate_with_rsv(struct super_block *sb, unsigned int group,
 
 		if ((my_rsv->rsv_start > group_last_block) ||
 				(my_rsv->rsv_end < group_first_block)) {
+			ext2_error(sb, __func__,
+				   "Out of group %u range goal %d fsb[%lu,%lu] rsv[%lu, %lu]",
+				   group, grp_goal, group_first_block,
+				   group_last_block, my_rsv->rsv_start,
+				   my_rsv->rsv_end);
 			rsv_window_dump(&EXT2_SB(sb)->s_rsv_window_root, 1);
 			BUG();
 		}