From patchwork Tue Jun 6 14:28:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bryant G. Ly" X-Patchwork-Id: 9768951 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 ECCE160393 for ; Tue, 6 Jun 2017 14:29:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D6C7D2654B for ; Tue, 6 Jun 2017 14:29:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CBA242847D; Tue, 6 Jun 2017 14:29:05 +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=unavailable 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 8639828438 for ; Tue, 6 Jun 2017 14:29:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751399AbdFFO3E (ORCPT ); Tue, 6 Jun 2017 10:29:04 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:38325 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751440AbdFFO3D (ORCPT ); Tue, 6 Jun 2017 10:29:03 -0400 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v56EOaAX086881 for ; Tue, 6 Jun 2017 10:29:02 -0400 Received: from e13.ny.us.ibm.com (e13.ny.us.ibm.com [129.33.205.203]) by mx0a-001b2d01.pphosted.com with ESMTP id 2awq3785kf-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 06 Jun 2017 10:29:02 -0400 Received: from localhost by e13.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 6 Jun 2017 10:29:00 -0400 Received: from b01cxnp22033.gho.pok.ibm.com (9.57.198.23) by e13.ny.us.ibm.com (146.89.104.200) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 6 Jun 2017 10:28:57 -0400 Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v56ESvXn30671026; Tue, 6 Jun 2017 14:28:57 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 667DFAE04B; Tue, 6 Jun 2017 10:28:54 -0400 (EDT) Received: from bryants-mbp-3.rchland.ibm.com (unknown [9.10.80.125]) by b01ledav005.gho.pok.ibm.com (Postfix) with ESMTP id 11FEDAE034; Tue, 6 Jun 2017 10:28:54 -0400 (EDT) From: "Bryant G. Ly" To: nab@linux-iscsi.org, mchristi@redhat.com Cc: seroyer@linux.vnet.ibm.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, "Bryant G. Ly" Subject: [PATCH v4 1/5] tcmu: Support emulate_write_cache Date: Tue, 6 Jun 2017 09:28:48 -0500 X-Mailer: git-send-email 2.5.4 (Apple Git-61) In-Reply-To: <1496759332-35216-1-git-send-email-bryantly@linux.vnet.ibm.com> References: <1496759332-35216-1-git-send-email-bryantly@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17060614-0008-0000-0000-00000237D0BC X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007183; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000212; SDB=6.00870973; UDB=6.00433148; IPR=6.00650965; BA=6.00005402; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00015719; XFM=3.00000015; UTC=2017-06-06 14:28:58 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17060614-0009-0000-0000-0000358EA60B Message-Id: <1496759332-35216-2-git-send-email-bryantly@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-06-06_11:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1706060243 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 This will enable the toggling of write_cache in tcmu through targetcli-fb Signed-off-by: Bryant G. Ly Reviewed-By: Mike Christie --- drivers/target/target_core_user.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c index beb5f09..0c797cc 100644 --- a/drivers/target/target_core_user.c +++ b/drivers/target/target_core_user.c @@ -1290,6 +1290,8 @@ static int tcmu_configure_device(struct se_device *dev) /* Other attributes can be configured in userspace */ if (!dev->dev_attrib.hw_max_sectors) dev->dev_attrib.hw_max_sectors = 128; + if (!dev->dev_attrib.emulate_write_cache) + dev->dev_attrib.emulate_write_cache = 0; dev->dev_attrib.hw_queue_depth = 128; /* @@ -1546,6 +1548,32 @@ 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_emulate_write_cache_show(struct config_item *item, + char *page) +{ + struct se_dev_attrib *da = container_of(to_config_group(item), + struct se_dev_attrib, da_group); + + return snprintf(page, PAGE_SIZE, "%i\n", da->emulate_write_cache); +} + +static ssize_t tcmu_emulate_write_cache_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); + int val; + int ret; + + ret = kstrtouint(page, 0, &val); + if (ret < 0) + return ret; + + da->emulate_write_cache = val; + return count; +} +CONFIGFS_ATTR(tcmu_, emulate_write_cache); + static struct configfs_attribute **tcmu_attrs; static struct target_backend_ops tcmu_ops = { @@ -1682,6 +1710,8 @@ static int __init tcmu_module_init(void) tcmu_attrs[i] = passthrough_attrib_attrs[i]; } tcmu_attrs[i] = &tcmu_attr_cmd_time_out; + i++; + tcmu_attrs[i] = &tcmu_attr_emulate_write_cache; tcmu_ops.tb_dev_attrib_attrs = tcmu_attrs; ret = transport_backend_register(&tcmu_ops);