Received: by 10.213.65.68 with SMTP id h4csp1105177imn; Wed, 21 Mar 2018 02:47:13 -0700 (PDT) X-Google-Smtp-Source: AG47ELvDH9Zi4cUZFqSpNvAWQ7tBW4Kp14Urh09nO04CU+YVo3xIW7VFkPFxg2Kv75i3dQcZiH5b X-Received: by 10.98.190.26 with SMTP id l26mr16359432pff.62.1521625633921; Wed, 21 Mar 2018 02:47:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521625633; cv=none; d=google.com; s=arc-20160816; b=tBvIn26qeSUKNc1MWu9PTiBF0ZLuyHtD3A2j9zP3WReDyLYEmE+S4wK/3vrM+2Udwq rLjRAWTZIxHu2Ts7Ty6C8Ed33C6vRzCdmvPmzRrSDXyUtsmaIo5Q9E5KIAbhWXs74gMP NGVbQ+TEVQCAMi64XBLNmJTqUR0FDDrc800ErzZ7euwm15ubBz7D5aGR9yVRa4hyiNIB WmLKTzxssueYUjGeIl32aYMrRDEMG6755NwXRiRd5eDkgf+CPkAr50eDMRrw08MBkztg kldNLXxSvP5cpoT0y4FDnE1vWgclME1aXAQCdsDkwOgYfuMwzuze3p2Zw3DyStXJpk1N fJWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=EDs2STV3nmiNIeQ7C6mNKEY/qyElWe1JDryKsHWDD3Y=; b=rUE7/5oOIdfsZ3nleHLuZZIRIUAAr9viz5u4e8XEBRLN6Pjv8lthk8FsYQNG+MSEN+ IYsNqdi/Rle82X0lP76/0vqlUrjjnPj/ICIhLBI4YlV3QNmnY2WOUcdGean0gdlR/S71 0CuL41vvgs8I1Qwn2Ykaeh0DPRDcBN9ZcxubQd8dh6QeKLFgpKu9YVF3H6uRwIZAoFGo ieQZg17dmPxEFwCs99Hl1XT7T7U6VAgZLsun1ILxE1PuqYeedDvcLGfrZKcdLcI3jtTW wiHYxSvX1hb1E9VLCiLJyZasMU596MhiWDz9Z9/sPhShuDblqC9OI14LdYmHqvxrR4pE FrGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@126.com header.s=s110527 header.b=J97UbFAT; 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 k8si2761452pfi.3.2018.03.21.02.46.59; Wed, 21 Mar 2018 02:47:13 -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=@126.com header.s=s110527 header.b=J97UbFAT; 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 S1751630AbeCUJqE (ORCPT + 99 others); Wed, 21 Mar 2018 05:46:04 -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: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; }; -- 1.8.3.1