target-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: Bodo Stroesser <bstroesser@ts.fujitsu.com>,
	Mike Christie <mchristi@redhat.com>,
	martin.petersen@oracle.com, linux-scsi@vger.kernel.org,
	target-devel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: Re: [PATCH 12/15] target: add sysfs session helper functions
Date: Mon, 11 May 2020 19:21:59 +0000	[thread overview]
Message-ID: <a3686299-8fab-3cf7-0641-5e7c98a7292d@acm.org> (raw)
In-Reply-To: <66e9bbf8-fdb2-d819-a496-75a1dea779cf@ts.fujitsu.com>

On 2020-05-11 11:39, Bodo Stroesser wrote:
> On 05/10/20 23:57, Mike Christie wrote:
>> This patch adds helpers to add/remove a dir per session. There is only 2
>> files/dirs initially.
>>
> 
> ...
> 
>> +
>> +int target_sysfs_add_session(struct se_portal_group *se_tpg,
>> +                 struct se_session *se_sess)
>> +{
>> +    int ret;
>> +
>> +    /*
>> +     * Copy ACL name so we don't have to worry about mixing configfs
>> +     * and sysfs refcounts.
>> +     */
>> +    if (!se_sess->se_node_acl->dynamic_node_acl) {
>> +        se_sess->acl_name = kstrdup(se_sess->se_node_acl->initiatorname,
>> +                        GFP_KERNEL);
>> +        if (!se_sess->acl_name)
>> +            return -ENOMEM;
>> +    }
>> +
>> +    ret = kobject_add(&se_sess->kobj, se_tpg->sessions_kobj, "%s-%d",
>> +              se_sess->tpt_id->name, se_sess->sid);
>> +    if (ret) {
>> +        pr_err("Could not add session%d to sysfs. Error %d.\n",
>> +               se_sess->sid, ret);
>> +        goto free_acl_name;
>> +    }
>> +
>> +    ret = add_transport_id_attrs(se_sess);
>> +    if (ret)
>> +        goto del_kobj;
>> +
>> +    if (se_sess->tfo->session_attrs) {
>> +        ret = sysfs_create_group(&se_sess->kobj,
>> +                     se_sess->tfo->session_attrs);
>> +        if (ret)
>> +            goto rm_tpt_id_grps;
>> +    }
>> +
>> +    ret = sysfs_create_link(tcm_core_sessions_kobj, &se_sess->kobj,
>> +                se_sess->kobj.name);
> 
> I would prefer to have links named "session-%d" or "%d" only, of course
> with se_sess->sid as the value for '%d'.

Isn't se_sess->sid a property that is filled in by the iSCSI target
driver only? Is se_sess->sid zero for all other target drivers than the
iSCSI target driver?

> If userspace knows the session-id only, such names make it easier to
> find the corresponding link.

Personally I prefer the %s-%d naming scheme. I think that naming scheme
has the following advantages:
1. No need to run cat ... to retrieve the initiator name.
2. It becomes possible to derive from the 'ls' output which initiators
created multiple sessions.
3. All sessions created by the same initiator appear consecutively.

Thanks,

Bart.

  reply	other threads:[~2020-05-11 19:21 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-10 21:57 [PATCH v5 00/15] target: add sysfs support Mike Christie
2020-05-10 21:57 ` [PATCH 01/15] target: check enforce_pr_isids during registration Mike Christie
2020-05-11  6:08   ` Hannes Reinecke
2020-05-13 20:55   ` Lee Duncan
2020-05-10 21:57 ` [PATCH 02/15] target: separate acl name from port ids Mike Christie
2020-05-11  6:09   ` Hannes Reinecke
2020-05-13 23:35   ` Lee Duncan
2020-05-10 21:57 ` [PATCH 03/15] target: add helper to parse acl and transport name Mike Christie
2020-05-11  6:09   ` Hannes Reinecke
2020-05-11 18:22   ` Bodo Stroesser
2020-05-11 21:04     ` Mike Christie
2020-05-13 23:57   ` Lee Duncan
2020-05-10 21:57 ` [PATCH 04/15] tcm loop: use target_parse_emulated_name Mike Christie
2020-05-11  6:10   ` Hannes Reinecke
2020-05-13 23:59   ` Lee Duncan
2020-05-10 21:57 ` [PATCH 05/15] vhost scsi: " Mike Christie
2020-05-11  6:11   ` Hannes Reinecke
2020-05-10 21:57 ` [PATCH 06/15] xen scsiback: " Mike Christie
2020-05-11  6:11   ` Hannes Reinecke
2020-05-11  6:16   ` Jürgen Groß
2020-05-10 21:57 ` [PATCH 07/15] iscsi target: setup transport_id Mike Christie
2020-05-11  6:12   ` Hannes Reinecke
2020-05-10 21:57 ` [PATCH 08/15] target: use tpt_id in target_stat_iport_port_ident_show Mike Christie
2020-05-11  6:13   ` Hannes Reinecke
2020-05-10 21:57 ` [PATCH 09/15] target: drop sess_get_initiator_sid from PR code Mike Christie
2020-05-11  6:13   ` Hannes Reinecke
2020-05-10 21:57 ` [PATCH 10/15] target: drop sess_get_initiator_sid Mike Christie
2020-05-11  6:14   ` Hannes Reinecke
2020-05-10 21:57 ` [PATCH 11/15] target: add sysfs support Mike Christie
2020-05-11  6:21   ` Hannes Reinecke
2020-05-11  6:30   ` Greg Kroah-Hartman
2020-05-11 17:15     ` Mike Christie
2020-05-12  5:54       ` Greg Kroah-Hartman
2020-05-10 21:57 ` [PATCH 12/15] target: add sysfs session helper functions Mike Christie
2020-05-11 18:39   ` Bodo Stroesser
2020-05-11 19:21     ` Bart Van Assche [this message]
2020-05-11 20:16       ` Mike Christie
2020-05-12 11:19         ` Bodo Stroesser
2020-05-12 15:55           ` Mike Christie
2020-05-10 21:57 ` [PATCH 13/15] target: add target_setup_session sysfs support Mike Christie
2020-05-10 21:57 ` [PATCH 14/15] iscsi target: use session sysfs helpers Mike Christie
2020-05-10 21:57 ` [PATCH 15/15] target: drop sess_get_index Mike Christie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a3686299-8fab-3cf7-0641-5e7c98a7292d@acm.org \
    --to=bvanassche@acm.org \
    --cc=bstroesser@ts.fujitsu.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=mchristi@redhat.com \
    --cc=target-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).