[Ocfs2-tools-devel] [PATCH] ocfs2_controld: Handle additional mounts racing umount(2).
Joel Becker
Joel.Becker at oracle.com
Fri Aug 22 16:43:05 PDT 2008
ocfs2_controld only allows one MOUNT/UNMOUNT operation at a time.
Racing operations will receive EBUSY.
Well, if the kernel is unmounting while an additional mount is in
progress, the daemon won't clean up after a failed additional mount.
mount /dev/sdb1 /ocfs2
mount /dev/sdb1 /ocfs3
umount /ocfs2
# Gets there first, umount(2) happens.
# ->put_super(7) calls ocfs2_hb_ctl,
# which gets -EBUSY from
# o2cb_group_leave(). The filesystem is
# no longer mounted in the kernel.
The solution is to clear the ms_additional flag when we notice this
race. The daemon, seeing it is about to send EBUSY to the unmount,
clears ms_additional on the mount of /ocfs3. Then, when that mount
fails, it knows to exit the group.
Signed-off-by: Joel Becker <joel.becker at oracle.com>
---
ocfs2_controld/mount.c | 25 ++++++++++++++++++++++++-
1 files changed, 24 insertions(+), 1 deletions(-)
diff --git a/ocfs2_controld/mount.c b/ocfs2_controld/mount.c
index 11c3e08..36459d1 100644
--- a/ocfs2_controld/mount.c
+++ b/ocfs2_controld/mount.c
@@ -821,7 +821,30 @@ int remove_mount(int ci, int fd, const char *uuid, const char *service)
if (mg->mg_ms_in_progress) {
fill_error(&mg_error, EBUSY,
"Another mount is in progress");
- goto out;;
+
+ /*
+ * If the service we're removing has ms_additional set, it
+ * must be the filesystem service. That means the
+ * in_progress service is an additional real mount, but
+ * the kernel is no longer mounted.
+ *
+ * As such, the in-progress service is now a new mount, and
+ * we clear the ms_addditional flag. It will succeed or
+ * fail as a new mount.
+ */
+ if (ms->ms_additional) {
+ if (ms != mg->mg_ms_in_progress)
+ log_error("Somehow ms_additional was set "
+ "even though the in-progress "
+ "mount isn't the filesystem "
+ "(group %s, removing %s, "
+ "in-progress %s",
+ mg->mg_uuid, ms->ms_service,
+ mg->mg_ms_in_progress->ms_service);
+ ms->ms_additional = 0;
+ }
+
+ goto out;
}
if ((mg->mg_mount_ci != -1) ||
--
1.5.6.3
--
Life's Little Instruction Book #510
"Count your blessings."
Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127
More information about the Ocfs2-tools-devel
mailing list