Skip to content

Commit b1dcc9b

Browse files
N-R-Knavi-desu
authored andcommitted
do_unmount: add parallel unmounting
this turns mouninfo into a multicall binary which can also do parallel unmounting. most mountinfo code is unchanged; only notable change is find_mounts() now returns the number of mounts found and also takes the "process" function as an argument; so that is_mounted() can be implemented on top of it. do_unmount mostly follows the logic of previous code. some notable changes: - do_unmount is now "lazy" when it comes to retrying failed unmounts. it will greedily keep running unmount as long as it can before it looks at the "waiting" queue. - it will check if the mountpoint is still mounted or not when umount returns non-zero exit code. this is due to the fact that multiple umount calls might race to unmount a shared mount. so if umount fails _but_ the mountpoint is no longer mounted, we assume success. - do_unmount used to fail if fuser did not find any pids using the mount. the new code tries one more time; the rationale being that there's a gap between the umount call and the fuser call, and so whatever was using the mount before might have stopped using it now and so it's worth another attempt. Fixes: #662 Closes: #698
1 parent feeb9f0 commit b1dcc9b

File tree

8 files changed

+419
-116
lines changed

8 files changed

+419
-116
lines changed

init.d/localmount.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ stop()
112112
# Umount loop devices
113113
einfo "Unmounting loop devices"
114114
eindent
115-
do_unmount "umount -d" --skip-point-regex "$no_umounts_r" \
115+
do_unmount -d -- --skip-point-regex "$no_umounts_r" \
116116
--node-regex "^/dev/loop"
117117
eoutdent
118118

@@ -125,7 +125,7 @@ stop()
125125
fs="$fs${fs:+|}$x"
126126
done
127127
[ -n "$fs" ] && fs="^($fs)$"
128-
do_unmount umount --skip-point-regex "$no_umounts_r" \
128+
do_unmount -- --skip-point-regex "$no_umounts_r" \
129129
"${fs:+--skip-fstype-regex}" $fs --nonetdev
130130
eoutdent
131131

init.d/mount-ro.in

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ start()
2525
sync
2626

2727
ebegin "Remounting remaining filesystems read-only"
28-
# We need the do_unmount function
29-
. "$RC_LIBEXECDIR"/sh/rc-mount.sh
3028
eindent
3129

3230
# Bug 381783
@@ -48,7 +46,7 @@ start()
4846
fs="$fs${fs:+|}$x"
4947
done
5048
[ -n "$fs" ] && fs="^($fs)$"
51-
do_unmount "umount -r" \
49+
do_unmount -r -- \
5250
--skip-point-regex "$m" \
5351
"${fs:+--skip-fstype-regex}" $fs --nonetdev
5452
ret=$?

init.d/netmount.in

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ stop()
6464
local x= fs=
6565

6666
ebegin "Unmounting network filesystems"
67-
. "$RC_LIBEXECDIR"/sh/rc-mount.sh
6867

6968
for x in $net_fs_list $extra_net_fs_list; do
7069
fs="$fs${fs:+,}$x"
@@ -79,7 +78,7 @@ stop()
7978
fs="$fs${fs:+|}$x"
8079
done
8180
[ -n "$fs" ] && fs="^($fs)$"
82-
do_unmount umount ${fs:+--fstype-regex} $fs --netdev
81+
do_unmount -- ${fs:+--fstype-regex} $fs --netdev
8382
retval=$?
8483

8584
eoutdent

sh/meson.build

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ sh_conf_data.set('SYSCONFDIR', get_option('sysconfdir'))
99

1010
sh = [
1111
'rc-functions.sh',
12-
'rc-mount.sh',
1312
'runit.sh',
1413
's6.sh',
1514
'start-stop-daemon.sh',

sh/rc-mount.sh

Lines changed: 0 additions & 87 deletions
This file was deleted.

src/mountinfo/meson.build

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
executable('mountinfo', 'mountinfo.c',
2-
include_directories: incdir,
3-
dependencies: [rc, einfo, shared],
4-
install: true,
5-
install_dir: rc_bindir)
1+
foreach exec : ['mountinfo', 'do_unmount']
2+
executable(exec, 'mountinfo.c',
3+
include_directories: incdir,
4+
dependencies: [rc, einfo, shared],
5+
install: true,
6+
install_dir: rc_bindir)
7+
endforeach

0 commit comments

Comments
 (0)