Re: [PATCH v2 1/2] libsas: Don't process sas events in static works

From: Johannes Thumshirn
Date: Wed Jun 14 2017 - 04:51:36 EST


On 06/14/2017 09:33 AM, Yijing Wang wrote:
> Now libsas hotplug work is static, LLDD driver queue
> the hotplug work into shost->work_q. If LLDD driver
> burst post lots hotplug events to libsas, the hotplug
> events may pending in the workqueue like
>
> shost->work_q
> new work[PORTE_BYTES_DMAED] --> |[PHYE_LOSS_OF_SIGNAL][PORTE_BYTES_DMAED] -> processing
> |<-------wait worker to process-------->|
> In this case, a new PORTE_BYTES_DMAED event coming, libsas try to queue it
> to shost->work_q, but this work is already pending, so it would be lost.
> Finally, libsas delete the related sas port and sas devices, but LLDD driver
> expect libsas add the sas port and devices(last sas event).
>
> This patch remove the static defined hotplug work, and use dynamic work to
> avoid missing hotplug events.
>
> Signed-off-by: Yijing Wang <wangyijing@xxxxxxxxxx>
> Signed-off-by: Yousong He <heyousong@xxxxxxxxxx>
> Signed-off-by: Qilin Chen <chenqilin2@xxxxxxxxxx>
> ---

[...]

> static void notify_ha_event(struct sas_ha_struct *sas_ha, enum ha_event event)
> {
> + struct sas_ha_event *ev;
> +
> BUG_ON(event >= HA_NUM_EVENTS);
>
> - sas_queue_event(event, &sas_ha->pending,
> - &sas_ha->ha_events[event].work, sas_ha);
> + ev = kzalloc(sizeof(*ev), GFP_ATOMIC);
> + if (!ev)
> + return;
GFP_ATOMIC allocations can fail and then no events will be queued *and* we
don't report the error back to the caller.



> index 64e9cdd..c227a8b 100644
> --- a/drivers/scsi/libsas/sas_init.c
> +++ b/drivers/scsi/libsas/sas_init.c
> @@ -111,10 +111,6 @@ void sas_hash_addr(u8 *hashed, const u8 *sas_addr)
>
> void sas_hae_reset(struct work_struct *work)
> {
> - struct sas_ha_event *ev = to_sas_ha_event(work);
> - struct sas_ha_struct *ha = ev->ha;
> -
> - clear_bit(HAE_RESET, &ha->pending);
> }

I don't really get why you need a stubbed out sas_hae_reset(). Can't we
just kill it if it doesn't have anything left to do?


--
Johannes Thumshirn Storage
jthumshirn@xxxxxxx +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