[Ocfs2-tools-commits] zab commits r653 - in branches/usysfsify: mkfs.ocfs2 mount.ocfs2

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Thu Mar 17 17:42:57 CST 2005


Author: zab
Date: 2005-03-17 17:42:55 -0600 (Thu, 17 Mar 2005)
New Revision: 653

Modified:
   branches/usysfsify/mkfs.ocfs2/Makefile
   branches/usysfsify/mount.ocfs2/Makefile
   branches/usysfsify/mount.ocfs2/mount.ocfs2.c
Log:
o teach mount to bring up the hb region using o2cb


Modified: branches/usysfsify/mkfs.ocfs2/Makefile
===================================================================
--- branches/usysfsify/mkfs.ocfs2/Makefile	2005-03-17 19:40:29 UTC (rev 652)
+++ branches/usysfsify/mkfs.ocfs2/Makefile	2005-03-17 23:42:55 UTC (rev 653)
@@ -19,9 +19,14 @@
 LIBOCFS2_LIBS = -L$(TOPDIR)/libocfs2 -locfs2
 LIBOCFS2_DEPS = $(TOPDIR)/libocfs2/libocfs2.a
 
-INCLUDES = $(LIBOCFS2_CFLAGS) -I. -I$(TOPDIR)/libo2dlm/include
-DEFINES = -DOCFS2_FLAT_INCLUDES -DVERSION=\"$(VERSION)\" -DO2DLM_FLAT_INCLUDES
+LIBO2CB_CFLAGS = -I$(TOPDIR)/libo2cb/include
+LIBO2CB_LIBS = -L$(TOPDIR)/libo2cb -lo2cb
+LIBO2CB_DEPS = $(TOPDIR)/libo2cb/libo2cb.a
 
+INCLUDES = $(LIBOCFS2_CFLAGS) $(LIBO2CB_CFLAGS) -I. -I$(TOPDIR)/libo2dlm/include
+DEFINES = -DOCFS2_FLAT_INCLUDES -DVERSION=\"$(VERSION)\" \
+	-DO2DLM_FLAT_INCLUDES -DO2CB_FLAT_INCLUDES
+
 CFILES = mkfs.c
 OBJS = $(subst .c,.o,$(CFILES))
 
@@ -29,7 +34,7 @@
 
 DIST_FILES = $(CFILES) mkfs.ocfs2.8.in
 
-mkfs.ocfs2: $(OBJS) $(LIBOCFS2_DEPS)
-	$(LINK) $(LIBOCFS2_LIBS) $(COM_ERR_LIBS)
+mkfs.ocfs2: $(OBJS) $(LIBOCFS2_DEPS) $(LIBO2CB_DEPS)
+	$(LINK) $(LIBOCFS2_LIBS) $(LIBO2CB_LIBS) $(COM_ERR_LIBS)
 
 include $(TOPDIR)/Postamble.make

Modified: branches/usysfsify/mount.ocfs2/Makefile
===================================================================
--- branches/usysfsify/mount.ocfs2/Makefile	2005-03-17 19:40:29 UTC (rev 652)
+++ branches/usysfsify/mount.ocfs2/Makefile	2005-03-17 23:42:55 UTC (rev 653)
@@ -10,6 +10,8 @@
 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
@@ -20,7 +22,8 @@
 CFLAGS := $(OPTS) -Wall -Wstrict-prototypes -Wmissing-prototypes \
            -Wmissing-declarations
 
-DEFINES = -DOCFS2_FLAT_INCLUDES -DO2DLM_FLAT_INCLUDES -DVERSION=\"$(VERSION)\"
+DEFINES = -DOCFS2_FLAT_INCLUDES -DO2DLM_FLAT_INCLUDES \
+		-DO2CB_FLAT_INCLUDES -DVERSION=\"$(VERSION)\"
 
 CFILES = opts.c mount.ocfs2.c
 CFILES += fstab.c mntent.c realpath.c sundries.c xmalloc.c
@@ -32,8 +35,8 @@
 
 DIST_FILES = $(CFILES) $(HFILES)
 
