Re: patch for 2.1.71 buffer.c

Dr. Werner Fink (werner@suse.de)
Wed, 10 Dec 1997 12:06:24 +0100


> Following a suggestion from Gadi Oxman, the attached patch adds a test
> to avoid waiting on loop-device buffers in refill_freelist. Loop buffers
> are locked before the required buffer resources are obtained, so this
> test will avoid a deadlock if the kflushd enters refill_freelist.

One simple patch more for fs/buffer.c ... this one should avoid a possible
race seen in 2.0.32 and should give also a minor performance win.
And one question: With your protection against the deadlock of
the loop device we may have the problem of using our reserved pages ... not
only in refill_freelist but also in get_unused_buffer_head.
The last function calls kmem_cache_alloc(bh_cachep, SLAB_ATOMIC) which
may causes problem due a high fragmentation of free memory.

Werner

Against 2.1.72
-------------------------------------------------------------------------
--- fs/buffer.c~1 Wed Dec 10 11:49:32 1997
+++ fs/buffer.c Wed Dec 10 11:58:08 1997
@@ -1299,8 +1299,9 @@
*/
add_wait_queue(&buffer_wait, &wait);
current->state = TASK_UNINTERRUPTIBLE;
+ if (!unused_list && !reuse_list)
+ schedule();
recover_reusable_buffer_heads();
- schedule();
remove_wait_queue(&buffer_wait, &wait);
current->state = TASK_RUNNING;
goto try_again;
@@ -1473,14 +1474,16 @@
* and unlock_buffer(). */
} else {
unsigned long flags;
- clear_bit(PG_locked, &page->flags);
- set_bit(PG_uptodate, &page->flags);
- wake_up(&page->wait);
save_flags(flags);
cli();
free_async_buffers(bh);
restore_flags(flags);
+ clear_bit(PG_locked, &page->flags);
+ set_bit(PG_uptodate, &page->flags);
+ wake_up(&page->wait);
after_unlock_page(page);
+ if (waitqueue_active(&buffer_wait))
+ wake_up(&buffer_wait);
}
++current->maj_flt;
return 0;