Received: by 10.192.165.156 with SMTP id m28csp63385imm; Tue, 10 Apr 2018 16:28:09 -0700 (PDT) X-Google-Smtp-Source: AIpwx49VUO+1ZB46z4fLYxhhINnJky8jprLCoYaEjz+bgcMJUjysOB58ThaTxAUZHg3LK/jGvCIr X-Received: by 2002:a17:902:24a5:: with SMTP id w34-v6mr2446923pla.328.1523402889213; Tue, 10 Apr 2018 16:28:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523402889; cv=none; d=google.com; s=arc-20160816; b=DaNvLXmotUi2PsqILbY9ke3xNEx55Y8wEcg+TBaq9cnmP26YAjbOxpUXQ5BWSrBpv7 y3nCGU+XUIVCY0QePPBHckIVIgzkMBbGrbco+OqpTDAE8MdJKcPiTOVrIJFyzexKZ3ZS hf7rY1y9SJvF1UmUIclRb2AGx6kEGSf16IJ97q3eGAwRpRMBfuDKmnzrA6EmPCrSDPW7 JMvUpI67KCyp5NZL1etC7NpWtTyaq+WUlYiLQOesiSm/R2SWL25xfrDvK9yiQAbv6Hb8 lRzG12iV8T30NVWFIpX4TgTeX40cc1uDxG8TSVeH8eQ0RjeIbFl4M8PQaEZSRd9AIecz MeXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=iAS4UHqg9i1jEDw3U1g7IFlexnpMJvfRnVeHtPZBYQ4=; b=RUYLjnAIAQrkelyrJTKJXzUBY4TidtxH3x0dI+b/JJQIL9pqXpF3W2dVkZsJYLC9+Y H8XI+RCpxFkIp2rngqpTkVgTLioA5wAcGc8tG2Hc7iRLVW4qatOrqO1Yo44bz4CZ+Zlc uejRwtZVOkgBlLeI9ZpgPk547+HnoPZFKUEQZ9MJ2UPwrVQnrbuVAtGXtMczZPzNzTmL bfoXAakkTdm+Nw/H7PaeOyZIERYooHJ8QaiITEUKWMYV2ygjOtwTkeTUyfdmcvIXbkDP iRnSdARDuFUFTHYijZ81gC77B8Vev18hNfb7uE1C9MT4WkdoLTbEiaC4Ckr8keF0juA6 HzMQ== 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 t3si2325160pgc.87.2018.04.10.16.27.32; Tue, 10 Apr 2018 16:28:09 -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 S1754883AbeDJXWk (ORCPT + 99 others); Tue, 10 Apr 2018 19:22:40 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:40028 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754587AbeDJWac (ORCPT ); Tue, 10 Apr 2018 18:30:32 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 955E6DE5; Tue, 10 Apr 2018 22:30:31 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mike Christie , Nicholas Bellinger , Sasha Levin Subject: [PATCH 4.15 105/168] tcmu: release blocks for partially setup cmds Date: Wed, 11 Apr 2018 00:24:07 +0200 Message-Id: <20180410212804.710990639@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180410212800.144079021@linuxfoundation.org> References: <20180410212800.144079021@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mike Christie [ Upstream commit 810b8153c4243d2012a6ec002ddd3bbc9a9ae8c2 ] If we cannot setup a cmd because we run out of ring space or global pages release the blocks before sleeping. This prevents a deadlock where dev0 has waiting_blocks set and needs N blocks, but dev1 to devX have each allocated N / X blocks and also hit the global block limit so they went to sleep. find_free_blocks is not able to take the sleeping dev's blocks becaause their waiting_blocks is set and even if it was not the block returned by find_last_bit could equal dbi_max. The latter will probably never happen because DATA_BLOCK_BITS is so high but in the next patches DATA_BLOCK_BITS and TCMU_GLOBAL_MAX_BLOCKS will be settable so it might be lower and could happen. Signed-off-by: Mike Christie Signed-off-by: Nicholas Bellinger Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/target/target_core_user.c | 7 +++++++ 1 file changed, 7 insertions(+) --- a/drivers/target/target_core_user.c +++ b/drivers/target/target_core_user.c @@ -805,6 +805,13 @@ tcmu_queue_cmd_ring(struct tcmu_cmd *tcm int ret; DEFINE_WAIT(__wait); + /* + * Don't leave commands partially setup because the unmap + * thread might need the blocks to make forward progress. + */ + tcmu_cmd_free_data(tcmu_cmd, tcmu_cmd->dbi_cur); + tcmu_cmd_reset_dbi_cur(tcmu_cmd); + prepare_to_wait(&udev->wait_cmdr, &__wait, TASK_INTERRUPTIBLE); pr_debug("sleeping for ring space\n");