From patchwork Wed Mar 21 09:52:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Zhuoyu X-Patchwork-Id: 10299011 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 EB188600F6 for ; Wed, 21 Mar 2018 09:46:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D90A529783 for ; Wed, 21 Mar 2018 09:46:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CD10429173; Wed, 21 Mar 2018 09:46:04 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 8B7EF29173 for ; Wed, 21 Mar 2018 09:46:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751459AbeCUJqC (ORCPT ); Wed, 21 Mar 2018 05:46:02 -0400 Received: from m15-112.126.com ([220.181.15.112]:55695 "EHLO m15-112.126.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751396AbeCUJqB (ORCPT ); Wed, 21 Mar 2018 05:46:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id; bh=EDs2STV3nmiNIeQ7C6 mNKEY/qyElWe1JDryKsHWDD3Y=; b=J97UbFATGqH0m5PUESrKdxozphMr2ffLmF MwFoFQF06s7m1uH1/XHu1yAOQ/JKcr/iDv8Lf04TFVyYlR/zLqDs16k2nudQNr9B o8zK7o5KufEgUE8EKLNdX/1kDUutgUCQAbfG9tcawjyA3WVeldSVpL1CvMTdldQU QhjV42pEw= Received: from localhost (unknown [223.105.0.130]) by smtp2 (Coremail) with SMTP id DMmowAB3lJHMKbJa_6tFBQ--.63447S3; Wed, 21 Mar 2018 17:45:50 +0800 (CST) From: Zhang Zhuoyu To: nab@linux-iscsi.org Cc: linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, linux-kernel@vger.kernel.org, Zhang Zhuoyu Subject: [PATCH 1/1] target:separate tx/rx cmd_puds Date: Wed, 21 Mar 2018 17:52:43 +0800 Message-Id: <1521625963-657195-1-git-send-email-zhangzhuoyu@cmss.chinamobile.com> X-Mailer: git-send-email 1.8.3.1 X-CM-TRANSID: DMmowAB3lJHMKbJa_6tFBQ--.63447S3 X-Coremail-Antispam: 1Uf129KBjvJXoWxCr1xCw4kXFy5Aw15Cr1Dtrb_yoWrWFW3pa 1UJF9xJrWDJay8Ar1DJF4qv34rXw1UW347XayxW3WfXa1UtrW3Kw1UCFWayFn8ZryxGryf Ga9FyFn0k3ykXrUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jcjjgUUUUU= X-Originating-IP: [223.105.0.130] X-CM-SenderInfo: xkhoz05221imiyy6ij2wof0z/1tbi2g8Q1FpD3dd3AwAAs2 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 Separate tx/rx cmd_pdus in order to distinguish LUN read/write IOPS. Signed-off-by: Zhang Zhuoyu --- drivers/target/target_core_stat.c | 26 ++++++++++++++++++++++---- drivers/target/target_core_transport.c | 11 ++++++++++- include/target/target_core_base.h | 3 ++- 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/drivers/target/target_core_stat.c b/drivers/target/target_core_stat.c index f0db91e..9099494 100644 --- a/drivers/target/target_core_stat.c +++ b/drivers/target/target_core_stat.c @@ -636,7 +636,7 @@ static ssize_t target_stat_tgt_port_port_index_show(struct config_item *item, return ret; } -static ssize_t target_stat_tgt_port_in_cmds_show(struct config_item *item, +static ssize_t target_stat_tgt_port_tx_cmds_show(struct config_item *item, char *page) { struct se_lun *lun = to_stat_tgt_port(item); @@ -647,7 +647,23 @@ static ssize_t target_stat_tgt_port_in_cmds_show(struct config_item *item, dev = rcu_dereference(lun->lun_se_dev); if (dev) ret = snprintf(page, PAGE_SIZE, "%lu\n", - atomic_long_read(&lun->lun_stats.cmd_pdus)); + atomic_long_read(&lun->lun_stats.tx_cmd_pdus)); + rcu_read_unlock(); + return ret; +} + +static ssize_t target_stat_tgt_port_rx_cmds_show(struct config_item *item, + char *page) +{ + struct se_lun *lun = to_stat_tgt_port(item); + struct se_device *dev; + ssize_t ret = -ENODEV; + + rcu_read_lock(); + dev = rcu_dereference(lun->lun_se_dev); + if (dev) + ret = snprintf(page, PAGE_SIZE, "%lu\n", + atomic_long_read(&lun->lun_stats.rx_cmd_pdus)); rcu_read_unlock(); return ret; } @@ -706,7 +722,8 @@ static ssize_t target_stat_tgt_port_hs_in_cmds_show(struct config_item *item, CONFIGFS_ATTR_RO(target_stat_tgt_port_, indx); CONFIGFS_ATTR_RO(target_stat_tgt_port_, name); CONFIGFS_ATTR_RO(target_stat_tgt_port_, port_index); -CONFIGFS_ATTR_RO(target_stat_tgt_port_, in_cmds); +CONFIGFS_ATTR_RO(target_stat_tgt_port_, tx_cmds); +CONFIGFS_ATTR_RO(target_stat_tgt_port_, rx_cmds); CONFIGFS_ATTR_RO(target_stat_tgt_port_, write_mbytes); CONFIGFS_ATTR_RO(target_stat_tgt_port_, read_mbytes); CONFIGFS_ATTR_RO(target_stat_tgt_port_, hs_in_cmds); @@ -717,7 +734,8 @@ static ssize_t target_stat_tgt_port_hs_in_cmds_show(struct config_item *item, &target_stat_tgt_port_attr_indx, &target_stat_tgt_port_attr_name, &target_stat_tgt_port_attr_port_index, - &target_stat_tgt_port_attr_in_cmds, + &target_stat_tgt_port_attr_tx_cmds, + &target_stat_tgt_port_attr_rx_cmds, &target_stat_tgt_port_attr_write_mbytes, &target_stat_tgt_port_attr_read_mbytes, &target_stat_tgt_port_attr_hs_in_cmds, diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 74b646f..79cb96f 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -1356,7 +1356,16 @@ void transport_init_se_cmd( return ret; cmd->se_cmd_flags |= SCF_SUPPORTED_SAM_OPCODE; - atomic_long_inc(&cmd->se_lun->lun_stats.cmd_pdus); + switch (cmd->data_direction) { + case DMA_FROM_DEVICE: + atomic_long_inc(&cmd->se_lun->lun_stats.tx_cmd_pdus); + break; + case DMA_TO_DEVICE: + atomic_long_inc(&cmd->se_lun->lun_stats.rx_cmd_pdus); + break; + default: + break; + } return 0; } EXPORT_SYMBOL(target_setup_cmd_from_cdb); diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h index 9f9f590..6a0a2a7 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h @@ -698,7 +698,8 @@ struct se_port_stat_grps { }; struct scsi_port_stats { - atomic_long_t cmd_pdus; + atomic_long_t tx_cmd_pdus; + atomic_long_t rx_cmd_pdus; atomic_long_t tx_data_octets; atomic_long_t rx_data_octets; };