[Ocfs2-tools-commits] jlbec commits r951 - in trunk: debian
debugfs.ocfs2 libocfs2 libocfs2/include mkfs.ocfs2
ocfs2_hb_ctl vendor/common
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Thu Jun 16 11:07:25 CDT 2005
Author: jlbec
Date: 2005-06-16 11:07:23 -0500 (Thu, 16 Jun 2005)
New Revision: 951
Modified:
trunk/debian/rules
trunk/debugfs.ocfs2/commands.c
trunk/libocfs2/include/ocfs2.h
trunk/libocfs2/include/ocfs2_fs.h
trunk/libocfs2/openfs.c
trunk/mkfs.ocfs2/mkfs.c
trunk/mkfs.ocfs2/mkfs.h
trunk/ocfs2_hb_ctl/ocfs2_hb_ctl.c
trunk/vendor/common/o2cb.init
Log:
o Add OCFS2_FEATURE_INCOMPAT_HEARTBEAT_DEV to the headers.
o Teach mkfs.ocfs2 how to create a heartbeat device. This includes
minimum sizing and ignoring irrelevant system inodes.
o Teach debugfs.ocfs2 to open heartbeat devices.
o Teach ocfs2_hb_ctl that heartbeat devices are OK.
Modified: trunk/debian/rules
===================================================================
--- trunk/debian/rules 2005-06-15 04:09:40 UTC (rev 950)
+++ trunk/debian/rules 2005-06-16 16:07:23 UTC (rev 951)
@@ -15,7 +15,7 @@
build-stamp:
dh_testdir
- ./configure --disable-debug --prefix=/usr --mandir=/usr/share/man
+ ./configure --disable-debug --enable-dynamic-ctl --enable-dynamic-fsck --prefix=/usr --mandir=/usr/share/man
$(MAKE)
touch build-stamp
Modified: trunk/debugfs.ocfs2/commands.c
===================================================================
--- trunk/debugfs.ocfs2/commands.c 2005-06-15 04:09:40 UTC (rev 950)
+++ trunk/debugfs.ocfs2/commands.c 2005-06-16 16:07:23 UTC (rev 951)
@@ -396,6 +396,7 @@
}
flags = gbls.allow_write ? OCFS2_FLAG_RW : OCFS2_FLAG_RO;
+ flags |= OCFS2_FLAG_HEARTBEAT_DEV_OK;
ret = ocfs2_open(dev, flags, 0, 0, &gbls.fs);
if (ret) {
gbls.fs = NULL;
Modified: trunk/libocfs2/include/ocfs2.h
===================================================================
--- trunk/libocfs2/include/ocfs2.h 2005-06-15 04:09:40 UTC (rev 950)
+++ trunk/libocfs2/include/ocfs2.h 2005-06-16 16:07:23 UTC (rev 951)
@@ -63,19 +63,20 @@
#include <o2dlm.h>
#include <o2cb.h>
-#define OCFS2_LIB_FEATURE_INCOMPAT_SUPP OCFS2_FEATURE_INCOMPAT_SUPP
+#define OCFS2_LIB_FEATURE_INCOMPAT_SUPP (OCFS2_FEATURE_INCOMPAT_SUPP | OCFS2_FEATURE_INCOMPAT_HEARTBEAT_DEV)
#define OCFS2_LIB_FEATURE_RO_COMPAT_SUPP OCFS2_FEATURE_RO_COMPAT_SUPP
/* Flags for the ocfs2_filesys structure */
-#define OCFS2_FLAG_RO 0x00
-#define OCFS2_FLAG_RW 0x01
-#define OCFS2_FLAG_CHANGED 0x02
-#define OCFS2_FLAG_DIRTY 0x04
-#define OCFS2_FLAG_SWAP_BYTES 0x08
-#define OCFS2_FLAG_BUFFERED 0x10
-#define OCFS2_FLAG_NO_REV_CHECK 0x20 /* Do not check the OCFS
- vol_header structure for
- revision info */
+#define OCFS2_FLAG_RO 0x00
+#define OCFS2_FLAG_RW 0x01
+#define OCFS2_FLAG_CHANGED 0x02
+#define OCFS2_FLAG_DIRTY 0x04
+#define OCFS2_FLAG_SWAP_BYTES 0x08
+#define OCFS2_FLAG_BUFFERED 0x10
+#define OCFS2_FLAG_NO_REV_CHECK 0x20 /* Do not check the OCFS
+ vol_header structure
+ for revision info */
+#define OCFS2_FLAG_HEARTBEAT_DEV_OK 0x40
/* Return flags for the extent iterator functions */
#define OCFS2_EXTENT_CHANGED 0x01
Modified: trunk/libocfs2/include/ocfs2_fs.h
===================================================================
--- trunk/libocfs2/include/ocfs2_fs.h 2005-06-15 04:09:40 UTC (rev 950)
+++ trunk/libocfs2/include/ocfs2_fs.h 2005-06-16 16:07:23 UTC (rev 951)
@@ -100,7 +100,14 @@
#define OCFS2_FEATURE_INCOMPAT_SUPP 0
#endif
+/*
+ * Heartbeat-only devices are missing journals and other files. The
+ * filesystem driver can't load them, but the library can. Never put
+ * this in OCFS2_FEATURE_INCOMPAT_SUPP, *ever*.
+ */
+#define OCFS2_FEATURE_INCOMPAT_HEARTBEAT_DEV 0x0002
+
/*
* Flags on ocfs2_dinode.i_flags
*/
@@ -619,7 +626,7 @@
/*
* Global system inodes can only have one copy. Everything
- * after OCFS_LAST_GLOBAL_SYSTEM_INODE in the system inode
+ * after OCFS2_LAST_GLOBAL_SYSTEM_INODE in the system inode
* list has a copy per slot.
*/
if (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE)
Modified: trunk/libocfs2/openfs.c
===================================================================
--- trunk/libocfs2/openfs.c 2005-06-15 04:09:40 UTC (rev 950)
+++ trunk/libocfs2/openfs.c 2005-06-16 16:07:23 UTC (rev 951)
@@ -276,6 +276,12 @@
~OCFS2_LIB_FEATURE_RO_COMPAT_SUPP))
goto out;
+ ret = OCFS2_ET_UNSUPP_FEATURE;
+ if (!(flags & OCFS2_FLAG_HEARTBEAT_DEV_OK) &&
+ (OCFS2_RAW_SB(fs->fs_super)->s_feature_incompat &
+ OCFS2_FEATURE_INCOMPAT_HEARTBEAT_DEV))
+ goto out;
+
ret = OCFS2_ET_CORRUPT_SUPERBLOCK;
if (!OCFS2_RAW_SB(fs->fs_super)->s_blocksize_bits)
goto out;
Modified: trunk/mkfs.ocfs2/mkfs.c
===================================================================
--- trunk/mkfs.ocfs2/mkfs.c 2005-06-15 04:09:40 UTC (rev 950)
+++ trunk/mkfs.ocfs2/mkfs.c 2005-06-16 16:07:23 UTC (rev 951)
@@ -129,6 +129,26 @@
return ;
}
+/* Is this something to skip for heartbeat-only devices */
+static int hb_dev_skip(State *s, int system_inode)
+{
+ int ret = 0;
+
+ if (s->hb_dev) {
+ switch (system_inode) {
+ case GLOBAL_BITMAP_SYSTEM_INODE:
+ case GLOBAL_INODE_ALLOC_SYSTEM_INODE:
+ case HEARTBEAT_SYSTEM_INODE:
+ break;
+
+ default:
+ ret = 1;
+ }
+ }
+
+ return ret;
+}
+
int
main(int argc, char **argv)
{
@@ -286,8 +306,10 @@
add_entry_to_directory(s, system_dir, "..", system_dir_rec.fe_off, OCFS2_FT_DIR);
for (i = 0; i < NUM_SYSTEM_INODES; i++) {
+ if (hb_dev_skip(s, i))
+ continue;
+
num = (system_files[i].global) ? 1 : s->initial_slots;
-
for (j = 0; j < num; j++) {
record[i][j].fe_off = alloc_inode(s, &(record[i][j].suballoc_bit));
sprintf(fname, system_files[i].name, j);
@@ -310,17 +332,29 @@
alloc_bytes_from_bitmap(s, need, s->global_bm, &tmprec->extent_off, &tmprec->extent_len);
tmprec->file_size = need;
- for (i = 0; i < s->initial_slots; ++i) {
- tmprec = &record[ORPHAN_DIR_SYSTEM_INODE][i];
- orphan_dir[i]->record = tmprec;
- alloc_from_bitmap(s, 1, s->global_bm, &tmprec->extent_off, &tmprec->extent_len);
- add_entry_to_directory(s, orphan_dir[i], ".", tmprec->fe_off, OCFS2_FT_DIR);
- add_entry_to_directory(s, orphan_dir[i], "..", system_dir_rec.fe_off, OCFS2_FT_DIR);
+ if (!hb_dev_skip(s, ORPHAN_DIR_SYSTEM_INODE)) {
+ for (i = 0; i < s->initial_slots; ++i) {
+ tmprec = &record[ORPHAN_DIR_SYSTEM_INODE][i];
+ orphan_dir[i]->record = tmprec;
+ alloc_from_bitmap(s, 1, s->global_bm,
+ &tmprec->extent_off,
+ &tmprec->extent_len);
+ add_entry_to_directory(s, orphan_dir[i], ".",
+ tmprec->fe_off,
+ OCFS2_FT_DIR);
+ add_entry_to_directory(s, orphan_dir[i], "..",
+ system_dir_rec.fe_off,
+ OCFS2_FT_DIR);
+ }
}
- tmprec = &(record[SLOT_MAP_SYSTEM_INODE][0]);
- alloc_from_bitmap(s, 1, s->global_bm, &tmprec->extent_off, &tmprec->extent_len);
- tmprec->file_size = s->cluster_size;
+ if (!hb_dev_skip(s, SLOT_MAP_SYSTEM_INODE)) {
+ tmprec = &(record[SLOT_MAP_SYSTEM_INODE][0]);
+ alloc_from_bitmap(s, 1, s->global_bm,
+ &tmprec->extent_off,
+ &tmprec->extent_len);
+ tmprec->file_size = s->cluster_size;
+ }
fsync(s->fd);
if (!s->quiet)
@@ -333,9 +367,13 @@
format_file(s, &system_dir_rec);
for (i = 0; i < NUM_SYSTEM_INODES; i++) {
+ if (hb_dev_skip(s, i))
+ continue;
+
num = system_files[i].global ? 1 : s->initial_slots;
for (j = 0; j < num; j++) {
tmprec = &(record[i][j]);
+
if (system_files[i].type == SFI_JOURNAL) {
alloc_bytes_from_bitmap(s, s->journal_size_in_bytes,
s->global_bm,
@@ -359,13 +397,18 @@
write_group_data(s, s->system_group);
- tmprec = &(record[SLOT_MAP_SYSTEM_INODE][0]);
- write_slot_map_data(s, tmprec);
+ if (!hb_dev_skip(s, SLOT_MAP_SYSTEM_INODE)) {
+ tmprec = &(record[SLOT_MAP_SYSTEM_INODE][0]);
+ write_slot_map_data(s, tmprec);
+ }
write_directory_data(s, root_dir);
write_directory_data(s, system_dir);
- for (i = 0; i < s->initial_slots; ++i)
- write_directory_data(s, orphan_dir[i]);
+
+ if (!hb_dev_skip(s, ORPHAN_DIR_SYSTEM_INODE)) {
+ for (i = 0; i < s->initial_slots; ++i)
+ write_directory_data(s, orphan_dir[i]);
+ }
tmprec = &(record[HEARTBEAT_SYSTEM_INODE][0]);
write_metadata(s, tmprec, NULL);
@@ -385,13 +428,15 @@
if (!s->quiet)
printf("done\n");
- if (!s->quiet)
- printf("Writing lost+found: ");
+ if (!s->hb_dev) {
+ if (!s->quiet)
+ printf("Writing lost+found: ");
- create_lost_found_dir(s);
+ create_lost_found_dir(s);
- if (!s->quiet)
- printf("done\n");
+ if (!s->quiet)
+ printf("done\n");
+ }
close_device(s);
@@ -412,7 +457,7 @@
char *dummy;
State *s;
int c;
- int verbose = 0, quiet = 0, force = 0, xtool = 0;
+ int verbose = 0, quiet = 0, force = 0, xtool = 0, hb_dev = 0;
int show_version = 0;
char *device_name;
int ret;
@@ -428,6 +473,7 @@
{ "quiet", 0, 0, 'q' },
{ "version", 0, 0, 'V' },
{ "journal-options", 0, 0, 'J'},
+ { "heartbeat-device", 0, 0, 'H'},
{ "force", 0, 0, 'F'},
{ 0, 0, 0, 0}
};
@@ -438,7 +484,7 @@
progname = strdup("mkfs.ocfs2");
while (1) {
- c = getopt_long(argc, argv, "b:C:L:N:J:vqVFx", long_options,
+ c = getopt_long(argc, argv, "b:C:L:N:J:vqVFHx", long_options,
NULL);
if (c == -1)
@@ -517,6 +563,10 @@
&journal_size_in_bytes);
break;
+ case 'H':
+ hb_dev = 1;
+ break;
+
case 'v':
verbose = 1;
break;
@@ -595,6 +645,8 @@
s->journal_size_in_bytes = journal_size_in_bytes;
+ s->hb_dev = hb_dev;
+
return s;
}
@@ -709,7 +761,7 @@
{
fprintf(stderr, "Usage: %s [-b block-size] [-C cluster-size] "
"[-N number-of-node-slots]\n"
- "\t[-L volume-label] [-J journal-options] [-FqvV] "
+ "\t[-L volume-label] [-J journal-options] [-HFqvV] "
"device [blocks-count]\n",
progname);
exit(0);
@@ -726,6 +778,9 @@
{
unsigned int j_blocks;
+ if (s->hb_dev)
+ return 0;
+
if (s->volume_size_in_blocks < 2048) {
fprintf(stderr, "Filesystem too small for a journal\n");
exit(1);
@@ -777,7 +832,13 @@
s->device_name);
exit(1);
}
+ if (!sectsize)
+ sectsize = OCFS2_MIN_BLOCKSIZE;
+ /* Heartbeat devices use the minimum size, unless specified */
+ if (!s->blocksize && s->hb_dev)
+ s->blocksize = sectsize;
+
if (s->blocksize)
blocksize = s->blocksize;
else
@@ -799,7 +860,31 @@
s->device_name);
exit(1);
}
+
+ if (s->hb_dev) {
+ uint64_t dev_size = 0;
+ /* Blocks for system dir, root dir,
+ * global allocator*/
+ dev_size = 4;
+ /* Blocks for hb region */
+ dev_size += OCFS2_MAX_SLOTS;
+ /* Slop for superblock + cluster bitmap */
+ dev_size += 10;
+
+ /* Convert to bytes */
+ dev_size *= blocksize;
+
+ /* Convert to megabytes */
+ dev_size = (dev_size + (1024 * 1024) - 1) >> ONE_MB_SHIFT;
+ dev_size <<= ONE_MB_SHIFT;
+
+ dev_size /= blocksize;
+
+ if (ret > dev_size)
+ ret = dev_size;
+ }
+
s->volume_size_in_blocks = ret;
if (s->specified_size_in_blocks) {
if (s->specified_size_in_blocks >
@@ -1456,6 +1541,7 @@
SystemFileDiskRecord *root_rec, SystemFileDiskRecord *sys_rec)
{
ocfs2_dinode *di;
+ uint32_t incompat;
uint64_t super_off = rec->fe_off;
di = do_malloc(s, s->blocksize);
@@ -1489,11 +1575,15 @@
di->id2.i_super.s_max_slots = cpu_to_le16(s->initial_slots);
di->id2.i_super.s_first_cluster_group = cpu_to_le64(s->first_cluster_group_blkno);
+ incompat = 0;
#ifdef CONFIG_ARCH_S390
- di->id2.i_super.s_feature_incompat =
- cpu_to_le32(OCFS2_FEATURE_INCOMPAT_B0RKEN_ENDIAN);
+ incompat |= OCFS2_FEATURE_INCOMPAT_BORKEN_ENDIAN;
#endif
+ if (s->hb_dev)
+ incompat |= OCFS2_FEATURE_INCOMPAT_HEARTBEAT_DEV;
+ di->id2.i_super.s_feature_incompat = cpu_to_le32(incompat);
+
strcpy(di->id2.i_super.s_label, s->vol_label);
memcpy(di->id2.i_super.s_uuid, s->uuid, 16);
@@ -1901,10 +1991,14 @@
printf("Volume size=%"PRIu64" (%u clusters) (%"PRIu64" blocks)\n",
s->volume_size_in_bytes, s->volume_size_in_clusters,
s->volume_size_in_blocks);
- printf("Journal size=%"PRIu64"\n", s->journal_size_in_bytes);
printf("%u cluster groups (tail covers %u clusters, rest cover %u "
"clusters)\n", s->nr_cluster_groups, s->tail_group_bits,
s->global_cpg);
+ if (s->hb_dev)
+ printf("Heartbeat device\n");
+ else
+ printf("Journal size=%"PRIu64"\n",
+ s->journal_size_in_bytes);
printf("Initial number of node slots: %u\n", s->initial_slots);
}
Modified: trunk/mkfs.ocfs2/mkfs.h
===================================================================
--- trunk/mkfs.ocfs2/mkfs.h 2005-06-15 04:09:40 UTC (rev 950)
+++ trunk/mkfs.ocfs2/mkfs.h 2005-06-16 16:07:23 UTC (rev 951)
@@ -194,6 +194,7 @@
int quiet;
int force;
int prompt;
+ int hb_dev;
uint32_t blocksize;
uint32_t blocksize_bits;
Modified: trunk/ocfs2_hb_ctl/ocfs2_hb_ctl.c
===================================================================
--- trunk/ocfs2_hb_ctl/ocfs2_hb_ctl.c 2005-06-15 04:09:40 UTC (rev 950)
+++ trunk/ocfs2_hb_ctl/ocfs2_hb_ctl.c 2005-06-16 16:07:23 UTC (rev 951)
@@ -43,7 +43,9 @@
ocfs2_filesys *fs = NULL;
errcode_t ret;
- ret = ocfs2_open(dev, OCFS2_FLAG_RO, 0, 0, &fs);
+ ret = ocfs2_open(dev,
+ OCFS2_FLAG_RO | OCFS2_FLAG_HEARTBEAT_DEV_OK,
+ 0, 0, &fs);
if (ret)
goto out;
Modified: trunk/vendor/common/o2cb.init
===================================================================
--- trunk/vendor/common/o2cb.init 2005-06-15 04:09:40 UTC (rev 950)
+++ trunk/vendor/common/o2cb.init 2005-06-16 16:07:23 UTC (rev 951)
@@ -704,6 +704,11 @@
start
;;
+ force-reload)
+ stop
+ start
+ ;;
+
load)
load
;;
@@ -747,7 +752,7 @@
;;
*)
- echo "Usage: $0 {start|stop|restart|enable|disable|configure|load|unload|online|offline|status}"
+ echo "Usage: $0 {start|stop|restart|force-reload|enable|disable|configure|load|unload|online|offline|status}"
exit 1
;;
esac
More information about the Ocfs2-tools-commits
mailing list