Re: [PATCH] block: fix inconsistent page index

From: Francesco Ruggeri
Date: Sun Feb 24 2019 - 23:17:24 EST


On Thu, Feb 21, 2019 at 11:27 AM Francesco Ruggeri <fruggeri@xxxxxxxxxx> wrote:
>
> __find_get_block_slow() and grow_buffers() use different methods to compute
> a page index for a given block: __find_get_block_slow() computes it from
> bd_inode->i_blkbits, while grow_buffers() computes it from the block size
> argument.
> The two can get out of sync, for example if bd_inode->i_blkbits is modified
> while a isofs_fill_super() (in mount) is between sb_min_blocksize() and
> sb_read/__bread_gfp/__getblk_gfp/__getblk_slow.
> The script below can reproduce such a scenario, resulting in an infinite
> loop in __getblk_slow(), as grow_buffers() allocates a page but
> __find_get_block() keeps looking for a different one.
> This patch changes __find_get_block_slow() to also use the block size.
> It implicitly relies on size being a power of 2 in the 256..PAGE_SIZE
> range.
>

Any comments?

Thanks,
Francesco Ruggeri