linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dennis Zhou <dennis@kernel.org>
To: Christoph Hellwig <hch@infradead.org>
Cc: Dennis Zhou <dennis@kernel.org>, Jens Axboe <axboe@kernel.dk>,
	Tejun Heo <tj@kernel.org>, Johannes Weiner <hannes@cmpxchg.org>,
	Josef Bacik <josef@toxicpanda.com>,
	kernel-team@fb.com, linux-block@vger.kernel.org,
	cgroups@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 04/13] blkcg: introduce common blkg association logic
Date: Mon, 3 Dec 2018 15:58:42 -0500	[thread overview]
Message-ID: <20181203205842.GA90035@dennisz-mbp.dhcp.thefacebook.com> (raw)
In-Reply-To: <20181130095209.GA17103@infradead.org>

Hi Christoph,

On Fri, Nov 30, 2018 at 01:52:09AM -0800, Christoph Hellwig wrote:
> >  EXPORT_SYMBOL_GPL(bio_associate_blkcg);
> >  
> >  /**
> > - * bio_associate_blkg - associate a bio with the a blkg
> > + * bio_has_queue - required check for blkg association
> > + * @bio: target bio
> > + *
> > + * A blkg represents the relationship between a blkcg and a request_queue.
> > + * If there is no request_queue, there is no blkg and therefore nothing to
> > + * associate with.
> > + */
> > +static inline bool bio_has_queue(struct bio *bio)
> > +{
> > +	return bio->bi_disk && bio->bi_disk->queue;
> > +}
> 
> How do you ever see a bio without a queue?  We can't even do I/O in
> that case.

The case I found was with the flush bio in dm which is statically
allocated in dm_alloc(). The issue issue is that bio_set_dev() is called
on a bdev that isn't opened. So, the bdev wasn't pointing to a genhd.
I've fixed the issue with the patch below, which will be added in v5.

I think I was being overly cautious with the change and have taken this
out in v5. It seems that this should be a one-off case which should work
with the patch below.

Thanks,
Dennis

---
From 3ee13402af369ee8618549b63593d68ffca574ca Mon Sep 17 00:00:00 2001
From: Dennis Zhou <dennis@kernel.org>
Date: Mon, 3 Dec 2018 10:56:34 -0800
Subject: [PATCH 05/14] dm: set flush bio device on demand

The next patch changes the macro bio_set_dev() to associate a bio with a
blkg based on the device set. However, dm creates a static bio to be
used as the basis for cloning empty flush bios on creation. This
association is with a not-opened bdev so bd_disk is %NULL. To easily get
around this, we will set the device on the static bio every time and use
that to copy to the other bios.

Signed-off-by: Dennis Zhou <dennis@kernel.org>
---
 drivers/md/dm.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index a733e4c920af..b5e996c5c709 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -1417,10 +1417,14 @@ static int __send_empty_flush(struct clone_info *ci)
 	unsigned target_nr = 0;
 	struct dm_target *ti;
 
+	bio_set_dev(ci->bio, ci->io->md->bdev);
+
 	BUG_ON(bio_has_data(ci->bio));
 	while ((ti = dm_table_get_target(ci->map, target_nr++)))
 		__send_duplicate_bios(ci, ti, ti->num_flush_bios, NULL);
 
+	bio_disassociate_blkg(ci->bio);
+
 	return 0;
 }
 
@@ -1939,7 +1943,6 @@ static struct mapped_device *alloc_dev(int minor)
 		goto bad;
 
 	bio_init(&md->flush_bio, NULL, 0);
-	bio_set_dev(&md->flush_bio, md->bdev);
 	md->flush_bio.bi_opf = REQ_OP_WRITE | REQ_PREFLUSH | REQ_SYNC;
 
 	dm_stats_init(&md->stats);
-- 
2.17.1


  reply	other threads:[~2018-12-03 20:58 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-26 21:19 [PATCH 00/13 v4] block: always associate blkg and refcount cleanup Dennis Zhou
2018-11-26 21:19 ` [PATCH 01/13] blkcg: fix ref count issue with bio_blkcg() using task_css Dennis Zhou
2018-11-27 20:54   ` Josef Bacik
2018-11-26 21:19 ` [PATCH 02/13] blkcg: update blkg_lookup_create() to do locking Dennis Zhou
2018-11-27 20:56   ` Josef Bacik
2018-11-26 21:19 ` [PATCH 03/13] blkcg: convert blkg_lookup_create() to find closest blkg Dennis Zhou
2018-11-27 21:01   ` Josef Bacik
2018-11-26 21:19 ` [PATCH 04/13] blkcg: introduce common blkg association logic Dennis Zhou
2018-11-27 21:04   ` Josef Bacik
2018-11-29 15:49   ` Tejun Heo
2018-11-29 19:48     ` Dennis Zhou
2018-11-30  9:52   ` Christoph Hellwig
2018-12-03 20:58     ` Dennis Zhou [this message]
2018-11-26 21:19 ` [PATCH 05/13] blkcg: associate blkg when associating a device Dennis Zhou
2018-11-29 15:53   ` Tejun Heo
2018-11-29 19:54     ` Dennis Zhou
2018-11-30  9:54   ` Christoph Hellwig
2018-12-03 22:52     ` Dennis Zhou
2018-11-26 21:19 ` [PATCH 06/13] blkcg: consolidate bio_issue_init() to be a part of core Dennis Zhou
2018-11-26 21:19 ` [PATCH 07/13] blkcg: associate a blkg for pages being evicted by swap Dennis Zhou
2018-11-26 21:19 ` [PATCH 08/13] blkcg: associate writeback bios with a blkg Dennis Zhou
2018-11-26 21:19 ` [PATCH 09/13] blkcg: remove bio->bi_css and instead use bio->bi_blkg Dennis Zhou
2018-11-26 21:19 ` [PATCH 10/13] blkcg: remove additional reference to the css Dennis Zhou
2018-11-26 21:19 ` [PATCH 11/13] blkcg: remove bio_disassociate_task() Dennis Zhou
2018-11-29 15:54   ` Tejun Heo
2018-11-26 21:19 ` [PATCH 12/13] blkcg: change blkg reference counting to use percpu_ref Dennis Zhou
2018-11-26 21:19 ` [PATCH 13/13] blkcg: rename blkg_try_get() to blkg_tryget() Dennis Zhou
2018-11-27 21:10 ` [PATCH 00/13 v4] block: always associate blkg and refcount cleanup Josef Bacik
2018-11-27 22:15   ` Dennis Zhou

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=20181203205842.GA90035@dennisz-mbp.dhcp.thefacebook.com \
    --to=dennis@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=cgroups@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=hch@infradead.org \
    --cc=josef@toxicpanda.com \
    --cc=kernel-team@fb.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tj@kernel.org \
    /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).