All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yufen Yu <yuyufen@huawei.com>
To: Keith Busch <kbusch@kernel.org>
Cc: <axboe@kernel.dk>, <linux-block@vger.kernel.org>, <hch@lst.de>,
	<ming.lei@redhat.com>, <bvanassche@acm.org>
Subject: Re: [RFC PATCH] block: protect bi_status with spinlock
Date: Mon, 29 Mar 2021 16:08:21 +0800	[thread overview]
Message-ID: <e6ec05a8-1db5-6cb2-aa76-987ce6f1852c@huawei.com> (raw)
In-Reply-To: <20210329030246.GA15392@redsun51.ssa.fujisawa.hgst.com>



On 2021/3/29 11:02, Keith Busch wrote:
> On Sun, Mar 28, 2021 at 10:23:37PM -0400, Yufen Yu wrote:
>>   static struct bio *__bio_chain_endio(struct bio *bio)
>>   {
>>   	struct bio *parent = bio->bi_private;
>> +	unsigned long flags;
>>   
>> +	spin_lock_irqsave(&parent->bi_lock, flags);
>>   	if (!parent->bi_status)
>>   		parent->bi_status = bio->bi_status;
>> +	spin_unlock_irqrestore(&parent->bi_lock, flags);
> 
> 
> I don't see a spin_lock_init() on this new lock, though a spinlock seems
> overkill here. If you need an atomic update, you could do:
> 
> 	cmpxchg(&parent->bi_status, 0, bio->bi_status);
> 
> But I don't even think that's necessary. There really is no need to set
> parent->bi_status if bio->bi_status is 0, so something like this should
> be fine:
> 
>    	if (bio->bi_status && !parent->bi_status)
>    		parent->bi_status = bio->bi_status;
> .
>

Yeah, this is more smart. Thanks a lot for your suggestion.
I will send v2.

Thanks,
Yufen


      parent reply	other threads:[~2021-03-29  8:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-29  2:23 [RFC PATCH] block: protect bi_status with spinlock Yufen Yu
2021-03-29  3:02 ` Keith Busch
2021-03-29  3:49   ` Bart Van Assche
2021-03-29  5:27     ` Christoph Hellwig
2021-03-29  5:47   ` Christoph Hellwig
2021-03-29  8:08   ` Yufen Yu [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=e6ec05a8-1db5-6cb2-aa76-987ce6f1852c@huawei.com \
    --to=yuyufen@huawei.com \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=ming.lei@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 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.