From owner-freebsd-hackers Sun Aug 3 14:24:04 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id OAA18652 for hackers-outgoing; Sun, 3 Aug 1997 14:24:04 -0700 (PDT) Received: from phaeton.artisoft.com (phaeton.Artisoft.COM [198.17.250.50]) by hub.freebsd.org (8.8.5/8.8.5) with SMTP id OAA18633 for ; Sun, 3 Aug 1997 14:24:01 -0700 (PDT) Received: (from terry@localhost) by phaeton.artisoft.com (8.6.11/8.6.9) id OAA02311; Sun, 3 Aug 1997 14:21:47 -0700 From: Terry Lambert Message-Id: <199708032121.OAA02311@phaeton.artisoft.com> Subject: Re: Too many open files in System! To: jkh@time.cdrom.com (Jordan K. Hubbard) Date: Sun, 3 Aug 1997 14:21:47 -0700 (MST) Cc: fbsdlist@federation.addy.com, edmond@shaman.lycaeum.org, hackers@FreeBSD.ORG In-Reply-To: <3101.870636403@time.cdrom.com> from "Jordan K. Hubbard" at Aug 3, 97 12:26:43 pm X-Mailer: ELM [version 2.4 PL24] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk > You simply need to implement file swapping. Keep a cache of file > descriptors you've opened and implement a simple LRU algorithm to > close those which haven't been used for awhile - in your code which > handles the failure cases for reads/writes, you then add an extra bit > of glue to handle the failure case (e.g. the handle was closed) which > jumps back to the cache code and asks that the file be reopened again > (you'll also need to save the current file position before you close > files, of course, so that you can seek back to where you left off when > you "reinstate" a cache entry). Easy. Except that you can't maintain file locks across an LRU this way, so if you have file locks, you get screwed when they are deasserted at close time. Unfortunately, maintaining the lock list in user space is not a real option either, since your close lets someone else lock something you believe you have locked. Then your application goes to do something with a range it believes it has locked, your open succeeds, but the file lock can not be reasserted transparently (ie: the reassertion must block). Even if your application is expecting to potentially block on an operation where you don't really expect a long time blocking to take place, you are still screwed, since if someone came in, locked, modified, and unlocked, then your application data cache is potentially stale, and you have no notification. Not to mention O_EXCL and whole-file locks. 8-). > (please realize that the above is a parody answer in response to an > intentional goad to get SOMEONE to realize that we don't rise to such > bait :-) Heh. That's OK; my response was parody, too. 8-). Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers.