Received: by 10.213.65.68 with SMTP id h4csp1617336imn; Mon, 19 Mar 2018 08:52:21 -0700 (PDT) X-Google-Smtp-Source: AG47ELvJs8fiFsz0Nf4r73UZT60fLs29xHaa7U9ZnIgakl8S9N55WqK3Ftd8sGSY4cENbzxd1vdY X-Received: by 10.99.186.14 with SMTP id k14mr9633053pgf.43.1521474741494; Mon, 19 Mar 2018 08:52:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521474741; cv=none; d=google.com; s=arc-20160816; b=QtZRLGMFv2e9xew49Xy39DEELD0XLKrD5bZKgrlAGswum1tKLaa4w29Bj0EWTQ1Zbc K6mmnulKfMFwqz8EmWEKBGeNUfKO9GOBDz972fY3bLiYuzhFCcjbn9ro9SgN4ILp/P7j JVLWO/FO9HBoD3VkE51KzOc9oSaQ5ptmKJFYQCzugKPiBvBk7TSDOvVO8r3v/vK8HD1O HZUvi2f97lfl7KbTrB+BwTjxqSh2BcUXxadW0cFWbzJyuxYaspOVu2CRaMxaMjMkpqnK SMAhD9MwUrarpKvVXowxIoVBtE6afI8aEm7gdsLffBc36NoJ5VUI0JT4xfdsIwQ56uxx EnVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=GKFEllnF5ndB7r/8utMj5Kp+6FdSjmNc/g4SW7OfT/g=; b=Ki/lHc1qOpINSHFFZc1OmaVxtrMQzdydTB2mCxA6H+oL7i3MMviH1iuhfAAqrvE8Jl 3yOyr1Zk5w0iB1uBUaaHXIkEs0SKAqyJ3yS8g9D+imvY1xdzGAHDgZDP/5yi9Eo8OavC szHV+cs4hoWXGBz65i3Riz97QL4S8TxB5CvaXX1XzD7vtEtRFNr7+/sFS1oAaEHzGh7v 5mX34vYX/OH+UG9dkk+2P46V6ywV/G8m64xYwIOMK33qioPmMB1B3A0CE4gRwRIkG2hK 7DlJCyNlQQcnXggGMata+O65snlyxRuE/lr7m7U90mYf+QfNT+1PJQRLnpTxD/LSL3rJ jPKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=PpHeWjSt; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e67si180070pfa.140.2018.03.19.08.52.06; Mon, 19 Mar 2018 08:52:21 -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; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=PpHeWjSt; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934149AbeCSPut (ORCPT + 99 others); Mon, 19 Mar 2018 11:50:49 -0400 Received: from mail-sn1nam01on0096.outbound.protection.outlook.com ([104.47.32.96]:13186 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934134AbeCSPuk (ORCPT ); Mon, 19 Mar 2018 11:50:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=GKFEllnF5ndB7r/8utMj5Kp+6FdSjmNc/g4SW7OfT/g=; b=PpHeWjSt3ThTE6uUqAL0Jb2kom3gLPvt6r1VrICpSmZOBmxTfziLDLSZrcZZoYWhg8eq3on0k6U9d+uwuUbKXlLocQaTmxv+jeJrwelKquyASAOf6ICyci0HA/OnIrlXY4JZ6ooQqt8Z5KI/0jSgNKacdhjkZ8bk0ZgBbxfJ1YA= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1029.namprd21.prod.outlook.com (52.132.128.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.631.0; Mon, 19 Mar 2018 15:50:38 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::3d9b:79e7:94eb:5d62]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::3d9b:79e7:94eb:5d62%5]) with mapi id 15.20.0631.004; Mon, 19 Mar 2018 15:50:38 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Mike Christie , Nicholas Bellinger , Sasha Levin Subject: [PATCH AUTOSEL for 4.15 123/124] tcmu: release blocks for partially setup cmds Thread-Topic: [PATCH AUTOSEL for 4.15 123/124] tcmu: release blocks for partially setup cmds Thread-Index: AQHTv5nYpPU7O7j1o0q1GGLeBghHZQ== Date: Mon, 19 Mar 2018 15:49:20 +0000 Message-ID: <20180319154645.11350-123-alexander.levin@microsoft.com> References: <20180319154645.11350-1-alexander.levin@microsoft.com> In-Reply-To: <20180319154645.11350-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB1029;7:FhyEDGH5nybR7wTWUa1wmupMdTA1D1QWWh0s4IhUodZCbBfY/FYgnijq48FneKxP8IkYlI+mniMZYy1rj+A0AbFl7Mn+AG3s6a2TZ/2w28Su4SSiCO0rmjwVD6zTFd+QpCguM6unV1LVzb+/DryaBHnTCrMliNMiOhdMdAPRTub0lzV7OwQX1UoJ/bhE4qzeBVsIL8AnWdmSJBBaa5gJxa4im/2kAL3EyG82J1VKYjQzdky9oBDu5UoIaM+O1Thz;20:nfu186ejJUApdbI0O7v1tnp76pliB6Vvy7wjBX5ZhHUe4O3oRSt1J9MhFsdC5+fSJJnh63se0nNxf+4XfvZb4SJwSrDNklZVgz9HOWjRsoq6euQy4EhHJ5SJR3P3/Ku+d8+daXAowxvMO2CZzj/7BlShGQG8OkCvH0ueaA72mi0= x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 045eb2ee-f8c9-4333-156b-08d58db12997 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB1029; x-ms-traffictypediagnostic: DM5PR2101MB1029: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(3231221)(944501300)(52105095)(3002001)(6055026)(61426038)(61427038)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(20161123558120)(20161123560045)(6072148)(201708071742011);SRVR:DM5PR2101MB1029;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB1029; x-forefront-prvs: 06167FAD59 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(366004)(396003)(39380400002)(39860400002)(376002)(346002)(189003)(199004)(59450400001)(10090500001)(102836004)(6506007)(2501003)(5250100002)(2950100002)(86612001)(6666003)(105586002)(14454004)(54906003)(110136005)(3660700001)(97736004)(99286004)(1076002)(2900100001)(6116002)(3846002)(36756003)(7736002)(5660300001)(305945005)(478600001)(186003)(575784001)(81166006)(2906002)(22452003)(3280700002)(76176011)(25786009)(316002)(6512007)(66066001)(4326008)(6486002)(53936002)(6436002)(86362001)(8936002)(107886003)(106356001)(72206003)(8676002)(10290500003)(81156014)(68736007)(26005)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB1029;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: 4kNAxJrxoSNc4XMceJuQEIX7xAZZarL1GEjqQCbAC5odHkXLfIB3tGKTyWrYKbE5lGlEM8OCGJYI/qT2x7aw9MHP38jd4ypb4qiDHSoViCnH35lXtAjXuJog94hg16fqIGu6WS/WOQ7EycVJ5mJHM/azjL3wCGzIBdyG9og6ZlzJF27lTskSIt1gAJaJ8RlSXX43qeD1ras7oCE++VYsLUgc2nea9/uwFA6twO1T4yjeeUWyEz9D/3bCA3Fqe5xy+4kohu8ADBmJXfdIPNvgYgwaTQAFdX1IeCPRFEyHqCgJKSt3xVhd/yIlhFINVhL6MuKkugU8Z9HCBrVs3S13bQ== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 045eb2ee-f8c9-4333-156b-08d58db12997 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Mar 2018 15:49:20.9963 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1029 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/target/target_core_user.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core= _user.c index a415d87f22d2..3ab96d0f705e 100644 --- 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 *tcmu_cmd) int ret; DEFINE_WAIT(__wait); =20 + /* + * 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); =20 pr_debug("sleeping for ring space\n"); --=20 2.14.1