[U-Boot] [PATCH v3 09/13] ext4: After completely filled group, scan next group from the beginning

Lukasz Majewski l.majewski at samsung.com
Mon Aug 29 16:06:29 CEST 2016


Hi Stefan,

> The last free block of a block group may be in its middle. After it
> has been allocated, the next block group should be scanned from its
> beginning.
> 
> The following command triggers the bad behaviour (on a blocksize 1024
> fs):
> 
> ./sandbox/u-boot -c 'i=0; host bind 0 ./disk.raw ;
> 	while test $i -lt 260 ; do echo $i; setexpr i $i + 1;
> 		ext4write host 0:2 0 /X${i} 0x1450; done ;
> 	ext4write host 0:2 0 /X240 0x2000 ; '
> 
> When 'X240' is extended from 5200 byte to 8192 byte, the new blocks
> should start from the first free block (8811), but it uses the blocks
> 8098-8103 and 16296-16297 -- 8103 + 1 + 8192 = 16296. This can be
> shown with debugfs, commands 'ffb' and 'stat X240'.
> 
> Signed-off-by: Stefan Brüns <stefan.bruens at rwth-aachen.de>
> ---
>  fs/ext4/ext4_common.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> v3: Patch added to series
> 
> diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c
> index 1ebdbe6..362668b 100644
> --- a/fs/ext4/ext4_common.c
> +++ b/fs/ext4/ext4_common.c
> @@ -895,8 +895,8 @@ uint32_t ext4fs_get_new_blk_no(void)
>  
>  		goto fail;
>  	} else {
> -restart:
>  		fs->curr_blkno++;
> +restart:
>  		/* get the blockbitmap index respective to blockno */
>  		bg_idx = fs->curr_blkno / blk_per_grp;
>  		if (fs->blksz == 1024) {
> @@ -914,8 +914,9 @@ restart:
>  
>  		if (bgd[bg_idx].free_blocks == 0) {
>  			debug("block group %u is full. Skipping\n",
> bg_idx);
> -			fs->curr_blkno = fs->curr_blkno +
> blk_per_grp;
> -			fs->curr_blkno--;
> +			fs->curr_blkno = (bg_idx + 1) * blk_per_grp;
> +			if (fs->blksz == 1024)
> +				fs->curr_blkno += 1;
>  			goto restart;
>  		}
>  
> @@ -932,6 +933,7 @@ restart:
>  				   bg_idx) != 0) {
>  			debug("going for restart for the block no
> %ld %u\n", fs->curr_blkno, bg_idx);
> +			fs->curr_blkno++;
>  			goto restart;
>  		}
>  

Reviewed-by: Lukasz Majewski <l.majewski at samsung.com> 

-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group


More information about the U-Boot mailing list