From patchwork Fri Aug 11 05:43:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 9894979 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5A126603B4 for ; Fri, 11 Aug 2017 05:43:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 45E8928992 for ; Fri, 11 Aug 2017 05:43:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3AE2928BDA; Fri, 11 Aug 2017 05:43:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 204D228BCE for ; Fri, 11 Aug 2017 05:43:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752507AbdHKFnm (ORCPT ); Fri, 11 Aug 2017 01:43:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46932 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752465AbdHKFnm (ORCPT ); Fri, 11 Aug 2017 01:43:42 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D3F1C4A718; Fri, 11 Aug 2017 05:43:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D3F1C4A718 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=mchristi@redhat.com Received: from rh2.redhat.com (ovpn-120-3.rdu2.redhat.com [10.10.120.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4A3BAA105F; Fri, 11 Aug 2017 05:43:41 +0000 (UTC) From: Mike Christie To: target-devel@vger.kernel.org, nab@linux-iscsi.org Cc: Mike Christie Subject: [PATCH 1/2] tcmu: add qfull timeout for ring space waits Date: Fri, 11 Aug 2017 00:43:38 -0500 Message-Id: <1502430219-7644-2-git-send-email-mchristi@redhat.com> In-Reply-To: <1502430219-7644-1-git-send-email-mchristi@redhat.com> References: <1502430219-7644-1-git-send-email-mchristi@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 11 Aug 2017 05:43:42 +0000 (UTC) Sender: target-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 30 secs (default timeout) is too long to wait for memory. For ESX we would have seen several aborts and linux will just be starting to send an abort. We would like to fail these commands with TASK SET FULL so the initaitor knows it is sendng too many commands. We do not want to use the same time out value as cmd_time_out because we may not want that set if userspace has its own timers for commands that have got ring space and made it to the userspace daemon. This adds a new tcmu timeout for this case, qfull_time-out which controls how long we wait for ring space. Signed-off-by: Mike Christie --- drivers/target/target_core_user.c | 42 +++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c index fd9fcea..7d1da43 100644 --- a/drivers/target/target_core_user.c +++ b/drivers/target/target_core_user.c @@ -145,6 +145,7 @@ struct tcmu_dev { struct timer_list timeout; unsigned int cmd_time_out; + unsigned int qfull_time_out; spinlock_t nl_cmd_lock; struct tcmu_nl_cmd curr_nl_cmd; @@ -864,12 +865,15 @@ static inline size_t tcmu_cmd_get_cmd_size(struct tcmu_cmd *tcmu_cmd, if (udev->cmd_time_out) ret = schedule_timeout( msecs_to_jiffies(udev->cmd_time_out)); + else if (udev->qfull_time_out) + ret = schedule_timeout( + msecs_to_jiffies(udev->qfull_time_out)); else ret = schedule_timeout(msecs_to_jiffies(TCMU_TIME_OUT)); finish_wait(&udev->wait_cmdr, &__wait); if (!ret) { - pr_warn("tcmu: command timed out\n"); - return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; + pr_warn("tcmu: command timed out waiting for ring space.\n"); + return TCM_OUT_OF_RESOURCES; } mutex_lock(&udev->cmdr_lock); @@ -1816,8 +1820,8 @@ static ssize_t tcmu_cmd_time_out_show(struct config_item *item, char *page) return snprintf(page, PAGE_SIZE, "%lu\n", udev->cmd_time_out / MSEC_PER_SEC); } -static ssize_t tcmu_cmd_time_out_store(struct config_item *item, const char *page, - size_t count) +static ssize_t tcmu_cmd_time_out_store(struct config_item *item, + const char *page, size_t count) { struct se_dev_attrib *da = container_of(to_config_group(item), struct se_dev_attrib, da_group); @@ -1840,6 +1844,35 @@ static ssize_t tcmu_cmd_time_out_store(struct config_item *item, const char *pag } CONFIGFS_ATTR(tcmu_, cmd_time_out); +static ssize_t tcmu_qfull_time_out_show(struct config_item *item, char *page) +{ + struct se_dev_attrib *da = container_of(to_config_group(item), + struct se_dev_attrib, da_group); + struct tcmu_dev *udev = container_of(da->da_dev, + struct tcmu_dev, se_dev); + + return snprintf(page, PAGE_SIZE, "%lu\n", udev->qfull_time_out / MSEC_PER_SEC); +} + +static ssize_t tcmu_qfull_time_out_store(struct config_item *item, + const char *page, size_t count) +{ + struct se_dev_attrib *da = container_of(to_config_group(item), + struct se_dev_attrib, da_group); + struct tcmu_dev *udev = container_of(da->da_dev, + struct tcmu_dev, se_dev); + u32 val; + int ret; + + ret = kstrtou32(page, 0, &val); + if (ret < 0) + return ret; + + udev->qfull_time_out = val * MSEC_PER_SEC; + return count; +} +CONFIGFS_ATTR(tcmu_, qfull_time_out); + static ssize_t tcmu_dev_config_show(struct config_item *item, char *page) { struct se_dev_attrib *da = container_of(to_config_group(item), @@ -1956,6 +1989,7 @@ static ssize_t tcmu_emulate_write_cache_store(struct config_item *item, CONFIGFS_ATTR(tcmu_, emulate_write_cache); static struct configfs_attribute *tcmu_attrib_attrs[] = { + &tcmu_attr_qfull_time_out, &tcmu_attr_cmd_time_out, &tcmu_attr_dev_config, &tcmu_attr_dev_size,