Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8787993imu; Tue, 4 Dec 2018 14:16:25 -0800 (PST) X-Google-Smtp-Source: AFSGD/VFKR04FdZNgiMb+GJpR28gdCLEX5azNEZIedbdVh3F5/1Ottp4DJfUi40J1HHmjow6f8/7 X-Received: by 2002:a63:2744:: with SMTP id n65mr18207748pgn.65.1543961785290; Tue, 04 Dec 2018 14:16:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543961785; cv=none; d=google.com; s=arc-20160816; b=Q40itn2Q4+MJ4OHdNRU/2PrINPAtStgOzZ8j3i+zkam4WemCgAaIxq3qfZkNE+kRLA AGziTcgWNBG/97FzvfedCju4uW2RnhroDOjm0YyHVIqTlSij/fnTt/ZgRJPiS8jSy/vy owta8u7rTM131PCyp/qAnjRzjuq/osBGHYRjHX2V4xxiWqRXhfmdhRXAkWovweNZACU5 0N29WzftcT84v+d29zHLUhTKLOhrZZ79UkQik5/+//NleHGjmANAc/5L3OMoEzBQZxVd pfPwNBIfjiCcyKx7iWlqZXPdKcrd45wx3CymixkLgg1bXs4Y3vOyfNDTrBe6oZy40SE1 oihw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=ixSjDezikF8McOAtpR6nufWD3806ERSgOMy1Cw5PMmQ=; b=i8H0h4vc2c9ZvHU9lmFRY6tAPVHqa4xZyLEBqMH6OFHv1gJ6zy+hclWaZix62LUzYN uN8F5TG1HAF/+YDI6bhqz32B26MrCvoT7ZgHy0rXJPFhwCSujLbtFkpA+OBRGlB3oFM1 xuFRnR4Lf8pFTxMgsKESVs2914o23R3gsmQDyYE89P9ObkFmiEPHqzaMaOV9qAxxQ8EX Rxh6F/jkECwefuSkDEXeYZAlGFSDeI3nvcXg7fDmumrFPxRothaFnqU9jeLCQ0CFQLoA xQ2n3ldYegjIJrPxWzsaTmgOgJV8qo2elEsSH7Lieyym9lQPT0lB7+MeUV4XqPxC4wTh 5Ovw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id be11si17429793plb.134.2018.12.04.14.16.07; Tue, 04 Dec 2018 14:16:25 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726073AbeLDWP3 (ORCPT + 99 others); Tue, 4 Dec 2018 17:15:29 -0500 Received: from mail-qt1-f194.google.com ([209.85.160.194]:44567 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725875AbeLDWP2 (ORCPT ); Tue, 4 Dec 2018 17:15:28 -0500 Received: by mail-qt1-f194.google.com with SMTP id n32so20030084qte.11; Tue, 04 Dec 2018 14:15:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=ixSjDezikF8McOAtpR6nufWD3806ERSgOMy1Cw5PMmQ=; b=iDG+//DRYyGyctFiwvcHEeJ4En/xtIbsN9sMVBlPqlHJPtJqQiVGHinOuFbrzjpaqm fBSEp4P6NkBNct8ul15WYKagXiOSnFIDFRyDtPGLsuhhQxx7U+OFIckh7sZRNbsx4ov8 YHK6KjA5fLbp9QVQglP3xOXHOkWKA+PuYXOpylIwsSmGe20PmGh1ap5awSX0Q5iFgca4 iq/asuZ2WXRNTtE+oEZw/VS0V7q5a6Q5HnSp1BqF4yWILSZadLW4d5Ge9fu+MsZN9E/7 iiLPh1mxPHHPQTQW9G+YmQHPxZujudd4UU+XPvC33mIYIzuqNUjc6y0kXikJK1V2C+U8 I41Q== X-Gm-Message-State: AA+aEWZjc4qvl60dwj18hg6xZfhX+CtKcVvEWn8pI8MSUh1lE+DhEqKZ Py6P10KH23tnF6O13jW+3Mk= X-Received: by 2002:a0c:f313:: with SMTP id j19mr21634021qvl.200.1543961727132; Tue, 04 Dec 2018 14:15:27 -0800 (PST) Received: from dennisz-mbp.dhcp.thefacebook.com ([2620:10d:c091:200::7:d0b1]) by smtp.gmail.com with ESMTPSA id 86sm14568635qky.92.2018.12.04.14.15.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Dec 2018 14:15:26 -0800 (PST) Date: Tue, 4 Dec 2018 17:15:23 -0500 From: Dennis Zhou To: Mike Snitzer Cc: Dennis Zhou , Jens Axboe , Tejun Heo , Johannes Weiner , Josef Bacik , kernel-team@fb.com, linux-block@vger.kernel.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, Alasdair Kergon Subject: Re: [PATCH 05/14] dm: set the static flush bio device on demand Message-ID: <20181204221523.GA14183@dennisz-mbp.dhcp.thefacebook.com> References: <20181204183600.99746-1-dennis@kernel.org> <20181204183600.99746-6-dennis@kernel.org> <20181204202807.GA4689@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181204202807.GA4689@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 04, 2018 at 03:28:07PM -0500, Mike Snitzer wrote: > On Tue, Dec 04 2018 at 1:35pm -0500, > Dennis Zhou 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 > > Cc: Alasdair Kergon > > Cc: Mike Snitzer > > --- > > 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. ..." > Cool, that reads better. > > + * 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 .......^ > Yeah, I did mean alloc_dev(). Fixed. > > + */ > > + 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 > Thanks, Dennis