From: Zoltan Menyhart <Zoltan.Menyhart@bull.net>
To: Jan Kara <jack@suse.cz>
Cc: "Stephen C. Tweedie" <sct@redhat.com>,
linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] Change ll_rw_block() calls in JBD
Date: Tue, 30 May 2006 17:36:13 +0200 [thread overview]
Message-ID: <447C666D.5030003@bull.net> (raw)
In-Reply-To: <20060524173314.GB28568@atrey.karlin.mff.cuni.cz>
I have got a concern about this code fragment:
> + if (buffer_dirty(bh)) {
> + if (test_set_buffer_locked(bh)) {
> + ...
> + get_bh(bh);
> + spin_unlock(&journal->j_list_lock);
> + /* Submit all accumulated buffers to prevent
> + * possible deadlocks */
> + submit_buffers(bufs, wbuf);
> + bufs = 0;
> + lock_buffer(bh);
> + spin_lock(&journal->j_list_lock);
> + /* Someone already cleaned up the buffer? */
> + if (!buffer_jbd(bh)
> + || jh->b_jlist != BJ_SyncData) {
> + unlock_buffer(bh);
> + BUFFER_TRACE(bh, "already cleaned up");
> + put_bh(bh);
> + continue;
> + }
> + put_bh(bh);
> + }
> + if (test_clear_buffer_dirty(bh)) {
> + BUFFER_TRACE(bh, "needs writeout, submitting");
> + get_bh(bh);
> + wbuf[bufs++] = bh;
> + if (bufs == journal->j_wbufsize) {
> + spin_unlock(&journal->j_list_lock);
> + /* Writeout will be done at the
> + * beginning of the loop */
> + goto write_out_data;
> + }
> + }
We lock up to "->j_wbufsize" buffers, one after the others.
Originally, we toke a buffer, we did something to it, and we released it.
When we wanted two of them and the second one was not available, we
released the first one, too, in order to avoid dead-locks.
Keeping a couple of buffer locked for an unpredictably long time...
(Here you keep N-1 buffer locked while you are waiting for the Nth one.)
And not imposing / respecting any locking order...
The original code did not lock the buffers while it was composing the
list of buffers. "ll_rw_block()" locked one by one the buffers
and submitted them to the BIO. These buffers got eventually unlocked,
possibly before the some last buffers got locked by "ll_rw_block()".
This change implies an important difference in locking behavior.
Regards,
Zoltan
next prev parent reply other threads:[~2006-05-30 15:36 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-05-18 8:25 [PATCH] Change ll_rw_block() calls in JBD Zoltan Menyhart
2006-05-18 13:45 ` Jan Kara
2006-05-18 15:11 ` Zoltan Menyhart
2006-05-18 22:25 ` Stephen C. Tweedie
2006-05-19 10:01 ` Zoltan Menyhart
2006-05-19 12:26 ` Stephen C. Tweedie
2006-05-19 1:30 ` Jan Kara
2006-05-19 12:33 ` Zoltan Menyhart
2006-05-19 15:05 ` Stephen C. Tweedie
2006-05-19 15:06 ` Stephen C. Tweedie
2006-05-24 17:33 ` Jan Kara
2006-05-30 15:36 ` Zoltan Menyhart [this message]
2006-05-30 16:40 ` Jan Kara
2006-05-23 16:01 ` Zoltan Menyhart
2006-05-24 9:14 ` Zoltan Menyhart
2006-05-24 17:18 ` Jan Kara
[not found] ` <447F13B3.6050505@bull.net>
[not found] ` <20060601162751.GH26933@atrey.karlin.mff.cuni.cz>
[not found] ` <44801E16.3040300@bull.net>
[not found] ` <20060602134923.GA1644@atrey.karlin.mff.cuni.cz>
2006-06-20 16:33 ` Zoltan Menyhart
2006-06-21 0:09 ` Jan Kara
-- strict thread matches above, loose matches on Subject: below --
2005-07-11 15:52 Jan Kara
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=447C666D.5030003@bull.net \
--to=zoltan.menyhart@bull.net \
--cc=jack@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=sct@redhat.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