From owner-freebsd-hackers Sat Dec 8 4:16:16 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from pintail.mail.pas.earthlink.net (pintail.mail.pas.earthlink.net [207.217.120.122]) by hub.freebsd.org (Postfix) with ESMTP id 983D037B416 for ; Sat, 8 Dec 2001 04:16:13 -0800 (PST) Received: from pool0029.cvx22-bradley.dialup.earthlink.net ([209.179.198.29] helo=mindspring.com) by pintail.mail.pas.earthlink.net with esmtp (Exim 3.33 #1) id 16CgOl-00047Y-00; Sat, 08 Dec 2001 04:16:07 -0800 Message-ID: <3C12048E.9DB7EB7D@mindspring.com> Date: Sat, 08 Dec 2001 04:16:14 -0800 From: Terry Lambert X-Mailer: Mozilla 4.7 [en]C-CCK-MCD {Sony} (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: Poul-Henning Kamp Cc: Dave Rufino , Alfred Perlstein , freebsd-hackers@FreeBSD.ORG Subject: Re: statefulness in character device drivers References: <47779.1007808692@critter.freebsd.dk> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Poul-Henning Kamp wrote: > >> The issue is non-trivial to fix because we currently don't pass > >> dup(2) events through the vnode layer. > > > >Are you sure this is even necessary? > > > >They are talking about "per-open", not "per-fd-instance" data, > >which could easily exclude dup, dup2, and fcntl(f_DUPFD). > > If you don't include dup/dup2/fnctl in your accounting, you > can only reliably tell "first open", "another open", "some close" > and "final close". You an modulate this with the pid, but you > still have no idea what is going on in any amount of detail. My point was not that you would not do reference counting, but that you would have unique information in only the open(2) case (as you point out, these other cases don't call down to the vnode). So if I open(2) and then dup(2), I have only one per-open instance with a reference count of 2, but if I then open(2) again, I get a second open instance, so I have a total open instance of 2, with reference counts of 2 and 1, respectively. If I close one of the first instances (either the result of the open or the dup), then my reference count goes to 1, and then if I close the second (the remaining one, the result of the dup or the open), then when the reference count goes from 1 to 0, I destroy the per instance data. There is actually a good argument for doing things this way, since it permits particular instances to be passed to other programs, whereas if each dup/dup2/F_DUPFD resulted in a new instance, you wouldn't be able to pass the instance to another program (since it, effectively, dup's the fd). -- Terry To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message