linux-next.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Benjamin Block <bblock@linux.ibm.com>
To: Steffen Maier <maier@linux.ibm.com>, bvanassche@acm.org
Cc: jwi@linux.ibm.com, martin.petersen@oracle.com,
	jejb@linux.ibm.com, linux-scsi@vger.kernel.org,
	gregkh@linuxfoundation.org, linux-next@vger.kernel.org,
	linux-s390@vger.kernel.org
Subject: Re: [PATCH v3] scsi: core: Fix early registration of sysfs attributes for scsi_device
Date: Tue, 26 Oct 2021 12:00:31 +0200	[thread overview]
Message-ID: <YXfRvxKu/xXVubF8@t480-pf1aa2c2.linux.ibm.com> (raw)
In-Reply-To: <20211026014240.4098365-1-maier@linux.ibm.com>

On Tue, Oct 26, 2021 at 03:42:40AM +0200, Steffen Maier wrote:
> v4.17 commit 86b87cde0b55 ("scsi: core: host template attribute groups")
> introduced explicit sysfs_create_groups() in scsi_sysfs_add_sdev()
> and sysfs_remove_groups() in __scsi_remove_device(), both for sdev_gendev,
> based on a new field const struct attribute_group **sdev_groups
> of struct scsi_host_template.
> 
> Commit 92c4b58b15c5 ("scsi: core: Register sysfs attributes earlier")
> removed above explicit (de)registration of scsi_device attribute groups.
> It also converted all scsi_device attributes and attribute_groups to
> end up in a new field const struct attribute_group *gendev_attr_groups[6]
> of struct scsi_device. However, that new field was not used anywhere.

Oh.. damn, I didn't notice either.

> 
> Surprisingly, this only caused missing LLDD specific scsi_device sysfs
> attributes. Whereas, scsi core attributes from scsi_sdev_attr_groups
> did continue to exist because of scsi_dev_type.groups.

Hmm, maybe this is out of scope for this fix, but couldn't we
essentially do the same thing for the host attributes. Have the
`shost_class` take the `scsi_shost_attr_group` as default attributes for
the shost class, and then assign the `shost_groups` from the LLDD
template to `shost_dev.groups` as optional attributes? 

Then we get rid of the indirection loop in `hosts.c` as well, that was
introduce with he original patch by Bart.

Just a shot in the dark, I don't know whether the `struct class` behaves
the same in this case as `struct device_type`.

> 
> We separate scsi core attibutes from LLDD specific attributes.
> Hence, we keep the initializing assignment scsi_dev_type =
> { .groups = scsi_sdev_attr_groups, } as this takes care of core
> attributes. Without the separation, it would cause attribute double
> registration due to scsi_dev_type.groups and sdev_gendev.groups.
> 
> Julian suggested to assign the sdev_groups pointer of the
> scsi_host_template directly to the groups pointer of sdev_gendev.
> This way we can delete the container scsi_device.gendev_attr_groups
> and the loop copying each entry from hostt->sdev_groups to
> sdev->gendev_attr_groups.
> 
> Alternative approaches ruled out:
> Assigning gendev_attr_groups to sdev_dev has no visible effect.
> Assigning sdev->gendev_attr_groups to scsi_dev_type.groups
> caused scsi_device of all scsi host types to get LLDD specific
> attributes of the LLDD for which the last sdev alloc happened to occur,
> as that overwrote scsi_dev_type.groups,
> e.g. scsi_debug had zfcp-specific scsi_device attributes.
> 
> Signed-off-by: Steffen Maier <maier@linux.ibm.com>
> Fixes: 92c4b58b15c5 ("scsi: core: Register sysfs attributes earlier")
> Suggested-by: Julian Wiedmann <jwi@linux.ibm.com>

-- 
Best Regards, Benjamin Block  / Linux on IBM Z Kernel Development / IBM Systems
IBM Deutschland Research & Development GmbH    /    https://www.ibm.com/privacy
Vorsitz. AufsR.: Gregor Pillen         /        Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen / Registergericht: AmtsG Stuttgart, HRB 243294

  reply	other threads:[~2021-10-26 10:01 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20211012233558.4066756-1-bvanassche@acm.org>
     [not found] ` <163478764102.7011.9375895285870786953.b4-ty@oracle.com>
2021-10-23 20:54   ` Missing driver-specific sysfs attributes of scsi_device [was: Re: [PATCH v4 00/46] Register SCSI sysfs attributes earlier] Steffen Maier
2021-10-24  0:39     ` Steffen Maier
2021-10-24  2:55       ` Bart Van Assche
2021-10-24 11:18       ` [PATCH] scsi: core: Fix early registration of sysfs attributes for scsi_device Steffen Maier
2021-10-24 21:25         ` Bart Van Assche
2021-10-24 22:16           ` [PATCH v2] " Steffen Maier
2021-10-25  9:23             ` Julian Wiedmann
2021-10-25 16:00               ` Bart Van Assche
2021-10-26  1:42               ` [PATCH v3] " Steffen Maier
2021-10-26 10:00                 ` Benjamin Block [this message]
2021-10-26 21:48                   ` Bart Van Assche
2021-10-29 17:55                     ` Benjamin Block
2021-10-26 18:31                 ` Bart Van Assche
2021-10-29 17:56                 ` Benjamin Block

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=YXfRvxKu/xXVubF8@t480-pf1aa2c2.linux.ibm.com \
    --to=bblock@linux.ibm.com \
    --cc=bvanassche@acm.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jejb@linux.ibm.com \
    --cc=jwi@linux.ibm.com \
    --cc=linux-next@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=maier@linux.ibm.com \
    --cc=martin.petersen@oracle.com \
    /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).