Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp460662pxx; Wed, 28 Oct 2020 08:51:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgNbOdEwOlEWnaPGclRtvEKHc9WBXcutJ9/9P9xMmtifAKviPVAXrKis+sZwuM5CIYjGU3 X-Received: by 2002:aa7:d892:: with SMTP id u18mr8659958edq.305.1603900313055; Wed, 28 Oct 2020 08:51:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603900313; cv=none; d=google.com; s=arc-20160816; b=ehjNZwWimcVQA6M4JYxHVRp9wXAwKpOPYKrFkAhlAD3+Hljkpg/hHBrDQisbZapM5s ShGTriZILTOaiKYE8wwQSCXfBiXoxTXBtTN8a1xOXSR3XyZoYGnDgBW46LJh80G7blWO IhbmBM2KwLM+noE6PFKT1I41GYYov6IvCbWo+YOWERlKUUEfqVZGqlEmkx5wjQ6tqTnU KR1GxQN4eFfl/ihhP3ER2fR+amyDsubYOw/tPe4bycTGNb5kVR/ZWbYsYkaH/grQc+qh 1fKhaWrFA40WWf2g+/fb2zFrfTVRhUFvSdjF8AlbnmQMieFdcdrmuh1iYWD5jUaVmlXF mv0A== 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=i1pnUqZgrtbeZMVVtFWQOAEni2+v/+0RkiRenSY+1t4=; b=W8UbBAEUzq9a0akG1E8C6/5gymFDaIjJzhq8utAtyUD7j7ub8MTWJA6HLhXpgGxhwt xVSsOqypgLKdI0GXCATLedRyCd8qwSRonmssxPrhaEG1zWwtWwRqo8YosECkyf3q7CSr Jl8mcrZbqy1DpsewnYmYVE1ffhv528ixYvEL6Y5QG9vTcGI/CNzwA7mbnnYuRQ/H86tN 2YXDUP08882U8G8j/CRt8Oe4hPo2+fHaAfk7xukmitLRTQg0avrdT4cThiTx7zs/fPs3 BDlBBo+ewvKY14M/WqMhMPc1Hq8MWt/MXnpPFk4VnS2dtus3uEuhE+NIW/DRzeqe789p WTwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=AxOGqyuY; 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 p19si2741759edu.169.2020.10.28.08.51.30; Wed, 28 Oct 2020 08:51:53 -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=AxOGqyuY; 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 S1813229AbgJ0Qtj (ORCPT + 99 others); Tue, 27 Oct 2020 12:49:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:50948 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1794860AbgJ0PN7 (ORCPT ); Tue, 27 Oct 2020 11:13:59 -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 60CC620657; Tue, 27 Oct 2020 15:13:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603811638; bh=7NorDwtBz89EfBAlrcmi2JV9J5c9nGobVF/FN+7wE6M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AxOGqyuYdyYrVukqYG7jcxMV0A8C6u9Utv8DK3vIUG7TcKGqiEd3weedKp20yLRft 1zeKFXOQzIbDRJyHhfc6HtE8rUfpOtpE88lF1aefvBcRIU90UudFCNODUQflB+ya6+ hmm6VPCePkXeZCRMKmia9lpgNxEieBe67f/1yMvo= 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 5.8 565/633] scsi: target: core: Add CONTROL field for trace events Date: Tue, 27 Oct 2020 14:55:08 +0100 Message-Id: <20201027135549.314131585@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135522.655719020@linuxfoundation.org> References: <20201027135522.655719020@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 77408edd29d2a..67fad2677ed55 100644 --- a/include/trace/events/target.h +++ b/include/trace/events/target.h @@ -141,6 +141,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 ) ), @@ -151,6 +152,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); ), @@ -160,9 +162,7 @@ TRACE_EVENT(target_sequencer_start, __entry->tag, 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 ) ); @@ -178,6 +178,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 ) @@ -191,6 +192,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; @@ -208,9 +210,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