Re: Does linux locks swap file?

Andrew Walker (andy@lysaker.kvaerner.no)
Thu, 30 Jan 1997 08:57:45 +0100 (MET)


Ion Badulescu wrote:
>
>
> On 30 Jan 1997, H. Peter Anvin wrote:
>
> > That's definitely a bug. IMNSHO a swapon() should be treated the same
> > way as an open() from this standpoint.
>
> It's not a bug, swapon() does increment the inode usage counter of the
> swapfile.

So the file sticks around until the last time its closed, even though
no directory entry points to it. That's fine and dandy - that's the way
it should be, but if its true then how come somebody claimed that removing
the swap file crashed the system :-(

> > It may also be a good idea
> > (although I don't know about this one, really) to record a lock on all
> > bytes in the file.
>
> It might be. Although, if it's just an advisory lock... it's kind of
> useless.

A mandatory lock would be pretty useless too if we're talking about
deleting the swap file. The mandatory lock will stop other processes
from opening the file and scribbling in our swap space, but will do
nothing to guard against deletion.

-Andy

-- 
Andy Walker                              Kvaerner Engineering a.s.
Andrew.Walker@lysaker.kvaerner.no        P.O. Box 222, N-1324 Lysaker, Norway

......if the answer isn't violence, neither is your silence......

(pwei barmy army - oslo "filial")