tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Locking strategy for device deletion (also see PR kern/48536)



    Date:        Wed, 8 Jun 2016 22:16:28 +0800 (PHT)
    From:        Paul Goyette <paul%whooppee.com@localhost>
    Message-ID:  <Pine.NEB.4.64.1606082214090.1631%pokey.whooppee.com@localhost>

  | Hmmm.  Would it be valid, then, for my close() routine to reset the 
  | ref-count to zero rather than simply decrementing?

Do you really need a reference count for anything?   Wasn't that just
a way of determining whether anything had the device open?

This is why device drivers have just an open flag in their private state
(when they care enough to have even that.)

  | Does the close() only get called if there are _NO_ outstanding open()s
  | for _any_ process?

Processes, yes, processes are irrelevant at this level.   There was once
(long ago) an issue when multiple inodes (vnodes now) referenced the same
device, the close would get called when the vnode ref count went to 0
(not caring that another might still be referencing the device.)   I hope
that bug has been long fixed...  (if not, it should be.)

But close routines can do stuff like resetting the hardware, rewinding a tape,
dropping DTR to a modem, ...   so there are plenty of reasons to make sure
that the close is only called when it really should be.

kre




Home | Main Index | Thread Index | Old Index