All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: fixup kernel warning during rmmod()
@ 2017-10-04  8:28 Hannes Reinecke
  2017-10-04  8:36 ` Johannes Thumshirn
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Hannes Reinecke @ 2017-10-04  8:28 UTC (permalink / raw)
  To: Martin K. Petersen
  Cc: Christoph Hellwig, James Bottomley, linux-scsi, Hannes Reinecke,
	Hannes Reinecke

Calling rmmod() on a FC driver will results in warnings like

WARNING: CPU: 60 PID: 14640 at fs/sysfs/group.c:237 device_del+0x54/0x240()
sysfs group ffffffff81eff140 not found for kobject '3:0:0:3'

The problem here is that during scsi_remove_target() we will iterate
over all devices, but fail to remove any of those as the call to
scsi_device_get() fails the check to module_is_live().
Hence the devices will not be removed at this point, but all
intermediate structures like fc rport etc. will be.
Later on during scsi_forget_host() the devices are removed for
real, but the device parent is already removed and causes
this warning.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/scsi/scsi_sysfs.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 1889761..995539f 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -1336,13 +1336,19 @@ static void __scsi_remove_target(struct scsi_target *starget)
 	spin_lock_irqsave(shost->host_lock, flags);
  restart:
 	list_for_each_entry(sdev, &shost->__devices, siblings) {
+		/*
+		 * We cannot call scsi_device_get() here, as
+		 * we might've been called from rmmod() causing
+		 * scsi_device_get() to fail the module_is_live()
+		 * check.
+		 */
 		if (sdev->channel != starget->channel ||
 		    sdev->id != starget->id ||
-		    scsi_device_get(sdev))
+		    !get_device(&sdev->sdev_gendev))
 			continue;
 		spin_unlock_irqrestore(shost->host_lock, flags);
 		scsi_remove_device(sdev);
-		scsi_device_put(sdev);
+		put_device(&sdev->sdev_gendev);
 		spin_lock_irqsave(shost->host_lock, flags);
 		goto restart;
 	}
-- 
1.8.5.6

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] scsi: fixup kernel warning during rmmod()
  2017-10-04  8:28 [PATCH] scsi: fixup kernel warning during rmmod() Hannes Reinecke
@ 2017-10-04  8:36 ` Johannes Thumshirn
  2017-10-04 14:30 ` Kyle Fortin
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Johannes Thumshirn @ 2017-10-04  8:36 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Martin K. Petersen, Christoph Hellwig, James Bottomley,
	linux-scsi, Hannes Reinecke

Looks good,
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
-- 
Johannes Thumshirn                                          Storage
jthumshirn@suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] scsi: fixup kernel warning during rmmod()
  2017-10-04  8:28 [PATCH] scsi: fixup kernel warning during rmmod() Hannes Reinecke
  2017-10-04  8:36 ` Johannes Thumshirn
