Re: [PATCH] Add kerneldoc for flush_scheduled_work()

Alan Stern
2009-08-12T20:41:01Z

On Wed, 12 Aug 2009, James Bottomley wrote:

> > I'll accept that. However it means that the SCSI midlayer violates
> > your own locking rules with regard to the scan mutex. Whereas if
> > flush_scheduled_work() were avoided, the locking rules would not be
> > violated.
>
> Why do you think I've been trying to get rid of it? Global mutexes
> covering large swathes of code are always a bad idea. The async code
> already picked up a deadlock entanglement with it.

And yet it does serve an important purpose.

An alternative to that mutex would be to make all scanning and removal
activities on a host funnel through a single thread. Do you think that
would be preferable? (I'm not trying to be sarcastic -- this is a
serious question.)

> > The rules for submission are _not_ the same. With
> > flush_scheduled_work():
> >
> > Make sure that any lock you hold while flushing is private
> > and is not used (even indirectly) by any of your publicly
> > exported routines.
> >
> > With cancel_work_sync():
> >
> > Make sure that any lock you hold while cancelling is not
> > used (even indirectly) by the work routine being cancelled.
>
> The hair splitting has got to the point where I don't really care. The
> point is that flush_scheduled_work() and cancel_work_sync() have similar
> problems. Amazingly that was my original point.

And my original point was that the problems, though similar in nature,
are harder to deal with in one case than in the other.

Alan Stern