Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8583963imu; Tue, 4 Dec 2018 10:37:15 -0800 (PST) X-Google-Smtp-Source: AFSGD/U2ZkrUgPGs0weof2dgPFSrbT1ZaxxK7+IJwB9EQe8et3T46VIOAG13PqcT3QUF4mSrYsU4 X-Received: by 2002:a65:6148:: with SMTP id o8mr17617801pgv.451.1543948635633; Tue, 04 Dec 2018 10:37:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543948635; cv=none; d=google.com; s=arc-20160816; b=kffk//h+4SkQ7aHsNd98BZ3pzQbbV/yLnTmiBccc5Wbi48Eb0raSwuIX+NJcSRJvwt dqBxku+wVc8XAWAN0C/vF2mJp7KnnOZS0flrDiOFpSDhhOL0CJmNbBixpGuFq3IcqTrv 1+7Oe6rb9bQGDoEo29uUBlsKm0B8Oq8rWD7R+lbC3uKNka38Slb+srJayE7BsJE5FfSZ GDjBBv+ULB38rCvotVy7NHIeG/ClxNkuuUa1O9XoEB7NIDrGH16m3TdgR3sa1VhDHAR6 TW2lW/EKTPuJUZzdTEfxQZoS8/5tLjj3Mr1XBGcuWlUEdwYjUuIyCTLZop46PdedWN5X VIkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=bQpKW5IQZRQCaOlxFPCc/zPZs+94fhLsbziJx/ehO80=; b=Dhh4f0AxvyIK7oLWZBRg2+r+Hkl5T0PY8GmSSMmWJKH6fFaNzhErgr9sfgQxA7Jxbm +0sl3D+aEabKlDfOryiBuygmeIheaXfnF3f4vNMQ3XZNzI8ZvCtsYckr7NaMJQ2FTaOH XzOB2Z4Zskj8U5NkoQPBzbrmT8dvb0aL8nI0YhcpnZPGbm5Fk3etOY6Z38mj0IuTc+x5 gRKOuQh3/2O4HjRdTyg9SCksuaUkTwH0cq3irmkW/NkeGGBFeeP8ULHzMJ0p0EqzB/ug 0dWjR1JLTHewMXdadJX3kSMLqW/iVoE23/jaH0p3j80KkUbwZXvvgV0NMBRChcIrro/9 jT2g== 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 82si19169450pfa.115.2018.12.04.10.37.00; Tue, 04 Dec 2018 10:37:15 -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 S1726179AbeLDSgO (ORCPT + 99 others); Tue, 4 Dec 2018 13:36:14 -0500 Received: from mail-yb1-f195.google.com ([209.85.219.195]:39854 "EHLO mail-yb1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726109AbeLDSgM (ORCPT ); Tue, 4 Dec 2018 13:36:12 -0500 Received: by mail-yb1-f195.google.com with SMTP id w17-v6so7269673ybl.6; Tue, 04 Dec 2018 10:36:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bQpKW5IQZRQCaOlxFPCc/zPZs+94fhLsbziJx/ehO80=; b=Yv7nFvqkbB16bhUT/6fvQoIcHPGKshSbg/1PENM+ej+vKUROCCFtZ7ZinGqv36RB9h RVcM4ixAcr4U4nBcr/GCUEma2aCpN+Z8YnMgeHzx+FqkJfgKawMj3IygD4kEx3NbrjIw HAtb1pouf9jzlQLYC4/OQrnlAfpYpFR9c/GMsGWj1gnljTIZ1pmo5wtoD5eIy89KSrpM WswfrzaGB7q6qcfj/ABd5Tj5Cl387suRXG5vz/MCckMpo+0PtCOq8QEtjUsC53XNOJMo vGMeeCPxErRdOfvaBkG4tjCRI8FzMBfVf5rF2If16dU+MG0NDTqYlZPbI8S45t5GXU1F v7/Q== X-Gm-Message-State: AA+aEWYjzeKM9aDhkNer164WIg5pKzC2DyKRd3NUpRd5ka14ZuJp4aB/ LSdVwtKfvMlCxEU5JmIGwMM= X-Received: by 2002:a25:5e43:: with SMTP id s64mr10311833ybb.242.1543948570801; Tue, 04 Dec 2018 10:36:10 -0800 (PST) Received: from dennisz-mbp.thefacebook.com ([199.201.65.135]) by smtp.gmail.com with ESMTPSA id x82sm4274798ywb.34.2018.12.04.10.36.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 04 Dec 2018 10:36:10 -0800 (PST) From: Dennis Zhou To: Jens Axboe , Tejun Heo , Johannes Weiner , Josef Bacik Cc: kernel-team@fb.com, linux-block@vger.kernel.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, Dennis Zhou , Alasdair Kergon , Mike Snitzer Subject: [PATCH 05/14] dm: set the static flush bio device on demand Date: Tue, 4 Dec 2018 13:35:51 -0500 Message-Id: <20181204183600.99746-6-dennis@kernel.org> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20181204183600.99746-1-dennis@kernel.org> References: <20181204183600.99746-1-dennis@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 + * 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(). + */ + 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); -- 2.17.1