another mount issue on jessie
Hi folks, I'm running in to a mount issue on Jessie, it seems different
from the one reported here:
https://lists.debian.org/debian-devel/2016/01/msg00750.html
I've attached a short shell script the reproduces the issue 100% of the
time.
The pattern that triggers the failure is this: rbind-mount a directory,
that under it has another filesystem mounted, onto a destination
directory. Then unmount the "submount" from under the destination
directory, then unmount the rbind mount from the destination directory
itself. The destination directory is now empty, lsof shows no files
open under the destination directory, and /proc/mounts show nothing
mounted there. But the destination directory cannot be removed,
complaining of "device in use".
The problem only manifests when running the Jessie or Wheezy kernel (on
the Jessie userspace) and Gnome is installed and colord, packagekit, and
rtkit-daemon are all running. Marvel at my gorgeous ascii art table:
Userspace | Kernel |
Processes running | Bug present?
----------+----------------------------------------------------+-------------------+--------------
Jessie | linux-image-3.2.0-4-amd64 (3.2.73-2+deb7u2) |
Yes | Yes
Jessie | linux-image-3.2.0-4-amd64 (3.2.73-2+deb7u2) |
No | No
----------+----------------------------------------------------+-------------------+--------------
Jessie | linux-image-3.16.0-4-amd64 (3.16.7-ckt20-1+deb8u3) |
Yes | Yes
Jessie | linux-image-3.16.0-4-amd64 (3.16.7-ckt20-1+deb8u3) |
No | No
----------+----------------------------------------------------+-------------------+--------------
Jessie | linux-image-4.3.0-1-amd64 (4.3.3-7) |
Yes | No
----------+----------------------------------------------------+-------------------+--------------
--
Sebastian Kuzminsky
#!/usr/bin/env bash
set -e
TEST_DIR="${PWD}/test-dir"
show_state() {
echo ${@}:
tree ${TEST_DIR}
findmnt
}
if [[ $(whoami) != 'root' ]]; then
echo "must be run as root to play with mounts"
exit 1
fi
# clean up the left-behind mess from last time the test ran
if [[ -d ${TEST_DIR} ]]; then
DEST=${TEST_DIR}.${BASHPID}
echo "moving old ${TEST_DIR} to ${DEST}"
mv ${TEST_DIR} ${DEST}
fi
#
# the test code starts here
#
echo "### setting up"
mkdir -p ${TEST_DIR}
mkdir ${TEST_DIR}/src
mkdir ${TEST_DIR}/src/subfs
mount -t tmpfs -o size=1M none ${TEST_DIR}/src/subfs
mkdir ${TEST_DIR}/dest
show_state "after setup"
echo "### bind mounting"
#mount --make-rprivate ${TEST_DIR}/src
mount -v --rbind ${TEST_DIR}/src ${TEST_DIR}/dest
mount -v --make-rprivate ${TEST_DIR}/dest
show_state after mount
echo "### recursive unmount"
umount -v -l ${TEST_DIR}/dest/subfs
umount -v -l ${TEST_DIR}/dest
show_state after recursive unmount
echo "### cleaning up"
umount -v -l ${TEST_DIR}/src/subfs
DEST_RM=0
SRC_RM=0
TEST_DIR_RM=0
# this first rm fails
rm -rf ${TEST_DIR}/dest || DEST_RM=$?
rm -rf ${TEST_DIR}/src || SRC_RM=$?
rm -rf ${TEST_DIR} || TEST_DIR_RM=$?
show_state after cleanup
if [[ ${DEST_RM} -eq 0 && ${TEST_DIR_RM} -eq 0 && ${SRC_RM} -eq 0 ]]; then
echo "PASS! no problem"
RESULT=0
else
echo "FAIL! rm did not succeed (dest=${DEST_RM}, src=${SRC_RM}, test-dir=${TEST_DIR_RM})"
RESULT=1
fi
exit ${RESULT}
Reply to: