Address recent SCST comments
Subsystems (2)
cover Address recent SCST comments
The paches in this patch series address the following issues:
- Make sure that all SCST sysfs attributes have only one value per file.
- Remove the '[key]' marker from sysfs files since it is nonstandard.
- Replace the symbolic constant SCST_SYSFS_BLOCK_SIZE by PAGE_SIZE.
- Improved the robustness of the sysfs parsing code.
- Fixed the errors in the online documentation of /sys/devices/scst/mgmt.
- Correct the version number of the SCST core.
- Update the documentation in Documentation/ABI/stable according to the above changes.
- Made the SCST sysfs documentation more clear. All comments formulated by Greg and Konrad about the documentation in Documentation/ABI/stable should have been addressed.
Notes:
- In case anyone starts wondering why set commands were introduced instead of making sysfs files writeable: the reason behind this is to avoid lock inversion.
- While examining how SCST has been configured via the sysfs interface is straightforward, configuring SCST via sysfs can be tedious. There exists a user space tool that allows to save a configuration to disk and to restore a configuration, even without restarting SCST. The source code of that tool can be obtained as follows:
svn co https://scst.svn.sourceforge.net/svnroot/scst/branches/sysfs-tree-changes/scstadmin
An example of a configuration file generated by the scstadmin tool:
# Automatically generated by SCST Configurator v2.0.0.
HANDLER vdisk_fileio {
DEVICE disk01 {
filename /dev/vdisk1
nv_cache 1
}
DEVICE disk02 {
filename /dev/vdisk2
nv_cache 1
}
DEVICE disk03 {
filename /dev/vdisk3
nv_cache 1
}
DEVICE disk04 {
filename /dev/vdisk4
nv_cache 1
}
}HANDLER vdisk_nullio {
DEVICE disk05
DEVICE disk06
DEVICE disk07
}
TARGET_DRIVER ib_srpt {
TARGET ib_srpt_target_0 {
rel_tgt_id 1
enabled 1
LUN 0 disk01
LUN 1 disk02
LUN 2 disk03
LUN 3 disk04
LUN 4 disk05
LUN 5 disk06
GROUP initiator1 {
INITIATOR 0x00000000000000000002c9030005f34b INITIATOR 0x00000000000000000002c9030005f34c LUN 0 disk01
LUN 1 disk02
LUN 2 disk03
LUN 3 disk04
LUN 4 disk05
LUN 5 disk06
LUN 6 disk07
}
}
TARGET ib_srpt_target_1 {
rel_tgt_id 2
enabled 1
LUN 0 disk01
LUN 1 disk02
LUN 2 disk03
LUN 3 disk04
LUN 4 disk05
LUN 5 disk06
}
}
PATCH 1/8 scst: Split sysfs type attribute
The device 'type' sysfs attribute contains two values: the SCSI peripheral device type as a number and its textual description. Split this sysfs attribute into two attributes such that both satisfy the "one value per file" rule. Also, fix a potential out-of-bounds access of the array scst_dev_handler_types.
--- .../ABI/stable/sysfs-devices-scst_tgt_dev | 8 +++- Documentation/ABI/stable/sysfs-driver-scst_tgt_dev | 12 +++-- drivers/scst/scst_sysfs.c | 46 ++++++++++++++----- 3 files changed, 49 insertions(+), 17 deletions(-)
Documentation/ABI/stable/sysfs-devices-scst_tgt_dev +7 -1
@@ -118,7 +118,13 @@ What: /sys/bus/scst_tgt_dev/device/*/type Date: December 2010 Contact: Bart Van Assche <[email protected]> Description: - SCSI type of this device. Read-only. + SCSI type of this device as a number. Read-only. + +What: /sys/bus/scst_tgt_dev/device/*/type_description +Date: December 2010 +Contact: Bart Van Assche <[email protected]> +Description: + SCSI type of this device as a textual description. Read-only. What: /sys/bus/scst_tgt_dev/device/*/usn Date: December 2010
Documentation/ABI/stable/sysfs-driver-scst_tgt_dev +8 -4
@@ -20,8 +20,12 @@ What: /sys/bus/scst_tgt_dev/drivers/*/type Date: December 2010 Contact: Bart Van Assche <[email protected]> Description: - SCSI type of the devices managed by this driver. Read-only. - An example: + SCSI type of the devices managed by this driver as a number. + Read-only. - $ cat /sys/bus/scst_tgt_dev/drivers/vcdrom/type - 5 - CD-ROM device +What: /sys/bus/scst_tgt_dev/drivers/*/type_description +Date: December 2010 +Contact: Bart Van Assche <[email protected]> +Description: + SCSI type of the devices managed by this driver as a textual + description. Read-only.
drivers/scst/scst_sysfs.c +34 -12
81 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH 2/8 scst: Split version and stats attributes
In reply to Bart Van AsscheSplit the scst_local 'stats' sysfs attribute into three attributes such that the "one value per file" rule is honered. The three new attributes
are: aborts, device_resets and target_resets. Export the scst_local release date via the module information instead of sysfs. Remove the build options from the 'version' attribute of scst_local and scst since this duplicates information already available in the kernel .config.
--- Documentation/ABI/stable/sysfs-driver-scst_target | 9 +--- .../ABI/stable/sysfs-driver-scst_target-scst_local | 23 ++++++--- drivers/scst/scst_local/scst_local.c | 49 +++++++++++-------- drivers/scst/scst_sysfs.c | 47 +------------------ 4 files changed, 47 insertions(+), 81 deletions(-)
Documentation/ABI/stable/sysfs-driver-scst_target +2 -7
@@ -48,12 +48,7 @@ What: /sys/bus/scst_target/drivers/*/version Date: December 2010 Contact: Bart Van Assche <[email protected]> Description: - Target driver version and build options. The driver version - and build date appear on the first line separated by a - slash and the build options appear on subsequent - lines. Read-only. An example: + Target driver version. Read-only. An example: $ cat /sys/bus/scst_target/drivers/scst_local/version - 1.0.0/20100910 - TRACING - DEBUG + 1.0.0
Documentation/ABI/stable/sysfs-driver-scst_target-scst_local +16 -7
@@ -1,11 +1,20 @@ -What: /sys/bus/scst_target/drivers/scst_local/stats +What: /sys/bus/scst_target/drivers/scst_local/aborts Date: December 2010 Contact: Richard Sharpe <[email protected]> Description: - Statistics about processing of SCSI commands received via the - Linux SCSI initiator: the number of SCSI commands that have - been aborted, the number of SCSI device resets and the number - of SCSI target resets. Read-only. An example: + Number of SCSI commands that have been aborted by the SCSI + initiator. Read-only. - # cat /sys/bus/scst_target/drivers/scst_local/stats - Aborts: 0, Device Resets: 0, Target Resets: 0 +What: /sys/bus/scst_target/drivers/scst_local/device_resets +Date: December 2010 +Contact: Richard Sharpe <[email protected]> +Description: + Number of SCSI device resets that have been performed by the + SCSI initiator. Read-only. + +What: /sys/bus/scst_target/drivers/scst_local/target_resets +Date: December 2010 +Contact: Richard Sharpe <[email protected]> +Description: + Number of SCSI target resets that have been performed by the + SCSI initiator. Read-only.
drivers/scst/scst_local/scst_local.c +28 -21
79 lines not on this page · raw message
drivers/scst/scst_sysfs.c +1 -46
53 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH 3/8 scst: Remove [key] marker from sysfs files
In reply to Bart Van AsscheWhile the '[key]' marker on the second line of sysfs files is convenient for user-space tools that save the SCST state (e.g. scstadmin) to find out whether or not a value is a default value, remove this marker to make the contents of sysfs files created by SCST uniform with other sysfs files.
--- .../ABI/stable/sysfs-devices-scst_tgt_dev | 1 - Documentation/scst/SysfsRules | 160 -------------------- drivers/scst/dev_handlers/scst_vdisk.c | 62 ++------ drivers/scst/scst_local/scst_local.c | 10 +- drivers/scst/scst_sysfs.c | 66 +++------ include/scst/scst_const.h | 2 - 6 files changed, 34 insertions(+), 267 deletions(-) delete mode 100644 Documentation/scst/SysfsRules
Documentation/ABI/stable/sysfs-devices-scst_tgt_dev +0 -1
@@ -24,7 +24,6 @@ Description: # cat /sys/devices/disk01/filename /dev/sdc - [key] What: /sys/bus/scst_tgt_dev/device/*/nv_cache Date: December 2010
Documentation/scst/SysfsRules deleted +0 -160
160 lines not on this page · raw message
drivers/scst/dev_handlers/scst_vdisk.c +12 -50
151 lines not on this page · raw message
drivers/scst/scst_local/scst_local.c +4 -6
@@ -285,10 +285,10 @@ static ssize_t scst_local_scsi_transport_version_show(struct device *dev, goto out_up;if (tgt->scsi_transport_version !=0 ) - res =sprintf (buf,"0x%x\n%s" , tgt->scsi_transport_version, -SCST_SYSFS_KEY_MARK "\n" ); + res =scnprintf (buf,PAGE_SIZE ,"0x%x\n" , + tgt->scsi_transport_version);else - res =sprintf (buf,"0x%x\n" ,0x0BE0 );/* SAS */ + res =scnprintf (buf,PAGE_SIZE ,"0x%x\n" ,0x0BE0 );/* SAS */ out_up:up_read (&scst_local_exit_rwsem);
@@ -350,9 +350,7 @@ static ssize_t scst_local_phys_transport_version_show(struct device *dev,if (!tgt) goto out_up; - res =sprintf (buf,"0x%x\n%s" , tgt->phys_transport_version, - (tgt->phys_transport_version !=0 ) ? -SCST_SYSFS_KEY_MARK "\n" :"" ); + res =scnprintf (buf,PAGE_SIZE ,"0x%x\n" , tgt->phys_transport_version); out_up:up_read (&scst_local_exit_rwsem);
drivers/scst/scst_sysfs.c +18 -48
133 lines not on this page · raw message
include/scst/scst_const.h +0 -2
@@ -385,8 +385,6 @@ enum scst_cdb_flags {#define TID_COMMON_SIZE 24 -#define SCST_SYSFS_KEY_MARK "[key]" -#define SCST_MIN_REL_TGT_ID 1#define SCST_MAX_REL_TGT_ID 65535
Signature · 1 line
1.7.1
PATCH 4/8 scst: Substitute SCST_SYSFS_BLOCK_SIZE
In reply to Bart Van AsscheReplace all instances of SCST_SYSFS_BLOCK_SIZE by PAGE_SIZE and remove the symbolic constant SCST_SYSFS_BLOCK_SIZE.
--- drivers/scst/scst_sysfs.c | 54 +++++++++++++++++++------------------------- include/scst/scst_const.h | 2 - 2 files changed, 23 insertions(+), 33 deletions(-)
drivers/scst/scst_sysfs.c +23 -31
@@ -1531,7 +1531,7 @@ static ssize_t scst_tgt_dev_latency_show(struct kobject *kobj, processed_cmds_wr = latency_stat->processed_cmds_wr; processed_cmds_rd = latency_stat->processed_cmds_rd; - res +=scnprintf (&buffer[res],SCST_SYSFS_BLOCK_SIZE - res, + res +=scnprintf (&buffer[res],PAGE_SIZE - res,"%-5s %-9s %-15lu " ,"Write" , scst_io_size_names[i], (unsigned long )processed_cmds_wr);if (processed_cmds_wr ==0 )
@@ -1543,8 +1543,7 @@ static ssize_t scst_tgt_dev_latency_show(struct kobject *kobj, (unsigned long )scst_time_wr, (unsigned long )latency_stat->max_scst_time_wr, (unsigned long)latency_stat->scst_time_wr); - res +=scnprintf (&buffer[res],SCST_SYSFS_BLOCK_SIZE - res, -"%-47s" , buf); + res +=scnprintf (&buffer[res],PAGE_SIZE - res,"%-47s" , buf);do_div (tgt_time_wr, processed_cmds_wr); snprintf(buf, sizeof(buf), "%lu/%lu/%lu/%lu",
@@ -1552,8 +1551,7 @@ static ssize_t scst_tgt_dev_latency_show(struct kobject *kobj, (unsigned long )tgt_time_wr, (unsigned long )latency_stat->max_tgt_time_wr, (unsigned long)latency_stat->tgt_time_wr); - res +=scnprintf (&buffer[res],SCST_SYSFS_BLOCK_SIZE - res, -"%-47s" , buf); + res +=scnprintf (&buffer[res],PAGE_SIZE - res,"%-47s" , buf);do_div (dev_time_wr, processed_cmds_wr); snprintf(buf, sizeof(buf), "%lu/%lu/%lu/%lu",
@@ -1561,10 +1559,9 @@ static ssize_t scst_tgt_dev_latency_show(struct kobject *kobj, (unsigned long )dev_time_wr, (unsigned long )latency_stat->max_dev_time_wr, (unsigned long)latency_stat->dev_time_wr); - res +=scnprintf (&buffer[res],SCST_SYSFS_BLOCK_SIZE - res, -"%-47s\n" , buf); + res +=scnprintf (&buffer[res],PAGE_SIZE - res,"%-47s\n" , buf); - res +=scnprintf (&buffer[res],SCST_SYSFS_BLOCK_SIZE - res, + res +=scnprintf (&buffer[res],PAGE_SIZE - res,"%-5s %-9s %-15lu " ,"Read" , scst_io_size_names[i], (unsigned long )processed_cmds_rd);if (processed_cmds_rd ==0 )
@@ -1576,8 +1573,7 @@ static ssize_t scst_tgt_dev_latency_show(struct kobject *kobj, (unsigned long )scst_time_rd, (unsigned long )latency_stat->max_scst_time_rd, (unsigned long)latency_stat->scst_time_rd); - res +=scnprintf (&buffer[res],SCST_SYSFS_BLOCK_SIZE - res, -"%-47s" , buf); + res +=scnprintf (&buffer[res],PAGE_SIZE - res,"%-47s" , buf);do_div (tgt_time_rd, processed_cmds_rd); snprintf(buf, sizeof(buf), "%lu/%lu/%lu/%lu",
@@ -1585,8 +1581,7 @@ static ssize_t scst_tgt_dev_latency_show(struct kobject *kobj, (unsigned long )tgt_time_rd, (unsigned long )latency_stat->max_tgt_time_rd, (unsigned long)latency_stat->tgt_time_rd); - res +=scnprintf (&buffer[res],SCST_SYSFS_BLOCK_SIZE - res, -"%-47s" , buf); + res +=scnprintf (&buffer[res],PAGE_SIZE - res,"%-47s" , buf);do_div (dev_time_rd, processed_cmds_rd); snprintf(buf, sizeof(buf), "%lu/%lu/%lu/%lu",
@@ -1594,8 +1589,7 @@ static ssize_t scst_tgt_dev_latency_show(struct kobject *kobj, (unsigned long )dev_time_rd, (unsigned long )latency_stat->max_dev_time_rd, (unsigned long)latency_stat->dev_time_rd); - res +=scnprintf (&buffer[res],SCST_SYSFS_BLOCK_SIZE - res, -"%-47s\n" , buf); + res +=scnprintf (&buffer[res],PAGE_SIZE - res,"%-47s\n" , buf); }return res; }
@@ -1671,7 +1665,7 @@ static ssize_t scst_sess_latency_show(struct kobject *kobj, sess =scst_kobj_to_sess (kobj); res =0 ; - res +=scnprintf (&buffer[res],SCST_SYSFS_BLOCK_SIZE - res, + res +=scnprintf (&buffer[res],PAGE_SIZE - res,"%-15s %-15s %-46s %-46s %-46s\n" ,"T-L names" ,"Total commands" ,"SCST latency" ,"Target latency" ,"Dev latency (min/avg/max/all ns)" );
@@ -1695,7 +1689,7 @@ static ssize_t scst_sess_latency_show(struct kobject *kobj, processed_cmds_wr = latency_stat->processed_cmds_wr; processed_cmds_rd = latency_stat->processed_cmds_rd; - res +=scnprintf (&buffer[res],SCST_SYSFS_BLOCK_SIZE - res, + res +=scnprintf (&buffer[res],PAGE_SIZE - res,"%-5s %-9s %-15lu " ,"Write" , scst_io_size_names[i], (unsigned long )processed_cmds_wr);
@@ -1708,7 +1702,7 @@ static ssize_t scst_sess_latency_show(struct kobject *kobj, (unsigned long )scst_time_wr, (unsigned long )latency_stat->max_scst_time_wr, (unsigned long)latency_stat->scst_time_wr); - res +=scnprintf (&buffer[res],SCST_SYSFS_BLOCK_SIZE - res, + res +=scnprintf (&buffer[res],PAGE_SIZE - res,"%-47s" , buf);do_div (tgt_time_wr, processed_cmds_wr);
@@ -1717,7 +1711,7 @@ static ssize_t scst_sess_latency_show(struct kobject *kobj, (unsigned long )tgt_time_wr, (unsigned long )latency_stat->max_tgt_time_wr, (unsigned long)latency_stat->tgt_time_wr); - res +=scnprintf (&buffer[res],SCST_SYSFS_BLOCK_SIZE - res, + res +=scnprintf (&buffer[res],PAGE_SIZE - res,"%-47s" , buf);do_div (dev_time_wr, processed_cmds_wr);
@@ -1726,10 +1720,10 @@ static ssize_t scst_sess_latency_show(struct kobject *kobj, (unsigned long )dev_time_wr, (unsigned long )latency_stat->max_dev_time_wr, (unsigned long)latency_stat->dev_time_wr); - res +=scnprintf (&buffer[res],SCST_SYSFS_BLOCK_SIZE - res, + res +=scnprintf (&buffer[res],PAGE_SIZE - res,"%-47s\n" , buf); - res +=scnprintf (&buffer[res],SCST_SYSFS_BLOCK_SIZE - res, + res +=scnprintf (&buffer[res],PAGE_SIZE - res,"%-5s %-9s %-15lu " ,"Read" , scst_io_size_names[i], (unsigned long )processed_cmds_rd);
@@ -1742,7 +1736,7 @@ static ssize_t scst_sess_latency_show(struct kobject *kobj, (unsigned long )scst_time_rd, (unsigned long )latency_stat->max_scst_time_rd, (unsigned long)latency_stat->scst_time_rd); - res +=scnprintf (&buffer[res],SCST_SYSFS_BLOCK_SIZE - res, + res +=scnprintf (&buffer[res],PAGE_SIZE - res,"%-47s" , buf);do_div (tgt_time_rd, processed_cmds_rd);
@@ -1751,7 +1745,7 @@ static ssize_t scst_sess_latency_show(struct kobject *kobj, (unsigned long )tgt_time_rd, (unsigned long )latency_stat->max_tgt_time_rd, (unsigned long)latency_stat->tgt_time_rd); - res +=scnprintf (&buffer[res],SCST_SYSFS_BLOCK_SIZE - res, + res +=scnprintf (&buffer[res],PAGE_SIZE - res,"%-47s" , buf);do_div (dev_time_rd, processed_cmds_rd);
@@ -1760,7 +1754,7 @@ static ssize_t scst_sess_latency_show(struct kobject *kobj, (unsigned long )dev_time_rd, (unsigned long )latency_stat->max_dev_time_rd, (unsigned long)latency_stat->dev_time_rd); - res +=scnprintf (&buffer[res],SCST_SYSFS_BLOCK_SIZE - res, + res +=scnprintf (&buffer[res],PAGE_SIZE - res,"%-47s\n" , buf); }
@@ -1769,7 +1763,7 @@ static ssize_t scst_sess_latency_show(struct kobject *kobj, dev_time = sess->dev_time; processed_cmds = sess->processed_cmds; - res +=scnprintf (&buffer[res],SCST_SYSFS_BLOCK_SIZE - res, + res +=scnprintf (&buffer[res],PAGE_SIZE - res,"\n%-15s %-16d" ,"Overall " , processed_cmds);if (processed_cmds ==0 )
@@ -1781,7 +1775,7 @@ static ssize_t scst_sess_latency_show(struct kobject *kobj, (unsigned long )scst_time, (unsigned long )sess->max_scst_time, (unsigned long)sess->scst_time); - res +=scnprintf (&buffer[res],SCST_SYSFS_BLOCK_SIZE - res, + res +=scnprintf (&buffer[res],PAGE_SIZE - res,"%-47s" , buf);do_div (tgt_time, processed_cmds);
@@ -1790,7 +1784,7 @@ static ssize_t scst_sess_latency_show(struct kobject *kobj, (unsigned long )tgt_time, (unsigned long )sess->max_tgt_time, (unsigned long)sess->tgt_time); - res +=scnprintf (&buffer[res],SCST_SYSFS_BLOCK_SIZE - res, + res +=scnprintf (&buffer[res],PAGE_SIZE - res,"%-47s" , buf);do_div (dev_time, processed_cmds);
@@ -1799,7 +1793,7 @@ static ssize_t scst_sess_latency_show(struct kobject *kobj, (unsigned long )dev_time, (unsigned long )sess->max_dev_time, (unsigned long)sess->dev_time); - res +=scnprintf (&buffer[res],SCST_SYSFS_BLOCK_SIZE - res, + res +=scnprintf (&buffer[res],PAGE_SIZE - res,"%-47s\n\n" , buf);spin_unlock_bh (&sess->lat_lock);
@@ -1937,8 +1931,7 @@ static ssize_t scst_sess_sysfs_initiator_name_show(struct kobject *kobj, sess =scst_kobj_to_sess (kobj); -return scnprintf (buf,SCST_SYSFS_BLOCK_SIZE ,"%s\n" , - sess->initiator_name); +return scnprintf (buf,PAGE_SIZE ,"%s\n" , sess->initiator_name); } static struct kobj_attribute session_initiator_name_attr =
@@ -2588,8 +2581,7 @@ out:static ssize_t scst_acn_file_show (struct kobject *kobj,struct kobj_attribute *attr,char *buf) { -return scnprintf (buf,SCST_SYSFS_BLOCK_SIZE ,"%s\n" , - attr->attr.name); +return scnprintf (buf,PAGE_SIZE ,"%s\n" , attr->attr.name); }int scst_acn_sysfs_create (struct scst_acn *acn)
include/scst/scst_const.h +0 -2
@@ -379,8 +379,6 @@ enum scst_cdb_flags {/************************************************************* ** Misc constants *************************************************************/ -#define SCST_SYSFS_BLOCK_SIZE PAGE_SIZE -#define SCST_PR_DIR "/var/lib/scst/pr"#define TID_COMMON_SIZE 24
Signature · 1 line
1.7.1
PATCH 5/8 scst: Improve sysfs parsing robustness
In reply to Bart Van AsscheImprove the robustness of the code for parsing management commands received via the sysfs file /sys/devices/scst/mgmt. Allow several spaces between parameters where only a single space was allowed, and consistenly ignore trailing newlines.
--- drivers/scst/scst_sysfs.c | 85 ++++++++++++++++++++++++-------------------- 1 files changed, 46 insertions(+), 39 deletions(-)
drivers/scst/scst_sysfs.c +46 -39
@@ -937,20 +937,24 @@ out_free:static int scst_process_tgt_mgmt_store (char *cmd,struct scst_tgt *tgt) { +char *arg, *tail;int res; res = -EINVAL ; + arg = cmd; + cmd =scst_get_next_lexem (&arg); + tail = arg; +scst_get_next_lexem (&tail);if (strcmp (cmd,"enable" ) ==0 ) res =scst_process_tgt_enable_store (tgt, true);else if (strcmp (cmd,"disable" ) ==0 ) res =scst_process_tgt_enable_store (tgt, false); -else if (strncmp (cmd,"set_cpu_mask " ,13 ) ==0 ) { +else if (strcmp (cmd,"set_cpu_mask" ) ==0 ) {cpumask_t *cpumask;BUG_ON (!tgt->default_acg); - res =scst_alloc_and_parse_cpumask (&cpumask, cmd +13 , -strlen (cmd +13 )); + res =scst_alloc_and_parse_cpumask (&cpumask, arg,strlen (arg));if (res) goto out; res = __scst_acg_process_cpu_mask_store(tgt, tgt->default_acg,
@@ -1264,20 +1268,25 @@ static const struct device_attribute *scst_devt_dev_attrs[] = {static int scst_process_dev_mgmt_store (char *cmd,struct scst_device *dev) { +char *arg, *tail;int res; res = -EINVAL ; -if (strncmp (cmd,"set_filename " ,13 ) ==0 ) { + arg = cmd; + cmd =scst_get_next_lexem (&arg); + tail = arg; +scst_get_next_lexem (&tail); +if (strcmp (cmd,"set_filename" ) ==0 ) { res = -EPERM ;if (!dev->handler->set_filename) goto out; - res = dev->handler->set_filename (dev, cmd +13 ); - }else if (strncmp (cmd,"set_threads_num " ,16 ) ==0 ) { + res = dev->handler->set_filename (dev, arg); + }else if (strcmp (cmd,"set_threads_num" ) ==0 ) {long num_threads; - res =strict_strtol (cmd +16 ,0 , &num_threads); + res =strict_strtol (arg,0 , &num_threads);if (res) { -PRINT_ERROR ("Bad thread count %s" , cmd +16 ); +PRINT_ERROR ("Bad thread count %s" , arg); goto out; }if (num_threads <0 ) {
@@ -1285,13 +1294,12 @@ static int scst_process_dev_mgmt_store(char *cmd, struct scst_device *dev) goto out; } res =scst_dev_set_threads_num (dev, num_threads); - }else if (strncmp (cmd,"set_thread_pool_type " ,21 ) ==0 ) { + }else if (strcmp (cmd,"set_thread_pool_type" ) ==0 ) {enum scst_dev_type_threads_pool_type newtpt; - newtpt =scst_parse_threads_pool_type (cmd +21 , -strlen (cmd +21 )); + newtpt =scst_parse_threads_pool_type (arg,strlen (arg));if (newtpt ==SCST_THREADS_POOL_TYPE_INVALID ) { -PRINT_ERROR ("Invalid thread pool type %s" , cmd +21 ); +PRINT_ERROR ("Invalid thread pool type %s" , arg); goto out; } res =scst_dev_set_thread_pool_type (dev, newtpt);
@@ -2095,16 +2103,20 @@ out_del:** ini_groups directory implementation. **/ -static int scst_process_acg_mgmt_store (const char *cmd,struct scst_acg *acg) +static int scst_process_acg_mgmt_store (char *cmd,struct scst_acg *acg) { +char *arg, *tail;int res; res = -EINVAL ; -if (strncmp (cmd,"set_cpu_mask " ,13 ) ==0 ) { + arg = cmd; + cmd =scst_get_next_lexem (&arg); + tail = arg; +scst_get_next_lexem (&tail); +if (strcmp (cmd,"set_cpu_mask" ) ==0 ) {cpumask_t *cpumask; - res =scst_alloc_and_parse_cpumask (&cpumask, cmd +13 , -strlen (cmd +13 )); + res =scst_alloc_and_parse_cpumask (&cpumask, arg,strlen (arg));if (res) goto out; res =__scst_acg_process_cpu_mask_store (acg->tgt, acg, cpumask);
@@ -3390,7 +3402,7 @@ static ssize_t scst_mgmt_store(struct device *device, struct device_attribute *attr, const char *buf, size_t count) { ssize_t res; -char *buffer, *path, *path_end, *cmd; +char *buffer, *path, *cmd, *tail;enum mgmt_path_type mgmt_path_type;struct scst_dev_type *devt;struct scst_device *dev;
@@ -3409,19 +3421,13 @@ static ssize_t scst_mgmt_store(struct device *device, goto out; res = -EINVAL ; -if (strncmp (buffer,"in " ,3 ) !=0 ) + path = buffer; + cmd =scst_get_next_lexem (&path); +if (strcmp (cmd,"in" ) !=0 ) goto out; - path = buffer +3 ; -while (*path &&isspace ((u8)*path)) - path++; - path_end = path; -while (*path_end && !isspace ((u8)*path_end)) - path_end++; - *path_end++ ='\0' ; - cmd = path_end; -while (*cmd &&isspace ((u8)*cmd)) - cmd++; + tail = path; +scst_get_next_lexem (&tail); res =scst_suspend_activity (true);if (res)
@@ -3437,36 +3443,37 @@ static ssize_t scst_mgmt_store(struct device *device, res = -EINVAL ;switch (mgmt_path_type) {case DEVICE_PATH : - res =scst_process_dev_mgmt_store (cmd, dev); + res =scst_process_dev_mgmt_store (tail, dev);break ;case DEVICE_TYPE_PATH :if (devt->add_device) - res =scst_process_devt_mgmt_store (cmd, devt); + res =scst_process_devt_mgmt_store (tail, devt);else - res =scst_process_devt_pass_through_mgmt_store (cmd, + res =scst_process_devt_pass_through_mgmt_store (tail, devt);break ;case TARGET_TEMPLATE_PATH : - res =scst_process_tgtt_mgmt_store (cmd, tgtt); + res =scst_process_tgtt_mgmt_store (tail, tgtt);break ;case TARGET_PATH : - res =scst_process_tgt_mgmt_store (cmd, tgt); + res =scst_process_tgt_mgmt_store (tail, tgt);break ;case TARGET_LUNS_PATH : - res =__scst_process_luns_mgmt_store (cmd, tgt, tgt->default_acg, - true); + res =__scst_process_luns_mgmt_store (tail, tgt, + tgt->default_acg, true);break ;case TARGET_INI_GROUPS_PATH : - res =scst_process_ini_group_mgmt_store (cmd, tgt); + res =scst_process_ini_group_mgmt_store (tail, tgt);break ;case ACG_PATH : - res =scst_process_acg_mgmt_store (cmd, acg); + res =scst_process_acg_mgmt_store (tail, acg);break ;case ACG_LUNS_PATH : - res =__scst_process_luns_mgmt_store (cmd, acg->tgt, acg, false); + res =__scst_process_luns_mgmt_store (tail, acg->tgt, acg, + false);break ;case ACG_INITIATOR_GROUPS_PATH : - res =scst_process_acg_ini_mgmt_store (cmd, acg->tgt, acg); + res =scst_process_acg_ini_mgmt_store (tail, acg->tgt, acg);break ;case PATH_NOT_RECOGNIZED :break ;
Signature · 1 line
1.7.1
PATCH 6/8 scst: Fix online documentation
In reply to Bart Van AsscheFix an error in the online documentation of /sys/devices/scst/mgmt, reorder it and make that documentation more consistent.
--- drivers/scst/scst_sysfs.c | 37 +++++++++++++++++-------------------- 1 files changed, 17 insertions(+), 20 deletions(-)
drivers/scst/scst_sysfs.c +17 -20
@@ -3217,21 +3217,21 @@ static ssize_t scst_mgmt_show(struct device *device, {ssize_t count;static const char help[] = -/* device/<dev>/filename */ -"in device/<dev> <dev_cmd>\n" /* scst_devt_mgmt or scst_devt_pass_through_mgmt */ "in device_driver/<devt> <devt_cmd>\n" +/* device/<dev>/filename */ +"in device/<dev> <dev_cmd>\n" /* scst_tgtt_mgmt */ "in target_driver/<tgtt> <tgtt_cmd>\n" /* scst_tgt_mgmt */ -"in target_driver/<tgtt>/<target>/luns <tgt_cmd>\n" +"in target_driver/<tgtt>/<target> <tgt_cmd>\n" /* scst_luns_mgmt */ "in target_driver/<tgtt>/<target>/luns <luns_cmd>\n" /* scst_ini_group_mgmt */ "in target_driver/<tgtt>/<target>/ini_groups <acg_mgmt_cmd>\n" "in target_driver/<tgtt>/<target>/ini_groups/<acg> <acg_cmd>\n" /* scst_acg_luns_mgmt */ -"in target_driver/<tgtt>/<target>/ini_groups/<acg>/luns <luns_cmd>\n" +"in target_driver/<tgtt>/<target>/ini_groups/<acg>/luns <lun_cmd>\n" /* scst_acg_ini_mgmt */ "in target_driver/<tgtt>/<target>/ini_groups/<acg>/initiators <acg_ini_cmd>\n" "\n"
@@ -3243,12 +3243,12 @@ static ssize_t scst_mgmt_show(struct device *device,"\n" "devt_cmd syntax:\n" "\n" -"add_device device_name [parameters]\n" -"del_device device_name\n" +"add_device <device_name> [<parameters>]\n" +"del_device <device_name>\n" "add_attribute <attribute> <value>\n" "del_attribute <attribute> <value>\n" -"add_device_attribute device_name <attribute> <value>\n" -"del_device_attribute device_name <attribute> <value>\n" +"add_device_attribute <device_name> <attribute> <value>\n" +"del_device_attribute <device_name> <attribute> <value>\n" "\n" "devt_cmd syntax for pass-through device types:\n" "\n"
@@ -3257,12 +3257,9 @@ static ssize_t scst_mgmt_show(struct device *device,"\n" "tgtt_cmd syntax:\n" "\n" -"add_target target_name [parameters]\n" -"del_target target_name\n" -"add_attribute <attribute> <value>\n" -"del_attribute <attribute> <value>\n" -"add_target_attribute target_name <attribute> <value>\"\n" -"del_target_attribute target_name <attribute> <value>\"\n" +"add_target <target_name> [<parameters>]\n" +"del_target <target_name>\n" +"<target-driver-specific-command-and-parameters>\n" "\n" "where parameters is one or more <name>=<value> pairs separated by ';'\n" "\n"
@@ -3272,13 +3269,13 @@ static ssize_t scst_mgmt_show(struct device *device,"disable\n" "set_cpu_mask <mask>\n" "\n" -"luns_cmd syntax:\n" +"lun_cmd syntax:\n" "\n" -"add|del H:C:I:L lun [parameters]\n" -"add VNAME lun [parameters]\n" -"del lun\n" -"replace H:C:I:L lun [parameters]\n" -"replace VNAME lun [parameters]\n" +"add|del H:C:I:L <lun> [<parameters>]\n" +"add <vname> <lun> [<parameters>]\n" +"del <lun>\n" +"replace H:C:I:L <lun> [<parameters>]\n" +"replace <vname> <lun> [<parameters>]\n" "clear\n" "\n" "where parameters is either 'read_only' or empty.\n"
Signature · 1 line
1.7.1
PATCH 7/8 scst: Correct SCST core version number
In reply to Bart Van AsscheChange the version number of the SCST core from 2.1.0-pre1 into 2.0.0.
--- include/scst/scst.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
include/scst/scst.h +1 -1
@@ -48,7 +48,7 @@#define SCST_VERSION (a, b, c, d) (((a) << 24) + ((b) << 16) + ((c) << 8) + d)#define SCST_VERSION_CODE SCST_VERSION(2, 0, 0, 0)#define SCST_VERSION_STRING_SUFFIX -#define SCST_VERSION_STRING "2.1.0-pre1" SCST_VERSION_STRING_SUFFIX +#define SCST_VERSION_STRING "2.0.0" SCST_VERSION_STRING_SUFFIX#define SCST_INTERFACE_VERSION \ SCST_VERSION_STRING "$Revision: 3139 $" SCST_CONST_VERSION
Signature · 1 line
1.7.1
PATCH 8/8 Make SCST sysfs documentation more complete
In reply to Bart Van AsscheSince the previous time the SCST sysfs documentation has been posted, detailed documentation about /sys/devices/scst/mgmt has been added and the documentation of several sysfs attributes has been made more clear.
Note: this patch contains the entire SCST sysfs documentation since it has been generated as follows:
git diff origin/master..scst Documentation/ABI/stable
--- sysfs-devices-scst | 318 +++++++++++++++++++++++++++++++++++ sysfs-devices-scst_target | 226 ++++++++++++++++++++++++ sysfs-devices-scst_target-scst_local | 23 ++ sysfs-devices-scst_tgt_dev | 217 +++++++++++++++++++++++ sysfs-driver-scst_target | 55 ++++++ sysfs-driver-scst_target-scst_local | 20 ++ sysfs-driver-scst_tgt_dev | 51 +++++ 7 files changed, 910 insertions(+)
Documentation/ABI/stable/sysfs-devices-scst new file +318 -0
@@ -0,0 +1,318 @@ +What: /sys/devices/scst/mgmt +Date: December 2010 +Contact: Bart Van Assche <[email protected]> +Description: + Interface through which SCST management commands can be + issued. Read-write. Brief documentation of the syntax of these + commands can be obtained by reading this file (e.g. cat + /sys/devices/scst/mgmt). Detailed information is available + below. + +What: /sys/devices/scst/setup_id +Date: December 2010 +Contact: Bart Van Assche <[email protected]> +Description: + SCST setup ID. Allows to identify otherwise identical SCST + setups on different systems. As an example, the + vdisk device handler uses this to generate the T10 vendor + specific identifier ID and USN of virtual devices. Must be + set before any virtual devices are created. Read-write. + +What: /sys/devices/scst/sgv/global_stats +Date: December 2010 +Contact: Bart Van Assche <[email protected]> +Description: + Global SGV (scatter/gather vector) cache statistics. Read-only. + An example: + + $ cat sgv/global_stats + Inactive/active pages 0/0 + Hi/lo watermarks [pages] 62208/0 + Hi watermark releases/failures 0/0 + Other allocs 0 + +What: /sys/devices/scst/sgv/sgv/stats +Date: December 2010 +Contact: Bart Van Assche <[email protected]> +Description: + Statistics for the regular SGV cache. Read-only. + +What: /sys/devices/scst/sgv/sgv-clust/stats +Date: December 2010 +Contact: Bart Van Assche <[email protected]> +Description: + Statistics for the clustering SGV cache. Read-only. + +What: /sys/devices/scst/sgv/sgv-dma/stats +Date: December 2010 +Contact: Bart Van Assche <[email protected]> +Description: + Statistics for the DMA SGV cache. Read-only. + +What: /sys/devices/scst/threads +Date: December 2010 +Contact: Bart Van Assche <[email protected]> +Description: + Number of global I/O threads. The global I/O threads are used + by asynchronous device handlers or when explicitly configured + (i.e. when threads_num has been set to zero). Read-write. + +What: /sys/devices/scst/version +Date: December 2010 +Contact: Bart Van Assche <[email protected]> +Description: + SCST version number. Read-only. An example: + + $ cat /sys/devices/scst/version + 2.0.0 + +------------------------------------------------------------------------------- + + +Issuing management commands via /sys/devices/scst/mgmt + + +1 Device driver commands +======================== + +1.1 Managing virtual devices +---------------------------- + +The syntax for creating a virtual device is as follows: + +echo "in device_driver/<devt> add_device <device_name> [<parameters>]" \ + >/sys/devices/scst/mgmt + +where <devt> is the name of a virtual device handler and <parameters> is a +semicolon-separated list of <name>=<value> pairs. The supported parameters are +enumerated in the add_device_parameters file of each virtual device +driver. E.g. for vdisk_fileio the parameters supported at device creation time +are: + +$ cat /sys/bus/scst_tgt_dev/drivers/vdisk_fileio/add_device_parameters +filename +blocksize +write_through +nv_cache +o_direct +read_only +removable +thin_provisioned + +An example of how to create a vdisk_fileio device with NV-cache and thin +provisioning enabled: + +echo "in device_driver/vdisk_fileio add_device disk01 filename=/home/exported-storage;nv_cache=1;thin_provisioned=1" >/sys/devices/scst/mgmt + +Removing virtual devices is possible via the del_device command. An example: + +echo "in device_driver/vdisk_fileio del_device disk01" >/sys/devices/scst/mgmt + +The remaining commands (add_attribute, del_attribute, add_device_attribute and +del_device_attribute) allow to add or remove dynamically sysfs files for +virtual devices and their drivers. There are not yet any virtual devices or +virtual device drivers that allow this. + +1.2 Managing pass-through devices +--------------------------------- + +SCST supports SCSI pass-through. Before a LUN number can be assigned to a SCSI +device, a device handler has to be assigned via the add_device command: + +echo "in device_driver/<devt> add_device H:C:I:L" >/sys/devices/scst/mgmt + +The syntax for disabling SCSI passthrough is similar: + +echo "in device_driver/<devt> del_device H:C:I:L" >/sys/devices/scst/mgmt + +In the above <devt> is the name of a pass-through handler and H:C:I:L is a +quadruplet identifying a local SCSI device. An example: + +echo "in device_driver/dev_disk add_device 2:0:0:0" >/sys/devices/scst/mgmt +echo "in device_driver/dev_disk del_device 2:0:0:0" >/sys/devices/scst/mgmt + +A list with the names of all currently loaded virtual and pass-through drivers +can be obtained as follows: + +$ ls /sys/bus/scst_tgt_dev/drivers +dev_cdrom dev_disk_perf dev_processor dev_tape_perf vdisk_fileio +dev_changer dev_modisk dev_raid vcdrom vdisk_nullio +dev_disk dev_modisk_perf dev_tape vdisk_blockio + + +2 Device management commands +============================ + +The syntax of device management commands is as follows: + +echo "in device/<dev> <dev_cmd>" >/sys/devices/scst/mgmt + +where <dev> is a device name and <dev_cmd> is one of: + +set_filename <filename> +set_threads_num <n> +set_thread_pool_type <thread_pool_type> + +These commands are documented in +Documentation/ABI/stable/sysfs-devices-scst_tgt_dev. + + +3 Target driver commands +======================== + +3.1 Adding and removing targets +------------------------------- + +Adding and removing targets dynamically is possible with the add_target and +remove_target commands. This is supported by scst_local but not by ib_srpt. An +example for scst_local: + +# echo "in target_driver/scst_local add_target tgt2 session_name=tgt2_sess" >/sys/devices/scst/mgmt +# ls /sys/bus/scst_target/drivers/scst_local/tgt2/sessions +tgt2_sess +# echo "in target_driver/scst_local del_target tgt2" >/sys/devices/scst/mgmt +# ls /sys/bus/scst_target/drivers/scst_local/tgt2/sessions +ls: cannot access /sys/bus/scst_target/drivers/scst_local/tgt2/sessions: No such file or directory + +3.2 Driver-specific commands +---------------------------- + +Each driver can define additional commands. As an example, the scst_local +driver supports the add_session and del_session commands. See also the +driver-specific documentation for more information. + + +4 Target commands +================= + +The following target commands are supported via /sys/devices/scst/mgmt: +enable, disable and set_cpu_mask. These commands are documented in +Documentation/ABI/stable/sysfs-devices-scst_target. + + +5 Target LUN commands +===================== + +The syntax of the commands for managing the set of LUNs associated with a +target is as follows: + +in target_driver/<tgtt>/<target>/luns <lun_cmd> + +where lun_cmd is one of: + +add|del H:C:I:L <lun> [<parameters>] +add <vname> <lun> [<parameters>] +del <lun> +replace H:C:I:L <lun> [<parameters>] +replace <vname> <lun> [<parameters>] +clear + +and where <vname> is the name of a virtual device, <lun> is a LUN number and +<parameters> is a semicolon-separated list of parameters. Currently the only +supported parameter is the parameter called "read_only" (either 0 or 1). + +# echo "in target_driver/ib_srpt/ib_srpt_target_0/luns clear" >/sys/devices/scst/mgmt +# echo "in target_driver/ib_srpt/ib_srpt_target_0/luns add disk01 0" >/sys/devices/scst/mgmt +# readlink /sys/bus/scst_target/drivers/ib_srpt/ib_srpt_target_0/luns/0/device +../../../disk01 +# echo "in target_driver/ib_srpt/ib_srpt_target_0/luns replace disk02 0" >/sys/devices/scst/mgmt +# readlink /sys/bus/scst_target/drivers/ib_srpt/ib_srpt_target_0/luns/0/device +../../../disk02 + + +6 Access control group commands +=============================== + +6.1 Access control group creation and removal +--------------------------------------------- + +A list of zero or more access control groups (ACGs) can be associated with +each target. ACGs allow to define which initiator has access to which LUNs. +The syntax for creating and removing ACGs is: + +in target_driver/<tgtt>/<target>/ini_groups <acg_mgmt_cmd> + +where <acg_mgmt_cmd> is one of: + +create <group_name> +del <group_name> + +An example: + +# echo "in target_driver/ib_srpt/ib_srpt_target_0/ini_groups create group1" >/sys/devices/scst/mgmt +# ls /sys/bus/scst_target/drivers/ib_srpt/ib_srpt_target_0/ini_groups +group1 + +6.2 Access control group properties +----------------------------------- + +The access control group CPU mask can be modified via the set_cpu_mask +command. See also Documentation/ABI/stable/sysfs-devices-scst_target for more +information. + +6.3 Managing ACG LUNs +--------------------- + +The syntax of the commands for managing the LUNs associated with an ACG is as +follows: + +in target_driver/<tgtt>/<target>/ini_groups/<acg>/luns <lun_cmd> + +add|del H:C:I:L <lun> [<parameters>] +add <vname> <lun> [<parameters>] +del <lun> +replace H:C:I:L <lun> [<parameters>] +replace <vname> <lun> [<parameters>] +clear + +See also section 5 for more information about these commands. An example: + +# echo "in target_driver/ib_srpt/ib_srpt_target_0/ini_groups/group1/luns add disk01 0" >/sys/devices/scst/mgmt +# readlink /sys/bus/scst_target/drivers/ib_srpt/ib_srpt_target_0/ini_groups/group1/luns/0/device +../../../disk01 + +6.4 Associating initiators with an ACG +-------------------------------------- + +The syntax of the commands for manipulating the list of initiators associated +with an ACG is as follows: + +in target_driver/<tgtt>/<target>/ini_groups/<acg>/initiators <acg_ini_cmd> + +where <acg_ini_cmd> is one of: + +add <initiator_name> +del <initiator_name> +move <initiator_name> <dest_group_name> +clear + +These commands allow to add an initiator name to the initiator name list of an +ACG, remove an initiator name from that list, move an initatior name from one +ACG to another or to clear that initiator name list entirely. For the "add" +and "del" commands the initiator name may be a pattern instead of a literal +initator name. The following wildcard characters are supported: +- '*' matches any substring. +- '?' matches any character. +- '!' at the start of a pattern will cause the pattern to match with every + initiator name that does not match with the subsequent pattern. +As an example, the pattern "!abc*" will match with every initiator name that +does not start with the sequence "abc". + +Below one can find an example for the target driver ib_srpt. For the SRP +protocol initiator names are 128-bit hexadecimal numbers (a HCA port GUID). +Associating the ACG called "group1" with the two HCA ports with GUIDs $port1 +and $port2 is possible as follows: + +# port1="0x00000000000000000002c9030005f34b" +# port2="0x00000000000000000002c9030005f34c" +# echo "in target_driver/ib_srpt/ib_srpt_target_0/ini_groups/group1/initiators add $port1" >/sys/devices/scst/mgmt +# echo "in target_driver/ib_srpt/ib_srpt_target_0/ini_groups/group1/initiators add $port2" >/sys/devices/scst/mgmt +# ls /sys/bus/scst_target/drivers/ib_srpt/ib_srpt_target_0/ini_groups/group1/initiators +0x00000000000000000002c9030005f34b 0x00000000000000000002c9030005f34c + +The cumulative effect of the commands shown as examples in sections 6.1, 6.3 +and this section is that the initiator identified by GUID $ini1 and only that +initiator will see the LUNs defined in the ACG with name "group1". If no other +ACGs have been defined, all other initiators that log in to the same target +will see the LUNs associated with the target itself. Making a LUN available to +some hosts and not available to other hosts is also called LUN masking.
Documentation/ABI/stable/sysfs-devices-scst_target new file +226 -0
226 lines not on this page · raw message
Documentation/ABI/stable/sysfs-devices-scst_target-scst_local new file +23 -0
@@ -0,0 +1,23 @@ +What: /sys/bus/scst_target/devices/scst_local/phys_transport_version +Date: December 2010 +Contact: Richard Sharpe <[email protected]> +Description: + SCSI physical transport version. Defines which physical + interface scst_local will resemble. See also SPC-4 for more + information. Read-write. + +What: /sys/bus/scst_target/devices/scst_local/scsi_transport_version +Date: December 2010 +Contact: Richard Sharpe <[email protected]> +Description: + SCSI transport version. Defines which SCSI transport + scst_local will resemble. The default is SAS. See also SPC-4 + for more information. Read-write. + +What: /sys/bus/scst_target/devices/scst_local/sessions/*/transport_id +Date: December 2010 +Contact: Richard Sharpe <[email protected]> +Description: + SCSI transport ID in binary format. Necessary e.g. for + implementing persistent reservation support. See also SPC-4 + for more information. Read-write.
Documentation/ABI/stable/sysfs-devices-scst_tgt_dev new file +217 -0
217 lines not on this page · raw message
Documentation/ABI/stable/sysfs-driver-scst_target new file +55 -0
55 lines not on this page · raw message
Documentation/ABI/stable/sysfs-driver-scst_target-scst_local new file +20 -0
@@ -0,0 +1,20 @@ +What: /sys/bus/scst_target/drivers/scst_local/aborts +Date: December 2010 +Contact: Richard Sharpe <[email protected]> +Description: + Number of SCSI commands that have been aborted by the SCSI + initiator. Read-only. + +What: /sys/bus/scst_target/drivers/scst_local/device_resets +Date: December 2010 +Contact: Richard Sharpe <[email protected]> +Description: + Number of SCSI device resets that have been performed by the + SCSI initiator. Read-only. + +What: /sys/bus/scst_target/drivers/scst_local/target_resets +Date: December 2010 +Contact: Richard Sharpe <[email protected]> +Description: + Number of SCSI target resets that have been performed by the + SCSI initiator. Read-only.
Documentation/ABI/stable/sysfs-driver-scst_tgt_dev new file +51 -0
51 lines not on this page · raw message
Quoted 3 lines · On Monday 27 December 2010 14:35:33 Bart Van Assche wrote:
The paches in this patch series address the following issues:
- Make sure that all SCST sysfs attributes have only one value per file. [ ... ]
Note: someone was so kind to inform me (via private e-mail) that two more classes of sysfs files did not yet satisfy the one-value-per-file rule, namely the SGV cache statistics and the I/O latency statistics. The two patches below move these sysfs files to debugfs too:
[SCSI] scst: Move SGV cache statistics to debugfs
--- Documentation/ABI/stable/sysfs-devices-scst | 31 ----- drivers/scst/Makefile | 4 +- drivers/scst/scst_mem.c | 168 +++----------------------- drivers/scst/scst_mem.h | 22 ++++- drivers/scst/scst_mem_stats.c | 168 +++++++++++++++++++++++++++ drivers/scst/scst_mem_stats.h | 21 ++++ drivers/scst/scst_priv.h | 2 - drivers/scst/scst_sysfs.c | 9 -- drivers/scst/scst_tracing.c | 17 +++- 9 files changed, 246 insertions(+), 196 deletions(-) create mode 100644 drivers/scst/scst_mem_stats.c create mode 100644 drivers/scst/scst_mem_stats.h
Documentation/ABI/stable/sysfs-devices-scst +0 -31
@@ -18,37 +18,6 @@ Description: specific identifier ID and USN of virtual devices. Must be set before any virtual devices are created. Read-write. -What: /sys/devices/scst/sgv/global_stats -Date: December 2010 -Contact: Bart Van Assche <[email protected]> -Description: - Global SGV (scatter/gather vector) cache statistics. Read-only. - An example: - - $ cat sgv/global_stats - Inactive/active pages 0/0 - Hi/lo watermarks [pages] 62208/0 - Hi watermark releases/failures 0/0 - Other allocs 0 - -What: /sys/devices/scst/sgv/sgv/stats -Date: December 2010 -Contact: Bart Van Assche <[email protected]> -Description: - Statistics for the regular SGV cache. Read-only. - -What: /sys/devices/scst/sgv/sgv-clust/stats -Date: December 2010 -Contact: Bart Van Assche <[email protected]> -Description: - Statistics for the clustering SGV cache. Read-only. - -What: /sys/devices/scst/sgv/sgv-dma/stats -Date: December 2010 -Contact: Bart Van Assche <[email protected]> -Description: - Statistics for the DMA SGV cache. Read-only. - What: /sys/devices/scst/threads Date: December 2010 Contact: Bart Van Assche <[email protected]>
drivers/scst/Makefile +2 -2
@@ -7,7 +7,7 @@ scst-y += scst_lib.o scst-y += scst_sysfs.o scst-y += scst_mem.o scst-y += scst_debug.o -scst-$(CONFIG_SCST_DEBUG) += scst_tracing.o -scst-$(CONFIG_SCST_TRACING) += scst_tracing.o +scst-$(CONFIG_SCST_DEBUG) += scst_tracing.o scst_mem_stats.o +scst-$(CONFIG_SCST_TRACING) += scst_tracing.o scst_mem_stats.o obj-$(CONFIG_SCST) += scst.o dev_handlers/ scst_local/ srpt/
drivers/scst/scst_mem.c +20 -148
255 lines not on this page · raw message
drivers/scst/scst_mem.h +21 -1
@@ -122,7 +122,9 @@ struct sgv_pool {struct list_head sgv_pools_list_entry; -struct kobject sgv_kobj; +#if defined(CONFIG_SCST_DEBUG ) || defined(CONFIG_SCST_TRACING ) +struct dentry *debugfs_dir; +#endif };static inline struct scatterlist *sgv_pool_sg (struct sgv_pool_obj *obj)
@@ -136,3 +138,21 @@ void scst_sgv_pools_deinit(void);void scst_sgv_pool_use_norm (struct scst_tgt_dev *tgt_dev);void scst_sgv_pool_use_norm_clust (struct scst_tgt_dev *tgt_dev);void scst_sgv_pool_use_dma (struct scst_tgt_dev *tgt_dev); + +#if defined(CONFIG_SCST_DEBUG ) || defined(CONFIG_SCST_TRACING ) + +int scst_sgv_debugfs_create (struct dentry *parent); +void scst_sgv_debugfs_del (void ); + +#else /*defined(CONFIG_SCST_DEBUG) || defined(CONFIG_SCST_TRACING)*/ + +static inline int scst_sgv_debugfs_create (struct dentry *parent) +{ +return 0 ; +} + +static inline void scst_sgv_debugfs_del (void ) +{ +} + +#endif /*defined(CONFIG_SCST_DEBUG) || defined(CONFIG_SCST_TRACING)*/
drivers/scst/scst_mem_stats.c new file +168 -0
168 lines not on this page · raw message
drivers/scst/scst_mem_stats.h new file +21 -0
@@ -0,0 +1,21 @@ +#if defined(CONFIG_SCST_DEBUG ) || defined(CONFIG_SCST_TRACING ) + +int scst_sgv_pool_debugfs_create (struct sgv_pool *pool); +void scst_sgv_pool_debugfs_del (struct sgv_pool *pool); +ssize_t sgv_pool_stat_show (struct sgv_pool *pool,char *buf); +void sgv_pool_stat_reset (struct sgv_pool *pool); +ssize_t sgv_global_stat_show (char *buf); +void sgv_global_stat_reset (void ); + +#else /*defined(CONFIG_SCST_DEBUG) || defined(CONFIG_SCST_TRACING)*/ + +static inline int scst_sgv_pool_debugfs_create (struct sgv_pool *pool) +{ +return 0 ; +} + +static void scst_sgv_pool_debugfs_del (struct sgv_pool *pool) +{ +} + +#endif /*defined(CONFIG_SCST_DEBUG) || defined(CONFIG_SCST_TRACING)*/
drivers/scst/scst_priv.h +0 -2
@@ -376,8 +376,6 @@ void scst_tgt_sysfs_put(struct scst_tgt *tgt);int scst_sess_sysfs_create (struct scst_session *sess);void scst_sess_sysfs_del (struct scst_session *sess);int scst_recreate_sess_luns_link (struct scst_session *sess); -int scst_add_sgv_kobj (struct kobject *parent,const char *name); -void scst_del_put_sgv_kobj (void );int scst_devt_sysfs_init (struct scst_dev_type *devt);int scst_devt_sysfs_create (struct scst_dev_type *devt);void scst_devt_sysfs_del (struct scst_dev_type *devt);
drivers/scst/scst_sysfs.c +0 -9
@@ -3860,16 +3860,9 @@ int __init scst_sysfs_init(void) goto out_remove_files; } - res =scst_add_sgv_kobj (&scst_device->kobj,"sgv" ); -if (res) { -PRINT_ERROR ("%s" ,"Creation of SCST sgv kernel object failed." ); - goto out_remove_trace_files; - } - out:return res; -out_remove_trace_files:scst_main_remove_trace_files (); out_remove_files:device_remove_files (scst_device, scst_root_default_attrs);
@@ -3891,8 +3884,6 @@ void scst_sysfs_cleanup(void) {PRINT_INFO ("%s" ,"Exiting SCST sysfs hierarchy..." ); -scst_del_put_sgv_kobj (); -scst_main_remove_trace_files ();device_remove_files (scst_device, scst_root_default_attrs);
drivers/scst/scst_tracing.c +14 -3
@@ -18,6 +18,7 @@#include <linux/debugfs.h> #include <scst/scst.h> #include <scst/scst_debug.h> +#include "scst_mem.h" #include "scst_priv.h" #include "scst_pres.h" #include "scst_tracing.h"
@@ -230,31 +231,41 @@ int scst_debugfs_init(void) goto out; } + res =scst_sgv_debugfs_create (scst_debug_root); +if (res) { +PRINT_ERROR ("%s" ,"Creation of /sys/kernel/debug/scst/sgv" +" failed" ); + goto err; + } + scst_debug_target =debugfs_create_dir ("target" , scst_debug_root);if (!scst_debug_target) {PRINT_ERROR ("%s" ,"Creation of /sys/kernel/debug/scst/target" " failed" ); - goto out; + goto err; } scst_debug_devt =debugfs_create_dir ("device_type" , scst_debug_root);if (!scst_debug_devt) {PRINT_ERROR ("%s" ,"Creation of /sys/kernel/debug/scst/" "device_type failed" ); - goto out; + goto err; } scst_debug_dev =debugfs_create_dir ("device" , scst_debug_root);if (!scst_debug_dev) {PRINT_ERROR ("%s" ,"Creation of /sys/kernel/debug/scst/device" " failed" ); - goto out; + goto err; } res =0 ; out:return res; +err: +scst_debugfs_cleanup (); + goto out; }void scst_debugfs_cleanup (void )
Signature · 21 lines
1.7.1 [SCSI] scst: Move latency statistics to debugfs Signed-off-by: Bart Van Assche <[email protected]> --- Documentation/ABI/stable/sysfs-devices-scst_target | 16 - drivers/scst/Kconfig | 2 +- drivers/scst/Makefile | 1 + drivers/scst/scst_lat_stats.c | 435 ++++++++++++++++++++ drivers/scst/scst_lat_stats.h | 28 ++ drivers/scst/scst_sysfs.c | 371 ++--------------- drivers/scst/scst_tracing.c | 204 +++++++--- drivers/scst/scst_tracing.h | 57 ++- include/scst/scst.h | 21 + 9 files changed, 719 insertions(+), 416 deletions(-) create mode 100644 drivers/scst/scst_lat_stats.c create mode 100644 drivers/scst/scst_lat_stats.h
Documentation/ABI/stable/sysfs-devices-scst_target +0 -16
@@ -182,28 +182,12 @@ Description: Session name. For most target drivers this is a name that identifies the initiator. Read-only. -What: /sys/bus/scst_target/devices/*/sessions/<session>/latency -Date: December 2010 -Contact: Bart Van Assche <[email protected]> -Description: - Latency statistics for this session. Only available if - CONFIG_SCST_MEASURE_LATENCY has been enabled in the - kernel configuration. Read-only. - What: /sys/bus/scst_target/devices/*/sessions/<session>/lun<number>/active_commands Date: December 2010 Contact: Bart Van Assche <[email protected]> Description: Number of active commands. Read-only. -What: /sys/bus/scst_target/devices/*/sessions/<session>/lun<number>/latency -Date: December 2010 -Contact: Bart Van Assche <[email protected]> -Description: - Latency statistics for this LUN. Only available if - CONFIG_SCST_MEASURE_LATENCY has been enabled in the kernel - configuration. Read-only. - What: /sys/bus/scst_target/devices/*/sessions/<session>/luns Date: December 2010 Contact: Bart Van Assche <[email protected]>
drivers/scst/Kconfig +1 -1
@@ -228,7 +228,7 @@ config SCST_TM_DBG_GO_OFFLINE config SCST_MEASURE_LATENCY bool "Commands processing latency measurement facility" - depends on SCST + depends on SCST && (SCST_DEBUG || SCST_TRACING) help This option enables commands processing latency measurement facility in SCST. It will provide in the sysfs interface
drivers/scst/Makefile +1 -0
@@ -9,5 +9,6 @@ scst-y += scst_mem.o scst-y += scst_debug.o scst-$(CONFIG_SCST_DEBUG) += scst_tracing.o scst_mem_stats.o scst-$(CONFIG_SCST_TRACING) += scst_tracing.o scst_mem_stats.o +scst-$(CONFIG_SCST_MEASURE_LATENCY) += scst_lat_stats.o obj-$(CONFIG_SCST) += scst.o dev_handlers/ scst_local/ srpt/
drivers/scst/scst_lat_stats.c new file +435 -0
435 lines not on this page · raw message
drivers/scst/scst_lat_stats.h new file +28 -0
@@ -0,0 +1,28 @@ +#if defined(CONFIG_SCST_MEASURE_LATENCY ) + +int scst_tgt_dev_lat_create (struct scst_tgt_dev *tgt_dev); +void scst_tgt_dev_lat_remove (struct scst_tgt_dev *tgt_dev); +int scst_sess_lat_create (struct scst_session *sess); +void scst_sess_lat_remove (struct scst_session *sess); + +#else /*defined(CONFIG_SCST_MEASURE_LATENCY)*/ + +static inline int scst_tgt_dev_lat_create (struct scst_tgt_dev *tgt_dev) +{ +return 0 ; +} + +static inline void scst_tgt_dev_lat_remove (struct scst_tgt_dev *tgt_dev) +{ +} + +static inline int scst_sess_lat_create (struct scst_session *sess) +{ +return 0 ; +} + +static inline void scst_sess_lat_remove (struct scst_session *sess) +{ +} + +#endif /*defined(CONFIG_SCST_MEASURE_LATENCY)*/
drivers/scst/scst_sysfs.c +35 -336
479 lines not on this page · raw message
drivers/scst/scst_tracing.c +153 -51
272 lines not on this page · raw message
drivers/scst/scst_tracing.h +45 -12
87 lines not on this page · raw message
include/scst/scst.h +21 -0
@@ -1316,6 +1316,11 @@ struct scst_tgt {struct kobject *tgt_sess_kobj;/* target/sessions/ */ struct kobject *tgt_luns_kobj;/* target/luns/ */ struct kobject *tgt_ini_grp_kobj;/* target/ini_groups/ */ + +#if defined(CONFIG_SCST_DEBUG ) || defined(CONFIG_SCST_TRACING ) +struct dentry *debugfs_dir; +struct dentry *sessions_dir; +#endif };#ifdef CONFIG_SCST_MEASURE_LATENCY
@@ -1449,6 +1454,10 @@ struct scst_session { int result);void (*unreg_done_fn) (struct scst_session *sess); +#if defined(CONFIG_SCST_DEBUG ) || defined(CONFIG_SCST_TRACING ) +struct dentry *debugfs_dir; +struct dentry *luns_dir; +#endif #ifdef CONFIG_SCST_MEASURE_LATENCY /* * Must be the last to allow to work with drivers who don't know
@@ -1460,6 +1469,8 @@ struct scst_session {uint64_t min_scst_time, min_tgt_time, min_dev_time;uint64_t max_scst_time, max_tgt_time, max_dev_time;struct scst_ext_latency_stat sess_latency_stat[SCST_LATENCY_STATS_NUM ]; + +struct dentry *latency_file;#endif };
@@ -1813,6 +1824,9 @@ struct scst_cmd {struct scst_cmd *orig_cmd;/* Used to issue REQUEST SENSE */ +#if defined(CONFIG_SCST_DEBUG ) || defined(CONFIG_SCST_TRACING ) +struct dentry *debugfs_dir; +#endif #ifdef CONFIG_SCST_MEASURE_LATENCY /* * Must be the last to allow to work with drivers who don't know
@@ -1822,6 +1836,8 @@ struct scst_cmd {uint64_t restart_waiting_time, rdy_to_xfer_time;uint64_t pre_exec_time, exec_time, dev_done_time;uint64_t xmit_time, tgt_on_free_time, dev_on_free_time; + +struct dentry *latency_file;#endif };
@@ -2228,6 +2244,9 @@ struct scst_tgt_dev {struct kobject tgt_dev_kobj;/* kobject for this struct */ +#if defined(CONFIG_SCST_DEBUG ) || defined(CONFIG_SCST_TRACING ) +struct dentry *debugfs_dir; +#endif #ifdef CONFIG_SCST_MEASURE_LATENCY /* * Must be the last to allow to work with drivers who don't know
@@ -2238,6 +2257,8 @@ struct scst_tgt_dev {uint64_t scst_time, tgt_time, dev_time;unsigned int processed_cmds;struct scst_ext_latency_stat dev_latency_stat[SCST_LATENCY_STATS_NUM ]; + +struct dentry *latency_file;#endif };
Signature · 1 line
1.7.1