@ 2017-10-04 14:30 ` Kyle Fortin
  2017-10-05 15:29 ` Don Brace
  2017-10-06 18:49 ` Martin K. Petersen
  3 siblings, 0 replies; 5+ messages in thread
From: Kyle Fortin @ 2017-10-04 14:30 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Martin K. Petersen, Christoph Hellwig, James Bottomley,
	linux-scsi, Hannes Reinecke

> On Oct 4, 2017, at 4:28 AM, Hannes Reinecke <hare@suse.de> wrote:
> 
> Signed-off-by: Hannes Reinecke <hare@suse.com>

Looks good to me.

Reviewed-by: Kyle Fortin <kyle.fortin@oracle.com>

--
Kyle Fortin - Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH] scsi: fixup kernel warning during rmmod()
  2017-10-04  8:28 [PATCH] scsi: fixup kernel warning during rmmod() Hannes Reinecke
  2017-10-04  8:36 ` Johannes Thumshirn
  2017-10-04 14:30 ` Kyle Fortin
@ 2017-10-05 15:29 ` Don Brace
  2017-10-06 18:49 ` Martin K. Petersen
  3 siblings, 0 replies; 5+ messages in thread
From: Don Brace @ 2017-10-05 15:29 UTC (permalink / raw)
  To: Hannes Reinecke, Martin K. Petersen
  Cc: Christoph Hellwig, James Bottomley, linux-scsi, Hannes Reinecke

> -----Original Message-----
> From: linux-scsi-owner@vger.kernel.org [mailto:linux-scsi-
> owner@vger.kernel.org] On Behalf Of Hannes Reinecke
> Sent: Wednesday, October 04, 2017 3:29 AM
> To: Martin K. Petersen <martin.petersen@oracle.com>
> Cc: Christoph Hellwig <hch@lst.de>; James Bottomley
> <james.bottomley@hansenpartnership.com>; linux-scsi@vger.kernel.org;
> Hannes Reinecke <hare@suse.de>; Hannes Reinecke <hare@suse.com>
> Subject: [PATCH] scsi: fixup kernel warning during rmmod()
> 
> EXTERNAL EMAIL
> 
> 
> Calling rmmod() on a FC driver will results in warnings like
> 
> WARNING: CPU: 60 PID: 14640 at fs/sysfs/group.c:237
> device_del+0x54/0x240()
> sysfs group ffffffff81eff140 not found for kobject '3:0:0:3'
> 
> The problem here is that during scsi_remove_target() we will iterate
> over all devices, but fail to remove any of those as the call to
> scsi_device_get() fails the check to module_is_live().
> Hence the devices will not be removed at this point, but all
> intermediate structures like fc rport etc. will be.
> Later on during scsi_forget_host() the devices are removed for
> real, but the device parent is already removed and causes
> this warning.
> 
> Signed-off-by: Hannes Reinecke <hare@suse.com>
Tested-by: Don Brace <don.brace@microsemi.com> 
Using the smartpqi driver.
Thanks for your effort.

Thanks,
Don Brace
ESC - Smart Storage
Microsemi Corporation


> ---
>  drivers/scsi/scsi_sysfs.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
> index 1889761..995539f 100644
> --- a/drivers/scsi/scsi_sysfs.c
> +++ b/drivers/scsi/scsi_sysfs.c
> @@ -1336,13 +1336,19 @@ static void __scsi_remove_target(struct
> scsi_target *starget)
>         spin_lock_irqsave(shost->host_lock, flags);
>   restart:
>         list_for_each_entry(sdev, &shost->__devices, siblings) {
> +               /*
> +                * We cannot call scsi_device_get() here, as
> +                * we might've been called from rmmod() causing
> +                * scsi_device_get() to fail the module_is_live()
> +                * check.
> +                */
>                 if (sdev->channel != starget->channel ||
>                     sdev->id != starget->id ||
> -                   scsi_device_get(sdev))
> +                   !get_device(&sdev->sdev_gendev))
>                         continue;
>                 spin_unlock_irqrestore(shost->host_lock, flags);
>                 scsi_remove_device(sdev);
> -               scsi_device_put(sdev);
> +               put_device(&sdev->sdev_gendev);
>                 spin_lock_irqsave(shost->host_lock, flags);
>                 goto restart;
>         }
> --
> 1.8.5.6

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] scsi: fixup kernel warning during rmmod()
  2017-10-04  8:28 [PATCH] scsi: fixup kernel warning during rmmod() Hannes Reinecke
                   ` (2 preceding siblings ...)
  2017-10-05 15:29 ` Don Brace
@ 2017-10-06 18:49 ` Martin K. Petersen
  3 siblings, 0 replies; 5+ messages in thread
From: Martin K. Petersen @ 2017-10-06 18:49 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Martin K. Petersen, Christoph Hellwig, James Bottomley,
	linux-scsi, Hannes Reinecke


Hannes,

> Calling rmmod() on a FC driver will results in warnings like

Applied to 4.14/scsi-fixes. Thank you!

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-10-06 18:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-04  8:28 [PATCH] scsi: fixup kernel warning during rmmod() Hannes Reinecke
2017-10-04  8:36 ` Johannes Thumshirn
2017-10-04 14:30 ` Kyle Fortin
2017-10-05 15:29 ` Don Brace
2017-10-06 18:49 ` Martin K. Petersen

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.