From: Mike Snitzer <snitzer@redhat.com>
To: Dennis Zhou <dennis@kernel.org>
Cc: 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,
Alasdair Kergon <agk@redhat.com>
Subject: Re: [PATCH 05/14] dm: set the static flush bio device on demand
Date: Tue, 4 Dec 2018 15:28:07 -0500 [thread overview]
Message-ID: <20181204202807.GA4689@redhat.com> (raw)
In-Reply-To: <20181204183600.99746-6-dennis@kernel.org>
On Tue, Dec 04 2018 at 1:35pm -0500,
Dennis Zhou <dennis@kernel.org> wrote:
> 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. The
> bio_set_dev() call in alloc_dev() will cause problems with the next
> patch adding association to bio_set_dev() because the call is before the
> bdev is associated with a gendisk (bd_disk is %NULL). To get around
> this, set the device on the static bio every time and use that to clone
> to the other bios.
>
> Signed-off-by: Dennis Zhou <dennis@kernel.org>
> Cc: Alasdair Kergon <agk@redhat.com>
> Cc: Mike Snitzer <snitzer@redhat.com>
> ---
> block/bio.c | 1 +
> drivers/md/dm.c | 12 +++++++++++-
> 2 files changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/block/bio.c b/block/bio.c
> index 452b8e79b998..41ebb3f8e2fc 100644
> --- a/block/bio.c
> +++ b/block/bio.c
> @@ -2021,6 +2021,7 @@ void bio_disassociate_blkg(struct bio *bio)
> bio->bi_blkg = NULL;
> }
> }
> +EXPORT_SYMBOL_GPL(bio_disassociate_blkg);
>
> /**
> * __bio_associate_blkg - associate a bio with the a blkg
> diff --git a/drivers/md/dm.c b/drivers/md/dm.c
> index a733e4c920af..a2d6f8b33d23 100644
> --- a/drivers/md/dm.c
> +++ b/drivers/md/dm.c
> @@ -1417,10 +1417,21 @@ static int __send_empty_flush(struct clone_info *ci)
> unsigned target_nr = 0;
> struct dm_target *ti;
>
> + /*
> + * Empty flush uses a statically initialized bio as the base for
> + * cloning, &md->flush_bio. However, blkg association requires that
Would prefer:
"Empty flush uses a statically initialized bio, &md->flush_bio, as the
base for cloning. ..."
> + * a bdev is associated with a gendisk, which doesn't happen until the
> + * bdev is opened. So, blkg association is done at issue time of the
> + * flush rather than when the device is created in dm_alloc().
Another nit but I think you mean "alloc_dev()" here .......^
> + */
> + 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 +1950,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);
The top-level DM device's bdev->bd_disk is only assigned after the first
blkdev_get(), so I can see why this is needed.
Think this type of life-cycle quirk was the kind of thing that caused
blk cgroup issues with DM.
Left wondering whether there would be a better way of handling N flush
bios for DM devices. But for the now this will have to do.
Acked-by: Mike Snitzer <snitzer@redhat.com>
Thanks,
Mike
next prev parent reply other threads:[~2018-12-04 20:28 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-04 18:35 [PATCH v5 00/14] block: always associate blkg and refcount cleanup Dennis Zhou
2018-12-04 18:35 ` [PATCH 01/14] blkcg: fix ref count issue with bio_blkcg() using task_css Dennis Zhou
2018-12-04 18:35 ` [PATCH 02/14] blkcg: update blkg_lookup_create() to do locking Dennis Zhou
2018-12-04 18:35 ` [PATCH 03/14] blkcg: convert blkg_lookup_create() to find closest blkg Dennis Zhou
2018-12-04 18:35 ` [PATCH 04/14] blkcg: introduce common blkg association logic Dennis Zhou
2018-12-04 18:35 ` [PATCH 05/14] dm: set the static flush bio device on demand Dennis Zhou
2018-12-04 20:28 ` Mike Snitzer [this message]
2018-12-04 22:15 ` Dennis Zhou
2018-12-04 18:35 ` [PATCH 06/14] blkcg: associate blkg when associating a device Dennis Zhou
2018-12-04 19:48 ` Josef Bacik
2018-12-04 18:35 ` [PATCH 07/14] blkcg: consolidate bio_issue_init() to be a part of core Dennis Zhou
2018-12-04 19:50 ` Josef Bacik
2018-12-04 18:35 ` [PATCH 08/14] blkcg: associate a blkg for pages being evicted by swap Dennis Zhou
2018-12-04 18:35 ` [PATCH 09/14] blkcg: associate writeback bios with a blkg Dennis Zhou
2018-12-04 18:35 ` [PATCH 10/14] blkcg: remove bio->bi_css and instead use bio->bi_blkg Dennis Zhou
2018-12-04 18:35 ` [PATCH 11/14] blkcg: remove additional reference to the css Dennis Zhou
2018-12-04 19:53 ` Josef Bacik
2018-12-04 18:35 ` [PATCH 12/14] blkcg: remove bio_disassociate_task() Dennis Zhou
2018-12-04 19:53 ` Josef Bacik
2018-12-04 18:35 ` [PATCH 13/14] blkcg: change blkg reference counting to use percpu_ref Dennis Zhou
2018-12-04 19:54 ` Josef Bacik
2018-12-04 18:36 ` [PATCH 14/14] blkcg: rename blkg_try_get() to blkg_tryget() Dennis Zhou
-- strict thread matches above, loose matches on Subject: below --
2018-12-05 17:10 [PATCH v6 00/14] block: always associate blkg and refcount cleanup Dennis Zhou
2018-12-05 17:10 ` [PATCH 05/14] dm: set the static flush bio device on demand 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=20181204202807.GA4689@redhat.com \
--to=snitzer@redhat.com \
--cc=agk@redhat.com \
--cc=axboe@kernel.dk \
--cc=cgroups@vger.kernel.org \
--cc=dennis@kernel.org \
--cc=hannes@cmpxchg.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).