Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95019C433DF for ; Wed, 24 Jun 2020 00:19:10 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4271C2078E for ; Wed, 24 Jun 2020 00:19:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="249lVJna" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4271C2078E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=grimberg.me Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-nvme-bounces+linux-nvme=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=Pw9B3AdxPsVu/tc7hT8E8kaqKe+l3BB6YlRxl9CFE5E=; b=249lVJnal/0aNQdIhHDUit2OQq sRLeot++2dNM9ErsX2WUWrmb/Efco/LQtF+VbQY06Ww5wYtwJQusau1NmB5YaUE54C3xNo1mZ8un/ /1DxvL0lpaZgC1ASKyTx9b7HFGepdsmGnlqMFJGKckdxvgKT/cM8LjHmMLjmTU/De4SdlD8akswfI uwwds0xlrOFV1eIjcllCAUHp0sauoskKDJVgq8sau8D4QbKXQTW201MRROdG6gluPvQxWi7Js6+gJ NKNIsOFhmH4tvk+OtDLtkp/fYOP80Q/4AX6crrXO/k5qVYWfC1K4dns3W7Ddoz9e8Tm7l42qVbzmI JGX3nB8Q==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jnt82-0001cR-QA; Wed, 24 Jun 2020 00:19:04 +0000 Received: from mail-pj1-f44.google.com ([209.85.216.44]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jnt7y-0001bB-RJ for linux-nvme@lists.infradead.org; Wed, 24 Jun 2020 00:18:59 +0000 Received: by mail-pj1-f44.google.com with SMTP id ga6so267216pjb.1 for ; Tue, 23 Jun 2020 17:18:56 -0700 (PDT) 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:mime-version :content-transfer-encoding; bh=p5L+1kkX31tUV+qumI6C/4nTkxW39sa6COMfmp1TW4M=; b=Lgz/J+KjYV6ZxWbVzzYi1t5b2+JujxA3ItmwZGBqA/WC8Lfw6WGpXqVmeOawnJFQCQ CzlPQQzJtB3pvugFVaFzsvZSIW8JRvdUOdPDZKkjdqT4mPgtfUP8rWJMD2uBVBh9i3lO TsRu149XnR+qQFmeStReE7C7KCC4J8mjWS/D2xWR1P+vPvOkeSRtCbbGKZjzBcctw/fW djarrB+QXap1wfeKf5Vk4MWctCOFIEjyC1Cj5mgkgO0+EWOOyRid367fLx14Qwz2+3BI 3s3dLRBfmL7esAEfN1n55f57QvPJJ9yQJOA7LZnrbK/eD9YWaDdzs39EDVjf9f6nx6mC sW9A== X-Gm-Message-State: AOAM530X78f0hLVjrcgleDeaXPRQQVEx1iunWw7z6cmQMsrVkFmqPldc iV6nRqtD3DWFOcWe1rM0kTaEPOXP X-Google-Smtp-Source: ABdhPJyTqBoIpUjkJJJYHdAmzuxpFLw4ehcn//MxUmlg3efSND60/Q4uV7TA36wPPonuXvxHGRbVXA== X-Received: by 2002:a17:90b:4d06:: with SMTP id mw6mr27406748pjb.190.1592957935782; Tue, 23 Jun 2020 17:18:55 -0700 (PDT) Received: from sagi-Latitude-7490.hsd1.ca.comcast.net ([2601:647:4802:9070:9915:87a9:9728:63e]) by smtp.gmail.com with ESMTPSA id d2sm14571840pgp.56.2020.06.23.17.18.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jun 2020 17:18:55 -0700 (PDT) From: Sagi Grimberg To: linux-nvme@lists.infradead.org, Christoph Hellwig , Keith Busch Subject: [PATCH v2 for-5.8-rc 0/6] address deadlocks in high stress ns scanning and ana updates Date: Tue, 23 Jun 2020 17:18:47 -0700 Message-Id: <20200624001853.5408-1-sagi@grimberg.me> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-BeenThere: linux-nvme@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anton Eidelman Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "Linux-nvme" Errors-To: linux-nvme-bounces+linux-nvme=archiver.kernel.org@lists.infradead.org Changes from v1: - Fixed compilation error in patch #4 - Added patch #5 to resolve a use-after-free condition Hey All, The following patches addresses some deadlocks observed while performing some stress testing of a connect/disconnect storm in addition to rapid ana path switches concurrently (paths may transition between live<->inaccessible) on a large number of namespaces (100+). The test mainly triggers three main flows: 1. ongoing ns scanning, in the presence of concurrent ANA path state changes and controller removals (disconnect). 2. ongoing ns scanning (or ana processing) in the presence of concurrent controller removal (disconnect). 3. ongoing ANA processing in the presence of concurrent controller removal (disconnect). What was observed is that basically when we disconnect while scan_work and/or ana_work are running, we can easily deadlock. The main reason is that scan_work and ana_work may both register the gendisk, triggering I/O (partition scans). Given that a controller removal (disconnect) may also be running at the same time, I/O may block. The issue with blocking the head->disk I/O under the locks taken by both ana_work and scan_work, it means that no other path may update path states and by doing so, unblock the blocking I/O. With this patchset applied, the test is able to pass successfully without any deadlocks. The last patch is posted as an RFC, while it solves a real problem, we are essentially adding state to the controller without it going via the normal controller state, the reason is that the controller state will also affect ongoing mpath I/O which is the original cause of the deadlock. We are open to alternative better suggestions if such exist. Anton Eidelman (3): nvme-multipath: fix deadlock between ana_work and scan_work nvme-multipath: fix deadlock due to head->lock nvme-core: fix deadlock in disconnect during scan_work and/or ana_work Sagi Grimberg (3): nvme: fix possible deadlock when I/O is blocked nvme: don't protect ns mutation with ns->head->lock nvme-multipath: fix bogus request queue reference put drivers/nvme/host/core.c | 11 +++++++- drivers/nvme/host/multipath.c | 48 +++++++++++++++++++++++++---------- drivers/nvme/host/nvme.h | 3 +++ 3 files changed, 47 insertions(+), 15 deletions(-) -- 2.25.1 _______________________________________________ Linux-nvme mailing list Linux-nvme@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-nvme