[Ocfs2-tools-devel] [PATCH 6/6] ocfs2_hb_ctl: Enable support for all cluster stacks
Joel Becker
joel.becker at oracle.com
Tue Jun 3 16:33:28 PDT 2008
Remove the check for non-o2cb cluster stacks in ocfs2_hb_ctl - it now
is used for all stacks.
With this, umount.ocfs2 is no longer needed.
Signed-off-by: Joel Becker <joel.becker at oracle.com>
---
configure.in | 27 ---
mount.ocfs2/.gitignore | 1 -
mount.ocfs2/Makefile | 9 +-
mount.ocfs2/umount.ocfs2.c | 269 -----------------------------
ocfs2_controld/mount.c | 2 +-
ocfs2_hb_ctl/ocfs2_hb_ctl.c | 15 --
vendor/common/ocfs2-tools.spec-generic.in | 1 -
7 files changed, 3 insertions(+), 321 deletions(-)
delete mode 100644 mount.ocfs2/umount.ocfs2.c
diff --git a/configure.in b/configure.in
index 9078336..69610e9 100644
--- a/configure.in
+++ b/configure.in
@@ -147,33 +147,6 @@ GLIB_REQUIRED_VERSION=2.2.3
AM_PATH_GLIB_2_0($GLIB_REQUIRED_VERSION, have_glib=yes,
AC_MSG_ERROR([GLib $GLIB_REQUIRED_VERSION or better is required]))
-umount_newp()
-{
- NEEDVER="2.12j"
- FOUNDVER="`/bin/umount -V | awk '
- /util-linux/{sub(/\)$/, "", $3); print $3}
- /mount-/{sub(/^.*mount-/, ""); print}'`"
-
- test "x$FOUNDVER" = "x" && return 1
- test "x$FOUNDVER" = "x$NEEDVER" && return 0
-
- # If we don't have exactly NEEDVER, we better sort to something better.
- RESVER="`(echo "$NEEDVER"; echo "$FOUNDVER") | sort -n | tail -1`"
- if test "x$RESVER" = "x$NEEDVER"; then
- return 1
- else
- return 0
- fi
-}
-
-AC_MSG_CHECKING([for a new enough umount])
-if umount_newp; then
- AC_MSG_RESULT([found])
-else
- AC_MSG_RESULT([not found])
- AC_MSG_ERROR([umount is not new enough to support umount.ocfs2])
-fi
-
AC_MSG_CHECKING(whether to build fsck dynamically)
AC_ARG_ENABLE([dynamic-fsck], [ --enable-dynamic-fsck=[yes/no] Build fsck dynamically [default=no]],,enable_dynamic_fsck=no)
OCFS2_DYNAMIC_FSCK=
diff --git a/mount.ocfs2/.gitignore b/mount.ocfs2/.gitignore
index 7b2665f..12254f9 100644
--- a/mount.ocfs2/.gitignore
+++ b/mount.ocfs2/.gitignore
@@ -1,6 +1,5 @@
.*.sw?
mount.ocfs2
-umount.ocfs2
mount.ocfs2.8
*.d
cscope.*
diff --git a/mount.ocfs2/Makefile b/mount.ocfs2/Makefile
index 7fe24be..1f0e688 100644
--- a/mount.ocfs2/Makefile
+++ b/mount.ocfs2/Makefile
@@ -3,7 +3,7 @@ TOPDIR = ..
include $(TOPDIR)/Preamble.make
sbindir = $(root_sbindir)
-SBIN_PROGRAMS = mount.ocfs2 umount.ocfs2
+SBIN_PROGRAMS = mount.ocfs2
INCLUDES = -I$(TOPDIR)/include
LIBOCFS2_LIBS = -L$(TOPDIR)/libocfs2 -locfs2
@@ -17,22 +17,17 @@ DEFINES = -DVERSION=\"$(VERSION)\"
CORE_CFILES = fstab.c mntent.c realpath.c sundries.c xmalloc.c opts.c
MOUNT_CFILES = mount.ocfs2.c
-UMOUNT_CFILES = umount.ocfs2.c
HFILES = $(subst .c,.h,$(MOUNT_CFILES) $(CORE_CFILES))
HFILES += mount_constants.h nls.h paths.h
MOUNT_OBJS = $(subst .c,.o,$(MOUNT_CFILES) $(CORE_CFILES))
-UMOUNT_OBJS = $(subst .c,.o,$(UMOUNT_CFILES) $(CORE_CFILES))
MANS = mount.ocfs2.8
-DIST_FILES = $(CORE_CFILES) $(MOUNT_CFILES) $(UMOUNT_CFILES) \
+DIST_FILES = $(CORE_CFILES) $(MOUNT_CFILES) \
$(HFILES) $(addsuffix .in,$(MANS))
mount.ocfs2: $(MOUNT_OBJS) $(LIBOCFS2_DEPS) $(LIBO2DLM_DEPS) $(LIBO2CB_DEPS)
$(LINK) $(LIBOCFS2_LIBS) $(LIBO2DLM_LIBS) $(LIBO2CB_LIBS) $(COM_ERR_LIBS)
-umount.ocfs2: $(UMOUNT_OBJS) $(LIBOCFS2_DEPS) $(LIBO2DLM_DEPS) $(LIBO2CB_DEPS)
- $(LINK) $(LIBOCFS2_LIBS) $(LIBO2DLM_LIBS) $(LIBO2CB_LIBS) $(COM_ERR_LIBS)
-
include $(TOPDIR)/Postamble.make
diff --git a/mount.ocfs2/umount.ocfs2.c b/mount.ocfs2/umount.ocfs2.c
deleted file mode 100644
index 464d4a9..0000000
--- a/mount.ocfs2/umount.ocfs2.c
+++ /dev/null
@@ -1,269 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; -*-
- * vim: noexpandtab sw=8 ts=8 sts=0:
- *
- * umount.ocfs2.c Unounts ocfs2 volume
- *
- * Copyright (C) 2007 Oracle. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public
- * License version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- */
-
-#include "mount.ocfs2.h"
-#include "o2cb/o2cb.h"
-
-/* Do not try to include <linux/mount.h> -- lots of errors */
-#if !defined(MNT_DETACH)
-# define MNT_DETACH 2
-#endif
-
-int verbose = 0;
-int mount_quiet = 0;
-char *progname = NULL;
-
-static int nomtab = 0;
-
-struct mount_options {
- char *dir;
- char *dev;
- int flags;
-};
-
-static void handle_signal(int sig)
-{
- switch (sig) {
- case SIGTERM:
- case SIGINT:
- printf("\numount interrupted\n");
- exit(1);
- }
-}
-
-static void read_options(int argc, char **argv, struct mount_options *mo)
-{
- int c;
-
- progname = basename(argv[0]);
-
- if (argc < 2)
- return;
-
- while(1) {
- c = getopt(argc, argv, "flvn");
- if (c == -1)
- break;
-
- switch (c) {
- case 'v':
- ++verbose;
- break;
-
- case 'n':
- ++nomtab;
- break;
-
- case 'f':
- /*
- * Do nothing, as we don't support MNT_FORCE. We
- * need to handle this option for autofs
- */
- break;
-
- case 'l':
- mo->flags |= MNT_DETACH;
- break;
-
- default:
- break;
- }
- }
-
- if (optind < argc && argv[optind])
- mo->dir = xstrdup(argv[optind]);
-}
-
-static int process_options(struct mount_options *mo)
-{
- struct mntentchn *mc;
-
- if (!mo->dir) {
- com_err(progname, OCFS2_ET_INVALID_ARGUMENT, "no mountpoint specified");
- return -1;
- }
-
- /*
- * We need the device to read heartbeat information, etc. Find
- * the *last* entry matching our mo->dir. This may be a mountpoint
- * or a device, so we try a mountpoint first (the usual case).
- */
- mc = getmntdirbackward(mo->dir, NULL);
- if (mc) {
- mo->dev = xstrdup(mc->m.mnt_fsname);
- } else {
- mc = getmntdevbackward(mo->dir, NULL);
- if (!mc) {
- fprintf(stderr, "Unable to find %s in mount list\n",
- mo->dir);
- return -1;
- }
- mo->dev = mo->dir;
- mo->dir = xstrdup(mc->m.mnt_dir);
- }
-
- return 0;
-}
-
-static int check_dev_readonly(const char *dev, int *dev_ro)
-{
- int fd;
- int ret;
-
- fd = open(dev, O_RDONLY);
- if (fd < 0)
- return errno;
-
- ret = ioctl(fd, BLKROGET, dev_ro);
- if (ret < 0)
- return errno;
-
- close(fd);
-
- return 0;
-}
-
-int main(int argc, char **argv)
-{
- int rc;
- errcode_t ret = 0;
- struct mount_options mo;
- ocfs2_filesys *fs = NULL;
- struct o2cb_cluster_desc cluster;
- struct o2cb_region_desc desc;
- int clustered = 1;
- const char *stack = "";
-
- initialize_ocfs_error_table();
- initialize_o2dl_error_table();
- initialize_o2cb_error_table();
-
- setbuf(stdout, NULL);
- setbuf(stderr, NULL);
-
- if (signal(SIGTERM, handle_signal) == SIG_ERR) {
- fprintf(stderr, "Could not set SIGTERM\n");
- exit(1);
- }
-
- if (signal(SIGINT, handle_signal) == SIG_ERR) {
- fprintf(stderr, "Could not set SIGINT\n");
- exit(1);
- }
-
- memset(&mo, 0, sizeof(mo));
- read_options (argc, argv, &mo);
-
- ret = process_options(&mo);
- if (ret)
- goto bail;
-
- ret = ocfs2_open(mo.dev, OCFS2_FLAG_RO, 0, 0, &fs); //O_EXCL?
- if (ret) {
- com_err(progname, ret, "while opening device %s", mo.dev);
- goto bail;
- }
-
- clustered = (0 == ocfs2_mount_local(fs));
-
- if (verbose)
- printf("dir=%s device=%s\n", mo.dir, mo.dev);
-
- if (clustered) {
- ret = o2cb_init();
- if (ret) {
- com_err(progname, ret, "Cannot initialize cluster");
- goto bail;
- }
-
- ret = o2cb_get_stack_name(&stack);
- if (ret) {
- com_err(progname, ret, "while querying cluster stack");
- ret = -EINVAL;
- goto bail;
- }
-
- ret = ocfs2_fill_cluster_desc(fs, &cluster);
- if (ret) {
- com_err(progname, ret,
- "while loading cluster information");
- goto bail;
- }
-
- ret = ocfs2_fill_heartbeat_desc(fs, &desc);
- if (ret) {
- com_err(progname, ret,
- "while loading heartbeat information");
- goto bail;
- }
- desc.r_persist = 1;
- desc.r_service = OCFS2_FS_NAME;
- }
-
- block_signals (SIG_BLOCK);
-
- rc = -ENOSYS;
- if (mo.flags) {
- rc = umount2(mo.dir, mo.flags);
- if (rc) {
- rc = -errno;
- fprintf(stderr, "Error calling umount2(): %s",
- strerror(-rc));
- if ((rc == -ENOSYS) && verbose)
- fprintf(stdout,
- "No umount2(), trying umount()...\n");
- }
- }
- if (rc == -ENOSYS) {
- rc = umount(mo.dir);
- if (rc) {
- rc = -errno;
- fprintf(stderr, "Error unmounting %s: %s\n", mo.dir,
- strerror(-rc));
- }
- }
-
- if (rc)
- goto unblock;
-
- /* For now, only call group_leave for non-o2cb stacks */
- if (clustered && strcmp(stack, "o2cb")) {
- ret = o2cb_group_leave(&cluster, &desc);
- if (ret) {
- com_err(progname, ret,
- "while leaving the group (WARNING)");
- /* Don't propagate the error, just warn */
- ret = 0;
- }
- }
-
- if (!nomtab)
- update_mtab(mo.dir, NULL);
-
-unblock:
- block_signals (SIG_UNBLOCK);
-
-bail:
- if (fs)
- ocfs2_close(fs);
- if (mo.dev)
- free(mo.dev);
- if (mo.dir)
- free(mo.dir);
-
- return ret ? 1 : 0;
-}
diff --git a/ocfs2_controld/mount.c b/ocfs2_controld/mount.c
index d834a5b..6422b84 100644
--- a/ocfs2_controld/mount.c
+++ b/ocfs2_controld/mount.c
@@ -50,7 +50,7 @@ struct mountgroup {
struct list_head mg_services;
struct service *mg_ms_in_progress;
- /* Communication with mount/umount.ocfs2 */
+ /* Communication with mount.ocfs2 */
int mg_mount_ci;
int mg_mount_fd;
int mg_mount_notified;
diff --git a/ocfs2_hb_ctl/ocfs2_hb_ctl.c b/ocfs2_hb_ctl/ocfs2_hb_ctl.c
index 4332f70..4649c7e 100644
--- a/ocfs2_hb_ctl/ocfs2_hb_ctl.c
+++ b/ocfs2_hb_ctl/ocfs2_hb_ctl.c
@@ -536,8 +536,6 @@ int main(int argc, char **argv)
.action = HB_ACTION_UNKNOWN,
};
char hbuuid[33];
- const char *stack = "";
-
setbuf(stdout, NULL);
setbuf(stderr, NULL);
@@ -570,19 +568,6 @@ int main(int argc, char **argv)
goto bail;
}
- err = o2cb_get_stack_name(&stack);
- if (err) {
- com_err(progname, err, "while querying cluster stack");
- ret = -EINVAL;
- goto bail;
- }
-
- /* For now, skip non-o2cb stacks */
- if (strcmp(stack, "o2cb")) {
- ret = 0;
- goto bail;
- }
-
if (!hbo.uuid_str) {
err = get_uuid(hbo.dev_str, hbuuid);
if (err) {
diff --git a/vendor/common/ocfs2-tools.spec-generic.in b/vendor/common/ocfs2-tools.spec-generic.in
index 2e46c07..3308279 100644
--- a/vendor/common/ocfs2-tools.spec-generic.in
+++ b/vendor/common/ocfs2-tools.spec-generic.in
@@ -117,7 +117,6 @@ fi
/sbin/debugfs.ocfs2
/sbin/o2cb_ctl
/sbin/mount.ocfs2
-/sbin/umount.ocfs2
/sbin/ocfs2cdsl
/sbin/o2image
/sbin/ocfs2_hb_ctl
--
1.5.4.5
More information about the Ocfs2-tools-devel
mailing list