Bug 69916 - swapoff doesn't understand LVM partitions
Summary: swapoff doesn't understand LVM partitions
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Red Hat Public Beta
Classification: Retired
Component: kernel
Version: limbo
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Stephen Tweedie
QA Contact: Brian Brock
URL:
Whiteboard:
Depends On:
Blocks: 67218
TreeView+ depends on / blocked
 
Reported: 2002-07-26 11:57 UTC by Jay Turner
Modified: 2015-01-07 23:58 UTC (History)
3 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2002-09-06 12:54:15 UTC
Embargoed:


Attachments (Terms of Use)

Description Jay Turner 2002-07-26 11:57:17 UTC
Description of Problem:
swapoff fails for swap partitions which are on LVM (such as
/dev/Volume00/LogVol01).  Running 'swapoff /dev/Volume00/LogVol01' gives the
message that the argument is invalid.  Running 'swapoff -a' returns cleanly, but
doesn't turn swap off on the LVM partition.  Seeing this with mount-2.11r-7.

Version-Release number of selected component (if applicable):


How Reproducible:


Steps to Reproduce:
1. 
2. 
3. 

Actual Results:


Expected Results:


Additional Information:

Comment 1 Elliot Lee 2002-07-26 14:44:25 UTC
Can't reproduce here with a LV that I manually created and did swapon/swapoff on (as 
well as a full reboot) without any problems.

Comment 2 Tim Clymo 2002-07-27 15:58:33 UTC
I see similar behaviour. My system uses a single RAID-1 VG containing LV's for
all filesystems except /boot (which lives on another small RAID-1 partition). As
well as the LV filesystems, I also have an LV configured for use as swap. The
system is booted and LVM activated by an initrd.

I'm fairly certain this is caused by running vgscan when LVM is already
activated and an LV is in use for swap:

swapon -s
Filename                        Type            Size    Used    Priority
/dev/vg00/lvol2                 partition       524280  0       -1

In this case, I can run swapon and swapoff as many times as I like to turn
swapping on and off on the LV - however, if I now run vgscan (with the swap LV
in use), I get:

swapon -s
Filename                        Type            Size    Used    Priority
/dev/vg00/lvol2 (deleted)       partition       524280  0       -1

Once the swap device is in "deleted" state, swapoff returns the error reported
by the original poster.

Unfortunately, although vgscan is not the kind of thing that gets run very
often, it does get called twice by /etc/rc.sysinit during system startup as it
attempts to activate LVM. Since my LVM has already started from the initrd,
these bits of rc.sysinit are not necessary so I have commented them out.

Obviously, a better fix would be for somebody to figure out why the vgscan has
this unfortunate effect if an LV is in use as a swap device.

Comment 3 Elliot Lee 2002-08-07 22:29:20 UTC
vgscan does it, thanks. After running vgscan, the swapoff("/dev/MYLVM/lvmswap") system 
call returns EINVAL.

Although I know nearly nothing about LVM, this is a kernel bug by the looks of it, 
reassigning.

Comment 4 Stephen Tweedie 2002-08-14 09:26:16 UTC
This is not entirely simple to fix --- the swap code works entirely on the bases
of pathnames, not the underlying objects, when associating swapoff names with
active swap partitions.  That means that even something like swapon on an initrd
then swapoff after root mount is going to fail.  The fix should be localised to
one place in the code, I think, but we'll need to get it accepted upstream
before we can possibly include it.

Comment 5 Stephen Tweedie 2002-08-26 23:03:03 UTC
There's a quick and easy hack which probably works fine for our tree; awaiting
feedback.

Comment 6 Jay Turner 2002-08-30 15:25:02 UTC
I'm still seeing the old behavior with kernel-2.4.18-12.5, but the fix might not
be in there.  Just checking.

Comment 7 Tim Clymo 2002-09-06 12:54:09 UTC
Just checked kernel 2.4.18-14. Swapoff now works :)
Unfortunately, vgscan still has the side effect of putting an active LVM-based 
swap partition into "deleted" state (which I guess means it isn't functional 
as a swap area any more)

Since vgscan runs (twice) from initscripts, this is still a bit of a problem :(

Comment 8 Stephen Tweedie 2002-09-06 13:22:51 UTC
No, it only means that the directory entry used to set up the swap initially is
now deleted.  The device is still there and swap on that device will still work.


Note You need to log in before you can comment on or make changes to this bug.