Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp622806pxx; Wed, 28 Oct 2020 12:39:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwUv6caFsQpSWjRjMXChJhUF6uPSnor3t5FR1Ctv0kkBQjTRboF5zPfjE3XKsHHUjdCO9HN X-Received: by 2002:a17:907:417d:: with SMTP id oe21mr640567ejb.233.1603913981381; Wed, 28 Oct 2020 12:39:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603913981; cv=none; d=google.com; s=arc-20160816; b=drf2P5TMYBK+ASTUHMmLIZBSAzVmCl9xLjF7XoCuQERDoejb/FAZJKmDOi7GEb6ynY e1Se7fFTWS9s+iEGsR8kRVSNoK/ZnZkRG/MwVwNR1WsW8SQQ3zc1Rk5CMmV84jlAJjvh pGFl/akWriOt1rrqcbPF5TNc8mCiaWd4R4elToJBf1kG6P5lCMsw5eabJi2IemZBbxKv dScX9T/+Aeh+EyMcwyVggBKnCeEN9L15c2Oj2Jb+ROScO0MyaUHg4zGBzy6/RocQ9WVB TX3E49HlIP1dW4PptaANP3Ep8GxZwLuyVAxZcN0rdAfvyCVBoqs4ioMmZwZez3A6pKrq y35Q== 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=Ly/02YrFhP2hxyBo5eTGTEx7ApDgGaAdT7ZtyQo3B1o=; b=pmYlkPb7cJdx3tTi0Icg8cjAVW/+a+Gamq81gsx9a8vjfrSpH3YskebP3AQjNR+S/m YxJU58wzkArEpJhYsjqc29tbwL9s6XoQTMHL5FDKGoT5RMBvE04EiOWxpUrS/rDM+0bl ZoZj4dDR1fsyQAGvXGsAW5XKIa1CG7wkn/8fwHfvjZ+EKCP5Gr9xucSBubqeA79km+eS l2dze0VC/5OpFlXDoB7Jw/FNjRx637Tc04HwjJxisEGskZkZ+Byqk6zVQyJpnIispjSe aYwgZ+S0zVAUnv0KSWZZfxyr5ZKtd6foeC6kXAoGCsKSZ09W9Cy0ievX7fjlbXuhRZPF tkqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kiZEtWzN; 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 p9si37501edm.38.2020.10.28.12.39.19; Wed, 28 Oct 2020 12:39:41 -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=kiZEtWzN; 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 S1827693AbgJ0S0r (ORCPT + 99 others); Tue, 27 Oct 2020 14:26:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:48100 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390959AbgJ0OAe (ORCPT ); Tue, 27 Oct 2020 10:00:34 -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 074C921D7B; Tue, 27 Oct 2020 14:00:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603807233; bh=08qxcCt7Hlmu9AiTjVzLyRv6NcOSyI4KdPv4xpvonkQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kiZEtWzNC/UYbGXDtQanNgpuFvCVpYbzk65NEOJcxI8r6+JxELSxX1oMbVFMkYMIL /UUlLpkPi/sLUJWvetasueL1xygkcQmCBo6KQ9gpPoFRZ2Bc9z3hfgoHfe/pXZSgLm dG543tJYT1H+qv5FY925eBXi8ZtL6eJAjIN6ER30= 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.4 090/112] scsi: target: core: Add CONTROL field for trace events Date: Tue, 27 Oct 2020 14:50:00 +0100 Message-Id: <20201027134904.806744426@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027134900.532249571@linuxfoundation.org> References: <20201027134900.532249571@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 11571b2a831e3..92ba09200f89b 100644 --- a/include/scsi/scsi_common.h +++ b/include/scsi/scsi_common.h @@ -24,6 +24,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 50fea660c0f89..d543e8b87e50a 100644 --- a/include/trace/events/target.h +++ b/include/trace/events/target.h @@ -139,6 +139,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 ) ), @@ -148,6 +149,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); ), @@ -157,9 +159,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 ) ); @@ -174,6 +174,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 ) @@ -186,6 +187,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; @@ -202,9 +204,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