From: Marcelo Tosatti <marcelo@conectiva.com.br>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: lkml <linux-kernel@vger.kernel.org>
Subject: [PATCH] exclusive wakeup for lock_buffer
Date: Mon, 19 Feb 2001 22:03:33 -0200 (BRST) [thread overview]
Message-ID: <Pine.LNX.4.21.0102192156330.3008-100000@freak.distro.conectiva> (raw)
Hi,
The following patch makes lock_buffer() use the exclusive wakeup scheme
added in 2.3.
Against 2.4.2pre4.
--- linux/fs/buffer.c.orig Mon Feb 19 23:13:08 2001
+++ linux/fs/buffer.c Mon Feb 19 23:16:26 2001
@@ -142,13 +142,18 @@
* if 'b_wait' is set before calling this, so that the queues aren't set
* up unnecessarily.
*/
-void __wait_on_buffer(struct buffer_head * bh)
+void __wait_on_buffer(struct buffer_head * bh, int exclusive)
{
struct task_struct *tsk = current;
DECLARE_WAITQUEUE(wait, tsk);
atomic_inc(&bh->b_count);
- add_wait_queue(&bh->b_wait, &wait);
+
+ if (exclusive)
+ add_wait_queue_exclusive(&bh->b_wait, &wait);
+ else
+ add_wait_queue(&bh->b_wait, &wait);
+
do {
run_task_queue(&tq_disk);
set_task_state(tsk, TASK_UNINTERRUPTIBLE);
@@ -2332,7 +2337,7 @@
tmp = tmp->b_this_page;
if (buffer_locked(p)) {
if (wait > 1)
- __wait_on_buffer(p);
+ __wait_on_buffer(p, 0);
} else if (buffer_dirty(p))
ll_rw_block(WRITE, 1, &p);
} while (tmp != bh);
--- linux/include/linux/locks.h.orig Mon Feb 19 23:21:10 2001
+++ linux/include/linux/locks.h Mon Feb 19 23:17:42 2001
@@ -12,18 +12,18 @@
* Buffer cache locking - note that interrupts may only unlock, not
* lock buffers.
*/
-extern void __wait_on_buffer(struct buffer_head *);
+extern void __wait_on_buffer(struct buffer_head *, int);
extern inline void wait_on_buffer(struct buffer_head * bh)
{
if (test_bit(BH_Lock, &bh->b_state))
- __wait_on_buffer(bh);
+ __wait_on_buffer(bh, 0);
}
extern inline void lock_buffer(struct buffer_head * bh)
{
while (test_and_set_bit(BH_Lock, &bh->b_state))
- __wait_on_buffer(bh);
+ __wait_on_buffer(bh, 1);
}
extern inline void unlock_buffer(struct buffer_head *bh)
next reply other threads:[~2001-02-20 1:52 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-02-20 0:03 Marcelo Tosatti [this message]
2001-02-20 2:00 ` [PATCH] exclusive wakeup for lock_buffer Linus Torvalds
2001-02-20 0:51 ` Marcelo Tosatti
2001-02-20 3:12 ` Alan Cox
2001-02-19 19:28 ` John Heil
2001-02-20 20:30 ` Marcelo Tosatti
2001-02-20 22:33 ` Alan Cox
2001-02-21 3:09 ` Ulf Carlsson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.21.0102192156330.3008-100000@freak.distro.conectiva \
--to=marcelo@conectiva.com.br \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@transmeta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).