Re: [PATCH] ext4: When reading from fallocated blocks make sure we return zero.

Aneesh Kumar K.V
2008-02-16T03:23:42Z

On Fri, Feb 15, 2008 at 11:43:04AM -0800, Mingming Cao wrote:
> On Fri, 2008-02-15 at 23:46 +0530, Aneesh Kumar K.V wrote:
> > fallocate blocks are considered as sparse area and read from them should
> > return zero. ext4_ext_get_blocks should return zero for read request.
> >
>
> The patch itself looks harmless, but I still don't see how this could
> fix the problem you described at irc: a write hit a BUG_ON() in
> fs/buffer.c saying the buffer is not mapped. Could you add more details
> here?

Write will take the below call chain

ext4_write_begin
block_write_begin
__block_prepare_write
ext4_getblock
ext4_get_blocks_wrap
(1) ext4_ext_get_blocks with create = 0 return allocated
ll_rw_block if buffer not uptodate.
submit_bh
BUG_ON(!buffer_mapped(bh))

ext4_ext_get_blocks at (1) should have returned 0. That would cause
ext4_get_blocks_wrap to again call ext4_ext_get_blocks with create = 1
and that would have returned us the buffer head which is mapped. This
would also result in splitting the extent to initialized and
uninitialized one.

-aneesh