-mount.ocfs2: $(OBJS) $(LIBOCFS2_DEPS) $(LIBO2DLM_DEPS)
-	$(LINK) $(LIBOCFS2_LIBS) $(LIBO2DLM_LIBS) $(COM_ERR_LIBS)
+mount.ocfs2: $(OBJS) $(LIBOCFS2_DEPS) $(LIBO2DLM_DEPS) $(LIBO2CB_DEPS)
+	$(LINK) $(LIBOCFS2_LIBS) $(LIBO2DLM_LIBS) $(LIBO2CB_LIBS) $(COM_ERR_LIBS)
 
 group: group.o $(LIBOCFS2_DEPS)
 	$(LINK) $(LIBOCFS2_LIBS) $(COM_ERR_LIBS)

Modified: branches/usysfsify/mount.ocfs2/mount.ocfs2.c
===================================================================
--- branches/usysfsify/mount.ocfs2/mount.ocfs2.c	2005-03-17 19:40:29 UTC (rev 652)
+++ branches/usysfsify/mount.ocfs2/mount.ocfs2.c	2005-03-17 23:42:55 UTC (rev 653)
@@ -21,6 +21,7 @@
  */
 
 #include "mount.ocfs2.h"
+#include "o2cb.h"
 
 int verbose = 0;
 int mount_quiet = 0;
@@ -387,25 +388,35 @@
 	ocfs2_filesys *fs = NULL;
 
 	ret = ocfs2_open(group_dev, OCFS2_FLAG_RO, 0, 0, &fs);
-	if (ret)
+	if (ret) {
+		com_err(progname, ret, "while opening the device.");
 		return status;
+	}
 
 	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)
+	if (ret) {
+		com_err(progname, ret, "while looking up the hb system inode.");
 		goto leave;
+	}
+
 	ret = ocfs2_malloc_block(fs->fs_io, &buf);
-	if (ret)
+	if (ret) {
+		com_err(progname, ret, "while allocating a block for hb.");
 		goto leave;
+	}
 	
 	ret = ocfs2_read_inode(fs, blkno, buf);
-	if (ret)
+	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]);
@@ -665,13 +676,40 @@
 #endif
 }
 
-/*
- * this will try to add the group (and the node to the group)
- * for every mount.  luckily, there are many shortcut paths
- * along the way, so checking for -EEXIST will save time.
- */
-static int add_me_to_group(char *groupname, char *groupdev)
+static int start_heartbeat(char *hbuuid, char *device)
 {
+	int ret;
+	char *cluster = "ks";
+	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;
+
+	err = o2cb_create_heartbeat_region_disk(cluster,
+						hbuuid,
+						device,
+						1 << block_bits,
+						start_block,
+						num_blocks);
+	if (err) {
+		com_err(progname, err, "while creating hb region with o2cb.");
+		return -EINVAL;
+	}
+
 #if 0
 	int ret;
 	uint8_t my_nodenum, groupnum;
@@ -825,9 +863,6 @@
 	initialize_ocfs_error_table();
 	initialize_o2dl_error_table();
 
-        fprintf(stderr, "mount.ocfs2 no workie!\n");
-        return EIO;
-
 	read_options (argc, argv, &mo);
 
 	ret = process_options(&mo);
@@ -843,25 +878,13 @@
 	if (verbose)
 		printf("device=%s hbuuid=%s\n", mo.dev, hbuuid);
 
-	ret = add_me_to_group(hbuuid, mo.dev);
+	ret = start_heartbeat(hbuuid, mo.dev);
 	if (ret < 0) {
-		fprintf(stderr, "%s: Error '%d' while adding to group\n", progname, (int)ret);
+		fprintf(stderr, "%s: Error '%d' while starting heartbeat\n",
+			progname, (int)ret);
 		goto bail;
 	}
 
-	mo.xtra_opts = realloc(mo.xtra_opts, (strlen(mo.xtra_opts) +
-					      strlen(hbuuid) +
-					      strlen("group=") + 1));
-	if (!mo.xtra_opts) {
-		com_err(progname, OCFS2_ET_NO_MEMORY, " ");
-		goto bail;
-	}
-
-	if (strlen(mo.xtra_opts))
-		strcat(mo.xtra_opts, ",");
-	strcat(mo.xtra_opts, "group=");
-	strcat(mo.xtra_opts, hbuuid);
-
 	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);



More information about the Ocfs2-tools-commits mailing list