Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp2929010pxy; Mon, 3 May 2021 11:06:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxbXQ4PcTNgyz7mZBpUq7SZ2oD2lwYaVJr2QGEypbISawUUHjU/kFdGweRuE7wRUCjYeN/Y X-Received: by 2002:a17:902:7c91:b029:ed:5748:901e with SMTP id y17-20020a1709027c91b02900ed5748901emr21551632pll.27.1620065172586; Mon, 03 May 2021 11:06:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620065172; cv=none; d=google.com; s=arc-20160816; b=ZL1MV8eiX9yKfeZhQgmfVfxnKTgoNAGKXUtp/hoYbYymx7pVKFR6dAAdQ75hjftVZO 8oAbZS7XGoTwpXe0Jde+QcOCpd6np09rLYqw0xED9kIHI4iP1UZmHqY17jif48lYN0XF CfncRVYI6hcRJDGUTCW2l/mhYGlGQX8YIG6MrBitfc+rdbZi8DNfbVRBa/CjO6UM1lp2 nybVZTHRcit1TLxiDoYXSuC94xi9ZqzKTclyj5VffWvqUw8LkI/H0zaSzbIwa/BWQtbx uBj3TnRSakr8MUbEUNTII8USDgqnkR8Sc6LnLehh4HYe6TTTv7L3Q7FvhiRxbJJOe99V +KpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=OYCeAO0sMXDZDTjMjIXIAYqt/mYeDyYR+eRpRHRCWxQ=; b=yOXwWV8Q+F3X7c/jLwiFhsbpTGOlq1BTY4K0Um9ZQz04y4al/uskq0VTwE/rzI1F8J vhWpLGvDkoHx7EKlElfCV21/ohrU/HID/qGjEvUGBC116SVDSwsvYbdM4Sd3HAd31Z7/ J3Wkw9NSw66OcagWlbgq0iGLtDa0swHfZbB8qSnMoCLsOGHbZ+6GXul9fh8Jd2w6XNlI vLcANO/+4STH4B5wDG2IqELkEA//L68lsJlkMyA/wl5ZP4YELP0GX9BiQ5l1zSv6HxKq UP3df29cuZQVLXIb8H+fyy5ixHXVJCaZrvulcOPWz0fvMoI+lUT7Esm4NvNzif1BXCo1 7UNQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j5si13954483pfc.206.2021.05.03.11.05.55; Mon, 03 May 2021 11:06:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233580AbhECM6k (ORCPT + 99 others); Mon, 3 May 2021 08:58:40 -0400 Received: from mx2.suse.de ([195.135.220.15]:39174 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231180AbhECM6j (ORCPT ); Mon, 3 May 2021 08:58:39 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id BBFD5AC38; Mon, 3 May 2021 12:57:45 +0000 (UTC) From: Daniel Wagner To: linux-nvme@lists.infradead.org Cc: linux-kernel@vger.kernel.org, Hannes Reinecke , Keith Busch , Jens Axboe , Christoph Hellwig , Daniel Wagner Subject: [PATCH] nvme-multipath: Reset bi_disk to ns head when failover Date: Mon, 3 May 2021 14:57:41 +0200 Message-Id: <20210503125741.68117-1-dwagner@suse.de> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The path can be stale when we failover. If we don't reset the bdev to the ns head and the I/O finally completes in end_io() it will triggers a crash. By resetting the to ns head disk so that the submit path can map the request to an active path. Signed-off-by: Daniel Wagner --- The patch is against nvme-5.13. [ 6552.155244] Call Trace: [ 6552.155251] bio_endio+0x74/0x120 [ 6552.155260] nvme_ns_head_submit_bio+0x36f/0x3e0 [nvme_core] [ 6552.155266] ? __switch_to_asm+0x34/0x70 [ 6552.155269] ? __switch_to_asm+0x40/0x70 [ 6552.155271] submit_bio_noacct+0x175/0x490 [ 6552.155274] ? __switch_to_asm+0x34/0x70 [ 6552.155277] ? __switch_to_asm+0x34/0x70 [ 6552.155284] ? nvme_requeue_work+0x5a/0x70 [nvme_core] [ 6552.155290] nvme_requeue_work+0x5a/0x70 [nvme_core] [ 6552.155296] process_one_work+0x1f4/0x3e0 [ 6552.155299] worker_thread+0x2d/0x3e0 [ 6552.155302] ? process_one_work+0x3e0/0x3e0 [ 6552.155305] kthread+0x10d/0x130 [ 6552.155307] ? kthread_park+0xa0/0xa0 [ 6552.155311] ret_from_fork+0x35/0x40 drivers/nvme/host/multipath.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c index 0d0de3433f37..0faf267faa58 100644 --- a/drivers/nvme/host/multipath.c +++ b/drivers/nvme/host/multipath.c @@ -69,7 +69,9 @@ void nvme_failover_req(struct request *req) { struct nvme_ns *ns = req->q->queuedata; u16 status = nvme_req(req)->status & 0x7ff; + struct block_device *bdev; unsigned long flags; + struct bio *bio; nvme_mpath_clear_current_path(ns); @@ -83,9 +85,13 @@ void nvme_failover_req(struct request *req) queue_work(nvme_wq, &ns->ctrl->ana_work); } + bdev = bdget_disk(ns->head->disk, 0); spin_lock_irqsave(&ns->head->requeue_lock, flags); + for (bio = req->bio; bio; bio = bio->bi_next) + bio_set_dev(bio, bdev); blk_steal_bios(&ns->head->requeue_list, req); spin_unlock_irqrestore(&ns->head->requeue_lock, flags); + bdput(bdev); blk_mq_end_request(req, 0); kblockd_schedule_work(&ns->head->requeue_work); -- 2.29.2