From patchwork Mon Oct 12 04:31:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Seymour, Shane M" X-Patchwork-Id: 7372081 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 687929F1B9 for ; Mon, 12 Oct 2015 04:31:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 72AAD20872 for ; Mon, 12 Oct 2015 04:31:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3D7DF2065E for ; Mon, 12 Oct 2015 04:31:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753155AbbJLEbb (ORCPT ); Mon, 12 Oct 2015 00:31:31 -0400 Received: from g4t3426.houston.hp.com ([15.201.208.54]:50982 "EHLO g4t3426.houston.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753042AbbJLEb3 convert rfc822-to-8bit (ORCPT ); Mon, 12 Oct 2015 00:31:29 -0400 Received: from G4W6310.americas.hpqcorp.net (g4w6310.houston.hp.com [16.210.26.217]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by g4t3426.houston.hp.com (Postfix) with ESMTPS id 10BF289; Mon, 12 Oct 2015 04:31:27 +0000 (UTC) Received: from G4W6306.americas.hpqcorp.net (16.210.26.231) by G4W6310.americas.hpqcorp.net (16.210.26.217) with Microsoft SMTP Server (TLS) id 14.3.169.1; Mon, 12 Oct 2015 04:31:18 +0000 Received: from G4W3219.americas.hpqcorp.net ([169.254.8.11]) by G4W6306.americas.hpqcorp.net ([16.210.26.231]) with mapi id 14.03.0169.001; Mon, 12 Oct 2015 04:31:18 +0000 From: "Seymour, Shane M" To: "Kai.Makisara@kolumbus.fi" CC: "linux-scsi@vger.kernel.org" , "James Bottomley (JBottomley@Odin.com)" Subject: [PATCH] st: allow debug output to be enabled or disabled via sysfs Thread-Topic: [PATCH] st: allow debug output to be enabled or disabled via sysfs Thread-Index: AdEEoxYHKtIlHDy1QxW7/pPR//Aajg== Date: Mon, 12 Oct 2015 04:31:17 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [16.210.48.31] MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Change st driver to allow enabling or disabling debug output via sysfs file /sys/bus/scsi/drivers/st/debug_flag. Previously the only way to enable debug output was: 1. loading the driver with the module parameter debug_flag=1 2. an ioctl call (this method was also the only way to dynamically disable debug output). To use the ioctl you need a second tape drive (if you are actively testing the first tape drive) since a second process cannot open the first tape drive if it is in use. The this change is only functional if the value of the macro DEBUG in st.c is a non-zero value (which it is by default). Signed-off-by: Shane Seymour Reviewed-by: Laurence Oberman Acked-by: Kai Mäkisara --- -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- a/drivers/scsi/st.c 2015-10-06 17:11:16.299801789 -0500 +++ b/drivers/scsi/st.c 2015-10-11 14:45:10.595060995 -0500 @@ -4452,11 +4452,41 @@ static ssize_t version_show(struct devic } static DRIVER_ATTR_RO(version); +#if DEBUG +static ssize_t debug_flag_store(struct device_driver *ddp, + const char *buf, size_t count) +{ +/* We only care what the first byte of the data is the rest is unused. + * if it's a '1' we turn on debug and if it's a '0' we disable it. All + * other values have -EINVAL returned if they are passed in. + */ + if (count > 0) { + if (buf[0] == '0') { + debugging = NO_DEBUG; + return count; + } else if (buf[0] == '1') { + debugging = 1; + return count; + } + } + return -EINVAL; +} + +static ssize_t debug_flag_show(struct device_driver *ddp, char *buf) +{ + return scnprintf(buf, PAGE_SIZE, "%d\n", debugging); +} +static DRIVER_ATTR_RW(debug_flag); +#endif + static struct attribute *st_drv_attrs[] = { &driver_attr_try_direct_io.attr, &driver_attr_fixed_buffer_size.attr, &driver_attr_max_sg_segs.attr, &driver_attr_version.attr, +#if DEBUG + &driver_attr_debug_flag.attr, +#endif NULL, }; ATTRIBUTE_GROUPS(st_drv); diff -uprN a/Documentation/ABI/testing/sysfs-driver-st b/Documentation/ABI/testing/sysfs-driver-st --- a/Documentation/ABI/testing/sysfs-driver-st 1969-12-31 18:00:00.000000000 -0600 +++ b/Documentation/ABI/testing/sysfs-driver-st 2015-10-11 14:28:43.537128220 -0500 @@ -0,0 +1,12 @@ +What: /sys/bus/scsi/drivers/st/debug_flag +Date: October 2015 +Kernel Version: ?.? +Contact: shane.seymour@hpe.com +Description: + This file allows you to turn debug output from the st driver + off if you write a '0' to the file or on if you write a '1'. + Note that debug output requires that the module be compiled + with the #define DEBUG set to a non-zero value (this is the + default). If DEBUG is set to 0 then this file will not + appear in sysfs as its presence is conditional upon debug + output support being compiled into the module. --- a/Documentation/scsi/st.txt 2015-10-06 17:11:12.323802060 -0500 +++ b/Documentation/scsi/st.txt 2015-10-11 14:19:48.176164681 -0500 @@ -569,7 +569,9 @@ Debugging code is now compiled in by def with the kernel module parameter debug_flag defaulting to 0. Debugging can still be switched on and off with an ioctl. To enable debug at module load time add debug_flag=1 to the module load options, the -debugging output is not voluminous. +debugging output is not voluminous. Debugging can also be enabled +and disabled by writing a '0' (disable) or '1' (enable) to the sysfs +file /sys/bus/scsi/drivers/st/debug_flag. If the tape seems to hang, I would be very interested to hear where the driver is waiting. With the command 'ps -l' you can see the state