autofs attempts unmount on directory in use
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2056321 There is a case where a multi-mount tree can be be umounted when it's still in use. This MR resolves one (hopefully the only remaining one) of those cases. Resolves: rhbz#2056321 Signed-off-by: Ian Kent ikent@redhat.com
This commit is contained in:
parent
8d8967870e
commit
1350def07e
@ -0,0 +1,110 @@
|
||||
autofs-5.1.8 - fix handling of incorrect return from umount_ent()
|
||||
|
||||
From: Ian Kent <raven@themaw.net>
|
||||
|
||||
Commit 0210535df4b ("autofs-5.1.0 - gaurd against incorrect umount
|
||||
return") guards against umount_ent() returning a fail when the mount
|
||||
has actually been umounted.
|
||||
|
||||
But we also see umount_ent() return success when in fact the mount has
|
||||
not been umounted leading to incorrect handling of automounts.
|
||||
|
||||
So checking the return of umount_ent() isn't always giving the correct
|
||||
result in more than just one case, consequently we should ignore the
|
||||
result from the spawned umount(8) and check if the mount has in fact
|
||||
been umounted.
|
||||
|
||||
Signed-off-by: Ian Kent <raven@themaw.net>
|
||||
---
|
||||
CHANGELOG | 1 +
|
||||
daemon/automount.c | 3 +--
|
||||
lib/mounts.c | 19 ++++++++++---------
|
||||
3 files changed, 12 insertions(+), 11 deletions(-)
|
||||
|
||||
--- autofs-5.1.7.orig/CHANGELOG
|
||||
+++ autofs-5.1.7/CHANGELOG
|
||||
@@ -95,6 +95,7 @@
|
||||
- avoid calling pthread_getspecific() with NULL key_thread_attempt_id.
|
||||
- fix sysconf(3) return handling.
|
||||
- remove nonstrict parameter from tree_mapent_umount_offsets().
|
||||
+- fix handling of incorrect return from umount_ent().
|
||||
|
||||
25/01/2021 autofs-5.1.7
|
||||
- make bind mounts propagation slave by default.
|
||||
--- autofs-5.1.7.orig/daemon/automount.c
|
||||
+++ autofs-5.1.7/daemon/automount.c
|
||||
@@ -605,8 +605,7 @@ static int umount_subtree_mounts(struct
|
||||
struct mnt_list *mnt;
|
||||
|
||||
debug(ap->logopt, "unmounting dir = %s", path);
|
||||
- if (umount_ent(ap, path) &&
|
||||
- is_mounted(path, MNTS_REAL)) {
|
||||
+ if (umount_ent(ap, path)) {
|
||||
warn(ap->logopt, "could not umount dir %s", path);
|
||||
left++;
|
||||
goto done;
|
||||
--- autofs-5.1.7.orig/lib/mounts.c
|
||||
+++ autofs-5.1.7/lib/mounts.c
|
||||
@@ -1869,8 +1869,7 @@ static int tree_mapent_umount_offset(str
|
||||
*/
|
||||
if (oe->ioctlfd != -1 ||
|
||||
is_mounted(oe->key, MNTS_REAL)) {
|
||||
- if (umount_ent(ap, oe->key) &&
|
||||
- is_mounted(oe->key, MNTS_REAL)) {
|
||||
+ if (umount_ent(ap, oe->key)) {
|
||||
debug(ap->logopt,
|
||||
"offset %s has active mount, invalidate",
|
||||
oe->key);
|
||||
@@ -2010,8 +2009,7 @@ int tree_mapent_umount_offsets(struct ma
|
||||
*/
|
||||
if (is_mounted(mp, MNTS_REAL)) {
|
||||
info(ap->logopt, "unmounting dir = %s", mp);
|
||||
- if (umount_ent(ap, mp) &&
|
||||
- is_mounted(mp, MNTS_REAL)) {
|
||||
+ if (umount_ent(ap, mp)) {
|
||||
if (!tree_mapent_mount_offsets(oe, 1))
|
||||
warn(ap->logopt,
|
||||
"failed to remount offset triggers");
|
||||
@@ -2982,6 +2980,7 @@ void set_direct_mount_tree_catatonic(str
|
||||
|
||||
int umount_ent(struct autofs_point *ap, const char *path)
|
||||
{
|
||||
+ unsigned int mounted;
|
||||
int rv;
|
||||
|
||||
if (ap->state != ST_SHUTDOWN_FORCE)
|
||||
@@ -2993,6 +2992,8 @@ int umount_ent(struct autofs_point *ap,
|
||||
rv = spawn_umount(ap->logopt, "-l", path, NULL);
|
||||
}
|
||||
|
||||
+ mounted = is_mounted(path, MNTS_REAL);
|
||||
+
|
||||
if (rv && (ap->state == ST_SHUTDOWN_FORCE || ap->state == ST_SHUTDOWN)) {
|
||||
/*
|
||||
* Verify that we actually unmounted the thing. This is a
|
||||
@@ -3004,20 +3005,20 @@ int umount_ent(struct autofs_point *ap,
|
||||
* so that we do not try to call rmdir_path on the
|
||||
* directory.
|
||||
*/
|
||||
- if (is_mounted(path, MNTS_REAL)) {
|
||||
+ if (mounted) {
|
||||
crit(ap->logopt,
|
||||
"the umount binary reported that %s was "
|
||||
"unmounted, but there is still something "
|
||||
"mounted on this path.", path);
|
||||
- rv = -1;
|
||||
+ mounted = -1;
|
||||
}
|
||||
}
|
||||
|
||||
- /* On success, check for mounted mount and remove it if found */
|
||||
- if (!rv)
|
||||
+ /* If mount is gone remove it from mounted mounts list. */
|
||||
+ if (!mounted)
|
||||
mnts_remove_mount(path, MNTS_MOUNTED);
|
||||
|
||||
- return rv;
|
||||
+ return mounted;
|
||||
}
|
||||
|
||||
int umount_amd_ext_mount(struct autofs_point *ap, const char *path)
|
@ -0,0 +1,77 @@
|
||||
autofs-5.1.8 - remove nonstrict parameter from tree_mapent_umount_offsets()
|
||||
|
||||
From: Ian Kent <raven@themaw.net>
|
||||
|
||||
The nonstrict parameter of tree_mapent_umount_offsets() ins't useful
|
||||
because if a real mount at the base of a sub-tree fails to umount all
|
||||
we can do is re-instate the offset mounts under it which must succeed
|
||||
for the mount tree to remain useful.
|
||||
|
||||
Signed-off-by: Ian Kent <raven@themaw.net>
|
||||
---
|
||||
CHANGELOG | 1 +
|
||||
daemon/automount.c | 2 +-
|
||||
include/mounts.h | 2 +-
|
||||
lib/mounts.c | 6 +++---
|
||||
4 files changed, 6 insertions(+), 5 deletions(-)
|
||||
|
||||
--- autofs-5.1.7.orig/CHANGELOG
|
||||
+++ autofs-5.1.7/CHANGELOG
|
||||
@@ -94,6 +94,7 @@
|
||||
- fix memory leak in xdr_exports().
|
||||
- avoid calling pthread_getspecific() with NULL key_thread_attempt_id.
|
||||
- fix sysconf(3) return handling.
|
||||
+- remove nonstrict parameter from tree_mapent_umount_offsets().
|
||||
|
||||
25/01/2021 autofs-5.1.7
|
||||
- make bind mounts propagation slave by default.
|
||||
--- autofs-5.1.7.orig/daemon/automount.c
|
||||
+++ autofs-5.1.7/daemon/automount.c
|
||||
@@ -554,7 +554,7 @@ static int umount_subtree_mounts(struct
|
||||
struct mapent *tmp;
|
||||
int ret;
|
||||
|
||||
- ret = tree_mapent_umount_offsets(me, 1);
|
||||
+ ret = tree_mapent_umount_offsets(me);
|
||||
if (!ret) {
|
||||
warn(ap->logopt,
|
||||
"some offset mounts still present under %s", path);
|
||||
--- autofs-5.1.7.orig/include/mounts.h
|
||||
+++ autofs-5.1.7/include/mounts.h
|
||||
@@ -182,7 +182,7 @@ int tree_mapent_add_node(struct mapent_c
|
||||
int tree_mapent_delete_offsets(struct mapent_cache *mc, const char *key);
|
||||
void tree_mapent_cleanup_offsets(struct mapent *oe);
|
||||
int tree_mapent_mount_offsets(struct mapent *oe, int nonstrict);
|
||||
-int tree_mapent_umount_offsets(struct mapent *oe, int nonstrict);
|
||||
+int tree_mapent_umount_offsets(struct mapent *oe);
|
||||
int unlink_mount_tree(struct autofs_point *ap, const char *mp);
|
||||
void free_mnt_list(struct mnt_list *list);
|
||||
int is_mounted(const char *mp, unsigned int type);
|
||||
--- autofs-5.1.7.orig/lib/mounts.c
|
||||
+++ autofs-5.1.7/lib/mounts.c
|
||||
@@ -1843,7 +1843,7 @@ static int tree_mapent_umount_offset(str
|
||||
* Check for and umount subtree offsets resulting from
|
||||
* nonstrict mount fail.
|
||||
*/
|
||||
- ret = tree_mapent_umount_offsets(oe, ctxt->strict);
|
||||
+ ret = tree_mapent_umount_offsets(oe);
|
||||
if (!ret)
|
||||
return 0;
|
||||
|
||||
@@ -1975,14 +1975,14 @@ static int tree_mapent_umount_offsets_wo
|
||||
return tree_mapent_umount_offset(oe, ptr);
|
||||
}
|
||||
|
||||
-int tree_mapent_umount_offsets(struct mapent *oe, int nonstrict)
|
||||
+int tree_mapent_umount_offsets(struct mapent *oe)
|
||||
{
|
||||
struct tree_node *base = MAPENT_NODE(oe);
|
||||
struct autofs_point *ap = oe->mc->ap;
|
||||
struct traverse_subtree_context ctxt = {
|
||||
.ap = ap,
|
||||
.base = base,
|
||||
- .strict = !nonstrict,
|
||||
+ .strict = 1,
|
||||
};
|
||||
int ret;
|
||||
|
13
autofs.spec
13
autofs.spec
@ -12,7 +12,7 @@
|
||||
Summary: A tool for automatically mounting and unmounting filesystems
|
||||
Name: autofs
|
||||
Version: 5.1.7
|
||||
Release: 28%{?dist}
|
||||
Release: 29%{?dist}
|
||||
Epoch: 1
|
||||
License: GPLv2+
|
||||
Source: https://www.kernel.org/pub/linux/daemons/autofs/v5/autofs-%{version}-2.tar.gz
|
||||
@ -118,6 +118,9 @@ Patch93: autofs-5.1.8-fix-memory-leak-in-xdr_exports.patch
|
||||
Patch94: autofs-5.1.8-avoid-calling-pthread_getspecific-with-NULL-key_thread_attempt_id.patch
|
||||
Patch95: autofs-5.1.8-fix-sysconf-return-handling.patch
|
||||
|
||||
Patch96: autofs-5.1.8-remove-nonstrict-parameter-from-tree_mapent_umount_offsets.patch
|
||||
Patch97: autofs-5.1.8-fix-handling-of-incorrect-return-from-umount_ent.patch
|
||||
|
||||
%if %{with_systemd}
|
||||
BuildRequires: systemd-units
|
||||
BuildRequires: systemd-devel
|
||||
@ -280,6 +283,8 @@ echo %{version}-%{release} > .version
|
||||
%patch93 -p1
|
||||
%patch94 -p1
|
||||
%patch95 -p1
|
||||
%patch96 -p1
|
||||
%patch97 -p1
|
||||
|
||||
%build
|
||||
LDFLAGS=-Wl,-z,now
|
||||
@ -388,6 +393,12 @@ fi
|
||||
%dir /etc/auto.master.d
|
||||
|
||||
%changelog
|
||||
* Fri May 13 2022 Ian Kent <ikent@redhat.com> - 1:5.1.7-29
|
||||
- bz2056321 - autofs attempts unmount on directory in use
|
||||
- remove nonstrict parameter from tree_mapent_umount_offsets().
|
||||
- fix handling of incorrect return from umount_ent().
|
||||
- Resolves: rhbz#2056321
|
||||
|
||||
* Wed May 11 2022 Ian Kent <ikent@redhat.com> - 1:5.1.7-28
|
||||
- bz2056320 - Using -hosts option does not work in RHEL 9
|
||||
- fix root offset error handling.
|
||||
|
Loading…
Reference in New Issue
Block a user