linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junxiao Bi <junxiao.bi@oracle.com>
To: Jan Kara <jack@suse.cz>
Cc: Mark Fasheh <mfasheh@suse.com>,
	linux-ext4@vger.kernel.org, ocfs2-devel@oss.oracle.com,
	jack@suse.com
Subject: Re: [PATCH] jbd2: fix null committed data return in undo_access
Date: Mon, 30 Nov 2015 11:03:57 +0800	[thread overview]
Message-ID: <565BBC9D.6040007@oracle.com> (raw)
In-Reply-To: <20151127084553.GB3093@quack.suse.cz>

On 11/27/2015 04:45 PM, Jan Kara wrote:
> On Fri 27-11-15 09:57:21, Junxiao Bi wrote:
>> commit de92c8c ("jbd2: speedup jbd2_journal_get_[write|undo]_access()")
>> introduced jbd2_write_access_granted() to improve write|undo_access
>> speed, but missed to check the status of b_committed_data which caused
>> a kernel panic on ocfs2.
> 
> Thanks for debugging this! Just a few minor nits:
> 
> 1) Please use at least 12 characters of the commit hash - i.e. de92c8caf16c
> - that is pretty much guaranteed to stay unique for the lifetime of Linux.
> Using just 7 characters will become non-unique with high probability rather
> soon.
I saw this report from checkpatch.pl. Since there have "patch subject",
so i didn't modify it. I will update it in v2 patch.
> 
> 2) Send this patch to Ted Tso as well as he is the one merging jbd2
> patches.
OK.
> 
> 3) The fact that OCFS2 hit this problem means that it is mixing
> jbd2_journal_get_write_access() and jbd2_journal_get_undo_access() for the
> same buffer. That is slightly suspicious to me. Not that it would be
> outright bug but you have to account for the fact that someone can be
> modifying the buffer data while you are getting undo access...
I am not sure about this. Mark involved this in commit b4414eea0e
("ocfs2: Clear undo bits when local alloc is freed").

Mark, is mixing using undo/write access a bug?
> 
> 4) Some other comments below in the code.
> 
>> diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
>> index 6b8338e..4750bda 100644
>> --- a/fs/jbd2/transaction.c
>> +++ b/fs/jbd2/transaction.c
>> @@ -1009,7 +1009,8 @@ out:
>>  }
>>  
>>  /* Fast check whether buffer is already attached to the required transaction */
>> -static bool jbd2_write_access_granted(handle_t *handle, struct buffer_head *bh)
>> +static bool jbd2_write_access_granted(handle_t *handle, struct buffer_head *bh,
>> +							int undo)
> 							^^^
> Use 'bool' please. The function is already using bools so it is good for
> consistency.
Will fix this in v2.

Thanks,
Junxiao.
> 
>>  {
>>  	struct journal_head *jh;
>>  	bool ret = false;
>> @@ -1036,6 +1037,8 @@ static bool jbd2_write_access_granted(handle_t *handle, struct buffer_head *bh)
>>  	jh = READ_ONCE(bh->b_private);
>>  	if (!jh)
>>  		goto out;
> 
> Short comment here please. Like:
> 
> 	/* For undo access buffer must have data copied */
> 
>> +	if (undo && !jh->b_committed_data)
>> +		goto out;
>>  	if (jh->b_transaction != handle->h_transaction &&
>>  	    jh->b_next_transaction != handle->h_transaction)
>>  		goto out;
>> @@ -1073,7 +1076,7 @@ int jbd2_journal_get_write_access(handle_t *handle, struct buffer_head *bh)
>>  	struct journal_head *jh;
>>  	int rc;
>>  
>> -	if (jbd2_write_access_granted(handle, bh))
>> +	if (jbd2_write_access_granted(handle, bh, 0))
> 
> Here 'false' instead of 0.
> 
>>  	JBUFFER_TRACE(jh, "entry");
>> -	if (jbd2_write_access_granted(handle, bh))
>> +	if (jbd2_write_access_granted(handle, bh, 1))
> 
> Here 'true' instead of 1.
> 
> Thanks.
> 
> 								Honza
> 

      reply	other threads:[~2015-11-30  3:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-27  1:57 [PATCH] jbd2: fix null committed data return in undo_access Junxiao Bi
2015-11-27  8:45 ` Jan Kara
2015-11-30  3:03   ` Junxiao Bi [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=565BBC9D.6040007@oracle.com \
    --to=junxiao.bi@oracle.com \
    --cc=jack@suse.com \
    --cc=jack@suse.cz \
    --cc=linux-ext4@vger.kernel.org \
    --cc=mfasheh@suse.com \
    --cc=ocfs2-devel@oss.oracle.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).