Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3085219ybt; Mon, 29 Jun 2020 14:59:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwVoT0GZphZx5dfvPsf1IOcfDWqHdCRfDa5lKRFmEkA0syzmoM/aurAiqmMRHoOyGbJ6Jcm X-Received: by 2002:a17:906:c44c:: with SMTP id ck12mr16255773ejb.145.1593467966182; Mon, 29 Jun 2020 14:59:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593467966; cv=none; d=google.com; s=arc-20160816; b=06YgEUn4d0PyzluH+gkm5J3+Osqvlo5FdXS9j2VWTxNUCHTf2Gaj0oqBxs1V7bw/Sl dw7GXIVZpF+HOKLSjxucSeE8Qc9jODj4Qky/XfEtcQH0MNrr3Lw5m43As6XapxpWS0rh uX5QljmvXcUqv3s3WecLz1cWqI1SH081VoV2IexuAlNKf6chwtF8Z5VTl2JzjamSKeva wsAO5mCn4YsMXCcB8V2IXFKRKXGnV0A5xHEnhRUuTAFMRXFAIs//DO0FqhdhfMYkuad4 wycdx9L7I/CaWeH57Z5WIP0sZIKPLzBEJqqXCbmldQTW+putqjGKyItWBT4KFK2vOg+H YOqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=UMJ7v7+bIfpW2j+iZdxTKMsGn20b8bNN1whgFEgvtTA=; b=Dv6HEQPPZdk3yVc4hHxcl/YM3QY+dPk0NlR7DTxn7pMxGRiWpafqz0p3fkX5nZODNC KmIvO5Mgbv4ODE/uqq3g9to4JtqDZVd1sDMgDYTg/j1TEIY5F+wYJxAiqSLJ1cvJPwDn B+3bNa1uEtV6wTB2uuSUPSK9s8PlVThVBI4Oc7nBVS3CIcAk2NMKhYqO4hrXCin0lpUQ tEofNzJ/YXlWfrYha9yxkYBiRnm/H3rRLEC4KsgDQSvTlrs3FWkfkXSTt1aU5XAlGAXb IW7KEe8fmTl8emrBIbBlngDDkG/kKHUH2RWphSrZE4q2ncR13TmtbGgcnaGNly8RmtVr L3WA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=x7oDvbLv; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l22si510986eji.104.2020.06.29.14.59.03; Mon, 29 Jun 2020 14:59:26 -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; dkim=pass header.i=@kernel.org header.s=default header.b=x7oDvbLv; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404761AbgF2V6A (ORCPT + 99 others); Mon, 29 Jun 2020 17:58:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:56912 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726466AbgF2Sf2 (ORCPT ); Mon, 29 Jun 2020 14:35:28 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F3DD224738; Mon, 29 Jun 2020 15:20:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593444056; bh=0V9LpGvwu46MBFnwcEy1Q6J7udxjm8FaxSsiywu298U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=x7oDvbLvISdolKsP5JSxwzA+L1pjeKuD7AXha3ttxMf4C7U9dNIOaDN0l709ZQXPA KyAedZhybjzrjOUD5WuAmU0k97sU8udyipksSDx5NSyMZVxrAC8QvvHSTgEjq3ZwNX 7Gun/mdGVbJuvw5eDdrOxKpXRIfR3tiifPpA1tys= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Sagi Grimberg , Anton Eidelman , Christoph Hellwig , Sasha Levin Subject: [PATCH 5.7 164/265] nvme: don't protect ns mutation with ns->head->lock Date: Mon, 29 Jun 2020 11:16:37 -0400 Message-Id: <20200629151818.2493727-165-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200629151818.2493727-1-sashal@kernel.org> References: <20200629151818.2493727-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.7.7-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.7.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.7.7-rc1 X-KernelTest-Deadline: 2020-07-01T15:14+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sagi Grimberg [ Upstream commit e164471dcf19308d154adb69e7760d8ba426a77f ] Right now ns->head->lock is protecting namespace mutation which is wrong and unneeded. Move it to only protect against head mutations. While we're at it, remove unnecessary ns->head reference as we already have head pointer. The problem with this is that the head->lock spans mpath disk node I/O that may block under some conditions (if for example the controller is disconnecting or the path became inaccessible), The locking scheme does not allow any other path to enable itself, preventing blocked I/O to complete and forward-progress from there. This is a preparation patch for the fix in a subsequent patch where the disk I/O will also be done outside the head->lock. Fixes: 0d0b660f214d ("nvme: add ANA support") Signed-off-by: Anton Eidelman Signed-off-by: Sagi Grimberg Signed-off-by: Christoph Hellwig Signed-off-by: Sasha Levin --- drivers/nvme/host/multipath.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c index fece4654fa3e7..f4287d8550a9f 100644 --- a/drivers/nvme/host/multipath.c +++ b/drivers/nvme/host/multipath.c @@ -410,11 +410,10 @@ static void nvme_mpath_set_live(struct nvme_ns *ns) { struct nvme_ns_head *head = ns->head; - lockdep_assert_held(&ns->head->lock); - if (!head->disk) return; + mutex_lock(&head->lock); if (!(head->disk->flags & GENHD_FL_UP)) device_add_disk(&head->subsys->dev, head->disk, nvme_ns_id_attr_groups); @@ -427,9 +426,10 @@ static void nvme_mpath_set_live(struct nvme_ns *ns) __nvme_find_path(head, node); srcu_read_unlock(&head->srcu, srcu_idx); } + mutex_unlock(&head->lock); - synchronize_srcu(&ns->head->srcu); - kblockd_schedule_work(&ns->head->requeue_work); + synchronize_srcu(&head->srcu); + kblockd_schedule_work(&head->requeue_work); } static int nvme_parse_ana_log(struct nvme_ctrl *ctrl, void *data, @@ -484,14 +484,12 @@ static inline bool nvme_state_is_live(enum nvme_ana_state state) static void nvme_update_ns_ana_state(struct nvme_ana_group_desc *desc, struct nvme_ns *ns) { - mutex_lock(&ns->head->lock); ns->ana_grpid = le32_to_cpu(desc->grpid); ns->ana_state = desc->state; clear_bit(NVME_NS_ANA_PENDING, &ns->flags); if (nvme_state_is_live(ns->ana_state)) nvme_mpath_set_live(ns); - mutex_unlock(&ns->head->lock); } static int nvme_update_ana_state(struct nvme_ctrl *ctrl, @@ -670,10 +668,8 @@ void nvme_mpath_add_disk(struct nvme_ns *ns, struct nvme_id_ns *id) nvme_update_ns_ana_state(&desc, ns); } } else { - mutex_lock(&ns->head->lock); ns->ana_state = NVME_ANA_OPTIMIZED; nvme_mpath_set_live(ns); - mutex_unlock(&ns->head->lock); } if (bdi_cap_stable_pages_required(ns->queue->backing_dev_info)) { -- 2.25.1