Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1121011pxx; Tue, 27 Oct 2020 08:43:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYDtWER3+gPJZgK9gzPIo0USx9hRjXHJTMZAVeS17H4ULekXVdebza5H0igQyqVyW55dxb X-Received: by 2002:aa7:d658:: with SMTP id v24mr2880738edr.327.1603813429500; Tue, 27 Oct 2020 08:43:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603813429; cv=none; d=google.com; s=arc-20160816; b=hhu8HEu8I5hBRQkWbp36ZVLrhoG5Wlf4/VOlPs7ZJ+mCQw6jKmbtFIsDGSedy6uKu8 vl9jdPOeOofVhE8WgTcnWQaXYdS6DoZoAxi2mGEfBAANj99RSUy3QRYLDhAIKBs3WhfW 4Me9VYDJevG66DsXlZ+LLfN3ZjzgUzcp1pZesqT+QWQpbHGYtwWZK4cRyEHmb4510jQi gvoyZwFXqBbiNoWqitdGEHTWBZ5T+RpwtKvFn0MYbQ6S8TdKbAmhs4tQXhr2chFQdkkz pHPFbhotLSoUVlwt56QbwEkkYHs56rq0SM3cxM9E4CyURu39RFUUARO9xmID072jbaJF q/KA== 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=ImLdfhjVkqORZju2ETe5/5xdRrJ7JntEdW4ttCByfl7GGYCn/qQnWQ0ocOQWCZDYON fWHUwCs1Gil4wP1u0PAYVpvzJfOVa9Oe1wX1TUm6UzM3bAYVLgxy9+UrevoHweiLJtvW 2qs4mxmXKdgo9yJYnsqiqPXWwSjvMCYiOmUkIJ5oDCcY74vkgXd+uq/q2zMguGo7G3Ip qPYR6CGVby5snFG4cyTr/ak3i8Ksl2q9L7vkD7KL9DqqFPVsSXpEsxdnhEk7LCeYRcQq jL7auxhypc5J4h8i6D4EM0g5mFE3sCQqDLtsHdoaJequyPT86EXRTKbwSEM6OsvojKB0 2D0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="0ydN95g/"; 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 m8si1125432edj.357.2020.10.27.08.43.25; Tue, 27 Oct 2020 08:43:49 -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="0ydN95g/"; 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 S1764144AbgJ0OqX (ORCPT + 99 others); Tue, 27 Oct 2020 10:46:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:46070 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1764059AbgJ0OqL (ORCPT ); Tue, 27 Oct 2020 10:46:11 -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 74B9D21D7B; Tue, 27 Oct 2020 14:46:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603809970; bh=1Y3Ovy7HhS/9an9kESEToXaRzV6Qxm8CLErPUU+lu/s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0ydN95g/YBYXp6t2Dr74fsZXN4GVD9lU9lgRR2mnvfmLa66PcOOWrQPHpWpleQMK4 UjMXP2ogUksyC95gFmIIJIIGEPqnntdYv8a4GetmBzGRYE/yU5Etcw3IN5Ln93toRy KFjsSlBWl42TeZhsov1/3f8MJ/DyAg4v8wccPCxg= 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.4 353/408] scsi: target: core: Add CONTROL field for trace events Date: Tue, 27 Oct 2020 14:54:51 +0100 Message-Id: <20201027135511.394680107@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135455.027547757@linuxfoundation.org> References: <20201027135455.027547757@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