Messages in this thread | | | Date | Sat, 26 Jul 1997 07:40:28 -0400 | From | Bill Hawes <> | Subject | Re: patch for fs/buffer.c get_unused_buffer_head |
| |
Colin Plumb wrote: > The problem is that create_buffers is called for a page worth of > buffers (up to 16, if the file system has a 512 byte block and this > is an Alpha with 8K pages), and if two processes each grab half of > the reserved list and hen block waiting for more to become available > so they can satisfy their quota, we have deadlock.
For the general case the reserve list should have enough buffer heads to satisfy several paging requests. Originally I was going to use
#define NR_RESERVE 3*PAGE_SIZE/BLOCK_SIZE
but might want instead to set reserve count dynamically. Perhaps determine the worst case (smallest block size) of any device, and guarantee some number of paging requests for that device?
> - Have create_buffers try for all the buffers it needs, and if it doesn't > get them all, put them all back and go to sleep on &buffer_wait until > more come available. > > The latter is probably easier. It takes the sleep out of > get_unused_buffer_head and moves it into create_buffers.
Moving the sleep into create_buffers when building an async request would work, and might be better if you have a wide mix of block sizes. (create_buffers is the only client of get_more_buffer_heads, so it shouldn't matter where the sleep occurs.) But this would involve tearing down partially built buffers. I'll give this some further thought.
> (I'm a little unclear on the locking here - is there any risk that > the lists will get refreshed before the sleep_on?)
Wake-up can come following calls to free_async_buffers or from any call to put_unused_buffer_head, but it might be worthwhile to build a special wait_on_xxx function for this case.
Thanks for your helpful comments!
Regards, Bill
| |