summaryrefslogtreecommitdiff
path: root/scripts/blkdeactivate.sh.in
Commit message (Collapse)AuthorAgeFilesLines
* blkdeactivate: add missing VDO_AVAILABLE check in deactivate_vdoPeter Rajnoha2020-06-081-0/+6
|
* blkdeactivate: add support for VDO in blkdeactivate scriptPeter Rajnoha2020-04-091-1/+47
| | | | | | Make it possible to tear down VDO volumes with blkdeactivate if VDO is part of a device stack (and if VDO binary is installed). Also, support optional -o|--vdooptions configfile=file.
* blkdeactive: use /sbin for mdamdZdenek Kabelac2017-11-071-4/+4
| | | | | | | Do not using lvm's @SBINDIR@ for mdadm path. Set this directly to /sbin/mdadm like other tools. Group them separately
* shellcheck: some apostrophe changes and cleanupsZdenek Kabelac2017-10-251-1/+1
|
* scripts: paths updateZdenek Kabelac2017-10-251-5/+7
| | | | | Correct usage of sbindir also for scripts so the path no longer needs resolving more vars like exec_prefix & prefix.
* blkdeactivate: cleanupPeter Rajnoha2017-09-221-9/+11
| | | | | Use a different variable for translated name in dm/md_deactivate fn Fix dmraidoption/dmraidoptions in man page.
* blkdeactivate: also try to unmount /boot on blkdeactivate -u if on top of ↵Peter Rajnoha2017-09-211-1/+1
| | | | | | | | | supported device There's nothing special about /boot other than it's used during boot. But when blkdeactivate is called either on all devices or including a device where the /boot is on top, we should also include this mount point when doing unmount before deactivation of supported devices.
* blkdeactivate: add blkdeactivate -r wait option to wait for MD ↵Peter Rajnoha2017-09-211-7/+42
| | | | | | | | | | | resync/recovery/reshape The new blkdeactivate -r|mdraidoption wait causes blkdeactivate to wait for any resync/recovery/reshape that is currently in progress before deactivating the device. If this option is used, blkdeactivate calls mdadm -W|--wait before mdadm -S|--stop.
* blkdeactivate: fix blkdeactivate regression with failing DM/MD devs deactivationPeter Rajnoha2017-09-211-6/+2
| | | | | | | | | | | | | | | | | | | | Revert dc50f2f4a03dd50c5e2411a258095484555421e9. We're canonicalizing/escaping the names here and we're reusing the variable name so the code doesn't need to use extra variables and further assignments that may confuse us. Let's keep the code simple. The local name=(...$name) is not the same as local name name=(...$name) (I know various code-checking tools fuss about this and recommend the 2nd way, but let's ignore those tools' nitpicking here please.)
* blkdeactivate: fix --{dm,lvm,mpath}options option name recognitionPeter Rajnoha2017-09-211-10/+10
| | | | | | There was a typo in blkdeactivate --dmoption/--lvmoption/mpathoption, it had missing "s" at the end and it was not recognized properly, only short names for the options (-d/-l/-m).
* blkdeactivate: quote literalZdenek Kabelac2017-06-291-2/+2
| | | | This { is literal. Check expression (missing ;/\n?) or quote it.
* blkdeactivate: more readable if-then-else-fiZdenek Kabelac2017-06-291-1/+5
|
* blkdeactivate: split local declaration and assignZdenek Kabelac2017-06-291-2/+6
|
* blkdeactivate: drop unused varZdenek Kabelac2017-06-291-1/+1
|
* blkdeactivate: double quoteZdenek Kabelac2017-06-291-33/+33
| | | | Using double quote to prevent globbing and word splitting.
* blkdeactivate: replace obsoleted syntaxZdenek Kabelac2017-06-291-7/+7
|
* blkdeactivate: also unmount mount point on top of MD device if using ↵Peter Rajnoha2017-01-061-1/+2
| | | | | | | | | | | blkdeactivate -u The blkdeactivate script processes MD devices too so we should unmount any mount point on top of an MD device if blkdeactivate -u|--umount is called. Diagnosed and reported by: Rick Warner <rick@microway.com> See also https://bugzilla.redhat.com/show_bug.cgi?id=1410585.
* blkdeactivate: deactivate dev stack if dev on top already unmountedPeter Rajnoha2016-11-011-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If blkdeactivate finds out that the device on top of device stack is already unmounted, it still proceeds with device stack deactivation underneath now. This situation can happen if blkdeactivate is started and the mount point is unmounted in parallel by chance (so when blkdeactivate gets the the actual umount call, the device is not mounted anymore). Before, the blkdeactivate added such device to skip list which caused all the stack underneath to be skipped too on deactivation. Now, we proceed just as if blkdeactivate did the umount itself. For example, in the example below, the vg-lvol0 is mounted on /mnt/test when blkdeactivate is called, but it gets unmounted in parallel later on when blkdeactivate gets to the actual umount call. Before this patch (vg-lvol0 underneath not deactivated): $ blkdeactivate -u Deactivating block devices: [UMOUNT]: unmounting vg-lvol0 (dm-2) mounted on /mnt/test... skipping With this patch applied (vg-lvol0 underneath still deactivated): $ blkdeactivate -u Deactivating block devices: [UMOUNT]: unmounting vg-lvol0 (dm-2) mounted on /mnt/test... already unmounted [LVM]: deactivating Logical Volume vg/lvol0... done
* scripts: blkdeactivate: fix typo for DEV_DIR when executing blkdeactivate -m ↵Peter Rajnoha2016-07-201-1/+1
| | | | disablequeueing
* blkdeactivate: add -m|--mpathoption disablequeueing and use it for ↵Peter Rajnoha2016-07-121-10/+48
| | | | | | | | | | | | blk-availability systemd service and initscript blkdeactivate -m disablequeueing causes "multipathd disablequeueing maps" call inside blkdeactivate script before deactivating devices. This avoids a situation where blkdeactivate may wait for paths to appear if multipath is set to queueing and there's a stack of other devices and/or mount points on top of such multipath device. See also https://bugzilla.redhat.com/show_bug.cgi?id=1344381.
* blkdeactivate: fix regression in blkdeactivate causing dm and md devices to ↵Peter Rajnoha2016-06-061-4/+2
| | | | | | | | be skipped. Commit #5b3a4a9 caused the "name" variable to be cleared if declaration and assignment is on two lines so put it back so it's on one line for it to work again.
* coverity: blkdeactivate: separate format and args for printf and declare and ↵Peter Rajnoha2016-05-311-3/+5
| | | | assign separately to avoid masking return values
* doc: change fsf addressZdenek Kabelac2016-01-211-1/+1
| | | | | Hmm rpmlint suggest fsf is using a different address these days, so lets keep it up-to-date
* blkdeactivate: recognize and deactivate MD devices tooPeter Rajnoha2015-10-061-0/+33
|
* blkdeactivate: check for lvm binary and skip LVM processing if not presentPeter Rajnoha2015-04-141-3/+21
| | | | | | | | | | | | This removes dependency on lvm binary - if it's not present, all LVM processing is skipped (shouldn't normally happen because if lvm binary is missing then there's obviously nothing that would activate it, but let's make sure). Without this tight dependency on lvm, the blkdeactivate script can be packaged with libdevmapper/dmsetup (in contrast to lvm as it was before) and as such the script can still be used to handle other DM devices.
* blkdeactivate: fix endless loop if device(s) given and unable to ↵Peter Rajnoha2013-10-221-1/+4
| | | | | | | | | | | | | umount/deactivate The blkdeactivate script iterates over the list of devices if they're given as an argument and it tries to umount/deactivate them one by one. This iteration failed to proceed if any of the umount/deactivation was unsuccessful - there was a missing "shift" call to move to the next argument (device) for processing. As a result of this, the same device was tried again and again, causing an endless loop, never proceeding to the next device given.
* blkdeactivate: add support for bind mountsPeter Rajnoha2013-08-131-5/+25
| | | | | | | | | | | Recent version of util-linux/umount (v2.23+) provides umount --all-targets that can unmount all the mount targets of the same device (the bind mounts). Use this if available when calling the umount blkdeactivate. Otherwise, for older versions of util-linux, use findmnt (that is also a part of the util-linux) to iterate over all mount targets of the same device - this is the manual way.
* blkdeactivate: change the way blkdeactivate reports statusPeter Rajnoha2013-08-131-26/+76
| | | | | | | | | | | | | | | | | | | The blkdeactivate now suppresses error messages from external tools that are called. Instead, only a summary message "done" or "skipped" is issued by blkdeactivate as any error in calling the external tool (e.g. unmounting or deactivating a device) causes the device to be skipped and the blkdeactivate continues with the next device in the tree. Add new -e/--errors switch to display any error messages from external tools. Also, suppress any output given by the external tools and add new -v/--verbose switch to display it including the verbose output of the tools called (this will enable error reporting as well). Also add blkdeactivate -vv for even more debug (the script's debug).
* blkdeactivate: prevent trying to unmount the same mountpoint more timesPeter Rajnoha2013-01-231-1/+1
| | | | An addendum to previous commit 1052863a1b35f7488758c78b3a9ebef5c63392bc.
* blkdeactivate: fix handling of nested mountpoints and mangled mount paths.Peter Rajnoha2013-01-231-6/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If there was a nested mountpoint inside an existing mount path, blkdeactivate could fail to unmount such a mountpoint as it needs to deactivate the deepest path first and continue upwards. For example the simplest reproducer: [root@rhel6-a ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 4G 0 disk |-vg-lvol0 (dm-2) 253:2 0 32M 0 lvm /mnt/a `-vg-lvol1 (dm-3) 253:3 0 32M 0 lvm /mnt/a/b Before this patch: [root@rhel6-a ~]# blkdeactivate -u Deactivating block devices: UMOUNT: unmounting vg-lvol0 (dm-2) mounted on /mnt/a umount: /mnt/a: device is busy. (In some cases useful info about processes that use the device is found by lsof(8) or fuser(1)) UMOUNT: unmounting vg-lvol1 (dm-3) mounted on /mnt/a/b LVM: deactivating Logical Volume vg/lvol1 (deactivation of vg/lvol0 is skipped as /mnt/a that is on lvol0 can't be unmounted - it still has /mnt/a/b as nested mountpoint!) With this patch applied: [root@rhel6-a ~]# blkdeactivate -u Deactivating block devices: UMOUNT: unmounting vg-lvol1 (dm-3) mounted on /mnt/a/b UMOUNT: unmounting vg-lvol0 (dm-2) mounted on /mnt/a LVM: deactivating Logical Volume vg/lvol0 LVM: deactivating Logical Volume vg/lvol1 === Also, this patch contains a fix for processing mangled mount paths: [root@rhel6-a ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 4G 0 disk `-vg-lvol0 (dm-2) 253:2 0 32M 0 lvm /mnt/x y z [root@rhel6-a ~]# lsblk -r vg-lvol0 253:2 0 32M 0 lvm /mnt/x\x20y\x20z (the mount path is mangled with \xNN that is visible in raw lsblk output only and which is used in blkdeactive as well) Before this patch: [root@rhel6-a ~]# blkdeactivate -u Deactivating block devices: umount: /mnt/x\x20y\x20z: not found After this patch applied: [root@rhel6-a ~]# blkdeactivate -u Deactivating block devices: UMOUNT: unmounting vg-lvol0 (dm-2) mounted on /mnt/x\x20y\x20z LVM: deactivating Logical Volume vg/lvol0
* blkdeactivate: fix long form of optionsPeter Rajnoha2012-10-121-2/+2
| | | | Actually, long form for -d and -l option is --dmoption and --lvmoption respectively.
* scripts: introduce blkdeactivatePeter Rajnoha2012-10-121-0/+313
blkdeactivate - utility to deactivate block devices Traverses the tree of block devices and tries to deactivate them. Currently, it supports device-mapper-based devices together with LVM. See man/blkdeactivate.8 for more info. It is targeted for use during shutdown to properly deactivate the whole block device stack - systemd and init scripts are provided as well. However, it might be used directly on command line too. Please, see the commentary at the top of the blkdeactivate script for dependencies and versions of other utilities required.