All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Snitzer <snitzer@redhat.com>
To: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: device-mapper development <dm-devel@redhat.com>
Subject: Re: [PATCH 7/7] dm-mpath: Fix a race condition in __multipath_map()
Date: Tue, 22 Nov 2016 19:48:03 -0500	[thread overview]
Message-ID: <20161123004803.GA32186@redhat.com> (raw)
In-Reply-To: <a8311b54-cd95-a1f9-7cd2-11adb10eec80@sandisk.com>

On Tue, Nov 22 2016 at  6:47pm -0500,
Bart Van Assche <bart.vanassche@sandisk.com> wrote:

> On 11/21/2016 04:34 PM, Mike Snitzer wrote:
> >But you WARN_ON_ONCE(clone && q->mq_ops) will trigger with sq-on-mq.
> 
> Hello Mike,
> 
> This behavior is indeed triggered by the sq-on-mq test. After having
> added the following code in __bind():
> 
> 	if (old_map &&
> 	    dm_table_all_blk_mq_devices(old_map) !=
> 	    dm_table_all_blk_mq_devices(t))
> 		pr_debug("%s: old all_blk_mq %d <> new all_blk_mq %d\n",
> 			 dm_device_name(md),
> 			 dm_table_all_blk_mq_devices(old_map),
> 			 dm_table_all_blk_mq_devices(t));
> 
> I see the following output appear frequently in the kernel log:
> 
> dm_mod:__bind: 254:0: old all_blk_mq 1 <> new all_blk_mq 0
> 
> Could these all_blk_mq state changes explain that WARN_ON_ONCE(clone
> && q->mq_ops) is triggered in __multipath_map()? Does this mean that
> the comment in patch http://marc.info/?l=dm-devel&m=147925314306752
> is correct?

Yes, looks like you're on to something.  dm_old_prep_tio() has:

        /*
         * Must clone a request if this .request_fn DM device
         * is stacked on .request_fn device(s).
         */
        if (!dm_table_all_blk_mq_devices(table)) { ...

So if your table->all_blk_mq is false (likely due to a temporary no
paths in multipath table scenario) a clone will be passed to
__multipath_map().  But what isn't clear is how __multipath_map() would
then go on to have any underlying paths available to issue IO to (given
the table would have been empty -- or so I would think).

Would be great if you could verify that the table is in fact empty.

It should be noted that dm_table_determine_type() has:

        if (list_empty(devices) && __table_type_request_based(live_md_type)) {
                /* inherit live MD type */
                t->type = live_md_type;
                return 0;
        }

So this explains how/why an empty table will inherit the
DM_TYPE_MQ_REQUEST_BASED, and it also explains why the new (empty) table
would not have ->all_blk_mq set to true.  But again, no IO is able to be
issued when there are no underlying paths.

And looking closer, __multipath_map() _should_ return early with either
DM_MAPIO_DELAY_REQUEUE or DM_MAPIO_REQUEUE when no paths are available.

Not seeing how you could have this scenario where you prepared a clone
(as if the clone request were to be issued to a .request_fn, aka "sq",
device) and then by the time you get into __multipath_map() there is an
underlying path available with q->mq_ops.

But regardless, what certainly needs fixing is the inconsistency of
inheriting DM_TYPE_MQ_REQUEST_BASED but not setting all_blk_mq to true
(all_blk_mq == true is implied by DM_TYPE_MQ_REQUEST_BASED).

I'm now questioning why we even need the 'all_blk_mq' state within the
table.  I'll revisit the "why?" on all that in my previous commits.
I'll likely get back with you on this point tomorrow.  And will
hopefully have a fix for you.

FYI: given all this I do think something like your 7/7 patch (which you
referenced with the above url) would be a possible added safety net to
guard against future inconsistencies/bug/regressions.

  reply	other threads:[~2016-11-23  0:48 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-15 23:31 [PATCH 0/7] dm-mpath: Fix a race condition in the blk-mq path Bart Van Assche
2016-11-15 23:32 ` [PATCH 1/7] dm: Fix a (theoretical?) race condition in rq_completed() Bart Van Assche
2016-11-16  0:46   ` Mike Snitzer
2016-11-15 23:33 ` [PATCH 2/7] dm: Simplify dm_table_determine_type() Bart Van Assche
2016-11-16 14:54   ` Mike Snitzer
2016-11-16 20:14     ` Bart Van Assche
2016-11-16 21:11       ` Mike Snitzer
2016-11-16 21:53         ` Bart Van Assche
2016-11-16 23:09           ` Mike Snitzer
2016-11-15 23:33 ` [PATCH 3/7] dm-mpath: Document a locking assumption Bart Van Assche
2016-11-18  0:07   ` Mike Snitzer
2016-11-15 23:34 ` [PATCH 4/7] dm-mpath: Change return type of pg_init_all_paths() from int into void Bart Van Assche
2016-11-15 23:34 ` [PATCH 5/7] dm-mpath: Do not touch *__clone if request allocation fails Bart Van Assche
2016-11-15 23:34 ` [PATCH 6/7] dm-mpath: Avoid code duplication in __multipath_map() Bart Van Assche
2016-11-16  0:39   ` Mike Snitzer
2016-11-15 23:35 ` [PATCH 7/7] dm-mpath: Fix a race condition " Bart Van Assche
2016-11-16  0:37   ` Mike Snitzer
2016-11-16  0:40     ` Bart Van Assche
2016-11-16  1:01       ` Mike Snitzer
2016-11-16  1:08         ` Bart Van Assche
2016-11-16  1:50           ` Mike Snitzer
2016-11-21 21:44     ` Bart Van Assche
2016-11-21 23:43       ` Mike Snitzer
2016-11-21 23:57         ` Bart Van Assche
2016-11-22  0:34           ` Mike Snitzer
2016-11-22 23:47             ` Bart Van Assche
2016-11-23  0:48               ` Mike Snitzer [this message]
2016-11-23  3:16                 ` Mike Snitzer
2016-11-23 18:28                   ` Bart Van Assche
2016-11-23 18:50                     ` Mike Snitzer
2016-11-16  0:47 ` [PATCH 0/7] dm-mpath: Fix a race condition in the blk-mq path Mike Snitzer
2016-11-16  0:57   ` Bart Van Assche
2016-11-16  1:08     ` Mike Snitzer
2016-11-16  1:10       ` Bart Van Assche
2016-11-16  1:53         ` Mike Snitzer
2016-11-16  7:39 ` Hannes Reinecke
2016-11-16 14:56   ` Mike Snitzer
2016-11-16 18:22     ` Bart Van Assche
2016-11-16 19:32       ` Mike Snitzer

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=20161123004803.GA32186@redhat.com \
    --to=snitzer@redhat.com \
    --cc=bart.vanassche@sandisk.com \
    --cc=dm-devel@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.