Re: [PATCH] bsg referencing bus driver module

From: Anatoliy Glagolev
Date: Fri Apr 20 2018 - 18:44:15 EST

> This patch isn't applyable because your mailer has changed all the tabs
> to spaces.
> I also think there's no need to do it this way. I think what we need
> is for fc_bsg_remove() to wait until the bsg queue is drained. It does
> look like the author thought this happened otherwise the code wouldn't
> have the note. If we fix it that way we can do the same thing in all
> the other transport classes that use bsg (which all have a similar
> issue).
> James

Thanks, James. Sorry about the tabs; re-sending.

On fc_bsg_remove()...: are you suggesting to implement the whole fix
in scsi_transport_fc.c? That would be nice, but I do not see how that
is possible. Even with the queue drained bsg still holds a reference
to the Scsi_Host via bsg_class_device; bsg_class_device itself is
referenced on bsg_open and kept around while a user-mode process keeps
a handle to bsg.
Even if we somehow implement the waiting the call may be stuck
forever if the user-mode process keeps the handle.
I think handling it via a rererence to the module is more consistent
with the way things are done in Linux. You suggested the approach
youself back in "Waiting for scsi_host_template release" discussion.