diff options
author | Sheng Yang <sheng@yasker.org> | 2015-11-14 17:17:16 -0500 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2015-11-29 06:01:45 -0500 |
commit | 2628b352c3d4905adf8129ea50900bd980b6ccef (patch) | |
tree | 632ad805862f0b022c668ed5d0192eb4a0e37a58 | |
parent | 1ec218373b8ebda821aec00bb156a9c94fad9cd4 (diff) |
tcm_loop: Show address of tpg in configfs
In the past, the scsi_host's number wasn't shown anywhere, user have
to depends on vpg_83 to find the block device, which is also depends
on backstore implementation.
It's better for tcm_loop to provide necessary straightforward
information on locate the block device it created.
This patch would help to locate the block device created by tcm_loop.
The address would be shown at e.g.
/sys/kernel/config/target/loopback/naa.60014059436855c1/tpgt_1/address
which would looks like "2:0:1", and the lun number can be found at
"/tpgt_1/lun/lun_0". Altogether they formated the scsi address of
device as "2:0:1:0", which can be used to locate the device easily
through 'lsscsi'.
(Update to >= v4.4-rc1 configfs attribute usage - nab)
Signed-off-by: Sheng Yang <sheng@yasker.org>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
-rw-r--r-- | drivers/target/loopback/tcm_loop.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c index 4fb0eca86857..d41a5c300e31 100644 --- a/drivers/target/loopback/tcm_loop.c +++ b/drivers/target/loopback/tcm_loop.c | |||
@@ -1036,12 +1036,26 @@ static ssize_t tcm_loop_tpg_transport_status_store(struct config_item *item, | |||
1036 | return -EINVAL; | 1036 | return -EINVAL; |
1037 | } | 1037 | } |
1038 | 1038 | ||
1039 | static ssize_t tcm_loop_tpg_address_show(struct config_item *item, | ||
1040 | char *page) | ||
1041 | { | ||
1042 | struct se_portal_group *se_tpg = to_tpg(item); | ||
1043 | struct tcm_loop_tpg *tl_tpg = container_of(se_tpg, | ||
1044 | struct tcm_loop_tpg, tl_se_tpg); | ||
1045 | struct tcm_loop_hba *tl_hba = tl_tpg->tl_hba; | ||
1046 | |||
1047 | return snprintf(page, PAGE_SIZE, "%d:0:%d\n", | ||
1048 | tl_hba->sh->host_no, tl_tpg->tl_tpgt); | ||
1049 | } | ||
1050 | |||
1039 | CONFIGFS_ATTR(tcm_loop_tpg_, nexus); | 1051 | CONFIGFS_ATTR(tcm_loop_tpg_, nexus); |
1040 | CONFIGFS_ATTR(tcm_loop_tpg_, transport_status); | 1052 | CONFIGFS_ATTR(tcm_loop_tpg_, transport_status); |
1053 | CONFIGFS_ATTR_RO(tcm_loop_tpg_, address); | ||
1041 | 1054 | ||
1042 | static struct configfs_attribute *tcm_loop_tpg_attrs[] = { | 1055 | static struct configfs_attribute *tcm_loop_tpg_attrs[] = { |
1043 | &tcm_loop_tpg_attr_nexus, | 1056 | &tcm_loop_tpg_attr_nexus, |
1044 | &tcm_loop_tpg_attr_transport_status, | 1057 | &tcm_loop_tpg_attr_transport_status, |
1058 | &tcm_loop_tpg_attr_address, | ||
1045 | NULL, | 1059 | NULL, |
1046 | }; | 1060 | }; |
1047 | 1061 | ||