am-utils/am-utils-6.2-fix-umount-to-mount-race.patch

56 lines
1.6 KiB
Diff
Raw Normal View History

am-utils-6.2 - fix umount to mount race
From: Richard P <richardp345@gmail.com>
If a mount request arrives while its mount fs is being umounted the
the reference count of the mount fs never reaches 1 so the location
MF_MOUNTED is not cleared and the mount fs instance is not freed.
This leads to amd thinking the mount fs is still mounted and the
mount request succeeds without its corresponding target being
mounted.
This patch from Richard P (with an added fix to a log message)
fixes the problem.
Signed-off-by: Richard P <richardp345@gmail.com>
Signed-off-by: Ian Kent <raven@themaw.net>
---
amd/amfs_generic.c | 8 ++++++--
amd/autil.c | 6 ++++++
2 files changed, 12 insertions(+), 2 deletions(-)
--- am-utils-6.2.orig/amd/amfs_generic.c
+++ am-utils-6.2/amd/amfs_generic.c
@@ -743,9 +743,13 @@ amfs_bgmount(struct continuation *cp)
if (mf->mf_flags & (MFF_MOUNTING | MFF_UNMOUNTING)) {
/*
- * Still mounting - retry later
+ * Still mounting or umounting - retry later
*/
- dlog("mount of \"%s\" already pending", mf->mf_info);
+ if (mf->mf_flags & MFF_MOUNTING) {
+ dlog("mount of \"%s\" already pending", mf->mf_info);
+ } else {
+ dlog("unmount of \"%s\" already pending", mf->mf_info);
+ }
goto retry;
}
--- am-utils-6.2.orig/amd/autil.c
+++ am-utils-6.2/amd/autil.c
@@ -703,6 +703,12 @@ am_unmounted(am_node *mp)
}
/*
+ * Clear the mounted flag in case there is a pending mount with
+ * the same target fs.
+ */
+ mf->mf_flags &= ~MFF_MOUNTED;
+
+ /*
* If this is a pseudo-directory then adjust the link count
* in the parent
*/