Bug 849714 - lvchange or vgchange Can't deactivate volume group with open logical volume(s) if LV present in any /proc/<pid>/mounts
lvchange or vgchange Can't deactivate volume group with open logical volume(s...
Status: CLOSED NOTABUG
Product: Fedora
Classification: Fedora
Component: lvm2 (Show other bugs)
17
x86_64 Linux
unspecified Severity unspecified
: ---
: ---
Assigned To: LVM and device-mapper development team
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-08-20 12:51 EDT by James Hartsock
Modified: 2012-08-20 13:06 EDT (History)
11 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-08-20 13:06:52 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description James Hartsock 2012-08-20 12:51:01 EDT
Description of problem:
If any process has logical volume listed in /proc/<pid>/mounts you are unable to de-activate the logical volume or volume group

Version-Release number of selected component (if applicable):
Fedora release 17 (Beefy Miracle)


How reproducible:
Very/Always for me

Steps to Reproduce:
$ cat /tmp/blah
1) Showing VG is not activated
  # vgchange -a n vg02
    0 logical volume(s) in volume group "vg02" now active

2) activate VG
  # vgchange -a y vg02
    3 logical volume(s) in volume group "vg02" now active

3) Mount a LV in the VG
  # mount /dev/mapper/vg02-guests /var/lib/libvirt/images

4) Show LV is mounted
  # df /var/lib/libvirt/images
  Filesystem               Size  Used Avail Use% Mounted on
  /dev/mapper/vg02-guests  493G  401G   67G  86% /var/lib/libvirt/images

5) Restart apache (other service work too, cups.service)
  # systemctl restart httpd.service

6) Un-mount the LV
  # umount /var/lib/libvirt/images

7) Try to de-activate LV, FAIL
  # lvchange -a n /dev/vg02/guests
    Logical volume vg02/guests contains a filesystem in use.

8) Try to de-activate VG, FAIL
  # vgchange -a n vg02
    Can't deactivate volume group "vg02" with 1 open logical volume(s)

9) Show it is httpd with /proc/*/mounts still having VG listed:

  # systemctl restart httpd.service
  root@# grep vg02 /proc/*/mounts
  /proc/7367/mounts:/dev/mapper/vg02-guests /var/lib/libvirt/images ext2 rw,seclabel,relatime 0 0
  /proc/7369/mounts:/dev/mapper/vg02-guests /var/lib/libvirt/images ext2 rw,seclabel,relatime 0 0
  /proc/7370/mounts:/dev/mapper/vg02-guests /var/lib/libvirt/images ext2 rw,seclabel,relatime 0 0
  /proc/7371/mounts:/dev/mapper/vg02-guests /var/lib/libvirt/images ext2 rw,seclabel,relatime 0 0
  /proc/7372/mounts:/dev/mapper/vg02-guests /var/lib/libvirt/images ext2 rw,seclabel,relatime 0 0
  /proc/7373/mounts:/dev/mapper/vg02-guests /var/lib/libvirt/images ext2 rw,seclabel,relatime 0 0
  /proc/7374/mounts:/dev/mapper/vg02-guests /var/lib/libvirt/images ext2 rw,seclabel,relatime 0 0
  /proc/7375/mounts:/dev/mapper/vg02-guests /var/lib/libvirt/images ext2 rw,seclabel,relatime 0 0
  /proc/7376/mounts:/dev/mapper/vg02-guests /var/lib/libvirt/images ext2 rw,seclabel,relatime 0 0

  # ps -flp 7367 7369 7370 7371 7372 7373 7374 7375 7376
  F S UID        PID  PPID  C PRI  NI ADDR SZ WCHAN  STIME TTY        TIME CMD
  5 S root      7367     1  0  80   0 - 91833 poll_s 11:30 ?          0:00 /usr/sbin/httpd -k start
  5 S apache    7369  7367  0  80   0 - 91866 epoll_ 11:30 ?          0:00 /usr/sbin/httpd -k start
  5 S apache    7370  7367  0  80   0 - 91866 semtim 11:30 ?          0:00 /usr/sbin/httpd -k start
  5 S apache    7371  7367  0  80   0 - 91866 semtim 11:30 ?          0:00 /usr/sbin/httpd -k start
  5 S apache    7372  7367  0  80   0 - 91866 semtim 11:30 ?          0:00 /usr/sbin/httpd -k start
  5 S apache    7373  7367  0  80   0 - 91866 semtim 11:30 ?          0:00 /usr/sbin/httpd -k start
  5 S apache    7374  7367  0  80   0 - 91866 semtim 11:30 ?          0:00 /usr/sbin/httpd -k start
  5 S apache    7375  7367  0  80   0 - 91866 semtim 11:30 ?          0:00 /usr/sbin/httpd -k start
  5 S apache    7376  7367  0  80   0 - 91866 semtim 11:30 ?          0:00 /usr/sbin/httpd -k start

