linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: NeilBrown <nfbrown@novell.com>
To: linux-raid@vger.kernel.org
Cc: dan.j.williams@intel.com, shli@fb.com, hch@infradead.org,
	kernel-team@fb.com, Song Liu <songliubraving@fb.com>
Subject: Re: [PATCH 1/2] allow md_flush_request to take NULL bio
Date: Thu, 11 Feb 2016 14:46:44 +1100	[thread overview]
Message-ID: <87egcjx61n.fsf@notabene.neil.brown.name> (raw)
In-Reply-To: <1455151995-240805-1-git-send-email-songliubraving@fb.com>

[-- Attachment #1: Type: text/plain, Size: 1333 bytes --]

On Thu, Feb 11 2016, Song Liu wrote:

> Signed-off-by: Song Liu <songliubraving@fb.com>
> Signed-off-by: Shaohua Li <shli@fb.com>
> ---
>  drivers/md/md.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index e55e6cf..2997104 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -406,6 +406,8 @@ static void md_submit_flush_data(struct work_struct *ws)
>  	struct mddev *mddev = container_of(ws, struct mddev, flush_work);
>  	struct bio *bio = mddev->flush_bio;
>  
> +	if (!bio)
> +		goto out;
>  	if (bio->bi_iter.bi_size == 0)
>  		/* an empty barrier - all done */
>  		bio_endio(bio);
> @@ -415,6 +417,7 @@ static void md_submit_flush_data(struct work_struct *ws)
>  	}
>  
>  	mddev->flush_bio = NULL;
> +out:
>  	wake_up(&mddev->sb_wait);
>  }
>  

I don't think this is safe.
->flush_bio is used for two different purposes.
One is to carry the bio so it can be passed to ->make_request after the
flush.
The other is to ensure exclusive access to mddev->flush_work.
The first thing md_flush_request() does is wait for ->flush_bio to be
NULL.  Then it knows that ->flush_work is no longer in use.
With your change you could get md_flush_request trying to INIT_WORK
->flush_work while it is already queued.

Not good.

NeilBrown

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]

      parent reply	other threads:[~2016-02-11  3:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-11  0:53 [PATCH 1/2] allow md_flush_request to take NULL bio Song Liu
2016-02-11  0:53 ` [PATCH 2/2] enable bypass raid5 journal for full stripe writes Song Liu
2016-02-11  4:07   ` NeilBrown
2016-02-23 16:34   ` Alireza Haghdoost
2016-02-11  3:46 ` NeilBrown [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=87egcjx61n.fsf@notabene.neil.brown.name \
    --to=nfbrown@novell.com \
    --cc=dan.j.williams@intel.com \
    --cc=hch@infradead.org \
    --cc=kernel-team@fb.com \
    --cc=linux-raid@vger.kernel.org \
    --cc=shli@fb.com \
    --cc=songliubraving@fb.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).