mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Zoltan Menyhart <Zoltan.Menyhart@bull.net>
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 18:40:53 +0200	[thread overview]
Message-ID: <20060530164053.GA4679@atrey.karlin.mff.cuni.cz> (raw)
In-Reply-To: <447C666D.5030003@bull.net>

  Hello,

> 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...
  You are not right here. This is exactly why we do submit_buffers()
before we do lock_buffer. So either we get the lock without waiting via
test_set_buffer_locked() or we send all buffers for IO (and hence they
will get unlocked eventually).

> 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.
  I agree the locking behaviour has changed a bit. But not as much as you
thought.

								Honza
-- 
Jan Kara <jack@suse.cz>
SuSE CR Labs

  reply	other threads:[~2006-05-30 16:39 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-18  8:25 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
2006-05-30 16:40         ` Jan Kara [this message]
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=20060530164053.GA4679@atrey.karlin.mff.cuni.cz \
    --to=jack@suse.cz \
    --cc=Zoltan.Menyhart@bull.net \
    --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

all inboxes | Powered by JetHome®