From: <vl...@us...> - 2014-10-17 02:35:08
|
Revision: 5851 http://sourceforge.net/p/scst/svn/5851 Author: vlnb Date: 2014-10-17 02:35:01 +0000 (Fri, 17 Oct 2014) Log Message: ----------- scst, iscsi-scst: Add thread_pid attribute For SCST devices with a short name determining which SCST command threads serve a given LUN requires an (expensive) walk of the process table. For SCST devices with a long name it is not possible to determine unambiguously which command threads serve a given LUN. Hence add a thread_pid sysfs attribute that makes it easy to figure out which command threads serve a LUN. Signed-off-by: Bart Van Assche <bva...@ac...> Modified Paths: -------------- trunk/iscsi-scst/README trunk/iscsi-scst/kernel/session.c trunk/scst/README trunk/scst/README_in-tree trunk/scst/src/scst_sysfs.c Modified: trunk/iscsi-scst/README =================================================================== --- trunk/iscsi-scst/README 2014-10-17 02:32:28 UTC (rev 5850) +++ trunk/iscsi-scst/README 2014-10-17 02:35:01 UTC (rev 5851) @@ -332,9 +332,14 @@ - tid - TID of this target. -Subdirectory "sessions" contains one subdirectory for each connected -session with name equal to name of the connected initiator. +The "sessions" subdirectory contains the following attribute: + - thread_pid - the process identifiers (PIDs) of the iscsird and iscsiwr + threads that process SCSI commands associated with this session. + +Additionally, the "sessions" subdirectory contains one subdirectory for each +connected session with name equal to name of the connected initiator. + Each session subdirectory contains the following entries: - One subdirectory for each TCP connection in this session. ISCSI-SCST Modified: trunk/iscsi-scst/kernel/session.c =================================================================== --- trunk/iscsi-scst/kernel/session.c 2014-10-17 02:32:28 UTC (rev 5850) +++ trunk/iscsi-scst/kernel/session.c 2014-10-17 02:35:01 UTC (rev 5851) @@ -560,6 +560,37 @@ static struct kobj_attribute iscsi_sess_attr_reinstating = __ATTR(reinstating, S_IRUGO, iscsi_sess_reinstating_show, NULL); +static ssize_t iscsi_sess_thread_pid_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + struct scst_session *scst_sess = container_of(kobj, struct scst_session, + sess_kobj); + struct iscsi_session *sess = scst_sess_get_tgt_priv(scst_sess); + struct iscsi_thread_pool *thr_pool = sess->sess_thr_pool; + struct iscsi_thread *t; + int res = -ENOENT; + + if (!thr_pool) + goto out; + + res = 0; + + mutex_lock(&thr_pool->tp_mutex); + list_for_each_entry(t, &thr_pool->threads_list, threads_list_entry) + res += scnprintf(buf + res, PAGE_SIZE - res, "%d%s", + task_pid_vnr(t->thr), + list_is_last(&t->threads_list_entry, + &thr_pool->threads_list) ? + "\n" : " "); + mutex_unlock(&thr_pool->tp_mutex); + +out: + return res; +} + +static struct kobj_attribute iscsi_sess_thread_pid = + __ATTR(thread_pid, S_IRUGO, iscsi_sess_thread_pid_show, NULL); + const struct attribute *iscsi_sess_attrs[] = { &iscsi_sess_attr_initial_r2t.attr, &iscsi_sess_attr_immediate_data.attr, @@ -572,6 +603,7 @@ &iscsi_sess_attr_data_digest.attr, &iscsi_attr_sess_sid.attr, &iscsi_sess_attr_reinstating.attr, + &iscsi_sess_thread_pid.attr, NULL, }; Modified: trunk/scst/README =================================================================== --- trunk/scst/README 2014-10-17 02:32:28 UTC (rev 5850) +++ trunk/scst/README 2014-10-17 02:35:01 UTC (rev 5851) @@ -695,7 +695,11 @@ - active_commands - contains number of active, i.e. not yet or being executed, SCSI commands for lun<X> in session <sess>. + - thread_pid - contains a single line with all the process identifiers + (PIDs) of the kernel threads that process SCSI commands intended for + lun<X> in session <sess>. + Access and devices visibility management (LUN masking) ------------------------------------------------------ Modified: trunk/scst/README_in-tree =================================================================== --- trunk/scst/README_in-tree 2014-10-17 02:32:28 UTC (rev 5850) +++ trunk/scst/README_in-tree 2014-10-17 02:35:01 UTC (rev 5851) @@ -557,7 +557,11 @@ - active_commands - contains number of active, i.e. not yet or being executed, SCSI commands for lun<X> in session <sess>. + - thread_pid - contains a single line with all the process identifiers + (PIDs) of the kernel threads that process SCSI commands intended for + lun<X> in session <sess>. + Access and devices visibility management (LUN masking) ------------------------------------------------------ Modified: trunk/scst/src/scst_sysfs.c =================================================================== --- trunk/scst/src/scst_sysfs.c 2014-10-17 02:32:28 UTC (rev 5850) +++ trunk/scst/src/scst_sysfs.c 2014-10-17 02:35:01 UTC (rev 5851) @@ -3506,6 +3506,31 @@ #endif /* CONFIG_SCST_MEASURE_LATENCY */ +static ssize_t scst_tgt_dev_thread_pid_show(struct kobject *kobj, + struct kobj_attribute *attr, + char *buffer) +{ + struct scst_tgt_dev *tgt_dev = + container_of(kobj, struct scst_tgt_dev, tgt_dev_kobj); + struct scst_cmd_threads *cmd_threads = tgt_dev->active_cmd_threads; + struct scst_cmd_thread_t *t; + int res = 0; + + spin_lock(&cmd_threads->thr_lock); + list_for_each_entry(t, &cmd_threads->threads_list, thread_list_entry) + res += scnprintf(buffer + res, PAGE_SIZE - res, "%d%s", + task_pid_vnr(t->cmd_thread), + list_is_last(&t->thread_list_entry, + &cmd_threads->threads_list) ? + "\n" : " "); + spin_unlock(&cmd_threads->thr_lock); + + return res; +} + +static struct kobj_attribute tgt_dev_thread_pid_attr = + __ATTR(thread_pid, S_IRUGO, scst_tgt_dev_thread_pid_show, NULL); + static ssize_t scst_tgt_dev_active_commands_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { @@ -3524,6 +3549,7 @@ scst_tgt_dev_active_commands_show, NULL); static struct attribute *scst_tgt_dev_attrs[] = { + &tgt_dev_thread_pid_attr.attr, &tgt_dev_active_commands_attr.attr, #ifdef CONFIG_SCST_MEASURE_LATENCY &tgt_dev_latency_attr.attr, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |