Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp9723331imu; Wed, 5 Dec 2018 09:13:32 -0800 (PST) X-Google-Smtp-Source: AFSGD/Vf+9wFrlh6Wf43TyFH/+RWpFxnRuSUrIygn2JcfpPBa//rld6olIkfzy6WI++lsbXOdIBX X-Received: by 2002:a17:902:2868:: with SMTP id e95mr25023849plb.317.1544030012870; Wed, 05 Dec 2018 09:13:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544030012; cv=none; d=google.com; s=arc-20160816; b=RS3sM8xkkF+mWh03xtlslnrvV61KFNqjOuM6MUa+92eJNadx5n8SoyxEsvqYfTy4Dw oMxzW3cs54OVnHav/iwad/6YBxpCroAlzeCsHme51y3C9jRpVm3GrKmb6ZrF721LxiaC PEh9Sz1NiORoAWawc3INELfbEMvmAUxajDRxL5kdbK+n9iCls+J9BYlpPuOCuHhYlh0w VGpu4UG9npIp2NmgyY4ftAJSNsL5TsXyhdb6s5ehkC2pdLCteYTm4ZITLJslp/6p5yYT eSH6QAindWhDwJ7dtP4+SLuVPkgjt7jcLaO+SDtTpS4vJJzgAeEN0r2je2I+GGZPRmj9 UHcA== 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=PAF09T9AUnRDZbdy+9W+1tWiUCzC21kl3xO6QVyamzk=; b=E3m5CHEnI8tBQfhIa3WtkeRUFi7x9iCLBeZwxjAiuwZEdRtrZDgfFziJ4Te4jOpvJz dVQ/qvRY2jI/jTzXTzxPdWPnQrM6H2olw55Kan98wjSOZa4GOLvEkkKBY85G3jOGGLii xGCtv2BwTF3Zhmfpc6pk++ZhnW1ZXcmOt5b99beEUwFlWHYtCfKyl90F4sxwwSeNv0VD gd7Z+fr4+hPWsGeR42QqgU6E2ySJRYEU5TQMKNRiQEoMJ+LhJGaQ37GMMNVtEW2espH0 lZu4ETTxDCq2wiejDLkRo/VnSvqLTUS0tIdi3ixLCGIMISFd2X8j6BIl/3a2eHzwbzq4 Ziqg== 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 x23si17990325pgk.272.2018.12.05.09.13.10; Wed, 05 Dec 2018 09:13:32 -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 S1728527AbeLERL5 (ORCPT + 99 others); Wed, 5 Dec 2018 12:11:57 -0500 Received: from mail-qt1-f196.google.com ([209.85.160.196]:44880 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728142AbeLERKv (ORCPT ); Wed, 5 Dec 2018 12:10:51 -0500 Received: by mail-qt1-f196.google.com with SMTP id n32so23074479qte.11; Wed, 05 Dec 2018 09:10:49 -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=PAF09T9AUnRDZbdy+9W+1tWiUCzC21kl3xO6QVyamzk=; b=i3Ad67oLv44e8CcO5HVmCxaZp+wb9SoJLcR7rG4unDXSTKA4RMJoaNl1j4hi3QOSuR FMJK0zRR0T7vRGo7mQnuplLpkkBsvu1hbI2fENT+VZD5+HXOjRNgb88bwGKh+XT1eMk3 xylY70CE29gLhNt1CGz8Of/DSuj8m7pZGB3XGcfNTFG/e2VoiZP6cc53no9v//e3K4Wg fmhkDr/vhupF4dLNAcaFxkYvpQiSlUDOmDNmPWL5zsBDp0AQ/QNMTvJj4TfQgB7Iboec Z+8cC+Lv0Rzs1W1OANVy1SzeiQd5Kld9eE5nyGrgqRKqVCy2sxNcUa8n+vnObH3f+YjJ X9Ow== X-Gm-Message-State: AA+aEWbvMMaIo+hpj0QDjze5CNX+PDx7lqByPNVyVUNaoXlmt+xZJz6P DbQU+nHAcxe/1XIADs1WTWc= X-Received: by 2002:a0c:b48d:: with SMTP id c13mr24204851qve.91.1544029849522; Wed, 05 Dec 2018 09:10:49 -0800 (PST) Received: from dennisz-mbp.thefacebook.com ([199.201.65.135]) by smtp.gmail.com with ESMTPSA id q15sm12098751qkl.81.2018.12.05.09.10.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 05 Dec 2018 09:10:48 -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 Subject: [PATCH 05/14] dm: set the static flush bio device on demand Date: Wed, 5 Dec 2018 12:10:30 -0500 Message-Id: <20181205171039.73066-6-dennis@kernel.org> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20181205171039.73066-1-dennis@kernel.org> References: <20181205171039.73066-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 Acked-by: Mike Snitzer Cc: Alasdair Kergon --- 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..ab72d79775ee 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, &md->flush_bio, as + * the base for cloning. 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 alloc_dev(). + */ + 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