10) Restart apache (cups works too)
  # systemctl restart httpd.service

11) Now able to de-active LV and/or VG
  # lvchange -a n /dev/vg02/guests

  # vgchange -a n vg02
    0 logical volume(s) in volume group "vg02" now active


NOTE: That the services on boot start after the file-system is mounted, so by default system starts these services that are not getting /proc/<pid>/mounts updated with file-system already mounted.  I am just restarting service to mimic the default boot action.  I originally saw this trying to umount a file-system in /etc/fstab after a system boot.

  
Actual results:
Steps 7 & 8 above:

  # lvchange -a n /dev/vg02/guests
    Logical volume vg02/guests contains a filesystem in use.

  # vgchange -a n vg02
    Can't deactivate volume group "vg02" with 1 open logical volume(s)

Expected results:
Steps 11, but without having to kill/restart PIDs that have LV/VG referenced in /proc/<pid>/mounts file:
  # lvchange -a n /dev/vg02/guests

  # vgchange -a n vg02
    0 logical volume(s) in volume group "vg02" now active


Additional info:

Issue originally seen trying to umount the file-system after a reboot to run fsck and was unable to fsck file-system:


# uptime
 11:44:33 up 0 min,  2 users,  load average: 0.62, 0.16, 0.05

# umount /var/lib/libvirt/images

# echo $?
0

# fsck -f /dev/vg02/guests
fsck from util-linux 2.21.2
e2fsck 1.42.3 (14-May-2012)
fsck.ext4: Device or resource busy while trying to open /dev/mapper/vg02-guests
Filesystem mounted or opened exclusively by another program?

# lvchange -a n /dev/vg02/guests
  Logical volume vg02/guests contains a filesystem in use.

# vgchange -a n vg02
  Can't deactivate volume group "vg02" with 2 open logical volume(s)

# grep -c /var/lib/libvirt/images /etc/mtab /proc/mounts
/etc/mtab:0
/proc/mounts:0

# ps -fp $(grep -l /var/lib/libvirt/images /proc/*/mounts | cut -d/ -f 3)
UID        PID  PPID  C STIME TTY      STAT   TIME CMD
root      1513     1  0 11:44 ?        Ss     0:00 /usr/sbin/httpd -k start
apache    1525  1513  0 11:44 ?        S      0:00 /usr/sbin/httpd -k start
apache    1526  1513  0 11:44 ?        S      0:00 /usr/sbin/httpd -k start
apache    1527  1513  0 11:44 ?        S      0:00 /usr/sbin/httpd -k start
apache    1528  1513  0 11:44 ?        S      0:00 /usr/sbin/httpd -k start
apache    1529  1513  0 11:44 ?        S      0:00 /usr/sbin/httpd -k start
apache    1530  1513  0 11:44 ?        S      0:00 /usr/sbin/httpd -k start
apache    1531  1513  0 11:44 ?        S      0:00 /usr/sbin/httpd -k start
apache    1532  1513  0 11:44 ?        S      0:00 /usr/sbin/httpd -k start
root      1632     1  0 11:44 ?        Ss     0:00 /usr/sbin/cupsd -f
colord    1636     1  0 11:44 ?        Ssl    0:00 /usr/libexec/colord
colord    1642     1  0 11:44 ?        Ssl    0:00 /usr/libexec/colord-sane




Also system is updated via 'yum update' as of Aug 20 and issue still present.
$ rpm -qf /usr/sbin/lvchange
lvm2-2.02.95-6.fc17.x86_64
Comment 1 Alasdair Kergon 2012-08-20 13:06:52 EDT
It doesn't look like a bug.  Read up on bind mounts/namespaces to try to understand the behaviour you're seeing and work out what you need to change to achieve whatever it is you are trying to achieve.  (E.g. read the 'bind mounts' section of 'man 8 mount'.)

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