lkml.org 
[lkml]   [1998]   [Feb]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: mkswap & swapon
Date
Apparently Andries.Brouwer@cwi.nl wrote:
% 1. swapon
%
% People complain to me that under recent kernels it is
% possible to do "swapon foo" on the same file twice,
% and twice some amount is added to the available swap.
%
% No, this is not a bug in the swapon which I maintain;
% it is a kernel bug present in 2.1.87 but not in 2.0.33.
%
% I wondered how to fix it but was not sure how to express
% the property of not being in use under the 2.1.* regime.
% In the good old days, testing i_count = 1 would suffice.
% Today, testing d_count = 1 is not enough, because two
% names can refer to the same file, and
% ln foo bar; swapon foo; swapon bar
% would succeed incorrectly.
% On the other hand, testing i_count = 1 is no good either.
% Indeed, i_count has become next to meaningless: there can
% always be dentries that refer to the inode. Thus,
% ln foo bar; swapon foo
% would fail because two dentries refer to the inode of foo.
%
% How does one express that a file is not in use?
%
% (In case anyone answers, cc to aeb@cwi.nl; I do not read linux-kernel.)

According to the manpage I have on swapon, there is an option:

-s Display swap usage summary by device

Unfortunately, when I try it, it doesn't work... (something about
/proc/swaps not being there... I haven't looked at the cause of that).

However, I figure that there is a way to find the (current) files that
are used for swap in some other way (how else would swapoff know what to
swap off?), so the thing that can be used then is looking at the inode
numbers of all the files that are currently used for swapping and
comparing those with the inode number of the new file that is given
to swapon.

This fails if you don't check the partition they're on, but that's just
another check too...

Make sense?

(I could be totally out to lunch on this, since I haven't looked at any
actual code yet.)

CHeers,
Gert-Jan.
+++++++++++++ -------- +++++ --- ++ - + 0 + + ++ +++ +++++ ++++++++ +++++++++++++
sed '/^[when][coders]/!d G.J.W. Hagenaars -- Product Dial Architect
/^...[discover].$/d Remembering Mike Carty 1968-1994
/^..[real].[code]$/!d gj at shell dot istar dot ca
' /usr/dict/words I'm Dutch, what's _your_ excuse?
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu

\
 
 \ /
  Last update: 2005-03-22 13:41    [from the cache]
©2003-2011 Jasper Spaans