Received: by 10.192.165.156 with SMTP id m28csp27806imm; Tue, 10 Apr 2018 15:41:38 -0700 (PDT) X-Google-Smtp-Source: AIpwx4//T6RpH1+HZ/Rk/6A1lqb9XOuQ8QdZCRhnh2+Ur67UDF4Gzmz8A3YXRvrWB9gxuVbN81Re X-Received: by 10.98.202.212 with SMTP id y81mr1832052pfk.227.1523400098906; Tue, 10 Apr 2018 15:41:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523400098; cv=none; d=google.com; s=arc-20160816; b=Wie1hGcJNqzL/RqR08TSE26XwAAH+esgVWoZu15IPoGRHs2vp2JrnjCr0K6wyNmGQy Y0qKcQpGxJulWQzCM1dC69lAJuo1Z8/lzjaholKZiyG6BUbNniT2H1UjA8e3CDZ+HZ7z RvgQN3gDpSbAgBXxrrZ7T+7g5FJdhq6xwTssu7HnZHxiWeh+Hrntztp+9rJAyB4ggdgG AdlfmytGrB30qSXSu5/AcaLsyvBt3UdDJldkbS6C9A/fsaC26P5mAWRUO+sIoABFfwEm ucSg26tMR7KCtSFtmF9TQ4gN38smJ6nPPguO3VFV12t9h4HDG5zVTCSiPZXDICRYflvN 889A== 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=oYCLZK1n3yUP+YlLm7ClBpGddT5Eeay0eXuZhO4y45Y=; b=SJmo8O08GscjZjUy7NFo7rC/XHk+6TCMyWJvnZ3Qe1kmXnoOd/t/p9RUT5JlTETX4t QvDAGlv2wnq4uMaqFM8AHGFge7EP09Wnnk2FkO7zOklsY9Wqt23Szn4B40l0wHeZgRrB d/ur0v5wGQirmwPV5x3Ei28gIwzhzW+zxjoCuJUR7PWG1I+lF3pwHZu01JhyW9lSLCZg DndiGvc3YcxNFGjsgSoguoKtDwanTevtAqRe376k1ep1Chb3sLDiU5pAMx4GM3QJsuyP h/LbFPhHEYZtClcyvE3L/Uu2p9G1d67x4nBtN/ECc2Uht1cQHZAYJ04tgrhTwJM1SVwS k42g== 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 g6-v6si3713427plt.580.2018.04.10.15.41.02; Tue, 10 Apr 2018 15:41:38 -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 S932441AbeDJWhT (ORCPT + 99 others); Tue, 10 Apr 2018 18:37:19 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:43730 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932429AbeDJWhQ (ORCPT ); Tue, 10 Apr 2018 18:37:16 -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 E0BF1BB6; Tue, 10 Apr 2018 22:37:15 +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.14 081/138] tcmu: release blocks for partially setup cmds Date: Wed, 11 Apr 2018 00:24:31 +0200 Message-Id: <20180410212911.554748451@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180410212902.121524696@linuxfoundation.org> References: <20180410212902.121524696@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.14-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 @@ -796,6 +796,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");