Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp2930569pxy; Mon, 3 May 2021 11:08:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvMq+Dw/axLaErbg3UDZNThZXtGLt+1zukY5BM7M6yKfx1pBQC6xSuZyGYtuALdovXFZyZ X-Received: by 2002:aa7:dc0b:: with SMTP id b11mr21785058edu.124.1620065284417; Mon, 03 May 2021 11:08:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620065284; cv=none; d=google.com; s=arc-20160816; b=X7HguYcYZyrYtZ9teOQWzjvsNW4rr/WSWw4qUYqU9QjlJGutH5zWsEOVX6ZTf4M0Sg XyTUDMLKntX5mh5v8XzOpyuDwt+5Bs66MCB74ee2EGa2B+jhBW0+wFp6G6irm+0YLTfe UlNWrQuN7p1sMCSyeECqz6Dj96Q68/vYgQ1BJqai4x/nq0AJD0MB3R+WWEf65kEOIjG0 sczhEdyWp+YNiPQOqnzoI2Xg5w+xuhuZSaPvEKEIn/naoqD2CMX0tkjSYTBpwaTF/2Bn WOA1+3CC2o6hefTTkRoWVUwtCyxzRtFEGbcoPvYvnn5/bsUO8LxovOCSYXNeQiCfF9ZF d48w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=1vgsJKEFASSp/gtXc0RMDJGM+tcpU99iGiCsIt1JwME=; b=lGVUiT3e9QiqOpk3w2WMB28zVNG11TsxDheX5/MZtFaKDo0VVPtqPcyQ1EyGGr5yPg H75b6nqJjsnygKAn4cFeTj/11+Yok7afP0XM2J6UlTRcqhEx6Y056S4dMnbCSQdYdVLj aDtJXqMqiyugInzduqGGGLN4IRLBABUSRHhGtbFpz9uLqunUpbucYPyWnGhxjm61dwHb BH56mqvS/dkY7BFBYyL3hgNNAgmiYqomZMKYEBSCRJmqG+rDjgxtlPaRz8K5d/Q3LMhn 3fGCYjPbusr3oJZbJJ42J9BsaKsUiNIgXF1yYiSMLhz5KfSo7zu0MXi3LR16nnxqdgZN ZezQ== 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 nc18si468377ejc.435.2021.05.03.11.07.33; Mon, 03 May 2021 11:08:04 -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 S234308AbhECNe3 (ORCPT + 99 others); Mon, 3 May 2021 09:34:29 -0400 Received: from mx2.suse.de ([195.135.220.15]:35622 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232984AbhECNe1 (ORCPT ); Mon, 3 May 2021 09:34:27 -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 E04A9B118; Mon, 3 May 2021 13:33:32 +0000 (UTC) Subject: Re: [PATCH] nvme-multipath: Reset bi_disk to ns head when failover To: Daniel Wagner , linux-nvme@lists.infradead.org Cc: linux-kernel@vger.kernel.org, Keith Busch , Jens Axboe , Christoph Hellwig References: <20210503125741.68117-1-dwagner@suse.de> From: Hannes Reinecke Message-ID: <7ab943e0-5ac4-d370-0a15-3108f689e478@suse.de> Date: Mon, 3 May 2021 15:33:32 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: <20210503125741.68117-1-dwagner@suse.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/3/21 2:57 PM, Daniel Wagner wrote: > 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); > Maybe a WARN_ON(!bdev) after bdget_disk(), but otherwise: Reviewed-by: Hannes Reinecke Cheers, Hannes -- Dr. Hannes Reinecke Kernel Storage Architect hare@suse.de +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer