From: Edward Shishkin <edward.shishkin@gmail.com>
To: "홍신 shin hong" <hongshin@gmail.com>
Cc: reiserfs-devel@vger.kernel.org
Subject: Re: a question on lock ordering in write_ordered_buffers()
Date: Thu, 20 Aug 2009 16:16:33 +0200 [thread overview]
Message-ID: <4A8D5AC1.1010707@gmail.com> (raw)
In-Reply-To: <2014bcab0908200055w10aa616h2c779c3b5690b792@mail.gmail.com>
Hello.
홍신 shin hong wrote:
> Hi. I have a question on lock ordering
> while I read ReiserFS code in Linux 2.6.30.4.
>
> At write_ordered_buffers() function in reiserfs/journal.c,
>
> What is the lock ordering between spin_lock(lock) and lock_buffer(bh)?
>
> It seems that the lock ordering between spin_lock(lock) and
> lock_buffer(bh) is inconsistent.
> At line 858, the lock ordering is spin_lock(lock) → lock_buffer(bh).
>
Nup, at line 858 we have trylock_buffer, which is not the same as
lock_buffer: in our case the process won't wait for the lock to be
released.
> However, at line 881, lock_buffer(bh) → spin_lock(lock) since add_to_chunk()
> releases and re-takes spin_lock(lock).
>
> Is it necessary that the ordering between two locks is consistent?
>
This is sufficient, but not necessary condition to prevent deadlock.
However, breaking a lock ordering is ugly, and you will need to defend
every such case explaining why there is no way to keep the ordering,
and writing a lot of (unclear) comments why the deadlock is impossible :)
--
To unsubscribe from this list: send the line "unsubscribe reiserfs-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
prev parent reply other threads:[~2009-08-20 14:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-20 7:55 a question on lock ordering in write_ordered_buffers() 홍신 shin hong
2009-08-20 14:16 ` Edward Shishkin [this message]
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=4A8D5AC1.1010707@gmail.com \
--to=edward.shishkin@gmail.com \
--cc=hongshin@gmail.com \
--cc=reiserfs-devel@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.