2005-09-28 09:50:12

by lk

[permalink] [raw]
Subject: alloc_page_buffers() - kernel panic?

I was looking at the fs(buffer.c) code, An observation:

alloc_page_buffers() is called from the function create_empty_buffers() . If
the memory allocation for the buffer head (through kmem_cache_alloc) fails
the allocation is retried till successful for async I/O. However for
synchronous I/O no such handling is done and create_buffer will return
NULL which is not checked in the calling function. The pointer returned by
NULL
is used without checking for the NULL condition. This would result in a
kernel panic when alloc_page_buffers() is not able to allocate buffer heads
from the cache for sync I/O.


Is anyone aware of the thought process behind this difference in
implementation for sync and async I/O.

regards
lk



2005-09-28 10:32:53

by Fawad Lateef

[permalink] [raw]
Subject: Re: alloc_page_buffers() - kernel panic?

On 9/28/05, lk <[email protected]> wrote:
> I was looking at the fs(buffer.c) code, An observation:
>
> alloc_page_buffers() is called from the function create_empty_buffers() . If
> the memory allocation for the buffer head (through kmem_cache_alloc) fails
> the allocation is retried till successful for async I/O. However for
> synchronous I/O no such handling is done and create_buffer will return
> NULL which is not checked in the calling function. The pointer returned by
> NULL
> is used without checking for the NULL condition. This would result in a
> kernel panic when alloc_page_buffers() is not able to allocate buffer heads
> from the cache for sync I/O.
>

I think you overlooked alloc_page_buffers call from
create_empty_buffers .... It is called with third argument as 1 and it
is the retry argument in alloc_page_buffers function which checks
if(!retry) return NULL; so it will never return NULL if retry is 1
..........

> Is anyone aware of the thought process behind this difference in
> implementation for sync and async I/O.
>

what kind of difference ?? If its allocation of page buffers then
async IOs are not allowed to fail so it waits to allocate
memory/buffers for it ....


--
Fawad Lateef