From ba4f29ee54717d13eb2527b0f8403ab37b4912f7 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Fri, 15 Dec 2006 15:59:21 +0000 Subject: [PATCH] Update to allow SCST built inside Linux kernel. Done together with Erik Habbinga. --This line, and below, will be ignored-- _M trunk/mpt _M trunk/mpt/in-tree M trunk/mpt/in-tree/Makefile.diff M trunk/mpt/mpt_scst.c M trunk/mpt/Makefile M trunk/qla2x00t/qla2x00-target/qla2x00t.c M trunk/scst/kernel/in-tree/Makefile.scsi_tgt D trunk/scst/include/scst_debug.c M trunk/scst/include/scst_debug.h M trunk/scst/src/scst_proc.c M trunk/scst/src/scst_priv.h A trunk/scst/src/scst_debug.c M trunk/scst/src/scst_targ.c M trunk/scst/src/scst_mem.c M trunk/scst/src/Makefile M trunk/scst/src/scst.c M trunk/scst/src/dev_handlers/scst_cdrom.c M trunk/scst/src/dev_handlers/scst_modisk.c M trunk/scst/src/dev_handlers/scst_changer.c M trunk/scst/src/dev_handlers/scst_fileio.c M trunk/scst/src/dev_handlers/scst_tape.c M trunk/scst/src/dev_handlers/scst_disk.c M trunk/scst/src/dev_handlers/scst_processor.c M trunk/scst/src/dev_handlers/scst_raid.c M trunk/scst/src/dev_handlers/Makefile M trunk/scst/src/dev_handlers/scst_dev_handler.h M trunk/scst/README git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@62 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- mpt/Makefile | 6 +- mpt/in-tree/Makefile.diff | 19 +- mpt/mpt_scst.c | 210 ++++++++-------- qla2x00t/qla2x00-target/qla2x00t.c | 11 +- scst/README | 8 +- scst/include/scst_debug.h | 308 +++++++++++------------ scst/kernel/in-tree/Makefile.scsi_tgt | 1 + scst/src/Makefile | 15 +- scst/src/dev_handlers/Makefile | 16 +- scst/src/dev_handlers/scst_cdrom.c | 8 +- scst/src/dev_handlers/scst_changer.c | 8 +- scst/src/dev_handlers/scst_dev_handler.h | 14 +- scst/src/dev_handlers/scst_disk.c | 10 +- scst/src/dev_handlers/scst_fileio.c | 9 +- scst/src/dev_handlers/scst_modisk.c | 8 +- scst/src/dev_handlers/scst_processor.c | 10 +- scst/src/dev_handlers/scst_raid.c | 10 +- scst/src/dev_handlers/scst_tape.c | 10 +- scst/src/scst.c | 9 +- scst/{include => src}/scst_debug.c | 13 +- scst/src/scst_mem.c | 2 +- scst/src/scst_priv.h | 7 + scst/src/scst_proc.c | 1 - scst/src/scst_targ.c | 1 - 24 files changed, 344 insertions(+), 370 deletions(-) rename scst/{include => src}/scst_debug.c (90%) diff --git a/mpt/Makefile b/mpt/Makefile index cbc5d6ba7..c681128b7 100644 --- a/mpt/Makefile +++ b/mpt/Makefile @@ -25,7 +25,9 @@ SCST_INC_DIR := $(SUBDIRS)/../scst/include SCST_DIR := $(shell pwd)/../scst/src -EXTRA_CFLAGS += -I$(SCST_INC_DIR) +FUSION_INC_DIR := drivers/message/fusion + +EXTRA_CFLAGS += -I$(SCST_INC_DIR) -I$(FUSION_INC_DIR) -Iinclude/scsi EXTRA_CFLAGS += -DEXTRACHECKS #EXTRA_CFLAGS += -DTRACING @@ -44,7 +46,7 @@ LSI_INC_DIR := $(KDIR)/drivers/message/fusion EXTRA_CFLAGS += -I$(LSI_INC_DIR) ifneq ($(KERNELRELEASE),) -obj-m := mpt_scst.o +obj-$(CONFIG_FUSION_SCST) += mpt_scst.o else diff --git a/mpt/in-tree/Makefile.diff b/mpt/in-tree/Makefile.diff index bf1582329..f95c088fc 100644 --- a/mpt/in-tree/Makefile.diff +++ b/mpt/in-tree/Makefile.diff @@ -1,21 +1,10 @@ ---- Makefile_orig 2006-03-05 22:07:54.000000000 +0300 -+++ Makefile 2006-12-13 14:50:36.000000000 +0300 -@@ -30,9 +30,18 @@ - #CFLAGS_mptctl.o += -DMPT_DEBUG_IOCTL - # - -+SCST_INC_DIR := /usr/local/include/scst -+ -+CFLAGS_mpt_scst.o += -I$(SCST_INC_DIR) -I$(src) -+CFLAGS_mpt_scst.o += -DEXTRACHECKS -+#CFLAGS_mpt_scst.o += -DTRACING -+#CFLAGS_mpt_scst.o += -DDEBUG -+#CFLAGS_mpt_scst.o += -DDEBUG_WORK_IN_THREAD -+ +--- Makefile.orig 2006-01-02 20:21:10.000000000 -0700 ++++ Makefile 2006-12-14 10:24:53.000000000 -0700 +@@ -33,6 +33,7 @@ #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-} LSI_LOGIC obj-$(CONFIG_FUSION_SPI) += mptbase.o mptscsih.o mptspi.o -+obj-$(CONFIG_FUSION_SCST) += mpt_scst/mpt_scst.o ++obj-$(CONFIG_FUSION_SCST) += mpt_scst/ obj-$(CONFIG_FUSION_FC) += mptbase.o mptscsih.o mptfc.o obj-$(CONFIG_FUSION_SAS) += mptbase.o mptscsih.o mptsas.o obj-$(CONFIG_FUSION_CTL) += mptctl.o diff --git a/mpt/mpt_scst.c b/mpt/mpt_scst.c index 9b24aa96f..0e20664d1 100644 --- a/mpt/mpt_scst.c +++ b/mpt/mpt_scst.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) @@ -39,9 +40,6 @@ #include -#include -#include - #include "mpt_scst.h" #define MYNAM "mpt_scst" @@ -62,6 +60,17 @@ static char *mpt_state_string[] = { }; #endif +#ifdef DEBUG +#define SCST_DEFAULT_MPT_LOG_FLAGS (TRACE_FUNCTION | TRACE_PID | \ + TRACE_OUT_OF_MEM | TRACE_MGMT | TRACE_MGMT_DEBUG | \ + TRACE_MINOR | TRACE_SPECIAL) +#else +# ifdef TRACING +#define SCST_DEFAULT_MPT_LOG_FLAGS (TRACE_FUNCTION | TRACE_PID | \ + TRACE_OUT_OF_MEM | TRACE_MGMT | TRACE_MINOR | TRACE_SPECIAL) +# endif +#endif + static MPT_STM_PRIV *mpt_stm_priv[MPT_MAX_ADAPTERS+1]; static int set_aliases_in_fcportpage1 = 1; @@ -113,48 +122,45 @@ static int stm_wait_for(MPT_STM_PRIV *priv, volatile int *flag, int seconds, static void stmapp_srr_process(MPT_STM_PRIV *priv, int rx_id, int r_ctl, u32 offset, LinkServiceBufferPostReply_t *rep, int index); +#ifdef DEBUG +#define trace_flag mpt_trace_flag +unsigned long mpt_trace_flag = TRACE_FUNCTION | TRACE_OUT_OF_MEM | TRACE_SPECIAL; +#else +# ifdef TRACING +#define trace_flag mpt_trace_flag +unsigned long mpt_trace_flag = TRACE_OUT_OF_MEM | TRACE_MGMT | TRACE_SPECIAL; +# endif +#endif + static int -mpt_proc_read(char *buffer, char **start, off_t offset, int length, int *eof, - struct scst_tgt *scst_tgt) +mpt_target_show(struct seq_file *seq, void *v) { - struct mpt_tgt *tgt = scst_tgt_get_tgt_priv(scst_tgt); + struct mpt_tgt *tgt = (struct mpt_tgt *)seq->private; MPT_ADAPTER *ioc = tgt->priv->ioc; - int res = 0, len = 0; MPT_STM_PRIV *priv = tgt->priv; TRACE_ENTRY(); - TRACE_DBG("res %d, buffer %p, length %d, %d, priv %p, tgt %p", - res, buffer, length, len, priv, tgt); + TRACE_DBG("priv %p, tgt %p", priv, tgt); sBUG_ON(tgt == NULL); sBUG_ON(ioc == NULL); - len = snprintf(buffer, length, - "ProductID :0x%04x (%s)\n" + seq_printf(seq, "ProductID :0x%04x (%s)\n" "Target Enable :%s\n", ioc->facts.ProductID, ioc->prod_name, tgt->target_enable ? "True" : "False"); -#define LEN_CHECK(res, buffer, length) \ - TRACE_DBG("res %d, buffer %p, length %d, %d", res, buffer, length, len); \ - res += len; buffer += len; length -= len; \ - if (length <= 0) goto out; - - LEN_CHECK(res, buffer, length) if (ioc->bus_type == SCSI) { int i = 0; - len = snprintf(buffer, length, - "Target ID :%d\n" + seq_printf(seq, "Target ID :%d\n" "Capabilities :0x%x\n" "PhysicalInterface:0x%x\n", tgt->target_id, priv->SCSIPortPage0.Capabilities, priv->SCSIPortPage0.PhysicalInterface); - LEN_CHECK(res, buffer, length) - len = snprintf(buffer, length, - "Configuration :0x%x\n" + seq_printf(seq, "Configuration :0x%x\n" "OnBusTimerValue :0x%x\n" "TargetConfig :0x%x\n" "IDConfig :0x%x\n", @@ -162,63 +168,55 @@ mpt_proc_read(char *buffer, char **start, off_t offset, int length, int *eof, priv->SCSIPortPage1.OnBusTimerValue, priv->SCSIPortPage1.TargetConfig, priv->SCSIPortPage1.IDConfig); - LEN_CHECK(res, buffer, length); - len = snprintf(buffer, length, - "PortFlags :0x%x\n" + seq_printf(seq, "PortFlags :0x%x\n" "PortSettings :0x%x\n", priv->SCSIPortPage2.PortFlags, priv->SCSIPortPage2.PortSettings); - LEN_CHECK(res, buffer, length); #if 0 for (i = 0; i < 16; i++) { - len = snprintf(buffer, length, - " DeviceSeting %02d: 0x%x 0x%x 0x%x\n", + seq_printf(seq, " DeviceSeting %02d: 0x%x 0x%x 0x%x\n", priv->SCSIPortPage2.DeviceSettings[i].Timeout, priv->SCSIPortPage2.DeviceSettings[i].SyncFactor, priv->SCSIPortPage2.DeviceSettings[i].DeviceFlags); - LEN_CHECK(res, buffer, length); } #endif for (i = 0; i < NUM_SCSI_DEVICES; i++) { - len = snprintf(buffer, length, - " Device %02d: 0x%x, 0x%x\n", + seq_printf(seq, " Device %02d: 0x%x, 0x%x\n", i, priv->SCSIDevicePage1[i].RequestedParameters, priv->SCSIDevicePage1[i].Configuration); - LEN_CHECK(res, buffer, length); } } if (ioc->bus_type == FC) { - len = snprintf(buffer, length, - "WWN :%08X%08X:%08X%08X\n", + seq_printf(seq, "WWN :%08X%08X:%08X%08X\n", ioc->fc_port_page0[0].WWNN.High, ioc->fc_port_page0[0].WWNN.Low, ioc->fc_port_page0[0].WWPN.High, ioc->fc_port_page0[0].WWPN.Low); - LEN_CHECK(res, buffer, length); } -#undef LEN_CHECK -out: - TRACE_EXIT_RES(res); - return res; + TRACE_EXIT(); + return 0; } static int -mpt_proc_write(struct file *file, const char *buf, unsigned long length, - struct scst_tgt *scst_tgt) +mpt_proc_target_write(struct file *file, const char __user *buf, + size_t length, loff_t *off) { - struct mpt_tgt *tgt = scst_tgt_get_tgt_priv(scst_tgt); + struct mpt_tgt *tgt = (struct mpt_tgt *)PDE(file->f_dentry->d_inode)->data; MPT_ADAPTER *ioc = tgt->priv->ioc; int res = 0; char tmp[32+1]; TRACE_ENTRY(); res = min(32, (int)length); - memcpy(tmp, buf, res); + if (copy_from_user(tmp, buf, res)) { + res = -EFAULT; + goto out; + } tmp[res] = 0; TRACE_DBG("buff '%s'", tmp); @@ -245,20 +243,16 @@ mpt_proc_write(struct file *file, const char *buf, unsigned long length, } #endif +out: TRACE_EXIT_RES(res); return length; } -static int mpt_proc_info(char *buffer, char **start, off_t offset, - int length, int *eof, struct scst_tgt *tgt, int inout) -{ - if (inout) { - return mpt_proc_write(NULL, buffer, length, tgt); - } - return mpt_proc_read(buffer, start, offset, length, eof, tgt); -} - +static struct scst_proc_data mpt_target_proc_data = { + SCST_DEF_RW_SEQ_OP(mpt_proc_target_write) + .show = mpt_target_show, +}; static int mpt_target_detect(struct scst_tgt_template *temp1); static int mpt_target_release(struct scst_tgt *scst_tgt); @@ -287,7 +281,6 @@ static struct scst_tgt_template tgt_template = { .rdy_to_xfer = mpt_rdy_to_xfer, .on_free_cmd = mpt_on_free_cmd, .task_mgmt_fn_done = mpt_task_mgmt_fn_done, -//ToDo: .proc_info = mpt_proc_info, }; static inline void @@ -339,6 +332,9 @@ mptstm_probe(struct pci_dev *pdev, const struct pci_device_id *id) MPT_ADAPTER *ioc = pci_get_drvdata(pdev); int ret = 0; struct mpt_tgt *tgt; + struct proc_dir_entry *p; + struct proc_dir_entry *root; + char name[4]; TRACE_ENTRY(); ret = mpt_stm_adapter_install(ioc); @@ -370,9 +366,23 @@ mptstm_probe(struct pci_dev *pdev, const struct pci_device_id *id) ret = -ENODEV; goto out; } + + root = scst_proc_get_tgt_root(&tgt_template); + scnprintf(name, sizeof(name), "%d", ioc->id); + mpt_target_proc_data.data = (void *)tgt; + p = scst_create_proc_entry(root, name, + &mpt_target_proc_data); + if (p == NULL) { + PRINT_ERROR("Not enough memory to register " + "target driver %s entry %s in /proc", + tgt_template.name, name); + scst_unregister(tgt->scst_tgt); + ret = -ENOMEM; + goto out; + } + scst_tgt_set_tgt_priv(tgt->scst_tgt, tgt); mpt_stm_priv[ioc->id]->tgt = tgt; - _mpt_ada_nums ++; out: @@ -5102,48 +5112,44 @@ stmapp_set_sense_info(MPT_STM_PRIV *priv, TRACE_EXIT(); } +#if defined(DEBUG) || defined(TRACING) + #define MPT_PROC_LOG_ENTRY_NAME "trace_level" -#ifdef TRACING -static struct scst_proc_log mpt_spec_tbl[] = + +#include + +static int mpt_log_info_show(struct seq_file *seq, void *v) { - { TRACE_MPI, "mpt_mpi" }, - { 0, NULL } + int res = 0; + + TRACE_ENTRY(); + + res = scst_proc_log_entry_read(seq, trace_flag, NULL); + + TRACE_EXIT_RES(res); + return res; +} + +static int mpt_proc_log_entry_write(struct file *file, const char __user *buf, + size_t length, loff_t *off) +{ + int res = 0; + + TRACE_ENTRY(); + + res = scst_proc_log_entry_write(file, buf, length, &trace_flag, + SCST_DEFAULT_MPT_LOG_FLAGS, NULL); + + TRACE_EXIT_RES(res); + return res; +} + +static struct scst_proc_data mpt_log_proc_data = { + SCST_DEF_RW_SEQ_OP(mpt_proc_log_entry_write) + .show = mpt_log_info_show, }; #endif -static int mpt_proc_log_entry_read(char *buffer, char **start, - off_t offset, int length, int *eof, - void *data) -{ - int res = 0; - - TRACE_ENTRY(); -#ifdef TRACING - res = scst_proc_log_entry_read(buffer, start, offset, length, eof, - data, trace_flag, mpt_spec_tbl); -#endif - - TRACE_EXIT_RES(res); - return res; -} - -static int mpt_proc_log_entry_write(struct file *file, const char *buf, - unsigned long length, void *data) -{ - int res = 0; - - TRACE_ENTRY(); - -#ifdef TRACING - res = scst_proc_log_entry_write(file, buf, length, data, - &trace_flag, (TRACE_FUNCTION | TRACE_OUT_OF_MEM | TRACE_MGMT | \ - TRACE_MINOR | TRACE_SPECIAL), mpt_spec_tbl); -#endif - - TRACE_EXIT_RES(res); - return res; -} - static int mpt_proc_log_entry_build(struct scst_tgt_template *templ) { int res = 0; @@ -5153,10 +5159,10 @@ static int mpt_proc_log_entry_build(struct scst_tgt_template *templ) root = scst_proc_get_tgt_root(templ); if (root) { - p = create_proc_read_entry(MPT_PROC_LOG_ENTRY_NAME, - S_IFREG | S_IRUGO | S_IWUSR, root, - mpt_proc_log_entry_read, - (void *)templ->name); +#if defined(DEBUG) || defined(TRACING) + mpt_log_proc_data.data = (void *)templ->name; + p = scst_create_proc_entry(root, MPT_PROC_LOG_ENTRY_NAME, + &mpt_log_proc_data); if (p == NULL) { PRINT_ERROR("Not enough memory to register " "target driver %s entry %s in /proc", @@ -5164,7 +5170,7 @@ static int mpt_proc_log_entry_build(struct scst_tgt_template *templ) res = -ENOMEM; goto out; } - p->write_proc = mpt_proc_log_entry_write; +#endif } out: @@ -5175,16 +5181,18 @@ out: static void mpt_proc_log_entry_clean(struct scst_tgt_template *templ) { +#if defined(DEBUG) || defined(TRACING) struct proc_dir_entry *root; TRACE_ENTRY(); + root = scst_proc_get_tgt_root(templ); if (root) { remove_proc_entry(MPT_PROC_LOG_ENTRY_NAME, root); } - TRACE_EXIT(); +#endif } static int __init mpt_target_init(void) @@ -5225,14 +5233,6 @@ static void __exit mpt_target_exit(void) return; } -#ifdef DEBUG -unsigned long trace_flag = TRACE_FUNCTION | TRACE_OUT_OF_MEM | TRACE_SPECIAL; -#else -# ifdef TRACING -unsigned long trace_flag = TRACE_OUT_OF_MEM | TRACE_MGMT | TRACE_SPECIAL; -# endif -#endif - module_init(mpt_target_init); module_exit(mpt_target_exit); diff --git a/qla2x00t/qla2x00-target/qla2x00t.c b/qla2x00t/qla2x00-target/qla2x00t.c index ade7b0e36..2a02be2e9 100644 --- a/qla2x00t/qla2x00-target/qla2x00t.c +++ b/qla2x00t/qla2x00-target/qla2x00t.c @@ -43,8 +43,6 @@ #include "qla2x00t.h" -#include - #ifndef FC_TARGET_SUPPORT #error "FC_TARGET_SUPPORT is NOT DEFINED" #endif @@ -59,12 +57,12 @@ #endif #ifdef DEBUG -#define SCST_DEFAULT_QLA_LOG_FLAGS (TRACE_FUNCTION | TRACE_PID | \ +#define Q2T_DEFAULT_LOG_FLAGS (TRACE_FUNCTION | TRACE_PID | \ TRACE_OUT_OF_MEM | TRACE_MGMT | TRACE_MGMT_DEBUG | \ TRACE_MINOR | TRACE_SPECIAL) #else # ifdef TRACING -#define SCST_DEFAULT_QLA_LOG_FLAGS (TRACE_FUNCTION | TRACE_PID | \ +#define Q2T_DEFAULT_LOG_FLAGS (TRACE_FUNCTION | TRACE_PID | \ TRACE_OUT_OF_MEM | TRACE_MGMT | TRACE_MINOR | TRACE_SPECIAL) # endif #endif @@ -93,7 +91,8 @@ static void q2t_send_term_exchange(scsi_qla_host_t *ha, struct q2t_cmd *cmd, */ #if defined(DEBUG) || defined(TRACING) -unsigned long trace_flag = SCST_DEFAULT_QLA_LOG_FLAGS; +#define trace_flag q2t_trace_flag +unsigned long q2t_trace_flag = Q2T_DEFAULT_LOG_FLAGS; #endif struct scst_tgt_template tgt_template = { @@ -2074,7 +2073,7 @@ static int q2t_proc_log_entry_write(struct file *file, const char __user *buf, TRACE_ENTRY(); res = scst_proc_log_entry_write(file, buf, length, &trace_flag, - SCST_DEFAULT_QLA_LOG_FLAGS, NULL); + Q2T_DEFAULT_LOG_FLAGS, NULL); TRACE_EXIT_RES(res); return res; diff --git a/scst/README b/scst/README index 64e4c0d2b..a8ccbd533 100644 --- a/scst/README +++ b/scst/README @@ -40,10 +40,10 @@ compilation (see their description below). To compile SCST type 'make'. It will build SCST itself and its device handlers. To install them type 'make install'. The driver modules will be installed in '/lib/modules/`you_kernel_version`/extra'. In addition, -scsi_tgt.h, scst_debug.h and scst_debug.c will be copied to -'/usr/local/include/scst'. The first file contains all SCST's public -data definition, which are used by target drivers. The other ones -support debug messages logging. +scsi_tgt.h, scst_debug.h as well as Module.symvers or Modules.symvers +will be copied to '/usr/local/include/scst'. The first file contains all +SCST's public data definition, which are used by target drivers. The +other ones support debug messages logging and build process. Then you can load any module by typing 'modprobe drive_name'. The names are: diff --git a/scst/include/scst_debug.h b/scst/include/scst_debug.h index cea7f9633..1c8391ac9 100644 --- a/scst/include/scst_debug.h +++ b/scst/include/scst_debug.h @@ -99,63 +99,61 @@ #if defined(DEBUG) || defined(TRACING) -extern unsigned long trace_flag; +extern int debug_print_prefix(unsigned long trace_flag, const char *func, int line); +extern void debug_print_buffer(unsigned long trace_flag, const void *data, int len); -extern int debug_print_prefix(const char *func, int line); -extern void debug_print_buffer(const void *data, int len); - -#define TRACE(trace, format, args...) \ -do { \ - if (trace_flag & (trace)) \ - { \ - char *__tflag = LOG_FLAG; \ - if (debug_print_prefix(__FUNCTION__, __LINE__) > 0) \ - { \ - __tflag = NO_FLAG; \ - } \ - PRINT(NO_FLAG, "%s" format, __tflag, args); \ - } \ +#define TRACE(trace, format, args...) \ +do { \ + if (trace_flag & (trace)) \ + { \ + char *__tflag = LOG_FLAG; \ + if (debug_print_prefix(trace_flag, __FUNCTION__, __LINE__) > 0) \ + { \ + __tflag = NO_FLAG; \ + } \ + PRINT(NO_FLAG, "%s" format, __tflag, args); \ + } \ } while(0) -#define TRACE_LOG_FLAG(log_flag, trace, format, args...) \ -do { \ - char *__tflag = log_flag; \ - if (trace_flag & (trace)) \ - { \ - if (debug_print_prefix(__FUNCTION__, __LINE__) > 0) \ - { \ - __tflag = NO_FLAG; \ - } \ - } \ - PRINT(NO_FLAG, "%s" format, __tflag, args); \ +#define TRACE_LOG_FLAG(log_flag, trace, format, args...) \ +do { \ + char *__tflag = log_flag; \ + if (trace_flag & (trace)) \ + { \ + if (debug_print_prefix(trace_flag, __FUNCTION__, __LINE__) > 0) \ + { \ + __tflag = NO_FLAG; \ + } \ + } \ + PRINT(NO_FLAG, "%s" format, __tflag, args); \ } while(0) -#define TRACE_BUFFER(message, buff, len) \ -do { \ - if (trace_flag & TRACE_BUFF) \ - { \ - char *__tflag = LOG_FLAG; \ - if (debug_print_prefix(__FUNCTION__, __LINE__) > 0) \ - { \ - __tflag = NO_FLAG; \ - } \ - PRINT(NO_FLAG, "%s%s:", __tflag, message); \ - debug_print_buffer(buff, len); \ - } \ +#define TRACE_BUFFER(message, buff, len) \ +do { \ + if (trace_flag & TRACE_BUFF) \ + { \ + char *__tflag = LOG_FLAG; \ + if (debug_print_prefix(trace_flag, __FUNCTION__, __LINE__) > 0) \ + { \ + __tflag = NO_FLAG; \ + } \ + PRINT(NO_FLAG, "%s%s:", __tflag, message); \ + debug_print_buffer(trace_flag, buff, len); \ + } \ } while(0) -#define TRACE_BUFF_FLAG(flag, message, buff, len) \ -do { \ - if (trace_flag & (flag)) \ - { \ - char *__tflag = LOG_FLAG; \ - if (debug_print_prefix(__FUNCTION__, __LINE__) > 0) \ - { \ - __tflag = NO_FLAG; \ - } \ - PRINT(NO_FLAG, "%s%s:", __tflag, message); \ - debug_print_buffer(buff, len); \ - } \ +#define TRACE_BUFF_FLAG(flag, message, buff, len) \ +do { \ + if (trace_flag & (flag)) \ + { \ + char *__tflag = LOG_FLAG; \ + if (debug_print_prefix(trace_flag, __FUNCTION__, __LINE__) > 0) \ + { \ + __tflag = NO_FLAG; \ + } \ + PRINT(NO_FLAG, "%s%s:", __tflag, message); \ + debug_print_buffer(trace_flag, buff, len); \ + } \ } while(0) #else /* DEBUG || TRACING */ @@ -168,54 +166,54 @@ do { \ #ifdef DEBUG -#define TRACE_MEM(format, args...) \ -do { \ - if (trace_flag & TRACE_MEMORY) \ - { \ - char *__tflag = LOG_FLAG; \ - if (debug_print_prefix(__FUNCTION__, __LINE__) > 0) \ - { \ - __tflag = NO_FLAG; \ - } \ - PRINT(NO_FLAG, "%s" format, __tflag, args); \ - } \ +#define TRACE_MEM(format, args...) \ +do { \ + if (trace_flag & TRACE_MEMORY) \ + { \ + char *__tflag = LOG_FLAG; \ + if (debug_print_prefix(trace_flag, __FUNCTION__, __LINE__) > 0) \ + { \ + __tflag = NO_FLAG; \ + } \ + PRINT(NO_FLAG, "%s" format, __tflag, args); \ + } \ } while(0) -#define TRACE_DBG(format, args...) \ -do { \ - if (trace_flag & TRACE_DEBUG) \ - { \ - char *__tflag = LOG_FLAG; \ - if (debug_print_prefix(__FUNCTION__, __LINE__) > 0) \ - { \ - __tflag = NO_FLAG; \ - } \ - PRINT(NO_FLAG, "%s" format, __tflag, args); \ - } \ +#define TRACE_DBG(format, args...) \ +do { \ + if (trace_flag & TRACE_DEBUG) \ + { \ + char *__tflag = LOG_FLAG; \ + if (debug_print_prefix(trace_flag, __FUNCTION__, __LINE__) > 0) \ + { \ + __tflag = NO_FLAG; \ + } \ + PRINT(NO_FLAG, "%s" format, __tflag, args); \ + } \ } while(0) -#define TRACE_MGMT_DBG(format, args...) \ -do { \ - if (trace_flag & TRACE_MGMT_DEBUG) \ - { \ - char *__tflag = LOG_FLAG; \ - if (debug_print_prefix(__FUNCTION__, __LINE__) > 0) \ - { \ - __tflag = NO_FLAG; \ - } \ - PRINT(NO_FLAG, "%s" format, __tflag, args); \ - } \ +#define TRACE_MGMT_DBG(format, args...) \ +do { \ + if (trace_flag & TRACE_MGMT_DEBUG) \ + { \ + char *__tflag = LOG_FLAG; \ + if (debug_print_prefix(trace_flag, __FUNCTION__, __LINE__) > 0) \ + { \ + __tflag = NO_FLAG; \ + } \ + PRINT(NO_FLAG, "%s" format, __tflag, args); \ + } \ } while(0) -#define PRINT_ERROR_PR(format, args...) \ -do { \ - if (ERROR_FLAG != LOG_FLAG) \ - { \ +#define PRINT_ERROR_PR(format, args...) \ +do { \ + if (ERROR_FLAG != LOG_FLAG) \ + { \ TRACE_LOG_FLAG(LOG_FLAG, trace_flag, "%s: ***ERROR*** " format, \ - LOG_PREFIX, args); \ - } \ + LOG_PREFIX, args); \ + } \ TRACE_LOG_FLAG(ERROR_FLAG, trace_flag, "%s: ***ERROR*** " format, \ - LOG_PREFIX, args); \ + LOG_PREFIX, args); \ } while(0) #define PRINT_INFO_PR(format, args...) \ @@ -229,86 +227,86 @@ do { \ format, LOG_PREFIX, args); \ } while(0) -#define PRINT_ERROR(format, args...) \ -do { \ - if (ERROR_FLAG != LOG_FLAG) \ - { \ +#define PRINT_ERROR(format, args...) \ +do { \ + if (ERROR_FLAG != LOG_FLAG) \ + { \ TRACE_LOG_FLAG(LOG_FLAG, trace_flag, "***ERROR*** " format, args); \ - } \ + } \ TRACE_LOG_FLAG(ERROR_FLAG, trace_flag, "***ERROR*** " format, args); \ } while(0) -#define PRINT_INFO(format, args...) \ -do { \ - if (INFO_FLAG != LOG_FLAG) \ - { \ +#define PRINT_INFO(format, args...) \ +do { \ + if (INFO_FLAG != LOG_FLAG) \ + { \ TRACE_LOG_FLAG(LOG_FLAG, trace_flag, format, args); \ - } \ - TRACE_LOG_FLAG(INFO_FLAG, trace_flag, format, args); \ + } \ + TRACE_LOG_FLAG(INFO_FLAG, trace_flag, format, args); \ } while(0) -#define TRACE_ENTRY() \ -do { \ - if (trace_flag & TRACE_ENTRYEXIT) \ - { \ - if (trace_flag & TRACE_PID) \ - { \ +#define TRACE_ENTRY() \ +do { \ + if (trace_flag & TRACE_ENTRYEXIT) \ + { \ + if (trace_flag & TRACE_PID) \ + { \ PRINT(LOG_FLAG, "[%d]: ENTRY %s", current->pid, \ - __FUNCTION__); \ - } \ - else \ - { \ - PRINT(LOG_FLAG, "ENTRY %s", __FUNCTION__); \ - } \ - } \ + __FUNCTION__); \ + } \ + else \ + { \ + PRINT(LOG_FLAG, "ENTRY %s", __FUNCTION__); \ + } \ + } \ } while(0) -#define TRACE_EXIT() \ -do { \ - if (trace_flag & TRACE_ENTRYEXIT) \ - { \ - if (trace_flag & TRACE_PID) \ - { \ +#define TRACE_EXIT() \ +do { \ + if (trace_flag & TRACE_ENTRYEXIT) \ + { \ + if (trace_flag & TRACE_PID) \ + { \ PRINT(LOG_FLAG, "[%d]: EXIT %s", current->pid, \ - __FUNCTION__); \ - } \ - else \ - { \ - PRINT(LOG_FLAG, "EXIT %s", __FUNCTION__); \ - } \ - } \ + __FUNCTION__); \ + } \ + else \ + { \ + PRINT(LOG_FLAG, "EXIT %s", __FUNCTION__); \ + } \ + } \ } while(0) -#define TRACE_EXIT_RES(res) \ -do { \ - if (trace_flag & TRACE_ENTRYEXIT) \ - { \ - if (trace_flag & TRACE_PID) \ - { \ - PRINT(LOG_FLAG, "[%d]: EXIT %s: %ld", current->pid, \ - __FUNCTION__, (long)(res)); \ - } \ - else \ - { \ +#define TRACE_EXIT_RES(res) \ +do { \ + if (trace_flag & TRACE_ENTRYEXIT) \ + { \ + if (trace_flag & TRACE_PID) \ + { \ + PRINT(LOG_FLAG, "[%d]: EXIT %s: %ld", current->pid, \ + __FUNCTION__, (long)(res)); \ + } \ + else \ + { \ PRINT(LOG_FLAG, "EXIT %s: %ld", __FUNCTION__, (long)(res)); \ - } \ - } \ + } \ + } \ } while(0) -#define TRACE_EXIT_HRES(res) \ -do { \ - if (trace_flag & TRACE_ENTRYEXIT) \ - { \ - if (trace_flag & TRACE_PID) \ - { \ - PRINT(LOG_FLAG, "[%d]: EXIT %s: 0x%lx", current->pid, \ - __FUNCTION__, (long)(res)); \ - } \ - else \ - { \ +#define TRACE_EXIT_HRES(res) \ +do { \ + if (trace_flag & TRACE_ENTRYEXIT) \ + { \ + if (trace_flag & TRACE_PID) \ + { \ + PRINT(LOG_FLAG, "[%d]: EXIT %s: 0x%lx", current->pid, \ + __FUNCTION__, (long)(res)); \ + } \ + else \ + { \ PRINT(LOG_FLAG, "EXIT %s: %lx", __FUNCTION__, (long)(res)); \ - } \ - } \ + } \ + } \ } while(0) #else /* DEBUG */ @@ -321,8 +319,8 @@ do { \ #define TRACE_EXIT_RES(res) {} #define TRACE_EXIT_HRES(res) {} -#define PRINT_INFO_PR(format, args...) \ -do { \ +#define PRINT_INFO_PR(format, args...) \ +do { \ PRINT(INFO_FLAG, "%s: " format, LOG_PREFIX, args); \ } while(0) diff --git a/scst/kernel/in-tree/Makefile.scsi_tgt b/scst/kernel/in-tree/Makefile.scsi_tgt index fcf5903d9..965bea6a6 100644 --- a/scst/kernel/in-tree/Makefile.scsi_tgt +++ b/scst/kernel/in-tree/Makefile.scsi_tgt @@ -5,6 +5,7 @@ scsi_tgt-y += scst.o scsi_tgt-y += scst_targ.o scsi_tgt-y += scst_lib.o scsi_tgt-y += scst_proc.o +scsi_tgt-y += scst_mem.o obj-$(CONFIG_SCSI_TARGET) += scsi_tgt.o obj-$(CONFIG_SCSI_TARGET_DISK) += scst_disk.o diff --git a/scst/src/Makefile b/scst/src/Makefile index 1f0805eff..4035112ad 100644 --- a/scst/src/Makefile +++ b/scst/src/Makefile @@ -29,9 +29,19 @@ DEV_HANDLERS_DIR = dev_handlers ifneq ($(KERNELRELEASE),) +SCST_INC_DIR := $(SUBDIRS)/../include + obj-m := scsi_tgt.o scsi_tgt-objs := scst.o scst_targ.o scst_lib.o scst_mem.o scst_proc.o +scsi_tgt-y += scst.o +scsi_tgt-y += scst_targ.o +scsi_tgt-y += scst_lib.o +scsi_tgt-y += scst_proc.o +scsi_tgt-y += scst_mem.o +scsi_tgt-y += scst_debug.o +obj-$(CONFIG_SCSI_TARGET) += scsi_tgt.o dev_handlers/ + obj-$(BUILD_DEV) += $(DEV_HANDLERS_DIR)/ else @@ -59,7 +69,6 @@ install: all install -d $(INSTALL_DIR_H) install -m 644 ../include/scsi_tgt.h $(INSTALL_DIR_H) install -m 644 ../include/scst_debug.h $(INSTALL_DIR_H) - install -m 644 ../include/scst_debug.c $(INSTALL_DIR_H) ifneq ($(MODS_VERS),) rm -f $(INSTALL_DIR_H)/Module.symvers install -m 644 Modules.symvers $(INSTALL_DIR_H) @@ -81,9 +90,7 @@ endif INSTALL_DIR := /lib/modules/$(shell uname -r)/extra INSTALL_DIR_H := /usr/local/include/scst -INC_DIR := $(SUBDIRS)/../include - -EXTRA_CFLAGS += -I$(INC_DIR) +EXTRA_CFLAGS += -I$(SCST_INC_DIR) #EXTRA_CFLAGS += -DSTRICT_SERIALIZING diff --git a/scst/src/dev_handlers/Makefile b/scst/src/dev_handlers/Makefile index e24965650..b528e2462 100644 --- a/scst/src/dev_handlers/Makefile +++ b/scst/src/dev_handlers/Makefile @@ -27,8 +27,20 @@ # ifneq ($(KERNELRELEASE),) +SCST_INC_DIR := $(SUBDIRS)/../include + obj-m := scst_cdrom.o scst_changer.o scst_disk.o scst_modisk.o scst_tape.o \ scst_fileio.o scst_raid.o scst_processor.o + +obj-$(CONFIG_SCSI_TARGET_DISK) += scst_disk.o +obj-$(CONFIG_SCSI_TARGET_TAPE) += scst_tape.o +obj-$(CONFIG_SCSI_TARGET_CDROM) += scst_cdrom.o +obj-$(CONFIG_SCSI_TARGET_MODISK) += scst_modisk.o +obj-$(CONFIG_SCSI_TARGET_CHANGER) += scst_changer.o +obj-$(CONFIG_SCSI_TARGET_RAID) += scst_raid.o +obj-$(CONFIG_SCSI_TARGET_PROCESSOR) += scst_processor.o +obj-$(CONFIG_SCSI_TARGET_FILEIO) += scst_fileio.o + else ifeq ($(KDIR),) KDIR := /lib/modules/$(shell uname -r)/build @@ -48,11 +60,9 @@ endif INSTALL_DIR := /lib/modules/$(shell uname -r)/extra -EXTRA_CFLAGS += -I$(SUBDIRS) -I$(SUBDIRS)/../include -#EXTRA_CFLAGS += -I$(SUBDIRS) -I$(SUBDIRS)/../../include -I$(SUBDIRS)/.. +EXTRA_CFLAGS += -I$(SUBDIRS) -I$(SCST_INC_DIR) #EXTRA_CFLAGS += -DTRACING - EXTRA_CFLAGS += -DDEBUG clean: diff --git a/scst/src/dev_handlers/scst_cdrom.c b/scst/src/dev_handlers/scst_cdrom.c index d0f84afdd..235bc8eb9 100644 --- a/scst/src/dev_handlers/scst_cdrom.c +++ b/scst/src/dev_handlers/scst_cdrom.c @@ -20,12 +20,10 @@ #include #define LOG_PREFIX "dev_cdrom" -#include "scst_debug.h" + #include "scsi_tgt.h" #include "scst_dev_handler.h" -#include "scst_debug.c" - #define CDROM_NAME "dev_cdrom" #define CDROM_TYPE { \ @@ -58,10 +56,6 @@ void cdrom_detach(struct scst_device *); int cdrom_parse(struct scst_cmd *, const struct scst_info_cdb *); int cdrom_done(struct scst_cmd *); -#if defined(DEBUG) || defined(TRACING) -unsigned long trace_flag = SCST_DEFAULT_DEV_LOG_FLAGS; -#endif - static struct scst_dev_type cdrom_devtype = CDROM_TYPE; /************************************************************** diff --git a/scst/src/dev_handlers/scst_changer.c b/scst/src/dev_handlers/scst_changer.c index c282575ff..dfbece362 100644 --- a/scst/src/dev_handlers/scst_changer.c +++ b/scst/src/dev_handlers/scst_changer.c @@ -18,12 +18,10 @@ */ #define LOG_PREFIX "dev_changer" -#include "scst_debug.h" + #include "scsi_tgt.h" #include "scst_dev_handler.h" -#include "scst_debug.c" - #define CHANGER_NAME "dev_changer" #define CHANGER_TYPE { \ @@ -47,10 +45,6 @@ void changer_detach(struct scst_device *); int changer_parse(struct scst_cmd *, const struct scst_info_cdb *); int changer_done(struct scst_cmd *); -#if defined(DEBUG) || defined(TRACING) -unsigned long trace_flag = SCST_DEFAULT_DEV_LOG_FLAGS; -#endif - static struct scst_dev_type changer_devtype = CHANGER_TYPE; /************************************************************** diff --git a/scst/src/dev_handlers/scst_dev_handler.h b/scst/src/dev_handlers/scst_dev_handler.h index 31f08e116..07c509f34 100644 --- a/scst/src/dev_handlers/scst_dev_handler.h +++ b/scst/src/dev_handlers/scst_dev_handler.h @@ -1,3 +1,6 @@ +#ifndef __SCST_DEV_HANDLER_H +#define __SCST_DEV_HANDLER_H + #include #define SCST_DEV_UA_RETRIES 5 @@ -10,6 +13,8 @@ #include #include +#include "scst_debug.h" + #ifdef DEBUG #define SCST_DEFAULT_DEV_LOG_FLAGS (TRACE_OUT_OF_MEM | TRACE_PID | \ TRACE_FUNCTION | TRACE_MGMT | TRACE_MINOR | TRACE_MGMT_DEBUG | \ @@ -18,6 +23,9 @@ #define SCST_DEFAULT_DEV_LOG_FLAGS (TRACE_OUT_OF_MEM | TRACE_MGMT | TRACE_MINOR) #endif +static unsigned long dh_trace_flag = SCST_DEFAULT_DEV_LOG_FLAGS; +#define trace_flag dh_trace_flag + static struct scst_proc_data dev_handler_log_proc_data; static int dev_handler_log_info_show(struct seq_file *seq, void *v) @@ -25,6 +33,7 @@ static int dev_handler_log_info_show(struct seq_file *seq, void *v) int res = 0; TRACE_ENTRY(); + res = scst_proc_log_entry_read(seq, trace_flag, NULL); TRACE_EXIT_RES(res); @@ -55,7 +64,6 @@ static int scst_dev_handler_build_std_proc(struct scst_dev_type *dev_type) TRACE_ENTRY(); root = scst_proc_get_dev_type_root(dev_type); - if (root) { /* create the proc file entry for the device */ dev_handler_log_proc_data.data = (void *)dev_type->name; @@ -84,10 +92,10 @@ static void scst_dev_handler_destroy_std_proc(struct scst_dev_type *dev_type) TRACE_ENTRY(); root = scst_proc_get_dev_type_root(dev_type); - if (root) { remove_proc_entry(DEV_HANDLER_LOG_ENTRY_NAME, root); } + TRACE_EXIT(); #endif } @@ -98,3 +106,5 @@ static struct scst_proc_data dev_handler_log_proc_data = { .show = dev_handler_log_info_show, }; #endif + +#endif /* __SCST_DEV_HANDLER_H */ diff --git a/scst/src/dev_handlers/scst_disk.c b/scst/src/dev_handlers/scst_disk.c index 3f173f1fb..1b572ec34 100644 --- a/scst/src/dev_handlers/scst_disk.c +++ b/scst/src/dev_handlers/scst_disk.c @@ -24,12 +24,10 @@ #include #define LOG_PREFIX "dev_disk" -#include "scst_debug.h" + #include "scsi_tgt.h" #include "scst_dev_handler.h" -#include "scst_debug.c" - # define DISK_NAME "dev_disk" # define DISK_PERF_NAME "dev_disk_perf" @@ -78,10 +76,6 @@ int disk_parse(struct scst_cmd *cmd, const struct scst_info_cdb *info_cmd); int disk_done(struct scst_cmd *cmd); int disk_exec(struct scst_cmd *cmd); -#if defined(DEBUG) || defined(TRACING) -unsigned long trace_flag = SCST_DEFAULT_DEV_LOG_FLAGS; -#endif - static struct scst_dev_type disk_devtype = DISK_TYPE; static struct scst_dev_type disk_devtype_perf = DISK_PERF_TYPE; @@ -90,7 +84,7 @@ static int __init init_scst_disk_driver(void) int res = 0; TRACE_ENTRY(); - + disk_devtype.module = THIS_MODULE; if (scst_register_dev_driver(&disk_devtype) < 0) { res = -ENODEV; diff --git a/scst/src/dev_handlers/scst_fileio.c b/scst/src/dev_handlers/scst_fileio.c index 8e5b8ad48..3113f637f 100644 --- a/scst/src/dev_handlers/scst_fileio.c +++ b/scst/src/dev_handlers/scst_fileio.c @@ -37,12 +37,10 @@ #include #define LOG_PREFIX "dev_fileio" -#include "scst_debug.h" + #include "scsi_tgt.h" #include "scst_dev_handler.h" -#include "scst_debug.c" - /* 8 byte ASCII Vendor of the FILE IO target */ #define SCST_FIO_VENDOR "SCST_FIO" /* 4 byte ASCII Product Revision Level of the FILE IO target - left aligned */ @@ -81,10 +79,6 @@ #define FILEIO_PROC_HELP "help" -#if defined(DEBUG) || defined(TRACING) -unsigned long trace_flag = SCST_DEFAULT_DEV_LOG_FLAGS; -#endif - struct scst_fileio_dev { uint32_t block_size; uint64_t nblocks; @@ -3109,7 +3103,6 @@ static int __init init_scst_fileio(struct scst_dev_type *devtype) TRACE_ENTRY(); devtype->module = THIS_MODULE; - res = scst_register_virtual_dev_driver(devtype); if (res < 0) goto out; diff --git a/scst/src/dev_handlers/scst_modisk.c b/scst/src/dev_handlers/scst_modisk.c index be4626463..8e9929f8b 100644 --- a/scst/src/dev_handlers/scst_modisk.c +++ b/scst/src/dev_handlers/scst_modisk.c @@ -24,12 +24,10 @@ #include #define LOG_PREFIX "dev_modisk" -#include "scst_debug.h" + #include "scsi_tgt.h" #include "scst_dev_handler.h" -#include "scst_debug.c" - # define MODISK_NAME "dev_modisk" # define MODISK_PERF_NAME "dev_modisk_perf" @@ -78,10 +76,6 @@ int modisk_parse(struct scst_cmd *, const struct scst_info_cdb *); int modisk_done(struct scst_cmd *); int modisk_exec(struct scst_cmd *); -#if defined(DEBUG) || defined(TRACING) -unsigned long trace_flag = SCST_DEFAULT_DEV_LOG_FLAGS; -#endif - static struct scst_dev_type modisk_devtype = MODISK_TYPE; static struct scst_dev_type modisk_devtype_perf = MODISK_PERF_TYPE; diff --git a/scst/src/dev_handlers/scst_processor.c b/scst/src/dev_handlers/scst_processor.c index 3ff30bc61..8ab3dd4a5 100644 --- a/scst/src/dev_handlers/scst_processor.c +++ b/scst/src/dev_handlers/scst_processor.c @@ -18,12 +18,10 @@ */ #define LOG_PREFIX "dev_processor" -#include "scst_debug.h" + #include "scsi_tgt.h" #include "scst_dev_handler.h" -#include "scst_debug.c" - #define PROCESSOR_NAME "dev_processor" #define PROCESSOR_TYPE { \ @@ -47,10 +45,6 @@ void processor_detach(struct scst_device *); int processor_parse(struct scst_cmd *, const struct scst_info_cdb *); int processor_done(struct scst_cmd *); -#if defined(DEBUG) || defined(TRACING) -unsigned long trace_flag = SCST_DEFAULT_DEV_LOG_FLAGS; -#endif - static struct scst_dev_type processor_devtype = PROCESSOR_TYPE; /************************************************************** @@ -211,7 +205,7 @@ static int __init processor_init(void) int res = 0; TRACE_ENTRY(); - + processor_devtype.module = THIS_MODULE; if (scst_register_dev_driver(&processor_devtype) < 0) { res = -ENODEV; diff --git a/scst/src/dev_handlers/scst_raid.c b/scst/src/dev_handlers/scst_raid.c index 1a1c94146..43a1b7fff 100644 --- a/scst/src/dev_handlers/scst_raid.c +++ b/scst/src/dev_handlers/scst_raid.c @@ -18,12 +18,10 @@ */ #define LOG_PREFIX "dev_raid" -#include "scst_debug.h" + #include "scsi_tgt.h" #include "scst_dev_handler.h" -#include "scst_debug.c" - #define RAID_NAME "dev_raid" #define RAID_TYPE { \ @@ -47,10 +45,6 @@ void raid_detach(struct scst_device *); int raid_parse(struct scst_cmd *, const struct scst_info_cdb *); int raid_done(struct scst_cmd *); -#if defined(DEBUG) || defined(TRACING) -unsigned long trace_flag = SCST_DEFAULT_DEV_LOG_FLAGS; -#endif - static struct scst_dev_type raid_devtype = RAID_TYPE; /************************************************************** @@ -211,7 +205,7 @@ static int __init raid_init(void) int res = 0; TRACE_ENTRY(); - + raid_devtype.module = THIS_MODULE; if (scst_register_dev_driver(&raid_devtype) < 0) { res = -ENODEV; diff --git a/scst/src/dev_handlers/scst_tape.c b/scst/src/dev_handlers/scst_tape.c index 9ea1d2c59..1bdd91e5d 100644 --- a/scst/src/dev_handlers/scst_tape.c +++ b/scst/src/dev_handlers/scst_tape.c @@ -24,12 +24,10 @@ #include #define LOG_PREFIX "dev_tape" -#include "scst_debug.h" + #include "scsi_tgt.h" #include "scst_dev_handler.h" -#include "scst_debug.c" - # define TAPE_NAME "dev_tape" # define TAPE_PERF_NAME "dev_tape_perf" @@ -91,10 +89,6 @@ int tape_parse(struct scst_cmd *, const struct scst_info_cdb *); int tape_done(struct scst_cmd *); int tape_exec(struct scst_cmd *); -#if defined(DEBUG) || defined(TRACING) -unsigned long trace_flag = SCST_DEFAULT_DEV_LOG_FLAGS; -#endif - static struct scst_dev_type tape_devtype = TAPE_TYPE; static struct scst_dev_type tape_devtype_perf = TAPE_PERF_TYPE; @@ -103,7 +97,7 @@ static int __init init_scst_tape_driver(void) int res = 0; TRACE_ENTRY(); - + tape_devtype.module = THIS_MODULE; if (scst_register_dev_driver(&tape_devtype) < 0) { res = -ENODEV; diff --git a/scst/src/scst.c b/scst/src/scst.c index 142445b16..ef0b73c65 100644 --- a/scst/src/scst.c +++ b/scst/src/scst.c @@ -28,12 +28,13 @@ #include #include -#include "scst_debug.h" #include "scsi_tgt.h" #include "scst_priv.h" #include "scst_mem.h" -#include "scst_debug.c" +#if defined(DEBUG) || defined(TRACING) +unsigned long scst_trace_flag = SCST_DEFAULT_LOG_FLAGS; +#endif /* * All targets, devices and dev_types management is done under @@ -70,10 +71,6 @@ LIST_HEAD(scst_init_cmd_list); LIST_HEAD(scst_cmd_list); DECLARE_WAIT_QUEUE_HEAD(scst_list_waitQ); -#if defined(DEBUG) || defined(TRACING) -unsigned long trace_flag = SCST_DEFAULT_LOG_FLAGS; -#endif - spinlock_t scst_cmd_mem_lock = SPIN_LOCK_UNLOCKED; unsigned long scst_cur_cmd_mem, scst_cur_max_cmd_mem; diff --git a/scst/include/scst_debug.c b/scst/src/scst_debug.c similarity index 90% rename from scst/include/scst_debug.c rename to scst/src/scst_debug.c index b2e4943a0..fc425c836 100644 --- a/scst/include/scst_debug.c +++ b/scst/src/scst_debug.c @@ -18,16 +18,18 @@ * GNU General Public License for more details. */ -#if defined(DEBUG) || defined(TRACING) +#include "scst_debug.h" +#include "scsi_tgt.h" -unsigned long trace_flag; +#if defined(DEBUG) || defined(TRACING) #define TRACE_BUF_SIZE 512 static char trace_buf[TRACE_BUF_SIZE]; static spinlock_t trace_buf_lock = SPIN_LOCK_UNLOCKED; -int debug_print_prefix(const char *func, int line) +int debug_print_prefix(unsigned long trace_flag, const char *func, + int line) { int i = 0; unsigned long flags; @@ -50,7 +52,8 @@ int debug_print_prefix(const char *func, int line) return i; } -void debug_print_buffer(const void *data, int len) +void debug_print_buffer(unsigned long trace_flag, const void *data, + int len) { int z, z1, i; const unsigned char *buf = (const unsigned char *) data; @@ -105,4 +108,6 @@ void debug_print_buffer(const void *data, int len) return; } +EXPORT_SYMBOL(debug_print_prefix); +EXPORT_SYMBOL(debug_print_buffer); #endif /* DEBUG || TRACING */ diff --git a/scst/src/scst_mem.c b/scst/src/scst_mem.c index 0f3079f50..5fca2ecf0 100644 --- a/scst/src/scst_mem.c +++ b/scst/src/scst_mem.c @@ -30,8 +30,8 @@ #endif #include "scsi_tgt.h" -#include "scst_debug.h" #include "scst_priv.h" +#include "scst_debug.h" #include "scst_mem.h" /* diff --git a/scst/src/scst_priv.h b/scst/src/scst_priv.h index 60ccd2067..c591d067b 100644 --- a/scst/src/scst_priv.h +++ b/scst/src/scst_priv.h @@ -30,6 +30,8 @@ #include #endif +#include "scst_debug.h" + #define SCST_MAJOR 177 #define TRACE_RETRY 0x80000000 @@ -41,6 +43,11 @@ #define LOG_PREFIX "scst" +#if defined(DEBUG) || defined(TRACING) +#define trace_flag scst_trace_flag +extern unsigned long scst_trace_flag; +#endif + #ifdef DEBUG /*#define SCST_DEFAULT_LOG_FLAGS (TRACE_ALL & ~TRACE_MEMORY & ~TRACE_BUFF \ & ~TRACE_FUNCTION) diff --git a/scst/src/scst_proc.c b/scst/src/scst_proc.c index bc8aa8049..edf46948d 100644 --- a/scst/src/scst_proc.c +++ b/scst/src/scst_proc.c @@ -30,7 +30,6 @@ #include #include -#include "scst_debug.h" #include "scsi_tgt.h" #include "scst_mem.h" #include "scst_priv.h" diff --git a/scst/src/scst_targ.c b/scst/src/scst_targ.c index 07075d7b8..2215471c2 100644 --- a/scst/src/scst_targ.c +++ b/scst/src/scst_targ.c @@ -27,7 +27,6 @@ #include #include -#include "scst_debug.h" #include "scsi_tgt.h" #include "scst_priv.h"