[Ocfs2-tools-commits] mfasheh commits r712 - in trunk: .
debugfs.ocfs2 extras fsck.ocfs2 libocfs2 libocfs2/include
listuuid mkfs.ocfs2 mount.ocfs2 mounted.ocfs2
ocfs2console/ocfs2interface sizetest tunefs.ocfs2
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Sun Mar 20 22:50:08 CST 2005
Author: mfasheh
Signed-off-by: zab
Date: 2005-03-20 22:50:07 -0600 (Sun, 20 Mar 2005)
New Revision: 712
Added:
trunk/libocfs2/heartbeat.c
Modified:
trunk/Makefile
trunk/debugfs.ocfs2/Makefile
trunk/extras/Makefile
trunk/fsck.ocfs2/Makefile
trunk/fsck.ocfs2/fsck.c
trunk/libocfs2/Makefile
trunk/libocfs2/dlm.c
trunk/libocfs2/include/ocfs2.h
trunk/libocfs2/ocfs2_err.et
trunk/libocfs2/openfs.c
trunk/listuuid/Makefile
trunk/mkfs.ocfs2/Makefile
trunk/mkfs.ocfs2/check.c
trunk/mount.ocfs2/mount.ocfs2.c
trunk/mount.ocfs2/mount_hb.c
trunk/mount.ocfs2/mount_hb.h
trunk/mount.ocfs2/ocfs2_hb_ctl.c
trunk/mounted.ocfs2/Makefile
trunk/mounted.ocfs2/mounted.c
trunk/ocfs2console/ocfs2interface/Makefile
trunk/sizetest/Makefile
trunk/tunefs.ocfs2/Makefile
trunk/tunefs.ocfs2/tunefs.c
Log:
* Mount.ocfs2 and ocfs2_hb_ctl were not initializing the o2cb error table.
fix that.
* Several paths were stringifying a file system uuid. Introduce
uuid_str to the fs object and change callers to use this.
* Provide a libocfs2 interface to start / stop heartbeat. Teach the dlm code
how to use this. Much of this was copied from mount_hb.c.
* Instead of having two copies of this code, teach mount.ocfs2 and
ocfs2_hb_ctl to use this new interface via a rewrite of mount_hb.c
* This introduced a new requirement for ocfs2_dlmfs users on libo2cb. Do
whatever make-foo was required to get things to build correctly. Some
C files required the addition of a call to "initialize_o2cb_error_table"
* While I was in mount and ocfs2_hb_ctl, fix things up to use com_err
properly.
Signed-off-by: zab
Modified: trunk/Makefile
===================================================================
--- trunk/Makefile 2005-03-21 02:33:50 UTC (rev 711)
+++ trunk/Makefile 2005-03-21 04:50:07 UTC (rev 712)
@@ -24,7 +24,7 @@
$(error could not detect architecture for tools)
endif
-SUBDIRS = libo2dlm libocfs2 libo2cb fsck.ocfs2 mkfs.ocfs2 mounted.ocfs2 tunefs.ocfs2 debugfs.ocfs2 o2cb_ctl mount.ocfs2 listuuid sizetest extras patches
+SUBDIRS = libo2dlm libo2cb libocfs2 fsck.ocfs2 mkfs.ocfs2 mounted.ocfs2 tunefs.ocfs2 debugfs.ocfs2 o2cb_ctl mount.ocfs2 listuuid sizetest extras patches
ifdef BUILD_OCFS2CDSL
SUBDIRS += ocfs2cdsl
Modified: trunk/debugfs.ocfs2/Makefile
===================================================================
--- trunk/debugfs.ocfs2/Makefile 2005-03-21 02:33:50 UTC (rev 711)
+++ trunk/debugfs.ocfs2/Makefile 2005-03-21 04:50:07 UTC (rev 712)
@@ -5,9 +5,9 @@
SBIN_PROGRAMS = debugfs.ocfs2
DEFINES = -DG_DISABLE_DEPRECATED -DLINUX -DDEBUGOCFS -DDEBUG
-DEFINES += -DOCFS2_FLAT_INCLUDES -DVERSION=\"$(VERSION)\" -DO2DLM_FLAT_INCLUDES
+DEFINES += -DOCFS2_FLAT_INCLUDES -DVERSION=\"$(VERSION)\" -DO2DLM_FLAT_INCLUDES -DO2CB_FLAT_INCLUDES
-INCLUDES = -Iinclude -I$(TOPDIR)/libocfs2/include -I$(TOPDIR)/libo2dlm/include
+INCLUDES = -Iinclude -I$(TOPDIR)/libocfs2/include -I$(TOPDIR)/libo2dlm/include -I$(TOPDIR)/libo2cb/include
INCLUDES += $(GLIB_CFLAGS)
ifdef OCFS_DEBUG
Modified: trunk/extras/Makefile
===================================================================
--- trunk/extras/Makefile 2005-03-21 02:33:50 UTC (rev 711)
+++ trunk/extras/Makefile 2005-03-21 04:50:07 UTC (rev 712)
@@ -13,11 +13,11 @@
UNINST_PROGRAMS = find_hardlinks find_dup_extents find_inode_paths set_random_bits
-INCLUDES = -I../libocfs2/include -I$(TOPDIR)/libo2dlm/include
+INCLUDES = -I../libocfs2/include -I$(TOPDIR)/libo2dlm/include -I$(TOPDIR)/libo2cb/include
OPTIMIZE = -O2
-DEFINES += -DOCFS2_FLAT_INCLUDES -DO2DLM_FLAT_INCLUDES
+DEFINES += -DOCFS2_FLAT_INCLUDES -DO2DLM_FLAT_INCLUDES -DO2CB_FLAT_INCLUDES
CFLAGS += $(OPTIMIZE)
Modified: trunk/fsck.ocfs2/Makefile
===================================================================
--- trunk/fsck.ocfs2/Makefile 2005-03-21 02:33:50 UTC (rev 711)
+++ trunk/fsck.ocfs2/Makefile 2005-03-21 04:50:07 UTC (rev 712)
@@ -4,11 +4,15 @@
SBIN_PROGRAMS = fsck.ocfs2
-INCLUDES = -Iinclude -I$(TOPDIR)/libocfs2/include -I$(TOPDIR)/libo2dlm/include
+INCLUDES = -Iinclude -I$(TOPDIR)/libocfs2/include \
+ -I$(TOPDIR)/libo2dlm/include \
+ -I$(TOPDIR)/libo2cb/include
LIBOCFS2_LIBS = -L$(TOPDIR)/libocfs2 -locfs2
LIBOCFS2_DEPS = $(TOPDIR)/libocfs2/libocfs2.a
LIBO2DLM_LIBS = -L$(TOPDIR)/libo2dlm -lo2dlm
LIBO2DLM_DEPS = $(TOPDIR)/libo2dlm/libo2dlm.a
+LIBO2CB_LIBS = -L$(TOPDIR)/libo2cb -lo2cb
+LIBO2CB_DEPS = $(TOPDIR)/libo2cb/libo2cb.a
ifdef OCFS_DEBUG
OPTS += -ggdb
@@ -19,7 +23,7 @@
CFLAGS := $(OPTS) -Wall -Wstrict-prototypes -Wmissing-prototypes \
-Wmissing-declarations
-DEFINES = -DOCFS2_FLAT_INCLUDES -DO2DLM_FLAT_INCLUDES
+DEFINES = -DOCFS2_FLAT_INCLUDES -DO2DLM_FLAT_INCLUDES -DO2CB_FLAT_INCLUDES
CFILES = fsck.c \
dirblocks.c \
@@ -61,8 +65,8 @@
dist-subdircreate:
$(TOPDIR)/mkinstalldirs $(DIST_DIR)/include
-fsck.ocfs2: $(OBJS) $(LIBOCFS2_DEPS) $(LIBO2DLM_DEPS)
- $(LINK) $(LIBOCFS2_LIBS) $(LIBO2DLM_LIBS) $(COM_ERR_LIBS)
+fsck.ocfs2: $(OBJS) $(LIBOCFS2_DEPS) $(LIBO2DLM_DEPS) $(LIBO2CB_DEPS)
+ $(LINK) $(LIBOCFS2_LIBS) $(LIBO2DLM_LIBS) $(LIBO2CB_LIBS) $(COM_ERR_LIBS)
$(OBJS): prompt-codes.h
Modified: trunk/fsck.ocfs2/fsck.c
===================================================================
--- trunk/fsck.ocfs2/fsck.c 2005-03-21 02:33:50 UTC (rev 711)
+++ trunk/fsck.ocfs2/fsck.c 2005-03-21 04:50:07 UTC (rev 712)
@@ -428,6 +428,7 @@
initialize_ocfs_error_table();
initialize_o2dl_error_table();
+ initialize_o2cb_error_table();
setlinebuf(stderr);
setlinebuf(stdout);
Modified: trunk/libocfs2/Makefile
===================================================================
--- trunk/libocfs2/Makefile 2005-03-21 02:33:50 UTC (rev 711)
+++ trunk/libocfs2/Makefile 2005-03-21 04:50:07 UTC (rev 712)
@@ -11,15 +11,18 @@
OPTS += -O2
endif
-INCLUDES = -Iinclude -I$(TOPDIR)/libo2dlm/include
+INCLUDES = -Iinclude -I$(TOPDIR)/libo2dlm/include -I$(TOPDIR)/libo2cb/include
LIBRARIES = libocfs2.a
LIBO2DLM_LIBS = -L$(TOPDIR)/libo2dlm -lo2dlm
LIBO2DLM_DEPS = $(TOPDIR)/libo2dlm/libo2dlm.a
+LIBO2CB_LIBS = -L$(TOPDIR)/libo2cb -lo2cb
+LIBO2CB_DEPS = $(TOPDIR)/libo2cb/libo2cb.a
+
CFLAGS = $(OPTS) $(WARNINGS) -fPIC
-CPPFLAGS += -DOCFS2_FLAT_INCLUDES -DO2DLM_FLAT_INCLUDES
+CPPFLAGS += -DOCFS2_FLAT_INCLUDES -DO2DLM_FLAT_INCLUDES -DO2CB_FLAT_INCLUDES
ifneq ($(OCFS2_DEBUG_EXE),)
DEBUG_EXE_FILES = $(shell awk '/DEBUG_EXE/{if (k[FILENAME] == 0) {print FILENAME; k[FILENAME] = 1;}}' $(CFILES))
@@ -34,8 +37,8 @@
$(INCLUDES) $(DEFINES) \
-DDEBUG_EXE -o $@ -c $<
-debug_%: debug_%.o libocfs2.a $(LIBO2DLM_DEPS)
- $(LINK) $(COM_ERR_LIBS) $(LIBO2DLM_LIBS)
+debug_%: debug_%.o libocfs2.a $(LIBO2DLM_DEPS) $(LIBO2CB_DEPS)
+ $(LINK) $(COM_ERR_LIBS) $(LIBO2DLM_LIBS) $(LIBO2CB_LIBS)
endif
@@ -72,7 +75,8 @@
extend_file.c \
namei.c \
truncate.c \
- dlm.c
+ dlm.c \
+ heartbeat.c
HFILES = \
include/jfs_user.h \
@@ -91,7 +95,7 @@
HFILES_GEN = \
include/ocfs2_err.h
-
+
OBJS = $(subst .c,.o,$(CFILES)) \
ocfs2_err.o
@@ -103,7 +107,7 @@
ocfs2_err.c ocfs2_err.h: ocfs2_err.et
compile_et ocfs2_err.et
-libocfs2.a: $(OBJS) $(LIBO2DLM_DEPS)
+libocfs2.a: $(OBJS) $(LIBO2DLM_DEPS) $(LIBO2CB_DEPS)
rm -f $@
$(AR) r $@ $^
$(RANLIB) $@
Modified: trunk/libocfs2/dlm.c
===================================================================
--- trunk/libocfs2/dlm.c 2005-03-21 02:33:50 UTC (rev 711)
+++ trunk/libocfs2/dlm.c 2005-03-21 04:50:07 UTC (rev 712)
@@ -134,20 +134,19 @@
errcode_t ocfs2_initialize_dlm(ocfs2_filesys *fs)
{
struct o2dlm_ctxt *dlm_ctxt = NULL;
- ocfs2_super_block *sb = OCFS2_RAW_SB(fs->fs_super);
errcode_t ret = 0;
- char uuid[34];
- char *p;
- int i;
- memset(uuid, 0, sizeof(uuid));
- for (i = 0, p = uuid; i < 16; ++i, p += 2)
- sprintf(p, "%02X", sb->s_uuid[i]);
-
- ret = o2dlm_initialize(DEFAULT_DLMFS_PATH, uuid, &dlm_ctxt);
+ ret = ocfs2_start_heartbeat(fs);
if (ret)
goto bail;
+ ret = o2dlm_initialize(DEFAULT_DLMFS_PATH, fs->uuid_str, &dlm_ctxt);
+ if (ret) {
+ /* What to do with an error code? */
+ ocfs2_stop_heartbeat(fs);
+ goto bail;
+ }
+
fs->fs_dlm_ctxt = dlm_ctxt;
bail:
@@ -164,6 +163,8 @@
fs->fs_dlm_ctxt = NULL;
+ ret = ocfs2_stop_heartbeat(fs);
+
bail:
return ret;
}
Added: trunk/libocfs2/heartbeat.c
===================================================================
--- trunk/libocfs2/heartbeat.c 2005-03-21 02:33:50 UTC (rev 711)
+++ trunk/libocfs2/heartbeat.c 2005-03-21 04:50:07 UTC (rev 712)
@@ -0,0 +1,121 @@
+/* -*- mode: c; c-basic-offset: 8; -*-
+ * vim: noexpandtab sw=8 ts=8 sts=0:
+ *
+ * heartbeat.c
+ *
+ * Interface the OCFS2 userspace library to the userspace heartbeat
+ * functionality
+ *
+ * Copyright (C) 2005 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.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 021110-1307, USA.
+ *
+ * Authors: Mark Fasheh, Zach Brown
+ */
+
+#define _XOPEN_SOURCE 600 /* Triggers magic in features.h */
+#define _LARGEFILE64_SOURCE
+
+#define __USE_MISC
+#include <string.h>
+#include <inttypes.h>
+
+#include "ocfs2.h"
+
+static errcode_t ocfs2_get_heartbeat_params(ocfs2_filesys *fs,
+ uint32_t *block_bits,
+ uint32_t *cluster_bits,
+ uint64_t *start_block,
+ uint64_t *num_blocks)
+{
+ errcode_t ret;
+ char *filename;
+ char *buf = NULL;
+ uint64_t blkno, blocks;
+ ocfs2_dinode *di;
+ ocfs2_extent_rec *rec;
+
+ filename = ocfs2_system_inodes[HEARTBEAT_SYSTEM_INODE].si_name;
+
+ ret = ocfs2_lookup(fs, fs->fs_sysdir_blkno, filename,
+ strlen(filename), NULL, &blkno);
+ if (ret)
+ goto leave;
+
+ ret = ocfs2_malloc_block(fs->fs_io, &buf);
+ if (ret)
+ goto leave;
+
+ ret = ocfs2_read_inode(fs, blkno, buf);
+ if (ret)
+ goto leave;
+
+ di = (ocfs2_dinode *)buf;
+ if (di->id2.i_list.l_tree_depth ||
+ di->id2.i_list.l_next_free_rec != 1) {
+ ret = OCFS2_ET_BAD_HEARTBEAT_FILE;
+ goto leave;
+ }
+ rec = &(di->id2.i_list.l_recs[0]);
+
+ *block_bits = OCFS2_RAW_SB(fs->fs_super)->s_blocksize_bits;
+ *cluster_bits = OCFS2_RAW_SB(fs->fs_super)->s_clustersize_bits;
+ *start_block = rec->e_blkno;
+
+ blocks = rec->e_clusters << *cluster_bits;
+ blocks >>= *block_bits;
+ *num_blocks = blocks;
+
+leave:
+ if (buf)
+ ocfs2_free(&buf);
+ return ret;
+}
+
+errcode_t ocfs2_start_heartbeat(ocfs2_filesys *fs)
+{
+ errcode_t ret;
+ uint32_t block_bits, cluster_bits;
+ uint64_t start_block, num_blocks;
+
+ ret = ocfs2_get_heartbeat_params(fs, &block_bits, &cluster_bits,
+ &start_block, &num_blocks);
+ if (ret)
+ goto leave;
+
+ /* clamp to NM_MAX_NODES */
+ if (num_blocks > 254)
+ num_blocks = 254;
+
+ /* XXX: NULL cluster is a hack for right now */
+ ret = o2cb_create_heartbeat_region_disk(NULL,
+ fs->uuid_str,
+ fs->fs_devname,
+ 1 << block_bits,
+ start_block,
+ num_blocks);
+
+leave:
+ return ret;
+}
+
+errcode_t ocfs2_stop_heartbeat(ocfs2_filesys *fs)
+{
+ errcode_t ret;
+
+ ret = o2cb_remove_heartbeat_region_disk(NULL, fs->uuid_str);
+
+ return ret;
+}
Modified: trunk/libocfs2/include/ocfs2.h
===================================================================
--- trunk/libocfs2/include/ocfs2.h 2005-03-21 02:33:50 UTC (rev 711)
+++ trunk/libocfs2/include/ocfs2.h 2005-03-21 04:50:07 UTC (rev 712)
@@ -61,6 +61,7 @@
#endif
#include <o2dlm.h>
+#include <o2cb.h>
#define OCFS2_LIB_FEATURE_INCOMPAT_SUPP OCFS2_FEATURE_INCOMPAT_SUPP
#define OCFS2_LIB_FEATURE_RO_COMPAT_SUPP OCFS2_FEATURE_RO_COMPAT_SUPP
@@ -186,6 +187,7 @@
uint64_t fs_root_blkno;
uint64_t fs_sysdir_blkno;
uint64_t fs_first_cg_blkno;
+ char uuid_str[MAX_VOL_ID_LENGTH * 2 + 1];
/* Allocators */
ocfs2_cached_inode *fs_cluster_alloc;
@@ -537,6 +539,10 @@
errcode_t ocfs2_file_read(ocfs2_cached_inode *ci, void *buf, uint32_t count,
uint64_t offset, uint32_t *got);
+errcode_t ocfs2_start_heartbeat(ocfs2_filesys *fs);
+
+errcode_t ocfs2_stop_heartbeat(ocfs2_filesys *fs);
+
errcode_t ocfs2_lock_down_cluster(ocfs2_filesys *fs);
errcode_t ocfs2_release_cluster(ocfs2_filesys *fs);
Modified: trunk/libocfs2/ocfs2_err.et
===================================================================
--- trunk/libocfs2/ocfs2_err.et 2005-03-21 02:33:50 UTC (rev 711)
+++ trunk/libocfs2/ocfs2_err.et 2005-03-21 04:50:07 UTC (rev 712)
@@ -147,4 +147,7 @@
ec OCFS2_ET_SYMLINK_LOOP,
"Too many symbolic links encountered"
+ec OCFS2_ET_BAD_HEARTBEAT_FILE,
+ "Invalid heartbeat file"
+
end
Modified: trunk/libocfs2/openfs.c
===================================================================
--- trunk/libocfs2/openfs.c 2005-03-21 02:33:50 UTC (rev 711)
+++ trunk/libocfs2/openfs.c 2005-03-21 04:50:07 UTC (rev 712)
@@ -190,6 +190,9 @@
{
ocfs2_filesys *fs;
errcode_t ret;
+ int i, len;
+ char *ptr;
+ unsigned char *raw_uuid;
ret = ocfs2_malloc0(sizeof(ocfs2_filesys), &fs);
if (ret)
@@ -319,6 +322,18 @@
fs->fs_first_cg_blkno =
OCFS2_RAW_SB(fs->fs_super)->s_first_cluster_group;
+ raw_uuid = OCFS2_RAW_SB(fs->fs_super)->s_uuid;
+ for (i = 0, ptr = fs->uuid_str; i < MAX_VOL_ID_LENGTH; i++) {
+ /* print with null */
+ len = snprintf(ptr, 3, "%02X", raw_uuid[i]);
+ if (len != 2) {
+ ret = OCFS2_ET_INTERNAL_FAILURE;
+ goto out;
+ }
+ /* then only advace past the last char */
+ ptr += 2;
+ }
+
*ret_fs = fs;
return 0;
Modified: trunk/listuuid/Makefile
===================================================================
--- trunk/listuuid/Makefile 2005-03-21 02:33:50 UTC (rev 711)
+++ trunk/listuuid/Makefile 2005-03-21 04:50:07 UTC (rev 712)
@@ -6,7 +6,8 @@
INCLUDES = -Iinclude -I$(TOPDIR)/libocfs2/include \
-I$(TOPDIR)/libocfs2cluster/include \
- -I$(TOPDIR)/libo2dlm/include
+ -I$(TOPDIR)/libo2dlm/include \
+ -I$(TOPDIR)/libo2cb/include
LIBOCFS2_LIBS = -L$(TOPDIR)/libocfs2 -locfs2
LIBOCFS2_DEPS = $(TOPDIR)/libocfs2/libocfs2.a
@@ -14,6 +15,9 @@
LIBO2DLM_LIBS = -L$(TOPDIR)/libo2dlm -lo2dlm
LIBO2DLM_DEPS = $(TOPDIR)/libo2dlm/libo2dlm.a
+LIBO2CB_LIBS = -L$(TOPDIR)/libo2cb -lo2cb
+LIBO2CB_DEPS = $(TOPDIR)/libo2cb/libo2cb.a
+
ifdef OCFS_DEBUG
OPTS += -ggdb
else
@@ -23,7 +27,7 @@
CFLAGS := $(OPTS) -Wall -Wstrict-prototypes -Wmissing-prototypes \
-Wmissing-declarations
-DEFINES = -DOCFS2_FLAT_INCLUDES -DO2DLM_FLAT_INCLUDES
+DEFINES = -DOCFS2_FLAT_INCLUDES -DO2DLM_FLAT_INCLUDES -DO2CB_FLAT_INCLUDES
CFILES = listuuid.c
@@ -35,7 +39,7 @@
dist-subdircreate:
$(TOPDIR)/mkinstalldirs $(DIST_DIR)/include
-listuuid: $(OBJS) $(LIBOCFS2_DEPS) $(LIBO2DLM_DEPS)
+listuuid: $(OBJS) $(LIBOCFS2_DEPS) $(LIBO2DLM_DEPS) $(LIBO2CB_DEPS)
$(LINK) $(LIBOCFS2_LIBS) $(COM_ERR_LIBS) $(LIBO2DLM_LIBS)
include $(TOPDIR)/Postamble.make
Modified: trunk/mkfs.ocfs2/Makefile
===================================================================
--- trunk/mkfs.ocfs2/Makefile 2005-03-21 02:33:50 UTC (rev 711)
+++ trunk/mkfs.ocfs2/Makefile 2005-03-21 04:50:07 UTC (rev 712)
@@ -23,7 +23,7 @@
LIBO2CB_LIBS = -L$(TOPDIR)/libo2cb -lo2cb
LIBO2CB_DEPS = $(TOPDIR)/libo2cb/libo2cb.a
-LIBO2CB_CFLAGS = -I$(TOPDIR)/libo2dlm/include
+LIBO2DLM_CFLAGS = -I$(TOPDIR)/libo2dlm/include
LIBO2DLM_LIBS = -L$(TOPDIR)/libo2dlm -lo2dlm
LIBO2DLM_DEPS = $(TOPDIR)/libo2dlm/libo2dlm.a
Modified: trunk/mkfs.ocfs2/check.c
===================================================================
--- trunk/mkfs.ocfs2/check.c 2005-03-21 02:33:50 UTC (rev 711)
+++ trunk/mkfs.ocfs2/check.c 2005-03-21 04:50:07 UTC (rev 712)
@@ -37,6 +37,7 @@
initialize_ocfs_error_table();
initialize_o2dl_error_table();
+ initialize_o2cb_error_table();
ret = ocfs2_open(s->device_name, OCFS2_FLAG_RW, 0, 0, &fs);
if (ret) {
Modified: trunk/mount.ocfs2/mount.ocfs2.c
===================================================================
--- trunk/mount.ocfs2/mount.ocfs2.c 2005-03-21 02:33:50 UTC (rev 711)
+++ trunk/mount.ocfs2/mount.ocfs2.c 2005-03-21 04:50:07 UTC (rev 712)
@@ -186,6 +186,7 @@
initialize_ocfs_error_table();
initialize_o2dl_error_table();
+ initialize_o2cb_error_table();
read_options (argc, argv, &mo);
@@ -202,16 +203,16 @@
if (verbose)
printf("device=%s hbuuid=%s\n", mo.dev, hbuuid);
- ret = start_heartbeat(hbuuid, mo.dev);
+ ret = start_heartbeat(mo.dev);
if (ret < 0) {
- fprintf(stderr, "%s: Error '%d' while starting heartbeat\n",
- progname, (int)ret);
+ com_err(progname, ret, "while starting heartbeat");
goto bail;
}
ret = mount(mo.dev, mo.dir, "ocfs2", mo.flags, mo.xtra_opts);
if (ret) {
- com_err(progname, errno, "while mounting %s on %s", mo.dev, mo.dir);
+ fprintf(stderr, "error %d while mounting %s on %s", errno,
+ mo.dev, mo.dir);
goto bail;
}
Modified: trunk/mount.ocfs2/mount_hb.c
===================================================================
--- trunk/mount.ocfs2/mount_hb.c 2005-03-21 02:33:50 UTC (rev 711)
+++ trunk/mount.ocfs2/mount_hb.c 2005-03-21 04:50:07 UTC (rev 712)
@@ -37,135 +37,46 @@
#include "o2cb.h"
#include "mount_hb.h"
-int get_uuid(char *dev, char *uuid)
+errcode_t get_uuid(char *dev, char *uuid)
{
ocfs2_filesys *fs = NULL;
- errcode_t ret = 0;
- int i;
- char *p;
- uint8_t *s_uuid;
+ errcode_t ret;
ret = ocfs2_open(dev, OCFS2_FLAG_RO, 0, 0, &fs);
if (ret)
goto out;
- s_uuid = OCFS2_RAW_SB(fs->fs_super)->s_uuid;
+ strcpy(uuid, fs->uuid_str);
- for (i = 0, p = uuid; i < 16; i++, p += 2)
- sprintf(p, "%02X", s_uuid[i]);
- *p = '\0';
-
ocfs2_close(fs);
out:
return ret;
}
-static int get_ocfs2_disk_hb_params(char *group_dev, uint32_t *block_bits, uint32_t *cluster_bits,
- uint64_t *start_block, uint32_t *num_clusters)
+errcode_t start_heartbeat(char *device)
{
- int status = -EINVAL;
- errcode_t ret = 0;
- uint64_t blkno;
- char *buf = NULL;
- char *heartbeat_filename;
- ocfs2_dinode *di;
- ocfs2_extent_rec *rec;
+ errcode_t err;
ocfs2_filesys *fs = NULL;
- ret = ocfs2_open(group_dev, OCFS2_FLAG_RO, 0, 0, &fs);
- if (ret) {
- com_err(progname, ret, "while opening the device.");
- return status;
- }
+ err = ocfs2_open(device, OCFS2_FLAG_RO, 0, 0, &fs);
+ if (err)
+ goto bail;
- heartbeat_filename = ocfs2_system_inodes[HEARTBEAT_SYSTEM_INODE].si_name;
- ret = ocfs2_lookup(fs, fs->fs_sysdir_blkno, heartbeat_filename,
- strlen(heartbeat_filename), NULL, &blkno);
- if (ret) {
- com_err(progname, ret, "while looking up the hb system inode.");
- goto leave;
- }
+ err = ocfs2_start_heartbeat(fs);
- ret = ocfs2_malloc_block(fs->fs_io, &buf);
- if (ret) {
- com_err(progname, ret, "while allocating a block for hb.");
- goto leave;
- }
-
- ret = ocfs2_read_inode(fs, blkno, buf);
- if (ret) {
- com_err(progname, ret, "while reading hb inode.");
- goto leave;
- }
-
- di = (ocfs2_dinode *)buf;
- if (di->id2.i_list.l_tree_depth ||
- di->id2.i_list.l_next_free_rec != 1) {
- com_err(progname, 0, "when checking for contiguous hb.");
- goto leave;
- }
- rec = &(di->id2.i_list.l_recs[0]);
-
- *block_bits = OCFS2_RAW_SB(fs->fs_super)->s_blocksize_bits;
- *cluster_bits = OCFS2_RAW_SB(fs->fs_super)->s_clustersize_bits;
- *start_block = rec->e_blkno;
- *num_clusters = rec->e_clusters;
- status = 0;
-
-leave:
- if (buf)
- ocfs2_free(&buf);
+bail:
if (fs)
ocfs2_close(fs);
- return status;
-}
-int start_heartbeat(char *hbuuid, char *device)
-{
- int ret;
- char *cluster = NULL;
- errcode_t err;
- uint32_t block_bits, cluster_bits, num_clusters;
- uint64_t start_block, num_blocks;
-
- ret = get_ocfs2_disk_hb_params(device, &block_bits, &cluster_bits,
- &start_block, &num_clusters);
- if (ret < 0) {
- printf("hb_params failed\n");
- return ret;
- }
-
- num_blocks = num_clusters << cluster_bits;
- num_blocks >>= block_bits;
-
- /* clamp to NM_MAX_NODES */
- if (num_blocks > 254)
- num_blocks = 254;
-
- /* XXX: NULL cluster is a hack for right now */
- err = o2cb_create_heartbeat_region_disk(NULL,
- hbuuid,
- device,
- 1 << block_bits,
- start_block,
- num_blocks);
- if (err) {
- com_err(progname, err, "while creating hb region with o2cb.");
- return -EINVAL;
- }
-
- return 0;
+ return err;
}
-int stop_heartbeat(const char *hbuuid)
+errcode_t stop_heartbeat(const char *hbuuid)
{
errcode_t err;
err = o2cb_remove_heartbeat_region_disk(NULL, hbuuid);
- if (err) {
- com_err(progname, err, "while creating hb region with o2cb.");
- return -EINVAL;
- }
- return 0;
+
+ return err;
}
Modified: trunk/mount.ocfs2/mount_hb.h
===================================================================
--- trunk/mount.ocfs2/mount_hb.h 2005-03-21 02:33:50 UTC (rev 711)
+++ trunk/mount.ocfs2/mount_hb.h 2005-03-21 04:50:07 UTC (rev 712)
@@ -22,6 +22,6 @@
extern char *progname;
-int start_heartbeat(char *hbuuid, char *device);
-int stop_heartbeat(const char *hbuuid);
-int get_uuid(char *dev, char *uuid);
+errcode_t start_heartbeat(char *device);
+errcode_t stop_heartbeat(const char *hbuuid);
+errcode_t get_uuid(char *dev, char *uuid);
Modified: trunk/mount.ocfs2/ocfs2_hb_ctl.c
===================================================================
--- trunk/mount.ocfs2/ocfs2_hb_ctl.c 2005-03-21 02:33:50 UTC (rev 711)
+++ trunk/mount.ocfs2/ocfs2_hb_ctl.c 2005-03-21 04:50:07 UTC (rev 712)
@@ -18,6 +18,7 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 021110-1307, USA.
*
+ * Authors: Mark Fasheh
*/
#include "ocfs2_hb_ctl.h"
@@ -130,6 +131,7 @@
initialize_ocfs_error_table();
initialize_o2dl_error_table();
+ initialize_o2cb_error_table();
read_options(argc, argv, &hbo);
@@ -157,7 +159,7 @@
break;
case HB_ACTION_START:
- err = start_heartbeat(hbo.uuid_str, hbo.dev_str);
+ err = start_heartbeat(hbo.dev_str);
if (err) {
com_err(progname, err, "while starting heartbeat");
ret = -EINVAL;
Modified: trunk/mounted.ocfs2/Makefile
===================================================================
--- trunk/mounted.ocfs2/Makefile 2005-03-21 02:33:50 UTC (rev 711)
+++ trunk/mounted.ocfs2/Makefile 2005-03-21 04:50:07 UTC (rev 712)
@@ -11,7 +11,8 @@
OPTS = -O2
endif
-CFLAGS = $(OPTS) $(WARNINGS) -DOCFS2_FLAT_INCLUDES -DO2DLM_FLAT_INCLUDES
+CFLAGS = $(OPTS) $(WARNINGS) -DOCFS2_FLAT_INCLUDES -DO2DLM_FLAT_INCLUDES \
+ -DO2CB_FLAT_INCLUDES
LIBOCFS2_LIBS = -L$(TOPDIR)/libocfs2 -locfs2
LIBOCFS2_DEPS = $(TOPDIR)/libocfs2/libocfs2.a
@@ -19,9 +20,13 @@
LIBO2DLM_LIBS = -L$(TOPDIR)/libo2dlm -lo2dlm
LIBO2DLM_DEPS = $(TOPDIR)/libo2dlm/libo2dlm.a
+LIBO2CB_LIBS = -L$(TOPDIR)/libo2cb -lo2cb
+LIBO2CB_DEPS = $(TOPDIR)/libo2cb/libo2cb.a
+
SBIN_PROGRAMS = mounted.ocfs2
-INCLUDES = -I$(TOPDIR)/libocfs2/include -I$(TOPDIR)/libo2dlm/include
+INCLUDES = -I$(TOPDIR)/libocfs2/include -I$(TOPDIR)/libo2dlm/include \
+ -I$(TOPDIR)/libo2cb/include
CFILES = mounted.c
OBJS = $(subst .c,.o,$(CFILES))
@@ -30,7 +35,7 @@
DIST_FILES = $(CFILES) mounted.ocfs2.8.in
-mounted.ocfs2: $(OBJS) $(LIBOCFS2_DEPS) $(LIBO2DLM_DEPS)
- $(LINK) $(LIBOCFS2_LIBS) $(LIBO2DLM_LIBS) $(COM_ERR_LIBS)
+mounted.ocfs2: $(OBJS) $(LIBOCFS2_DEPS) $(LIBO2DLM_DEPS) $(LIBO2CB_DEPS)
+ $(LINK) $(LIBOCFS2_LIBS) $(LIBO2DLM_LIBS) $(LIBO2CB_LIBS) $(COM_ERR_LIBS)
include $(TOPDIR)/Postamble.make
Modified: trunk/mounted.ocfs2/mounted.c
===================================================================
--- trunk/mounted.ocfs2/mounted.c 2005-03-21 02:33:50 UTC (rev 711)
+++ trunk/mounted.ocfs2/mounted.c 2005-03-21 04:50:07 UTC (rev 712)
@@ -263,6 +263,7 @@
initialize_ocfs_error_table();
initialize_o2dl_error_table();
+ initialize_o2cb_error_table();
ret = read_options(argc, argv);
if (ret)
Modified: trunk/ocfs2console/ocfs2interface/Makefile
===================================================================
--- trunk/ocfs2console/ocfs2interface/Makefile 2005-03-21 02:33:50 UTC (rev 711)
+++ trunk/ocfs2console/ocfs2interface/Makefile 2005-03-21 04:50:07 UTC (rev 712)
@@ -19,6 +19,10 @@
LIBO2DLM_LIBS = -L$(TOPDIR)/libo2dlm -lo2dlm
LIBO2DLM_DEPS = $(TOPDIR)/libo2dlm/libo2dlm.a
+LIBO2CB_CFLAGS = -I$(TOPDIR)/libo2cb/include
+LIBO2CB_LIBS = -L$(TOPDIR)/libo2cb -lo2cb
+LIBO2CB_DEPS = $(TOPDIR)/libo2cb/libo2cb.a
+
ifdef HAVE_BLKID
BLKID_DEPS =
else
@@ -28,8 +32,8 @@
BLKID_LIBS = -L$(TOPDIR)/ocfs2console/blkid -lblkid-internal -luuid
endif
-DEFINES = -DOCFS2_FLAT_INCLUDES -DO2DLM_FLAT_INCLUDES -DG_DISABLE_DEPRECATED
-INCLUDES = $(LIBOCFS2_CFLAGS) $(LIBO2DLM_CFLAGS) $(BLKID_CFLAGS) $(PYTHON_INCLUDES) $(GLIB_CFLAGS)
+DEFINES = -DOCFS2_FLAT_INCLUDES -DO2DLM_FLAT_INCLUDES -DO2CB_FLAT_INCLUDES -DG_DISABLE_DEPRECATED
+INCLUDES = $(LIBOCFS2_CFLAGS) $(LIBO2DLM_CFLAGS) $(LIBO2CB_CFLAGS) $(BLKID_CFLAGS) $(PYTHON_INCLUDES) $(GLIB_CFLAGS)
OPTIMIZE = -O2
OPTIMIZE = -O0
@@ -71,8 +75,8 @@
DIST_FILES = $(CFILES) $(HFILES) $(PYSRC)
-ocfs2module.so: $(OBJS) $(LIBOCFS2_DEPS) $(LIBO2DLM_DEPS) $(BLKID_DEPS)
- $(LINK) -shared $(LIBOCFS2_LIBS) $(LIBO2DLM_LIBS) $(BLKID_LIBS) $(COM_ERR_LIBS) $(GLIB_LIBS)
+ocfs2module.so: $(OBJS) $(LIBOCFS2_DEPS) $(LIBO2DLM_DEPS) $(LIBO2CB_DEPS) $(BLKID_DEPS)
+ $(LINK) -shared $(LIBOCFS2_LIBS) $(LIBO2DLM_LIBS) $(LIBO2CB_LIBS) $(BLKID_LIBS) $(COM_ERR_LIBS) $(GLIB_LIBS)
install-pylib:
$(SHELL) $(TOPDIR)/mkinstalldirs $(DESTDIR)$(pyexecdir)/ocfs2interface
Modified: trunk/sizetest/Makefile
===================================================================
--- trunk/sizetest/Makefile 2005-03-21 02:33:50 UTC (rev 711)
+++ trunk/sizetest/Makefile 2005-03-21 04:50:07 UTC (rev 712)
@@ -15,8 +15,8 @@
SBIN_PROGRAMS = sizetest.ocfs2
-INCLUDES = -I$(TOPDIR)/libocfs2/include -I$(TOPDIR)/libo2dlm/include
-DEFINES = -DOCFS2_FLAT_INCLUDES -DVERSION=\"$(VERSION)\" -DO2DLM_FLAT_INCLUDES
+INCLUDES = -I$(TOPDIR)/libocfs2/include -I$(TOPDIR)/libo2dlm/include -I$(TOPDIR)/libo2cb/include
+DEFINES = -DOCFS2_FLAT_INCLUDES -DVERSION=\"$(VERSION)\" -DO2DLM_FLAT_INCLUDES -DO2CB_FLAT_INCLUDES
CFILES = sizetest.c
OBJS = $(subst .c,.o,$(CFILES))
Modified: trunk/tunefs.ocfs2/Makefile
===================================================================
--- trunk/tunefs.ocfs2/Makefile 2005-03-21 02:33:50 UTC (rev 711)
+++ trunk/tunefs.ocfs2/Makefile 2005-03-21 04:50:07 UTC (rev 712)
@@ -19,10 +19,13 @@
LIBO2DLM_LIBS = -L$(TOPDIR)/libo2dlm -lo2dlm
LIBO2DLM_DEPS = $(TOPDIR)/libo2dlm/libo2dlm.a
+LIBO2CB_LIBS = -L$(TOPDIR)/libo2cb -lo2cb
+LIBO2CB_DEPS = $(TOPDIR)/libo2cb/libo2cb.a
+
SBIN_PROGRAMS = tunefs.ocfs2
-INCLUDES = -I$(TOPDIR)/libocfs2/include $(GLIB_CFLAGS) -I$(TOPDIR)/libo2dlm/include
-DEFINES = -DOCFS2_FLAT_INCLUDES -DVERSION=\"$(VERSION)\" -DO2DLM_FLAT_INCLUDES
+INCLUDES = -I$(TOPDIR)/libocfs2/include $(GLIB_CFLAGS) -I$(TOPDIR)/libo2dlm/include -I$(TOPDIR)/libo2cb/include
+DEFINES = -DOCFS2_FLAT_INCLUDES -DVERSION=\"$(VERSION)\" -DO2DLM_FLAT_INCLUDES -DO2CB_FLAT_INCLUDES
MANS = tunefs.ocfs2.8
@@ -31,7 +34,7 @@
DIST_FILES = $(CFILES) tunefs.ocfs2.8.in
-tunefs.ocfs2: $(OBJS) $(LIBOCFS2_DEPS) $(LIBO2DLM_DEPS)
- $(LINK) $(LIBOCFS2_LIBS) $(LIBO2DLM_LIBS) $(GLIB_LIBS) $(COM_ERR_LIBS)
+tunefs.ocfs2: $(OBJS) $(LIBOCFS2_DEPS) $(LIBO2DLM_DEPS) $(LIBO2CB_DEPS)
+ $(LINK) $(LIBOCFS2_LIBS) $(LIBO2DLM_LIBS) $(LIBO2CB_LIBS) $(GLIB_LIBS) $(COM_ERR_LIBS)
include $(TOPDIR)/Postamble.make
Modified: trunk/tunefs.ocfs2/tunefs.c
===================================================================
--- trunk/tunefs.ocfs2/tunefs.c 2005-03-21 02:33:50 UTC (rev 711)
+++ trunk/tunefs.ocfs2/tunefs.c 2005-03-21 04:50:07 UTC (rev 712)
@@ -553,6 +553,7 @@
initialize_ocfs_error_table();
initialize_o2dl_error_table();
+ initialize_o2cb_error_table();
setbuf(stdout, NULL);
setbuf(stderr, NULL);
More information about the Ocfs2-tools-commits
mailing list