2000-12-09 21:55:52

by Pavel Machek

[permalink] [raw]
Subject: swapoff weird

Hi!

It is possible to remove swapfile in use. Great, but how do you swap
off then? Who is to blame?

root@bug:~# swapoff /tmp/swap
swapoff: /tmp/swap: No such file or directory
root@bug:~# > /tmp/swap
root@bug:~# swapoff /tmp/swap
swapoff: /tmp/swap: Invalid argument
root@bug:~#

How do I get out of this bad situation?
Pavel


2000-12-09 22:12:53

by Rik van Riel

[permalink] [raw]
Subject: Re: swapoff weird

On Sat, 9 Dec 2000, Pavel Machek wrote:

> It is possible to remove swapfile in use. Great, but how do you
> swap off then? Who is to blame?

As usual, root is to blame ;)

> root@bug:~# swapoff /tmp/swap
> swapoff: /tmp/swap: No such file or directory
> root@bug:~# > /tmp/swap
> root@bug:~# swapoff /tmp/swap
> swapoff: /tmp/swap: Invalid argument
> root@bug:~#

Don't let your automatic /tmp cleaners remove the swap
file ;)

> How do I get out of this bad situation?

Reboot.

cheers,

Rik
--
Hollywood goes for world dumbination,
Trailer at 11.

http://www.surriel.com/
http://www.conectiva.com/ http://distro.conectiva.com.br/

2000-12-09 22:35:38

by Pavel Machek

[permalink] [raw]
Subject: Re: swapoff weird

> On Sat, 9 Dec 2000, Pavel Machek wrote:
>
> > It is possible to remove swapfile in use. Great, but how do you
> > swap off then? Who is to blame?
>
> As usual, root is to blame ;)

I do not agree. It is too easy to get to situation like this.

> > root@bug:~# swapoff /tmp/swap
> > swapoff: /tmp/swap: No such file or directory
> > root@bug:~# > /tmp/swap
> > root@bug:~# swapoff /tmp/swap
> > swapoff: /tmp/swap: Invalid argument
> > root@bug:~#
>
> Don't let your automatic /tmp cleaners remove the swap
> file ;)
>
> > How do I get out of this bad situation?
>
> Reboot.

I'm afraid even reboot will not work.

I can't swapoff. Therefore filesystem is busy (it must be -- kernel
might be writing to file on it!). And no way to get out of that.
--
The best software in life is free (not shareware)! Pavel
GCM d? s-: !g p?:+ au- a--@ w+ v- C++@ UL+++ L++ N++ E++ W--- M- Y- R+

2000-12-09 23:12:30

by David Feuer

[permalink] [raw]
Subject: Re: swapoff weird

At 10:24 PM 12/9/2000 +0100, you wrote:d
>It is possible to remove swapfile in use. Great, but how do you swap
>off then? Who is to blame?

Perhaps it would be good to put a check in unlink to make sure that this is
not the last link to a swapfile. Are there any other sorts of files that
don't belong to any user process and may remain active after unlink?

--
This message has been brought to you by the letter alpha and the number pi.
Open Source: Think locally; act globally.
David Feuer
[email protected]

2000-12-09 23:13:20

by David Ford

[permalink] [raw]
Subject: Re: swapoff weird

> I can't swapoff. Therefore filesystem is busy (it must be -- kernel
> might be writing to file on it!). And no way to get out of that.

It's busy because some portion of memory is in use. manually kill things as
best you can. this will clean out the swap. once you've gotten all
applications killed cleanly you can forcibly reboot with little damage. this
is pretty much the only way out. we don't have any method (currently) to
turn off a swap file if it's deleted.

Some ideas for the future, /var/run/swap.inode files, some form of sysctl.

-d


Attachments:
david.vcf (274.00 B)
Card for David Ford

2000-12-10 08:27:23

by Peter Samuelson

[permalink] [raw]
Subject: Re: swapoff weird


[David Feuer]
> Perhaps it would be good to put a check in unlink to make sure that
> this is not the last link to a swapfile.

Much better to add code to /sbin/swapon and /sbin/swapoff to set and
clear immutable bit. Sure it only works on ext2 but how far do you
want to take this thing?

Peter

2000-12-10 09:36:41

by David Feuer

[permalink] [raw]
Subject: Re: swapoff weird

At 01:56 AM 12/10/2000 -0600, Peter Samuelson wrote:

>[David Feuer]
> > Perhaps it would be good to put a check in unlink to make sure that
> > this is not the last link to a swapfile.
>
>Much better to add code to /sbin/swapon and /sbin/swapoff to set and
>clear immutable bit. Sure it only works on ext2 but how far do you
>want to take this thing?

In a private email, [email protected] wrote:

>No; we should add some more magic-symlink /proc entries, like
>/proc/<pid>/fd/<n> for swap files. Then they can be accessed
>by swapoff even if they're deleted.

Seems like a good idea to me...

--
This message has been brought to you by the letter alpha and the number pi.
Open Source: Think locally; act globally.
David Feuer
[email protected]

2000-12-15 20:37:49

by Pavel Machek

[permalink] [raw]
Subject: Re: swapoff weird

Hi!

> >[David Feuer]
> > > Perhaps it would be good to put a check in unlink to make sure that
> > > this is not the last link to a swapfile.
> >
> >Much better to add code to /sbin/swapon and /sbin/swapoff to set and
> >clear immutable bit. Sure it only works on ext2 but how far do you
> >want to take this thing?
>
> In a private email, [email protected] wrote:
>
> >No; we should add some more magic-symlink /proc entries, like
> >/proc/<pid>/fd/<n> for swap files. Then they can be accessed
> >by swapoff even if they're deleted.
>
> Seems like a good idea to me...

We could make them opened by kswapd.

Pavel
--
I'm [email protected]. "In my country we have almost anarchy and I don't care."
Panos Katsaloulis describing me w.r.t. patents at [email protected]