Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp8373789ybi; Tue, 9 Jul 2019 14:30:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqxDICMiLmiQ4wlLIzPVko6Lw9xug9+IJE7KPS9QYnl8lmiONLIMYeMwYPWeLZ2gCWK7FriK X-Received: by 2002:a63:7358:: with SMTP id d24mr32879185pgn.224.1562707803235; Tue, 09 Jul 2019 14:30:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562707803; cv=none; d=google.com; s=arc-20160816; b=RI2lB6R2M1p8iTm9eJEu2wJtZeHEWZFf2vdMsmLoduluPB0HKCEeczPjnn7UBwkndx gxo35j9NSIG8iC/J1ttzCqIRbkuJSD21sjlKSz1/Vo3vuVa7rFlsYFsw/8AsxgOLg8pz jfDNUgTbxXVBMemV558filPrYgXjD8PScPA7oSHj72uOVNkGX+iPxsguV03O+mamSs5f jwDaQQNpVuH3WIIO18R06QFK1G8cpn7CChDx/Mj7GRtZLw48I9MCsWON/mwLkf7t3C1s ivU7eheCbFo5pOZ82ladSTa5arvDu9l3jIyAwH6QNYlzoHEUC2IUQVqAGOdrZ1cWouw8 357w== 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=sOS6siw98mR2lV9ZofdoLXy24+yfqjlFYkAR6ATAgR0=; b=yWQSZYkH4yTSqI2Yif0Yf75/afkgOeiw5HiM+HOaxor3nwDiEA2WoDMe+VA++zjgxw hFBc/3z/7PDg2Pg1zpI4VvJIzV4DoudtF5KR9YMUwJDreNzSv39mmioVgvJl0+cu9KmL tE9ky3VZwwXbkzEKBKdRXqbPgw9+cFY/dX624Bl+CMMSfujN/kpmCJ+gaXOTuj52ZR4J 8T1XhTjhZblxNggxr8Dap0y6B4duhrWmH9vd2XWEnuDGdvB/evoXQb1Bs+Fo8rmJwyB9 sF+2NStcjfKaHKCfMbxa19G+pFwwE1/vKHkEQKSVCB/QOwwYzVYXt/NgAz7MOCG83C7z foaw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s23si29404pgm.345.2019.07.09.14.29.47; Tue, 09 Jul 2019 14:30:03 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729108AbfGIV3H (ORCPT + 99 others); Tue, 9 Jul 2019 17:29:07 -0400 Received: from verein.lst.de ([213.95.11.211]:45686 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726428AbfGIV3H (ORCPT ); Tue, 9 Jul 2019 17:29:07 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id E0B2468B02; Tue, 9 Jul 2019 23:29:04 +0200 (CEST) Date: Tue, 9 Jul 2019 23:29:04 +0200 From: Christoph Hellwig To: Max Gurtovoy Cc: Marta Rybczynska , kbusch@kernel.org, axboe@fb.com, hch@lst.de, sagi@grimberg.me, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Samuel Jones , Jean-Baptiste Riaux Subject: Re: [PATCH v2] nvme: fix multipath crash when ANA desactivated Message-ID: <20190709212904.GB9636@lst.de> References: <1575872828.30576006.1562335512322.JavaMail.zimbra@kalray.eu> <989987da-6711-0abc-785c-6574b3bb768c@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <989987da-6711-0abc-785c-6574b3bb768c@mellanox.com> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jul 06, 2019 at 01:06:44PM +0300, Max Gurtovoy wrote: >> + /* check if multipath is enabled and we have the capability */ >> + if (!multipath) >> + return 0; >> + if (!ctrl->subsys || ((ctrl->subsys->cmic & (1 << 3)) != 0)) > > shouldn't it be: > > if (!ctrl->subsys || ((ctrl->subsys->cmic & (1 << 3)) == 0)) > > or > > if (!ctrl->subsys || !(ctrl->subsys->cmic & (1 << 3))) > > > Otherwise, you don't really do any initialization and return 0 in case you have the capability, right ? Yes. FYI, my idea how to fix this would be something like: diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c index a9a927677970..cdb3e5baa329 100644 --- a/drivers/nvme/host/multipath.c +++ b/drivers/nvme/host/multipath.c @@ -12,11 +12,6 @@ module_param(multipath, bool, 0444); MODULE_PARM_DESC(multipath, "turn on native support for multiple controllers per subsystem"); -inline bool nvme_ctrl_use_ana(struct nvme_ctrl *ctrl) -{ - return multipath && ctrl->subsys && (ctrl->subsys->cmic & (1 << 3)); -} - /* * If multipathing is enabled we need to always use the subsystem instance * number for numbering our devices to avoid conflicts between subsystems that @@ -622,7 +617,7 @@ int nvme_mpath_init(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id) { int error; - if (!nvme_ctrl_use_ana(ctrl)) + if (!multipath || !ctrl->subsys || !(ctrl->subsys->cmic & (1 << 3))) return 0; ctrl->anacap = id->anacap; diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h index 716a876119c8..14eca76bec5c 100644 --- a/drivers/nvme/host/nvme.h +++ b/drivers/nvme/host/nvme.h @@ -485,7 +485,10 @@ extern const struct attribute_group *nvme_ns_id_attr_groups[]; extern const struct block_device_operations nvme_ns_head_ops; #ifdef CONFIG_NVME_MULTIPATH -bool nvme_ctrl_use_ana(struct nvme_ctrl *ctrl); +static inline bool nvme_ctrl_use_ana(struct nvme_ctrl *ctrl) +{ + return ctrl->ana_log_buf != NULL; +} void nvme_set_disk_name(char *disk_name, struct nvme_ns *ns, struct nvme_ctrl *ctrl, int *flags); void nvme_failover_req(struct request *req);