Re: [PATCH] tcm_loop: Show address of tpg in configfs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Sheng,

Apologies for the delayed response.  Comments below.

On Thu, 2015-10-22 at 11:28 -0700, Sheng Yang wrote:
> 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'.
> 
> Signed-off-by: Sheng Yang <sheng@xxxxxxxxxx>
> ---
>  drivers/target/loopback/tcm_loop.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c
> index 5bc85ff..a38ddd6 100644
> --- a/drivers/target/loopback/tcm_loop.c
> +++ b/drivers/target/loopback/tcm_loop.c
> @@ -1046,9 +1046,26 @@ static ssize_t tcm_loop_tpg_store_transport_status(
>  
>  TF_TPG_BASE_ATTR(tcm_loop, transport_status, S_IRUGO | S_IWUSR);
>  
> +static ssize_t tcm_loop_tpg_show_address(
> +	struct se_portal_group *se_tpg,
> +	char *page)
> +{
> +	struct tcm_loop_tpg *tl_tpg = container_of(se_tpg,
> +			struct tcm_loop_tpg, tl_se_tpg);
> +	struct tcm_loop_hba *tl_hba = tl_tpg->tl_hba;
> +	ssize_t ret = -EINVAL;
> +
> +	ret = snprintf(page, PAGE_SIZE, "%d:0:%d\n",
> +			tl_hba->sh->host_no, tl_tpg->tl_tpgt);
> +	return ret;
> +}
> +
> +TF_TPG_BASE_ATTR_RO(tcm_loop, address);
> +
>  static struct configfs_attribute *tcm_loop_tpg_attrs[] = {
>  	&tcm_loop_tpg_nexus.attr,
>  	&tcm_loop_tpg_transport_status.attr,
> +	&tcm_loop_tpg_address.attr,
>  	NULL,
>  };
>  

So the way configfs attributes has changed in v4.4-rc0 code.

I've updated your original patch to use the new macros, and applied it
to target-pending/queue-next as v4.5-rc1 material here.

https://git.kernel.org/cgit/linux/kernel/git/nab/target-pending.git/commit/?h=queue-next&id=25ca46858b9d9ea233cbebcbcf72274e1b6a6ecd

--nab

--
To unsubscribe from this list: send the line "unsubscribe target-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux SCSI]     [Kernel Newbies]     [Linux SCSI Target Infrastructure]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Device Mapper]

  Powered by Linux