On Fri, Aug 6, 2010 at 9:22 PM, Greg KH <gregkh@suse.de> wrote:
I have been looking at the proposed change to the TTY locking here.
The conversion of the BKL into a real non-preemptable lock for the TTY
layer has had an interesting semantic change on racing open/closes on
the same TTY. Prior to the changes we would:
- grab the BLK and tty_mutex
- mark the device TTY_CLOSING
- drop the tty_mutex
- call device shutdown
- prevent the device from being found
- drop the BKL
The use of the BLK to cover the device shutdown has an interesting
effect. Where the shutdown processing is simple the lock is
maintained and the whole processing is atomic with respect to racing
opens and closes, such that an open would never see TTY_CLOSING. For
any shutdown processing which resulted in a sleep then the BKL would
be implicitly dropped and reaquired allowing any racing opens to
continue and triggering an open failure errno=EIO, something POSIX at
least hints at as reasonable. As shutdown can include hardware
interactions this seems like appropriate behaviour, and cirtinly the
git log documents this as expected and desirable semantics.
With the new locking the BTM is held in place of the BKL, which
effectivly means throughout open and close processing, which
effectively means _all_ TTY open/closes are serialised throughout
regardless of the length of the shutdown processing. The EIO appears
to be no longer returnable.
Is this change in semantics expected? If not, it is likely something
which could be addressed separately after merging, as long as we are
aware.
-apw
--