From: Alex Tomas <alex@clusterfs.com>
To: "Stephen C. Tweedie" <sct@redhat.com>
Cc: Alex Tomas <alex@clusterfs.com>,
linux-kernel <linux-kernel@vger.kernel.org>,
<ext2-devel@lists.sourceforge.net>, Andrew Morton <akpm@osdl.org>
Subject: Re: [Ext2-devel] [PATCH] JBD: journal_release_buffer()
Date: Tue, 25 Jan 2005 01:24:28 +0300 [thread overview]
Message-ID: <m3brbebh43.fsf@bzzz.home.net> (raw)
In-Reply-To: <1106604342.2103.395.camel@sisko.sctweedie.blueyonder.co.uk> (Stephen C. Tweedie's message of "Mon, 24 Jan 2005 22:05:42 +0000")
>>>>> Stephen C Tweedie (SCT) writes:
>> + /* return credit back to the handle if it was really spent */
>> + if (credits)
>> + handle->h_buffer_credits++;
>> + jh->b_tcount--;
>> + if (jh->b_tcount == 0) {
>> + /*
>> + * this was last reference to the block from the current
>> + * transaction and we'd like to return credit to the
>> + * whole transaction -bzzz
>> + */
>> + if (!credits)
>> + handle->h_buffer_credits++;
SCT> I think there's a problem here.
SCT> What if:
SCT> Process A gets write access, and is the first to do so (*credits=1)
SCT> Processes B gets write access (*credits=0)
SCT> B modifies the buffer and finishes
SCT> A looks again, sees B's modifications, and releases the buffer because
SCT> it's no use any more.
SCT> Now, B's release didn't return credits. The bh is part of the
SCT> transaction and was not released.
hmmm. that's a good catch. so, with this patch A increments h_buffer_credits
and this one will go to the t_outstanding_credits while the buffer is still
part of the transaction. indeed, an imbalance.
probably something like the following would be enough?
+ /* return credit back to the handle if it was really spent */
+ if (credits) {
+ handle->h_buffer_credits++;
+ spin_lock(&handle->h_transaction->t_handle_lock);
+ handle->h_transaction->t_outstanding_credits++;
+ spin_lock(&handle->h_transaction->t_handle_lock);
+ }
thanks, Alex
next prev parent reply other threads:[~2005-01-24 22:29 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-01-19 15:32 Alex Tomas
2005-01-24 22:05 ` [Ext2-devel] " Stephen C. Tweedie
2005-01-24 22:24 ` Alex Tomas [this message]
2005-01-24 23:35 ` Stephen C. Tweedie
2005-01-25 0:08 ` Alex Tomas
2005-01-25 14:36 ` Alex Tomas
2005-01-25 16:21 ` Stephen C. Tweedie
2005-01-25 19:30 ` Alex Tomas
2005-01-26 17:12 ` Stephen C. Tweedie
2005-01-30 10:55 ` Alex Tomas
2005-02-04 23:45 ` Stephen C. Tweedie
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=m3brbebh43.fsf@bzzz.home.net \
--to=alex@clusterfs.com \
--cc=akpm@osdl.org \
--cc=ext2-devel@lists.sourceforge.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®