All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Bart Van Assche <bvanassche@acm.org>
Cc: "Martin K . Petersen" <martin.petersen@oracle.com>,
	linux-scsi@vger.kernel.org, Christoph Hellwig <hch@lst.de>,
	Hannes Reinecke <hare@suse.com>,
	Damien Le Moal <damien.lemoal@opensource.wdc.com>,
	Doug Ledford <dledford@redhat.com>,
	Jason Gunthorpe <jgg@ziepe.ca>,
	Sathya Prakash <sathya.prakash@broadcom.com>,
	Sreekanth Reddy <sreekanth.reddy@broadcom.com>,
	Suganath Prabu Subramani  <suganath-prabu.subramani@broadcom.com>,
	Steffen Maier <maier@linux.ibm.com>,
	Benjamin Block <bblock@linux.ibm.com>,
	Heiko Carstens <hca@linux.ibm.com>,
	Vasily Gorbik <gor@linux.ibm.com>,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	Adam Radford <aradford@gmail.com>,
	"James E.J. Bottomley" <jejb@linux.ibm.com>,
	Adaptec OEM Raid Solutions <aacraid@microsemi.com>,
	Subbu Seetharaman <subbu.seetharaman@broadcom.com>,
	Ketan Mukadam <ketan.mukadam@broadcom.com>,
	Jitendra Bhivare <jitendra.bhivare@broadcom.com>,
	Anil Gurumurthy <anil.gurumurthy@qlogic.com>,
	Sudarsana Kalluru <sudarsana.kalluru@qlogic.com>,
	Saurav Kashyap <skashyap@marvell.com>,
	Javed Hasan <jhasan@marvell.com>,
	GR-QLogic-Storage-Upstream@marvell.com,
	Nilesh Javali <njavali@marvell.com>,
	Manish Rangankar <mrangankar@marvell.com>,
	"Manoj N. Kumar" <manoj@linux.ibm.com>,
	"Matthew R. Ochs" <mrochs@linux.ibm.com>,
	Uma Krishnan <ukrishn@linux.ibm.com>,
	Satish Kharat <satishkh@cisco.com>,
	Sesidhar Baddela <sebaddel@cisco.com>,
	Karan Tilak Kumar <kartilak@cisco.com>,
	John Garry <john.garry@huawei.com>,
	Don Brace <don.brace@microchip.com>,
	HighPoint Linux Team <linux@highpoint-tech.com>,
	Tyrel Datwyler <tyreld@linux.ibm.com>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Brian King <brking@us.ibm.com>,
	Artur Paszkiewicz <artur.paszkiewicz@intel.com>,
	James Smart <james.smart@broadcom.com>,
	Dick Kennedy <dick.kennedy@broadcom.com>,
	Kashyap Desai <kashyap.desai@broadcom.com>,
	Sumit Saxena <sumit.saxena@broadcom.com>,
	Shivasharan S <shivasharan.srikanteshwara@broadcom.com>,
	Hannes Reinecke <hare@kernel.org>,
	Jack Wang <jinpu.wang@cloud.ionos.com>,
	ching Huang <ching2048@areca.com.tw>,
	Jiapeng Chong <jiapeng.chong@linux.alibaba.com>,
	Yufen Yu <yuyufen@huawei.com>,
	Zhen Lei <thunder.leizhen@huawei.com>
Subject: Re: [PATCH 1/2] scsi: Register SCSI host sysfs attributes earlier
Date: Sat, 25 Sep 2021 11:02:14 +0200	[thread overview]
Message-ID: <YU7llg2wj555lte8@kroah.com> (raw)
In-Reply-To: <20210924232635.1637763-2-bvanassche@acm.org>

On Fri, Sep 24, 2021 at 04:26:34PM -0700, Bart Van Assche wrote:
> A quote from Documentation/driver-api/driver-model/device.rst:
> "Word of warning:  While the kernel allows device_create_file() and
> device_remove_file() to be called on a device at any time, userspace has
> strict expectations on when attributes get created.  When a new device is
> registered in the kernel, a uevent is generated to notify userspace (like
> udev) that a new device is available.  If attributes are added after the
> device is registered, then userspace won't get notified and userspace will
> not know about the new attributes."
> 
> Hence register SCSI host sysfs attributes before the SCSI host shost_dev
> uevent is emitted instead of after that event has been emitted.
> 
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>

Nice work, this is good to see.

Tiny comments below:

> diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
> index 3f6f14f0cafb..f424aca6dc6e 100644
> --- a/drivers/scsi/hosts.c
> +++ b/drivers/scsi/hosts.c
> @@ -480,7 +480,15 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
>  	shost->shost_dev.parent = &shost->shost_gendev;
>  	shost->shost_dev.class = &shost_class;
>  	dev_set_name(&shost->shost_dev, "host%d", shost->host_no);
> -	shost->shost_dev.groups = scsi_sysfs_shost_attr_groups;
> +	shost->shost_dev.groups = shost->shost_dev_attr_groups;
> +	shost->shost_dev_attr_groups[0] = &scsi_host_attr_group;
> +	if (shost->hostt->shost_attrs) {
> +		shost->shost_dev_attr_groups[1] =
> +			&shost->shost_driver_attr_group;
> +		shost->shost_driver_attr_group = (struct attribute_group){
> +			.attrs = shost->hostt->shost_attrs,
> +		};

Did you just allocate this off the stack?  What happens when the
function returns and the stack data is returned?

> --- a/include/scsi/scsi_host.h
> +++ b/include/scsi/scsi_host.h
> @@ -476,7 +476,7 @@ struct scsi_host_template {
>  	/*
>  	 * Pointer to the sysfs class properties for this host, NULL terminated.
>  	 */
> -	struct device_attribute **shost_attrs;
> +	struct attribute **shost_attrs;

Why isn't this "struct attribute_group **groups"?

>  
>  	/*
>  	 * Pointer to the SCSI device properties for this host, NULL terminated.
> @@ -695,6 +695,8 @@ struct Scsi_Host {
>  
>  	/* ldm bits */
>  	struct device		shost_gendev, shost_dev;
> +	struct attribute_group  shost_driver_attr_group;
> +	const struct attribute_group *shost_dev_attr_groups[3];

Why just 3?

thanks,

greg k-h

  reply	other threads:[~2021-09-25  9:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-24 23:26 [PATCH 0/2] Register SCSI sysfs attributes earlier Bart Van Assche
2021-09-24 23:26 ` [PATCH 1/2] scsi: Register SCSI host " Bart Van Assche
2021-09-25  9:02   ` Greg Kroah-Hartman [this message]
2021-09-27 17:35     ` Bart Van Assche
2021-09-24 23:26 ` [PATCH 2/2] scsi: Register SCSI device " Bart Van Assche
2021-09-25  9:03   ` Greg Kroah-Hartman
2021-09-27 17:37     ` Bart Van Assche
2021-09-28  4:48       ` Greg Kroah-Hartman

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=YU7llg2wj555lte8@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=GR-QLogic-Storage-Upstream@marvell.com \
    --cc=aacraid@microsemi.com \
    --cc=anil.gurumurthy@qlogic.com \
    --cc=aradford@gmail.com \
    --cc=artur.paszkiewicz@intel.com \
    --cc=bblock@linux.ibm.com \
    --cc=borntraeger@de.ibm.com \
    --cc=brking@us.ibm.com \
    --cc=bvanassche@acm.org \
    --cc=ching2048@areca.com.tw \
    --cc=damien.lemoal@opensource.wdc.com \
    --cc=dick.kennedy@broadcom.com \
    --cc=dledford@redhat.com \
    --cc=don.brace@microchip.com \
    --cc=gor@linux.ibm.com \
    --cc=hare@kernel.org \
    --cc=hare@suse.com \
    --cc=hca@linux.ibm.com \
    --cc=hch@lst.de \
    --cc=james.smart@broadcom.com \
    --cc=jejb@linux.ibm.com \
    --cc=jgg@ziepe.ca \
    --cc=jhasan@marvell.com \
    --cc=jiapeng.chong@linux.alibaba.com \
    --cc=jinpu.wang@cloud.ionos.com \
    --cc=jitendra.bhivare@broadcom.com \
    --cc=john.garry@huawei.com \
    --cc=kartilak@cisco.com \
    --cc=kashyap.desai@broadcom.com \
    --cc=ketan.mukadam@broadcom.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linux@highpoint-tech.com \
    --cc=maier@linux.ibm.com \
    --cc=manoj@linux.ibm.com \
    --cc=martin.petersen@oracle.com \
    --cc=mpe@ellerman.id.au \
    --cc=mrangankar@marvell.com \
    --cc=mrochs@linux.ibm.com \
    --cc=njavali@marvell.com \
    --cc=sathya.prakash@broadcom.com \
    --cc=satishkh@cisco.com \
    --cc=sebaddel@cisco.com \
    --cc=shivasharan.srikanteshwara@broadcom.com \
    --cc=skashyap@marvell.com \
    --cc=sreekanth.reddy@broadcom.com \
    --cc=subbu.seetharaman@broadcom.com \
    --cc=sudarsana.kalluru@qlogic.com \
    --cc=suganath-prabu.subramani@broadcom.com \
    --cc=sumit.saxena@broadcom.com \
    --cc=thunder.leizhen@huawei.com \
    --cc=tyreld@linux.ibm.com \
    --cc=ukrishn@linux.ibm.com \
    --cc=yuyufen@huawei.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.