Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp579857pxx; Wed, 28 Oct 2020 11:35:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyBFT7f5iY00ajHwCKyOLZh9Aysv/w1VIlosjhFkoneNxe3j5KNa3YEf+fVw21pC1ZI+usM X-Received: by 2002:a17:906:e10e:: with SMTP id gj14mr481140ejb.134.1603910119389; Wed, 28 Oct 2020 11:35:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603910119; cv=none; d=google.com; s=arc-20160816; b=ATWM8wVpC87HHqKUj5dGtjeGcJAKAlY6hdHjUr4jQhWcVtwUhMd3NKvhsW4Ht9soWw qXUuKMXrfNEoxvS+3loc1u74qsvFPMoNwq7d3/TdCgJor8+ptfYATzZ6XyMfVWg5uA5T n0RC4nTb5GMIRAdr2DXkZ8TVsMCVxDJcy9gOdyTbOpfvV/UKmg7TihEMG5DLpQfJuLDX ZBLTuVFxZV4rz3DF0BG+LFWa/es0FssWYGOn4USFCDQ/IxBdt+a6z68eRBosW1w/CLWR WTA0bHou+d+pKvi22RacpTyovuLXxZxfTmq+D7kEIpAJUB6IK64SHwpZxPqvt71PQfG/ lu8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=L0+ulJJDiida7M8eS2wnIws4JQe3DisUrpnAFWRKniA=; b=vMeaDfMf0yj2Q4RrJ0GP7DkWlyF+kzEscp2Q2EEHVSqnisgLjS1wxERgxVNuvbuj4L qs/jxHlDnGPJhnDf9GsQ7HzNXkM4jmSVp+LRGRiCI49EHHTfPT/Jq9Srr+O9VA4SbbmV wYsSNChCx1EAZbjMnncd5JlxWSPhYOQzlDHl2ZAHgOA8daRO5nqaWzNvjaXPY4u9U0ch lhDyleCI5jyEhpnwBsLxvNONHg0IJWOWX2LaKh8oV4ypLsjd141pGzykjFuMmCTFhpec rdHiYC68fz064ivJcnCa5+CULyIPMv79FAG1UqMazsj+WxSIF552tFwPSDcTFKIMF1aB nCNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jQ81lHKY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c8si22307edl.252.2020.10.28.11.34.56; Wed, 28 Oct 2020 11:35:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jQ81lHKY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1825572AbgJ0SLa (ORCPT + 99 others); Tue, 27 Oct 2020 14:11:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:36868 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756897AbgJ0OPG (ORCPT ); Tue, 27 Oct 2020 10:15:06 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D2AB2206F7; Tue, 27 Oct 2020 14:15:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603808105; bh=1Y3Ovy7HhS/9an9kESEToXaRzV6Qxm8CLErPUU+lu/s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jQ81lHKYHMrMarCoTGEuzTTrBlSKgPrJWnMri1RI/gw4/NwSRp+cKZuIzpQeLnc0d 3aFylOXwWl2nudl2n/eLnt/2/+5rl/FWJHWJsBU4mQ4F2y8MRUPcTtMhWh3ap43mwf DtIdZ10GwC1xUN0sXTIKH5OLlZQ/dgrwRtEbRyB8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mike Christie , Roman Bolshakov , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 4.14 158/191] scsi: target: core: Add CONTROL field for trace events Date: Tue, 27 Oct 2020 14:50:13 +0100 Message-Id: <20201027134917.314313255@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027134909.701581493@linuxfoundation.org> References: <20201027134909.701581493@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Roman Bolshakov [ Upstream commit 7010645ba7256992818b518163f46bd4cdf8002a ] trace-cmd report doesn't show events from target subsystem because scsi_command_size() leaks through event format string: [target:target_sequencer_start] function scsi_command_size not defined [target:target_cmd_complete] function scsi_command_size not defined Addition of scsi_command_size() to plugin_scsi.c in trace-cmd doesn't help because an expression is used inside TP_printk(). trace-cmd event parser doesn't understand minus sign inside [ ]: Error: expected ']' but read '-' Rather than duplicating kernel code in plugin_scsi.c, provide a dedicated field for CONTROL byte. Link: https://lore.kernel.org/r/20200929125957.83069-1-r.bolshakov@yadro.com Reviewed-by: Mike Christie Signed-off-by: Roman Bolshakov Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- include/scsi/scsi_common.h | 7 +++++++ include/trace/events/target.h | 12 ++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/include/scsi/scsi_common.h b/include/scsi/scsi_common.h index 731ac09ed2313..5b567b43e1b16 100644 --- a/include/scsi/scsi_common.h +++ b/include/scsi/scsi_common.h @@ -25,6 +25,13 @@ scsi_command_size(const unsigned char *cmnd) scsi_varlen_cdb_length(cmnd) : COMMAND_SIZE(cmnd[0]); } +static inline unsigned char +scsi_command_control(const unsigned char *cmnd) +{ + return (cmnd[0] == VARIABLE_LENGTH_CMD) ? + cmnd[1] : cmnd[COMMAND_SIZE(cmnd[0]) - 1]; +} + /* Returns a human-readable name for the device */ extern const char *scsi_device_type(unsigned type); diff --git a/include/trace/events/target.h b/include/trace/events/target.h index 914a872dd3435..e87a3716b0ac9 100644 --- a/include/trace/events/target.h +++ b/include/trace/events/target.h @@ -140,6 +140,7 @@ TRACE_EVENT(target_sequencer_start, __field( unsigned int, opcode ) __field( unsigned int, data_length ) __field( unsigned int, task_attribute ) + __field( unsigned char, control ) __array( unsigned char, cdb, TCM_MAX_COMMAND_SIZE ) __string( initiator, cmd->se_sess->se_node_acl->initiatorname ) ), @@ -149,6 +150,7 @@ TRACE_EVENT(target_sequencer_start, __entry->opcode = cmd->t_task_cdb[0]; __entry->data_length = cmd->data_length; __entry->task_attribute = cmd->sam_task_attr; + __entry->control = scsi_command_control(cmd->t_task_cdb); memcpy(__entry->cdb, cmd->t_task_cdb, TCM_MAX_COMMAND_SIZE); __assign_str(initiator, cmd->se_sess->se_node_acl->initiatorname); ), @@ -158,9 +160,7 @@ TRACE_EVENT(target_sequencer_start, show_opcode_name(__entry->opcode), __entry->data_length, __print_hex(__entry->cdb, 16), show_task_attribute_name(__entry->task_attribute), - scsi_command_size(__entry->cdb) <= 16 ? - __entry->cdb[scsi_command_size(__entry->cdb) - 1] : - __entry->cdb[1] + __entry->control ) ); @@ -175,6 +175,7 @@ TRACE_EVENT(target_cmd_complete, __field( unsigned int, opcode ) __field( unsigned int, data_length ) __field( unsigned int, task_attribute ) + __field( unsigned char, control ) __field( unsigned char, scsi_status ) __field( unsigned char, sense_length ) __array( unsigned char, cdb, TCM_MAX_COMMAND_SIZE ) @@ -187,6 +188,7 @@ TRACE_EVENT(target_cmd_complete, __entry->opcode = cmd->t_task_cdb[0]; __entry->data_length = cmd->data_length; __entry->task_attribute = cmd->sam_task_attr; + __entry->control = scsi_command_control(cmd->t_task_cdb); __entry->scsi_status = cmd->scsi_status; __entry->sense_length = cmd->scsi_status == SAM_STAT_CHECK_CONDITION ? min(18, ((u8 *) cmd->sense_buffer)[SPC_ADD_SENSE_LEN_OFFSET] + 8) : 0; @@ -203,9 +205,7 @@ TRACE_EVENT(target_cmd_complete, show_opcode_name(__entry->opcode), __entry->data_length, __print_hex(__entry->cdb, 16), show_task_attribute_name(__entry->task_attribute), - scsi_command_size(__entry->cdb) <= 16 ? - __entry->cdb[scsi_command_size(__entry->cdb) - 1] : - __entry->cdb[1] + __entry->control ) ); -- 2.25.1