[Ocfs-tools-commits] smushran commits r46 - in trunk/format: . inc
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Thu Jun 3 18:16:51 CDT 2004
Author: smushran
Date: 2004-06-03 17:16:48 -0500 (Thu, 03 Jun 2004)
New Revision: 46
Modified:
trunk/format/
trunk/format/Cscope.make
trunk/format/format.c
trunk/format/inc/format.h
trunk/format/tune.c
Log:
in format new autoconf hdr filled
tuneocfs supports updating diskhb and hbtimeo
Property changes on: trunk/format
___________________________________________________________________
Name: svn:ignore
- cscope.files
cscope.out
stamp-md5
mounted.ocfs
mkfs.ocfs
mkfs.ocfs.8
tuneocfs
tuneocfs.8
+ cscope.*
stamp-md5
mounted.ocfs
mkfs.ocfs
mkfs.ocfs.8
tuneocfs
tuneocfs.8
Modified: trunk/format/Cscope.make
===================================================================
--- trunk/format/Cscope.make 2004-06-02 20:09:22 UTC (rev 45)
+++ trunk/format/Cscope.make 2004-06-03 22:16:48 UTC (rev 46)
@@ -2,13 +2,8 @@
cscope:
rm -f cscope.*
echo "-k" >> cscope.files
- echo "-I $(TOPDIR)/ocfs2/Common/inc" >> cscope.files
echo "-I inc" >> cscope.files
find . -maxdepth 2 -name '*.c' -print >>cscope.files
find . -maxdepth 2 -name '*.h' -print >>cscope.files
- find ../libocfs -maxdepth 2 -name '*.h' -print >>cscope.files
- find ../../ocfs2/Common -maxdepth 2 -name ocfsheartbeat\* -print >>cscope.files
- find $(TOPDIR)/ocfs2/Common/inc -maxdepth 2 -name 'ocfscom.h' -print >>cscope.files
- find $(TOPDIR)/ocfs2/Common/inc -maxdepth 2 -name 'ocfsvol.h' -print >>cscope.files
- find $(TOPDIR)/ocfs2/Common/inc -maxdepth 2 -name 'ocfstrace.h' -print >>cscope.files
+ find ../libocfs -name '*.h' -print >>cscope.files
cscope -b
Modified: trunk/format/format.c
===================================================================
--- trunk/format/format.c 2004-06-02 20:09:22 UTC (rev 45)
+++ trunk/format/format.c 2004-06-03 22:16:48 UTC (rev 46)
@@ -238,8 +238,14 @@
/* Clear NewConf */
offset = volhdr->node_cfg_off + volhdr->node_cfg_size;
- if (!ClearSectors(file, offset, 4, sect_size))
+ if (!ClearSectors(file, offset, 1, sect_size))
goto bail;
+ offset += sect_size;
+ if (!InitNodeConfHdr(file, offset, sect_size))
+ goto bail;
+ offset += (2 * sect_size);
+ if (!ClearSectors(file, offset, 1, sect_size))
+ goto bail;
fsync(file);
sect_count += OCFS_MAXIMUM_NODES + 6;
Modified: trunk/format/inc/format.h
===================================================================
--- trunk/format/inc/format.h 2004-06-02 20:09:22 UTC (rev 45)
+++ trunk/format/inc/format.h 2004-06-03 22:16:48 UTC (rev 46)
@@ -158,6 +158,8 @@
__u64 device_size;
bool list_nodes;
int convert;
+ __u32 disk_hb;
+ __u32 hb_timeo;
}
ocfs_options;
Modified: trunk/format/tune.c
===================================================================
--- trunk/format/tune.c 2004-06-02 20:09:22 UTC (rev 45)
+++ trunk/format/tune.c 2004-06-03 22:16:48 UTC (rev 46)
@@ -26,6 +26,11 @@
#include <format.h>
#include <tune.h>
+/* getopt stuff */
+int getopt(int argc, char *const argv[], const char *optstring);
+extern char *optarg;
+extern int optind, opterr, optopt;
+
void init_global_context(void);
int create_orphan_dirs(ocfs_vol_disk_hdr *volhdr, bool *update, int fd);
int ocfs_init_orphan_dir(ocfs_super *osb, int node_num, char *filename);
@@ -51,7 +56,9 @@
.slot_num = OCFS_INVALID_NODE_NUM,
.device_size = 0,
.list_nodes = false,
- .convert = -1
+ .convert = -1,
+ .disk_hb = 0,
+ .hb_timeo = 0
};
bool ignore_signal = false;
@@ -60,8 +67,9 @@
char rawdev[FILE_NAME_SIZE];
char *usage_string =
-"usage: %s [-F] [-g gid] [-h] [-l] [-n] [-N nodenum] [-p permissions] "
-"[-q] [-S size] [-u uid] [-V] device\n\n"
+"usage: %s [-d ms] [-F] [-g gid] [-h] [-l] [-n] [-N nodenum] [-p permissions] "
+"[-q] [-S size] [-t ms] [-u uid] [-V] device\n\n"
+" -d disk heartbeat in ms\n"
" -F Force resize existing OCFS volume\n"
" -g Group ID for the root directory\n"
" -h Help\n"
@@ -71,6 +79,7 @@
" -p Permissions for the root directory\n"
" -q Quiet execution\n"
" -S Volume size, e.g., 50G (M for mega, G for giga, T for tera)\n"
+" -t heartbeat timeout in ms\n"
" -u User ID for the root directory\n"
" -c Convert filesystem versions\n"
" -V Print version and exit\n";
@@ -188,7 +197,7 @@
/* Update volume disk header */
if (opts.gid != -1 || opts.uid != -1 || opts.perms != -1 ||
- opts.device_size || opts.convert != -1) {
+ opts.device_size || opts.convert != -1 || opts.disk_hb || opts.hb_timeo) {
if (!(update_volume_header(file, volhdr, sect_size, vol_size,
&update)))
goto bail;
@@ -253,7 +262,7 @@
/* Write volume disk header */
if (opts.gid != -1 || opts.uid != -1 || opts.perms != -1 ||
- opts.device_size || opts.convert != -1) {
+ opts.device_size || opts.convert != -1 || opts.disk_hb || opts.hb_timeo) {
offset = volhdr->start_off;
if (!write_sectors(file, offset, 1, sect_size, (void *)volhdr))
goto bail;
@@ -278,15 +287,14 @@
/*
* read_options()
*
- * tuneocfs [ -C ] [ -f ] [ -g gid] [ -L label] [ -m mount-point]
- * [ -p permissions] [ -q ] [ -S size] [ -u uid] [ -V ] device
+ * "usage: %s [-d ms] [-F] [-g gid] [-h] [-l] [-n] [-N nodenum] [-p permissions] "
+ * "[-q] [-S size] [-t ms] [-u uid] [-V] device\n\n"
*
*/
int read_options(int argc, char **argv)
{
- int i;
int ret = 1;
- char tmp[128];
+ int c;
char *p;
__u64 fac = 1;
long double size;
@@ -298,143 +306,99 @@
goto bail;
}
- for (i = 1; i < argc && ret; i++) {
- switch(*argv[i]) {
- case '-':
- switch(*++argv[i]) {
- case 'C': /* clear all data blocks */
- opts.clear_data_blocks = true;
- break;
+ while(1) {
+ c = getopt(argc, argv, "CFhlnqVd:g:N:p:S:t:u:");
+ if (c == -1)
+ break;
- case 'F': /* force resize */
- opts.force_op = true;
- break;
+ switch (c) {
+ case 'd': /* disk heartbeat */
+ opts.disk_hb = strtoul(optarg, NULL, 0);
+ break;
- case 'g': /* gid */
- ++i;
- if (i < argc && argv[i])
- opts.gid = get_gid(argv[i]);
- else {
- fprintf(stderr, "Invalid group id.\n"
- "Aborting.\n");
- ret = 0;
- }
- break;
+ case 'C': /* clear all data blocks */
+ opts.clear_data_blocks = true;
+ break;
- case 'h': /* help */
- version(argv[0]);
- usage(argv[0]);
- ret = 0;
- break;
+ case 'F': /* force resize */
+ opts.force_op = true;
+ break;
- case 'l': /* list node configs */
- opts.list_nodes = true;
- break;
+ case 'g': /* gid */
+ opts.gid = get_gid(optarg);
+ break;
- case 'n': /* query */
- opts.query_only = true;
- break;
+ case 'h': /* help */
+ version(argv[0]);
+ usage(argv[0]);
+ ret = 0;
+ break;
- case 'N': /* node cfg slot */
- ++i;
- if (i < argc && argv[i])
- opts.slot_num = atoi(argv[i]);
- else {
- fprintf(stderr,"Invalid node config slot.\n"
- "Aborting.\n");
- ret = 0;
- }
- break;
+ case 'l': /* list node configs */
+ opts.list_nodes = true;
+ break;
- case 'p': /* permissions */
- ++i;
- if (i < argc && argv[i]) {
- opts.perms = strtoul(argv[i], NULL, 8);
- opts.perms &= 0007777;
- } else {
- fprintf(stderr,"Invalid permissions.\n"
- "Aborting.\n");
- ret = 0;
- }
- break;
+ case 'n': /* query */
+ opts.query_only = true;
+ break;
- case 'q': /* quiet */
- opts.quiet = true;
- break;
+ case 'N': /* node cfg slot */
+ opts.slot_num = atoi(optarg);
+ break;
- case 'S': /* device size */
- ++i;
- if (i < argc && argv[i]) {
- strcpy(tmp, argv[i]);
- size = strtold(tmp, &p);
- if (p)
- MULT_FACTOR(*p, fac);
- opts.device_size = (__u64)(size * fac);
- } else {
- fprintf(stderr,"Invalid device size.\n"
- "Aborting.\n");
- ret = 0;
- }
- break;
+ case 'p': /* permissions */
+ opts.perms = strtoul(optarg, NULL, 8);
+ opts.perms &= 0007777;
+ break;
- case 'u': /* uid */
- ++i;
- if (i < argc && argv[i])
- opts.uid = get_uid(argv[i]);
- else {
- fprintf(stderr,"Invalid user id.\n"
- "Aborting.\n");
- ret = 0;
- }
- break;
+ case 'q': /* quiet */
+ opts.quiet = true;
+ break;
- case 'V': /* print version */
- version(argv[0]);
- ret = 0;
- break;
+ case 'S': /* device size */
+ size = strtold(optarg, &p);
+ if (p)
+ MULT_FACTOR(*p, fac);
+ opts.device_size = (__u64)(size * fac);
+ break;
- case 'x': /* used for debugocfs */
- opts.print_progress = true;
- break;
+ case 't': /* node timeout */
+ opts.hb_timeo = strtoul(optarg, NULL, 0);
+ break;
- case 'c': /* convert */
- ++i;
- if (i < argc && argv[i]) {
- opts.convert = atoi(argv[i]);
- if (opts.convert == OCFS_MAJOR_VERSION) {
- fprintf(stderr, "Conversion to"
- " V1 ocfs not yet"
- " supported.\n"
- "Aborting.\n");
- ret = 0;
- } else if (opts.convert < OCFS_MAJOR_VERSION || opts.convert > OCFS2_MAJOR_VERSION) {
- fprintf(stderr, "Invalid "
- "version.\n"
- "Aborting.\n");
- ret = 0;
- }
- } else {
- fprintf(stderr, "No version "
- "specified.\nAborting.\n");
- ret = 0;
- }
- break;
+ case 'u': /* uid */
+ opts.uid = get_uid(optarg);
+ break;
- default:
- fprintf(stderr, "Invalid switch -%c.\n"
- "Aborting.\n", *argv[i]);
+ case 'V': /* print version */
+ version(argv[0]);
+ ret = 0;
+ break;
+
+ case 'x': /* used for debugocfs */
+ opts.print_progress = true;
+ break;
+
+ case 'c': /* convert */
+ opts.convert = atoi(optarg);
+ if (opts.convert == OCFS_MAJOR_VERSION) {
+ fprintf(stderr, "Conversion to V1 ocfs not yet supported.\nAborting.\n");
ret = 0;
- break;
+ } else if (opts.convert < OCFS_MAJOR_VERSION || opts.convert > OCFS2_MAJOR_VERSION) {
+ fprintf(stderr, "Invalid version.\nAborting.\n");
+ ret = 0;
}
break;
default:
- strncpy(opts.device, argv[i], FILE_NAME_SIZE);
break;
}
}
- bail:
+ if (ret && optind < argc && argv[optind])
+ strncpy(opts.device, argv[optind], FILE_NAME_SIZE);
+
+bail:
return ret;
} /* read_options */
@@ -445,6 +409,9 @@
*/
bool validate_options(char *progname)
{
+ __u32 miss_cnt;
+ __u32 min_hbt;
+
if (opts.device[0] == '\0') {
fprintf(stderr, "Error: Device not specified.\n");
usage(progname);
@@ -453,13 +420,41 @@
if (opts.slot_num != OCFS_INVALID_NODE_NUM) {
if (opts.slot_num < 0 || opts.slot_num >= OCFS_MAXIMUM_NODES) {
- fprintf(stderr, "Error: Invalid node config slot "
- "specified.\n");
- usage(progname);
+ fprintf(stderr, "Error: Node config slot should be "
+ "between 0 and 31.\n");
return 0;
}
}
+ if (opts.disk_hb && !IS_VALID_DISKHB(opts.disk_hb)) {
+ fprintf(stderr, "Error: Disk heartbeat should be between %d "
+ "and %d.\n", OCFS_MIN_DISKHB, OCFS_MAX_DISKHB);
+ return 0;
+ }
+
+ if (opts.hb_timeo && !IS_VALID_HBTIMEO(opts.hb_timeo)) {
+ fprintf(stderr, "Error: Node timeout should be between %d "
+ "and %d.\n", OCFS_MIN_HBTIMEO, OCFS_MAX_HBTIMEO);
+ return 0;
+ }
+
+ if (opts.disk_hb || opts.hb_timeo) {
+ if (!(opts.disk_hb && opts.hb_timeo)) {
+ fprintf(stderr, "Error: Both node timeout and disk "
+ "heartbeat need to be specified.\n");
+ return 0;
+ }
+
+ miss_cnt = opts.hb_timeo / opts.disk_hb;
+ if (miss_cnt < MIN_MISS_COUNT_VALUE) {
+ min_hbt = opts.disk_hb * MIN_MISS_COUNT_VALUE;
+ fprintf(stderr, "Error: For %d ms disk heartbeat, "
+ "node timeout cannot be less than %d ms.\n",
+ opts.disk_hb, min_hbt);
+ return 0;
+ }
+ }
+
return 1;
} /* validate_options */
@@ -534,6 +529,21 @@
}
*update = true;
}
+
+ if (opts.disk_hb) {
+ printf("Changing disk heartbeat from %u ms to %u ms\n",
+ volhdr->disk_hb, opts.disk_hb);
+ volhdr->disk_hb = opts.disk_hb;
+ *update = true;
+ }
+
+ if (opts.hb_timeo) {
+ printf("Changing node timeout from %u ms to %u ms\n",
+ volhdr->hb_timeo, opts.hb_timeo);
+ volhdr->hb_timeo = opts.hb_timeo;
+ *update = true;
+ }
+
bail:
return ret;
} /* update_volume_header */
More information about the Ocfs-tools-commits
mailing list