gfs2-utils: master - libgfs2: Remove some more log_xxx calls
by Steven Whitehouse
Gitweb: http://git.fedorahosted.org/git/gfs2-utils.git?p=gfs2-utils.git;a=commitd...
Commit: 61c1a2ba81b7cd7f529261055e9f74af1722d141
Parent: f910f288e063ccb64df90c8dff371bffdd4a8620
Author: Steven Whitehouse <swhiteho(a)redhat.com>
AuthorDate: Wed Nov 30 14:57:54 2011 +0000
Committer: Steven Whitehouse <swhiteho(a)redhat.com>
CommitterDate: Wed Nov 30 14:57:54 2011 +0000
libgfs2: Remove some more log_xxx calls
One is changed to fprintf, on a temporary basis - really it should
be removed. The others are removed and an error code returned.
Signed-off-by: Steven Whitehouse <swhiteho(a)redhat.com>
---
gfs2/libgfs2/structures.c | 2 +-
gfs2/libgfs2/super.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/gfs2/libgfs2/structures.c b/gfs2/libgfs2/structures.c
index 8733444..0c22b01 100644
--- a/gfs2/libgfs2/structures.c
+++ b/gfs2/libgfs2/structures.c
@@ -511,7 +511,7 @@ static int __gfs2_next_rg_meta(struct rgrp_tree *rgd, uint64_t *block,
int i;
if (!first && (*block < rgd->ri.ri_data0)) {
- log_err("next_rg_meta: Start block is outside rgrp bounds.\n");
+ fprintf(stderr, "next_rg_meta: Start block is outside rgrp bounds.\n");
exit(1);
}
for (i = 0; i < length; i++){
diff --git a/gfs2/libgfs2/super.c b/gfs2/libgfs2/super.c
index c9a9ad3..37152c2 100644
--- a/gfs2/libgfs2/super.c
+++ b/gfs2/libgfs2/super.c
@@ -96,7 +96,7 @@ int read_sb(struct gfs2_sbd *sdp)
sdp->sd_heightsize[x] = space;
}
if (x > GFS2_MAX_META_HEIGHT){
- log_err("Bad max metadata height.\n");
+ errno = E2BIG;
return -1;
}
@@ -111,7 +111,7 @@ int read_sb(struct gfs2_sbd *sdp)
}
sdp->sd_max_jheight = x;
if(sdp->sd_max_jheight > GFS2_MAX_META_HEIGHT) {
- log_err("Bad max jheight.\n");
+ errno = E2BIG;
return -1;
}
sdp->fssize = lseek(sdp->device_fd, 0, SEEK_END) / sdp->sd_sb.sb_bsize;
12 years, 4 months
gfs2-utils: master - libgfs2: Clean up sb read/check functions
by Steven Whitehouse
Gitweb: http://git.fedorahosted.org/git/gfs2-utils.git?p=gfs2-utils.git;a=commitd...
Commit: f910f288e063ccb64df90c8dff371bffdd4a8620
Parent: ef9c2102d49a848f69edb8f7bd7605bf317b808c
Author: Steven Whitehouse <swhiteho(a)redhat.com>
AuthorDate: Wed Nov 30 13:19:33 2011 +0000
Committer: Steven Whitehouse <swhiteho(a)redhat.com>
CommitterDate: Wed Nov 30 13:19:33 2011 +0000
libgfs2: Clean up sb read/check functions
There is no need to specify in advance whether we want to accept
gfs1 format super blocks or not. We can simply return that info
and let the caller decide if gfs1 format is acceptable or not.
We can also remove the message regarding the magic number of the
superblock, since the caller prints out a message anyway if
the check fails.
That removes some more of the log_ messages from libgfs2 as a
result.
Signed-off-by: Steven Whitehouse <swhiteho(a)redhat.com>
---
gfs2/edit/savemeta.c | 4 ++--
gfs2/fsck/initialize.c | 4 ++--
gfs2/libgfs2/libgfs2.h | 4 ++--
gfs2/libgfs2/super.c | 23 ++++++-----------------
gfs2/mkfs/main_grow.c | 6 ++++--
5 files changed, 16 insertions(+), 25 deletions(-)
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index 31af23d..9d790fe 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -670,7 +670,7 @@ void savemeta(char *out_fn, int saveoption, int gziplevel)
fprintf(stderr, "Bad constants (1)\n");
exit(-1);
}
- ret = read_sb(&sbd, 1);
+ ret = read_sb(&sbd);
if (ret < 0) {
slow = TRUE;
sbd.gfs1 = 0;
@@ -911,7 +911,7 @@ static int restore_data(int fd, gzFile *gzin_fd, int printblocksonly,
memcpy(&bufsb, savedata->buf, sizeof(bufsb));
gfs2_sb_in(&sbd.sd_sb, &dummy_bh);
sbd1 = (struct gfs_sb *)&sbd.sd_sb;
- ret = check_sb(&sbd.sd_sb, 1);
+ ret = check_sb(&sbd.sd_sb);
if (ret < 0) {
fprintf(stderr,"Error: Invalid superblock data.\n");
return -1;
diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c
index ba0df41..132d65a 100644
--- a/gfs2/fsck/initialize.c
+++ b/gfs2/fsck/initialize.c
@@ -1227,12 +1227,12 @@ static int fill_super_block(struct gfs2_sbd *sdp)
log_crit(_("Bad constants (1)\n"));
exit(FSCK_ERROR);
}
- ret = read_sb(sdp, 1);
+ ret = read_sb(sdp);
if (ret < 0) {
if (sb_repair(sdp) != 0)
return -1; /* unrepairable, so exit */
/* Now that we've tried to repair it, re-read it. */
- ret = read_sb(sdp, 1);
+ ret = read_sb(sdp);
if (ret < 0)
return -1;
}
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 04169bf..b24e555 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -722,8 +722,8 @@ extern int gfs2_next_rg_freemeta(struct rgrp_tree *rgd, uint64_t *block,
int first);
/* super.c */
-extern int check_sb(struct gfs2_sb *sb, int allow_gfs);
-extern int read_sb(struct gfs2_sbd *sdp, int allow_gfs);
+extern int check_sb(struct gfs2_sb *sb);
+extern int read_sb(struct gfs2_sbd *sdp);
extern int rindex_read(struct gfs2_sbd *sdp, int fd, int *count1, int *sane);
extern int ri_update(struct gfs2_sbd *sdp, int fd, int *rgcount, int *sane);
extern int write_sb(struct gfs2_sbd *sdp);
diff --git a/gfs2/libgfs2/super.c b/gfs2/libgfs2/super.c
index 2f544ab..c9a9ad3 100644
--- a/gfs2/libgfs2/super.c
+++ b/gfs2/libgfs2/super.c
@@ -13,7 +13,6 @@
/**
* check_sb - Check superblock
- * @sdp: the filesystem
* @sb: The superblock
*
* Checks the version code of the FS is one that we understand how to
@@ -22,25 +21,17 @@
*
* Returns: -1 on failure, 1 if this is gfs (gfs1), 2 if this is gfs2
*/
-int check_sb(struct gfs2_sb *sb, int allow_gfs)
+int check_sb(struct gfs2_sb *sb)
{
if (sb->sb_header.mh_magic != GFS2_MAGIC ||
sb->sb_header.mh_type != GFS2_METATYPE_SB) {
- log_crit("Either the super block is corrupted, or this "
- "is not a GFS2 filesystem\n");
- log_crit("Header magic: %X Header Type: %X\n",
- sb->sb_header.mh_magic,
- sb->sb_header.mh_type);
- return -EINVAL;
+ errno = -EIO;
+ return -1;
}
if (sb->sb_fs_format == GFS_FORMAT_FS &&
sb->sb_header.mh_format == GFS_FORMAT_SB &&
sb->sb_multihost_format == GFS_FORMAT_MULTI) {
- if (allow_gfs)
- return 1;
-
- log_crit("Old gfs1 file system detected.\n");
- return -EINVAL;
+ return 1;
}
return 2;
}
@@ -54,12 +45,10 @@ int check_sb(struct gfs2_sb *sb, int allow_gfs)
* initializes various constants maintained in the super
* block
*
- * allow_gfs - passed in as 1 if we're allowed to accept gfs1 file systems
- *
* Returns: 0 on success, -1 on failure
* sdp->gfs1 will be set if this is gfs (gfs1)
*/
-int read_sb(struct gfs2_sbd *sdp, int allow_gfs)
+int read_sb(struct gfs2_sbd *sdp)
{
struct gfs2_buffer_head *bh;
uint64_t space = 0;
@@ -70,7 +59,7 @@ int read_sb(struct gfs2_sbd *sdp, int allow_gfs)
gfs2_sb_in(&sdp->sd_sb, bh);
brelse(bh);
- ret = check_sb(&sdp->sd_sb, allow_gfs);
+ ret = check_sb(&sdp->sd_sb);
if (ret < 0)
return ret;
if (ret == 1)
diff --git a/gfs2/mkfs/main_grow.c b/gfs2/mkfs/main_grow.c
index 1dc911a..5ed5a2d 100644
--- a/gfs2/mkfs/main_grow.c
+++ b/gfs2/mkfs/main_grow.c
@@ -358,9 +358,11 @@ main_grow(int argc, char *argv[])
perror(_("Bad constants (1)"));
exit(EXIT_FAILURE);
}
- if (read_sb(sdp, 0) < 0)
+ if (read_sb(sdp) < 0)
die( _("gfs: Error reading superblock.\n"));
-
+ if (sdp->gfs1) {
+ die( _("cannot grow gfs1 filesystem\n"));
+ }
if (fix_device_geometry(sdp)) {
fprintf(stderr, _("Device is too small (%llu bytes)\n"),
(unsigned long long)sdp->device.length << GFS2_BASIC_BLOCK_SHIFT);
12 years, 4 months
gfs2-utils: master - libgfs2: Move some debug messages out into mkfs/fsck
by Steven Whitehouse
Gitweb: http://git.fedorahosted.org/git/gfs2-utils.git?p=gfs2-utils.git;a=commitd...
Commit: ef9c2102d49a848f69edb8f7bd7605bf317b808c
Parent: 34a03a09dd4a1c527ce559fbd0bf30c6850d5f34
Author: Steven Whitehouse <swhiteho(a)redhat.com>
AuthorDate: Wed Nov 30 12:37:02 2011 +0000
Committer: Steven Whitehouse <swhiteho(a)redhat.com>
CommitterDate: Wed Nov 30 12:37:02 2011 +0000
libgfs2: Move some debug messages out into mkfs/fsck
We don't need to print these messages from the function which
calculates the resource group layout, we can do it afterwards.
There are still some other messages which need to be relocated
from this function, but that is a more tricky operation.
Signed-off-by: Steven Whitehouse <swhiteho(a)redhat.com>
---
gfs2/fsck/rgrepair.c | 19 +++++++++++++++++++
gfs2/libgfs2/fs_geometry.c | 12 ------------
gfs2/mkfs/gfs2_mkfs.h | 9 +++++----
gfs2/mkfs/main_grow.c | 19 +++++++++++++++++++
gfs2/mkfs/main_mkfs.c | 1 +
5 files changed, 44 insertions(+), 16 deletions(-)
diff --git a/gfs2/fsck/rgrepair.c b/gfs2/fsck/rgrepair.c
index 1ffa2c0..c11558b 100644
--- a/gfs2/fsck/rgrepair.c
+++ b/gfs2/fsck/rgrepair.c
@@ -593,6 +593,24 @@ static int gfs2_rindex_rebuild(struct gfs2_sbd *sdp, int *num_rgs,
return 0;
}
+static void debug_print_rgrps(struct gfs2_sbd *sdp, struct osi_root *rgtree)
+{
+ struct osi_node *n, *next;
+ struct rgrp_tree *rl;
+
+ if (sdp->debug) {
+ log_info("\n");
+
+ for (n = osi_first(rgtree); n; n = next) {
+ next = osi_next(n);
+ rl = (struct rgrp_tree *)n;
+ log_info("rg_o = %llu, rg_l = %llu\n",
+ (unsigned long long)rl->start,
+ (unsigned long long)rl->length);
+ }
+ }
+}
+
/*
* gfs2_rindex_calculate - calculate what the rindex should look like
* in a perfect world (trust_lvl == open_minded)
@@ -643,6 +661,7 @@ static int gfs2_rindex_calculate(struct gfs2_sbd *sdp, int *num_rgs)
}
/* Compute the default resource group layout as mkfs would have done */
compute_rgrp_layout(sdp, &sdp->rgcalc, TRUE);
+ debug_print_rgrps(sdp, &sdp->rgcalc);
build_rgrps(sdp, FALSE); /* FALSE = calc but don't write to disk. */
log_debug( _("fs_total_size = 0x%llx blocks.\n"),
(unsigned long long)sdp->device.length);
diff --git a/gfs2/libgfs2/fs_geometry.c b/gfs2/libgfs2/fs_geometry.c
index 4278bbf..5ff9813 100644
--- a/gfs2/libgfs2/fs_geometry.c
+++ b/gfs2/libgfs2/fs_geometry.c
@@ -142,18 +142,6 @@ void compute_rgrp_layout(struct gfs2_sbd *sdp, struct osi_root *rgtree,
}
sdp->rgrps = nrgrp;
-
- if (sdp->debug) {
- log_info("\n");
-
- for (n = osi_first(rgtree); n; n = next) {
- next = osi_next(n);
- rl = (struct rgrp_tree *)n;
- log_info("rg_o = %llu, rg_l = %llu\n",
- (unsigned long long)rl->start,
- (unsigned long long)rl->length);
- }
- }
}
/**
diff --git a/gfs2/mkfs/gfs2_mkfs.h b/gfs2/mkfs/gfs2_mkfs.h
index 14bf4f6..6f0ac2b 100644
--- a/gfs2/mkfs/gfs2_mkfs.h
+++ b/gfs2/mkfs/gfs2_mkfs.h
@@ -6,16 +6,17 @@
#include "copyright.cf"
/* main_grow */
-void main_grow(int argc, char *argv[]);
+extern void main_grow(int argc, char *argv[]);
+extern void debug_print_rgrps(struct gfs2_sbd *sdp, struct osi_root *rgtree);
/* main_jadd */
-void main_jadd(int argc, char *argv[]);
+extern void main_jadd(int argc, char *argv[]);
/* main_mkfs */
-void main_mkfs(int argc, char *argv[]);
+extern void main_mkfs(int argc, char *argv[]);
/* main_shrink */
-void main_shrink(int argc, char *argv[]);
+extern void main_shrink(int argc, char *argv[]);
/*
* The following inode IOCTL macros and inode flags
diff --git a/gfs2/mkfs/main_grow.c b/gfs2/mkfs/main_grow.c
index f6d7bf0..1dc911a 100644
--- a/gfs2/mkfs/main_grow.c
+++ b/gfs2/mkfs/main_grow.c
@@ -284,6 +284,24 @@ static void print_info(struct gfs2_sbd *sdp)
(unsigned long long)fsgrowth / MB);
}
+void debug_print_rgrps(struct gfs2_sbd *sdp, struct osi_root *rgtree)
+{
+ struct osi_node *n, *next;
+ struct rgrp_tree *rl;
+
+ if (sdp->debug) {
+ log_info("\n");
+
+ for (n = osi_first(rgtree); n; n = next) {
+ next = osi_next(n);
+ rl = (struct rgrp_tree *)n;
+ log_info("rg_o = %llu, rg_l = %llu\n",
+ (unsigned long long)rl->start,
+ (unsigned long long)rl->length);
+ }
+ }
+}
+
/**
* main_grow - do everything
* @argc:
@@ -391,6 +409,7 @@ main_grow(int argc, char *argv[])
int old_rg_count;
compute_rgrp_layout(sdp, &sdp->rgtree, TRUE);
+ debug_print_rgrps(sdp, &sdp->rgtree);
print_info(sdp);
initialize_new_portion(sdp, &old_rg_count);
fix_rindex(sdp, rindex_fd, old_rg_count);
diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c
index eeff47b..700b434 100644
--- a/gfs2/mkfs/main_mkfs.c
+++ b/gfs2/mkfs/main_mkfs.c
@@ -629,6 +629,7 @@ void main_mkfs(int argc, char *argv[])
/* Compute the resource group layouts */
compute_rgrp_layout(sdp, &sdp->rgtree, rgsize_specified);
+ debug_print_rgrps(sdp, &sdp->rgtree);
/* Generate a random uuid */
get_random_bytes(uuid, sizeof(uuid));
12 years, 4 months
gfs2-utils: master - libgfs2: Prepare to remove log_xxx() macros from library
by Steven Whitehouse
Gitweb: http://git.fedorahosted.org/git/gfs2-utils.git?p=gfs2-utils.git;a=commitd...
Commit: 34a03a09dd4a1c527ce559fbd0bf30c6850d5f34
Parent: fc3fa5fd347fc0f47f7f1f40cff9116d1d557636
Author: Steven Whitehouse <swhiteho(a)redhat.com>
AuthorDate: Wed Nov 30 12:07:28 2011 +0000
Committer: Steven Whitehouse <swhiteho(a)redhat.com>
CommitterDate: Wed Nov 30 12:07:28 2011 +0000
libgfs2: Prepare to remove log_xxx() macros from library
This will need to be done in stages. The first stage is to
clean up what is there. There are calls to the log_ functions
in the library itself, and those will need to be removed
in later patches.
This patch moves the gfs2_options structure into the two
utils which actually require it, removes the print_fsck_log
function, replacing the 3 calls to it from fsck with
the equivalent printf functions - it looks like those could
be merged in future as they all look very similar.
The log_ macros are also updated, so that they will do excatly
the same as before, but now don't depend on any code in libgfs2
itself.
Signed-off-by: Steven Whitehouse <swhiteho(a)redhat.com>
---
gfs2/convert/gfs2_convert.c | 7 +++++++
gfs2/fsck/fsck.h | 7 +++++++
gfs2/fsck/metawalk.c | 40 ++++++++++++++++++----------------------
gfs2/fsck/util.h | 1 +
gfs2/libgfs2/gfs2_log.c | 34 ----------------------------------
gfs2/libgfs2/libgfs2.h | 29 +++++++++--------------------
gfs2/libgfs2/super.c | 2 +-
7 files changed, 43 insertions(+), 77 deletions(-)
diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index 9f24137..09a689c 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -139,6 +139,13 @@ struct blocklist {
char *ptrbuf;
};
+struct gfs2_options {
+ char *device;
+ unsigned int yes:1;
+ unsigned int no:1;
+ unsigned int query:1;
+};
+
struct gfs1_sb raw_gfs1_ondisk_sb;
struct gfs2_sbd sb2;
char device[256];
diff --git a/gfs2/fsck/fsck.h b/gfs2/fsck/fsck.h
index edd73d7..70fc3d7 100644
--- a/gfs2/fsck/fsck.h
+++ b/gfs2/fsck/fsck.h
@@ -124,6 +124,13 @@ extern void dirtree_delete(struct dir_info *b);
* of pass1 and put somewhere else... */
struct dir_info *dirtree_insert(uint64_t dblock);
+struct gfs2_options {
+ char *device;
+ unsigned int yes:1;
+ unsigned int no:1;
+ unsigned int query:1;
+};
+
extern struct gfs2_options opts;
extern struct gfs2_inode *lf_dip; /* Lost and found directory inode */
extern struct gfs2_bmap *bl;
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index ef7f05d..d78df72 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -129,38 +129,34 @@ int _fsck_blockmap_set(struct gfs2_inode *ip, uint64_t bblock,
log_info("\n");
prevcount = 0;
}
- print_fsck_log(MSG_DEBUG, caller, fline,
- _("%s inode found at block "
- "(0x%llx): marking as '%s'\n"),
- btype, (unsigned long long)
- ip->i_di.di_num.no_addr,
- block_type_string(mark));
+ printf( _("(%s:%d) %s inode found at block "
+ "(0x%llx): marking as '%s'\n"), caller, fline,
+ btype,
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ block_type_string(mark));
+
} else if (mark == gfs2_bad_block || mark == gfs2_meta_inval) {
if (prevcount) {
log_info("\n");
prevcount = 0;
}
- print_fsck_log(MSG_DEBUG, caller, fline,
- _("inode (0x%llx) references "
- "%s block (0x%llx): "
- "marking as '%s'\n"),
- (unsigned long long)
- ip->i_di.di_num.no_addr,
- btype, (unsigned long long)bblock,
- block_type_string(mark));
+ printf( _("(%s:%d) inode (0x%llx) references %s block"
+ " (0x%llx): marking as '%s'\n"),
+ caller, fline,
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ btype, (unsigned long long)bblock,
+ block_type_string(mark));
} else {
if (prevcount) {
log_info("\n");
prevcount = 0;
}
- print_fsck_log(MSG_DEBUG, caller, fline,
- _("inode (0x%llx) references "
- "%s block (0x%llx): "
- "marking as '%s'\n"),
- (unsigned long long)
- ip->i_di.di_num.no_addr, btype,
- (unsigned long long)bblock,
- block_type_string(mark));
+ printf( _("(%s:%d) inode (0x%llx) references %s block"
+ " (0x%llx): marking as '%s'\n"),
+ caller, fline,
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ btype, (unsigned long long)bblock,
+ block_type_string(mark));
}
prev_ino_addr = ip->i_di.di_num.no_addr;
prev_mark = mark;
diff --git a/gfs2/fsck/util.h b/gfs2/fsck/util.h
index 6de61e2..80ed0c4 100644
--- a/gfs2/fsck/util.h
+++ b/gfs2/fsck/util.h
@@ -184,5 +184,6 @@ extern char generic_interrupt(const char *caller, const char *where,
const char *progress, const char *question,
const char *answers);
extern char gfs2_getch(void);
+#define stack log_debug("<backtrace> - %s()\n", __func__)
#endif /* __UTIL_H__ */
diff --git a/gfs2/libgfs2/gfs2_log.c b/gfs2/libgfs2/gfs2_log.c
index a1ceaeb..da5f489 100644
--- a/gfs2/libgfs2/gfs2_log.c
+++ b/gfs2/libgfs2/gfs2_log.c
@@ -22,37 +22,3 @@ void decrease_verbosity(void)
{
print_level--;
}
-
-static __attribute__((format (printf, 4, 0)))
-void print_msg(int priority, const char *file, int line,
- const char *format, va_list args) {
-
- switch (priority) {
-
- case MSG_DEBUG:
- printf("(%s:%d) ", file, line);
- vprintf(format, args);
- break;
- case MSG_INFO:
- case MSG_NOTICE:
- case MSG_WARN:
- vprintf(format, args);
- fflush(NULL);
- break;
- case MSG_ERROR:
- case MSG_CRITICAL:
- default:
- vfprintf(stderr, format, args);
- break;
- }
-}
-
-
-void print_fsck_log(int priority, const char *file, int line,
- const char *format, ...)
-{
- va_list args;
- va_start(args, format);
- print_msg(priority, file, line, format, args);
- va_end(args);
-}
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index d02d63e..04169bf 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -617,12 +617,6 @@ extern void gfs_put_leaf_nr(struct gfs2_inode *dip, uint32_t inx,
uint64_t leaf_out);
/* gfs2_log.c */
-struct gfs2_options {
- char *device;
- unsigned int yes:1;
- unsigned int no:1;
- unsigned int query:1;
-};
extern int print_level;
@@ -634,33 +628,28 @@ extern int print_level;
#define MSG_CRITICAL 2
#define MSG_NULL 1
-#define print_log(priority, format...) \
- do { print_fsck_log(priority, __FUNCTION__, __LINE__, ## format); } while(0)
-
#define log_debug(format...) \
- do { if(print_level >= MSG_DEBUG) print_log(MSG_DEBUG, format); } while(0)
+ do { if (print_level >= MSG_DEBUG) { \
+ printf("(%s:%d) ", __FUNCTION__, __LINE__); \
+ printf(format); } } while(0)
+
#define log_info(format...) \
- do { if(print_level >= MSG_INFO) print_log(MSG_INFO, format); } while(0)
+ do { if (print_level >= MSG_INFO) printf(format); } while(0)
#define log_notice(format...) \
- do { if(print_level >= MSG_NOTICE) print_log(MSG_NOTICE, format); } while(0)
+ do { if (print_level >= MSG_NOTICE) printf(format); } while(0)
#define log_warn(format...) \
- do { if(print_level >= MSG_WARN) print_log(MSG_WARN, format); } while(0)
+ do { if (print_level >= MSG_WARN) printf(format); } while(0)
#define log_err(format...) \
- do { if(print_level >= MSG_ERROR) print_log(MSG_ERROR, format); } while(0)
+ do { if (print_level >= MSG_ERROR) fprintf(stderr, format); } while(0)
#define log_crit(format...) \
- do { if(print_level >= MSG_CRITICAL) print_log(MSG_CRITICAL, format); } while(0)
-
-#define stack log_debug("<backtrace> - %s()\n", __func__)
+ do { if (print_level >= MSG_CRITICAL) fprintf(stderr, format); } while(0)
extern void increase_verbosity(void);
extern void decrease_verbosity(void);
-extern void print_fsck_log(int priority, const char *file, int line,
- const char *format, ...)
- __attribute__((format(printf,4,5)));
/* misc.c */
extern int compute_heightsize(struct gfs2_sbd *sdp, uint64_t *heightsize,
diff --git a/gfs2/libgfs2/super.c b/gfs2/libgfs2/super.c
index c844287..2f544ab 100644
--- a/gfs2/libgfs2/super.c
+++ b/gfs2/libgfs2/super.c
@@ -28,7 +28,7 @@ int check_sb(struct gfs2_sb *sb, int allow_gfs)
sb->sb_header.mh_type != GFS2_METATYPE_SB) {
log_crit("Either the super block is corrupted, or this "
"is not a GFS2 filesystem\n");
- log_debug("Header magic: %X Header Type: %X\n",
+ log_crit("Header magic: %X Header Type: %X\n",
sb->sb_header.mh_magic,
sb->sb_header.mh_type);
return -EINVAL;
12 years, 4 months
gfs2-utils: master - libgfs2: Move gfs2_getch into utils
by Steven Whitehouse
Gitweb: http://git.fedorahosted.org/git/gfs2-utils.git?p=gfs2-utils.git;a=commitd...
Commit: fc3fa5fd347fc0f47f7f1f40cff9116d1d557636
Parent: 3e061b117a6f254359199be7129fb44875ac14fe
Author: Steven Whitehouse <swhiteho(a)redhat.com>
AuthorDate: Wed Nov 30 10:45:00 2011 +0000
Committer: Steven Whitehouse <swhiteho(a)redhat.com>
CommitterDate: Wed Nov 30 10:45:00 2011 +0000
libgfs2: Move gfs2_getch into utils
More UI code being moved out of the library.
Signed-off-by: Steven Whitehouse <swhiteho(a)redhat.com>
---
gfs2/convert/gfs2_convert.c | 36 ++++++++++++++++++++++++++++++++----
gfs2/fsck/util.c | 28 ++++++++++++++++++++++++++++
gfs2/fsck/util.h | 1 +
gfs2/libgfs2/gfs2_log.c | 28 ----------------------------
gfs2/libgfs2/libgfs2.h | 1 -
5 files changed, 61 insertions(+), 33 deletions(-)
diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index f79b4a4..9f24137 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -23,6 +23,7 @@
#include <sys/time.h>
#include <errno.h>
#include <ctype.h>
+#include <termios.h>
#include <libintl.h>
#include <locale.h>
#define _(String) gettext(String)
@@ -2057,24 +2058,51 @@ static void copy_quotas(struct gfs2_sbd *sdp)
inode_put(&oq_ip);
}
+static char gfs2_getch(void)
+{
+ struct termios termattr, savetermattr;
+ char ch;
+ ssize_t size;
+
+ tcgetattr (STDIN_FILENO, &termattr);
+ savetermattr = termattr;
+ termattr.c_lflag &= ~(ICANON | IEXTEN | ISIG);
+ termattr.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON);
+ termattr.c_cflag &= ~(CSIZE | PARENB);
+ termattr.c_cflag |= CS8;
+ termattr.c_oflag &= ~(OPOST);
+ termattr.c_cc[VMIN] = 0;
+ termattr.c_cc[VTIME] = 0;
+
+ tcsetattr (STDIN_FILENO, TCSANOW, &termattr);
+ do {
+ size = read(STDIN_FILENO, &ch, 1);
+ if (size)
+ break;
+ usleep(50000);
+ } while (!size);
+
+ tcsetattr (STDIN_FILENO, TCSANOW, &savetermattr);
+ return ch;
+}
static char generic_interrupt(const char *caller, const char *where,
const char *progress, const char *question,
const char *answers)
{
fd_set rfds;
- struct timeval tv;
+ struct timeval stv;
char response;
int err, i;
FD_ZERO(&rfds);
FD_SET(STDIN_FILENO, &rfds);
- tv.tv_sec = 0;
- tv.tv_usec = 0;
+ stv.tv_sec = 0;
+ stv.tv_usec = 0;
/* Make sure there isn't extraneous input before asking the
* user the question */
- while((err = select(STDIN_FILENO + 1, &rfds, NULL, NULL, &tv))) {
+ while((err = select(STDIN_FILENO + 1, &rfds, NULL, NULL, &stv))) {
if(err < 0) {
log_debug("Error in select() on stdin\n");
break;
diff --git a/gfs2/fsck/util.c b/gfs2/fsck/util.c
index ddbc757..d912920 100644
--- a/gfs2/fsck/util.c
+++ b/gfs2/fsck/util.c
@@ -6,6 +6,7 @@
#include <unistd.h>
#include <sys/time.h>
#include <stdio.h>
+#include <termios.h>
#include <libintl.h>
#include <ctype.h>
#define _(String) gettext(String)
@@ -87,6 +88,33 @@ void warm_fuzzy_stuff(uint64_t block)
}
}
+char gfs2_getch(void)
+{
+ struct termios termattr, savetermattr;
+ char ch;
+ ssize_t size;
+
+ tcgetattr (STDIN_FILENO, &termattr);
+ savetermattr = termattr;
+ termattr.c_lflag &= ~(ICANON | IEXTEN | ISIG);
+ termattr.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON);
+ termattr.c_cflag &= ~(CSIZE | PARENB);
+ termattr.c_cflag |= CS8;
+ termattr.c_oflag &= ~(OPOST);
+ termattr.c_cc[VMIN] = 0;
+ termattr.c_cc[VTIME] = 0;
+
+ tcsetattr (STDIN_FILENO, TCSANOW, &termattr);
+ do {
+ size = read(STDIN_FILENO, &ch, 1);
+ if (size)
+ break;
+ usleep(50000);
+ } while (!size);
+
+ tcsetattr (STDIN_FILENO, TCSANOW, &savetermattr);
+ return ch;
+}
char generic_interrupt(const char *caller, const char *where,
const char *progress, const char *question,
diff --git a/gfs2/fsck/util.h b/gfs2/fsck/util.h
index 7c32404..6de61e2 100644
--- a/gfs2/fsck/util.h
+++ b/gfs2/fsck/util.h
@@ -183,5 +183,6 @@ extern int set_ip_blockmap(struct gfs2_inode *ip, int instree);
extern char generic_interrupt(const char *caller, const char *where,
const char *progress, const char *question,
const char *answers);
+extern char gfs2_getch(void);
#endif /* __UTIL_H__ */
diff --git a/gfs2/libgfs2/gfs2_log.c b/gfs2/libgfs2/gfs2_log.c
index 39b09c7..a1ceaeb 100644
--- a/gfs2/libgfs2/gfs2_log.c
+++ b/gfs2/libgfs2/gfs2_log.c
@@ -56,31 +56,3 @@ void print_fsck_log(int priority, const char *file, int line,
print_msg(priority, file, line, format, args);
va_end(args);
}
-
-char gfs2_getch(void)
-{
- struct termios termattr, savetermattr;
- char ch;
- ssize_t size;
-
- tcgetattr (STDIN_FILENO, &termattr);
- savetermattr = termattr;
- termattr.c_lflag &= ~(ICANON | IEXTEN | ISIG);
- termattr.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON);
- termattr.c_cflag &= ~(CSIZE | PARENB);
- termattr.c_cflag |= CS8;
- termattr.c_oflag &= ~(OPOST);
- termattr.c_cc[VMIN] = 0;
- termattr.c_cc[VTIME] = 0;
-
- tcsetattr (STDIN_FILENO, TCSANOW, &termattr);
- do {
- size = read(STDIN_FILENO, &ch, 1);
- if (size)
- break;
- usleep(50000);
- } while (!size);
-
- tcsetattr (STDIN_FILENO, TCSANOW, &savetermattr);
- return ch;
-}
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 80c84fa..d02d63e 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -656,7 +656,6 @@ extern int print_level;
#define stack log_debug("<backtrace> - %s()\n", __func__)
-extern char gfs2_getch(void);
extern void increase_verbosity(void);
extern void decrease_verbosity(void);
extern void print_fsck_log(int priority, const char *file, int line,
12 years, 4 months
gfs2-utils: master - libgfs2: Move generic_interrupt() into utils
by Steven Whitehouse
Gitweb: http://git.fedorahosted.org/git/gfs2-utils.git?p=gfs2-utils.git;a=commitd...
Commit: 3e061b117a6f254359199be7129fb44875ac14fe
Parent: 51c8c915e33afd25fea64370b90a31fd51a8f224
Author: Steven Whitehouse <swhiteho(a)redhat.com>
AuthorDate: Wed Nov 30 10:29:43 2011 +0000
Committer: Steven Whitehouse <swhiteho(a)redhat.com>
CommitterDate: Wed Nov 30 10:29:43 2011 +0000
libgfs2: Move generic_interrupt() into utils
First patch moving user interface code out of the library
Signed-off-by: Steven Whitehouse <swhiteho(a)redhat.com>
---
gfs2/convert/gfs2_convert.c | 48 +++++++++++++++++++++++++++++++++++++++++++
gfs2/fsck/util.c | 48 +++++++++++++++++++++++++++++++++++++++++++
gfs2/fsck/util.h | 4 +++
gfs2/libgfs2/gfs2_log.c | 48 -------------------------------------------
gfs2/libgfs2/libgfs2.h | 3 --
5 files changed, 100 insertions(+), 51 deletions(-)
diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index 396e899..f79b4a4 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -2057,6 +2057,54 @@ static void copy_quotas(struct gfs2_sbd *sdp)
inode_put(&oq_ip);
}
+
+static char generic_interrupt(const char *caller, const char *where,
+ const char *progress, const char *question,
+ const char *answers)
+{
+ fd_set rfds;
+ struct timeval tv;
+ char response;
+ int err, i;
+
+ FD_ZERO(&rfds);
+ FD_SET(STDIN_FILENO, &rfds);
+
+ tv.tv_sec = 0;
+ tv.tv_usec = 0;
+ /* Make sure there isn't extraneous input before asking the
+ * user the question */
+ while((err = select(STDIN_FILENO + 1, &rfds, NULL, NULL, &tv))) {
+ if(err < 0) {
+ log_debug("Error in select() on stdin\n");
+ break;
+ }
+ if(read(STDIN_FILENO, &response, sizeof(char)) < 0) {
+ log_debug("Error in read() on stdin\n");
+ break;
+ }
+ }
+ while (TRUE) {
+ printf("\n%s interrupted during %s: ", caller, where);
+ if (progress)
+ printf("%s.\n", progress);
+ printf("%s", question);
+
+ /* Make sure query is printed out */
+ fflush(NULL);
+ response = gfs2_getch();
+ printf("\n");
+ fflush(NULL);
+ if (strchr(answers, response))
+ break;
+ printf("Bad response, please type ");
+ for (i = 0; i < strlen(answers) - 1; i++)
+ printf("'%c', ", answers[i]);
+ printf(" or '%c'.\n", answers[i]);
+ }
+ return response;
+}
+
static int __attribute__((format(printf, 3, 4))) gfs2_query(int *setonabort,
struct gfs2_options *opts, const char *format, ...)
{
diff --git a/gfs2/fsck/util.c b/gfs2/fsck/util.c
index 0d243e0..ddbc757 100644
--- a/gfs2/fsck/util.c
+++ b/gfs2/fsck/util.c
@@ -87,6 +87,54 @@ void warm_fuzzy_stuff(uint64_t block)
}
}
+
+char generic_interrupt(const char *caller, const char *where,
+ const char *progress, const char *question,
+ const char *answers)
+{
+ fd_set rfds;
+ struct timeval tv;
+ char response;
+ int err, i;
+
+ FD_ZERO(&rfds);
+ FD_SET(STDIN_FILENO, &rfds);
+
+ tv.tv_sec = 0;
+ tv.tv_usec = 0;
+ /* Make sure there isn't extraneous input before asking the
+ * user the question */
+ while((err = select(STDIN_FILENO + 1, &rfds, NULL, NULL, &tv))) {
+ if(err < 0) {
+ log_debug("Error in select() on stdin\n");
+ break;
+ }
+ if(read(STDIN_FILENO, &response, sizeof(char)) < 0) {
+ log_debug("Error in read() on stdin\n");
+ break;
+ }
+ }
+ while (TRUE) {
+ printf("\n%s interrupted during %s: ", caller, where);
+ if (progress)
+ printf("%s.\n", progress);
+ printf("%s", question);
+
+ /* Make sure query is printed out */
+ fflush(NULL);
+ response = gfs2_getch();
+ printf("\n");
+ fflush(NULL);
+ if (strchr(answers, response))
+ break;
+ printf("Bad response, please type ");
+ for (i = 0; i < strlen(answers) - 1; i++)
+ printf("'%c', ", answers[i]);
+ printf(" or '%c'.\n", answers[i]);
+ }
+ return response;
+}
+
/* fsck_query: Same as gfs2_query except it adjusts errors_found and
errors_corrected. */
int fsck_query(const char *format, ...)
diff --git a/gfs2/fsck/util.h b/gfs2/fsck/util.h
index b56fe69..7c32404 100644
--- a/gfs2/fsck/util.h
+++ b/gfs2/fsck/util.h
@@ -180,4 +180,8 @@ extern void *gfs2_bmap_destroy(struct gfs2_sbd *sdp, struct gfs2_bmap *il);
extern int gfs2_blockmap_set(struct gfs2_bmap *il, uint64_t block,
enum gfs2_mark_block mark);
extern int set_ip_blockmap(struct gfs2_inode *ip, int instree);
+extern char generic_interrupt(const char *caller, const char *where,
+ const char *progress, const char *question,
+ const char *answers);
+
#endif /* __UTIL_H__ */
diff --git a/gfs2/libgfs2/gfs2_log.c b/gfs2/libgfs2/gfs2_log.c
index aa5ca73..39b09c7 100644
--- a/gfs2/libgfs2/gfs2_log.c
+++ b/gfs2/libgfs2/gfs2_log.c
@@ -84,51 +84,3 @@ char gfs2_getch(void)
tcsetattr (STDIN_FILENO, TCSANOW, &savetermattr);
return ch;
}
-
-char generic_interrupt(const char *caller, const char *where,
- const char *progress, const char *question,
- const char *answers)
-{
- fd_set rfds;
- struct timeval tv;
- char response;
- int err, i;
-
- FD_ZERO(&rfds);
- FD_SET(STDIN_FILENO, &rfds);
-
- tv.tv_sec = 0;
- tv.tv_usec = 0;
- /* Make sure there isn't extraneous input before asking the
- * user the question */
- while((err = select(STDIN_FILENO + 1, &rfds, NULL, NULL, &tv))) {
- if(err < 0) {
- log_debug("Error in select() on stdin\n");
- break;
- }
- if(read(STDIN_FILENO, &response, sizeof(char)) < 0) {
- log_debug("Error in read() on stdin\n");
- break;
- }
- }
- while (TRUE) {
- printf("\n%s interrupted during %s: ", caller, where);
- if (progress)
- printf("%s.\n", progress);
- printf("%s", question);
-
- /* Make sure query is printed out */
- fflush(NULL);
- response = gfs2_getch();
- printf("\n");
- fflush(NULL);
- if (strchr(answers, response))
- break;
- printf("Bad response, please type ");
- for (i = 0; i < strlen(answers) - 1; i++)
- printf("'%c', ", answers[i]);
- printf(" or '%c'.\n", answers[i]);
- }
- return response;
-}
-
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 95fd2b4..80c84fa 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -662,9 +662,6 @@ extern void decrease_verbosity(void);
extern void print_fsck_log(int priority, const char *file, int line,
const char *format, ...)
__attribute__((format(printf,4,5)));
-extern char generic_interrupt(const char *caller, const char *where,
- const char *progress, const char *question,
- const char *answers);
/* misc.c */
extern int compute_heightsize(struct gfs2_sbd *sdp, uint64_t *heightsize,
12 years, 4 months
cluster: STABLE31 - config: filterout fence_pcmk from metadata generation
by Fabio M. Di Nitto
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 8285548a5fcab7b3cb3e6631d782816dd4f134cf
Parent: 8edb0d0eb31d94b8a3ba81f6d5b4c398accc950d
Author: Fabio M. Di Nitto <fdinitto(a)redhat.com>
AuthorDate: Tue Nov 29 09:44:27 2011 +0100
Committer: Fabio M. Di Nitto <fdinitto(a)redhat.com>
CommitterDate: Tue Nov 29 09:45:33 2011 +0100
config: filterout fence_pcmk from metadata generation
fence_pcmk hangs on -o metadata call
Signed-off-by: Fabio M. Di Nitto <fdinitto(a)redhat.com>
---
config/tools/xml/ccs_update_schema.in | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/config/tools/xml/ccs_update_schema.in b/config/tools/xml/ccs_update_schema.in
index d082ed3..a5aa351 100644
--- a/config/tools/xml/ccs_update_schema.in
+++ b/config/tools/xml/ccs_update_schema.in
@@ -101,6 +101,7 @@ filter_fence_list() {
[ "${i}" = "$fasdir/fence_legacy" ] && continue
[ "${i}" = "$fasdir/fence_node" ] && continue
[ "${i}" = "$fasdir/fence_nss_wrapper" ] && continue
+ [ "${i}" = "$fasdir/fence_pcmk" ] && continue
[ "${i}" = "$fasdir/fence_tool" ] && continue
[ "${i}" = "$fasdir/fence_vmware_helper" ] && continue
echo "$i"
12 years, 4 months
cluster: STABLE31 - qdiskd: fix memcpy direction and possible memory leak
by Fabio M. Di Nitto
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 8edb0d0eb31d94b8a3ba81f6d5b4c398accc950d
Parent: c39f49052a97fe2bdd5f46c29409676bd1783ed9
Author: Fabio M. Di Nitto <fdinitto(a)redhat.com>
AuthorDate: Mon Nov 28 16:48:28 2011 +0100
Committer: Fabio M. Di Nitto <fdinitto(a)redhat.com>
CommitterDate: Mon Nov 28 16:48:28 2011 +0100
qdiskd: fix memcpy direction and possible memory leak
Signed-off-by: Fabio M. Di Nitto <fdinitto(a)redhat.com>
---
cman/qdisk/disk.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/cman/qdisk/disk.c b/cman/qdisk/disk.c
index 9884ea7..524742c 100644
--- a/cman/qdisk/disk.c
+++ b/cman/qdisk/disk.c
@@ -432,10 +432,10 @@ diskRawRead(target_info_t *disk, char *buf, int len)
io_state(STATE_NONE);
if (readret > 0) {
if (readret > len) {
- memcpy(alignedBuf, buf, len);
+ memcpy(buf, alignedBuf, len);
readret = len;
} else {
- memcpy(alignedBuf, buf, readret);
+ memcpy(buf, alignedBuf, readret);
}
}
@@ -505,13 +505,14 @@ diskRawWrite(target_info_t *disk, char *buf, int len)
}
if (len > disk->d_blksz) {
+ free(alignedBuf);
logt_print(LOG_ERR,
"diskRawWrite: not setup for larger than %d.\n",
(int)disk->d_blksz);
return (-1);
}
- memcpy(buf, alignedBuf, len);
+ memcpy(alignedBuf, buf, len);
io_state(STATE_WRITE);
ret = write(disk->d_fd, alignedBuf, writelen);
io_state(STATE_NONE);
12 years, 4 months
cluster: STABLE31 - config: make altname validation position indipendent
by Fabio M. Di Nitto
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: c39f49052a97fe2bdd5f46c29409676bd1783ed9
Parent: 707e2c72c21ab0b90ad04a32cb40114dcd0cc012
Author: Fabio M. Di Nitto <fdinitto(a)redhat.com>
AuthorDate: Mon Nov 28 10:47:56 2011 +0100
Committer: Fabio M. Di Nitto <fdinitto(a)redhat.com>
CommitterDate: Mon Nov 28 10:47:56 2011 +0100
config: make altname validation position indipendent
Resolves: rhbz#740552
Signed-off-by: Fabio M. Di Nitto <fdinitto(a)redhat.com>
---
config/tools/xml/cluster.rng.in.head | 55 +++++++++++++++++++---------------
1 files changed, 31 insertions(+), 24 deletions(-)
diff --git a/config/tools/xml/cluster.rng.in.head b/config/tools/xml/cluster.rng.in.head
index e6e4633..11d5052 100644
--- a/config/tools/xml/cluster.rng.in.head
+++ b/config/tools/xml/cluster.rng.in.head
@@ -785,32 +785,11 @@ To validate your cluster.conf against this schema, run:
dlm_controld(8)"/>
</optional>
- <optional>
- <element name="altname" rha:description="Defines a second network
- interface to use for corosync redundant ring mode. cman(5)">
-
- <attribute name="name" rha:description="A second hostname or IP
- address of the node. cman(5)"/>
-
- <optional>
- <attribute name="port" rha:description="The network port to use
- on the second interface. cman(5)"/>
- </optional>
-
- <optional>
- <attribute name="mcast" rha:description="The multicast address
- to use on the second interface. cman(5)"/>
- </optional>
-
- <optional>
- <attribute name="ttl" rha:description="The multicast TTL
- to use on the second interface. cman(5)"/>
- </optional>
- </element>
- </optional>
-
<interleave>
<optional>
+ <ref name="ALTNAME"/>
+ </optional>
+ <optional>
<ref name="FENCE"/>
</optional>
<optional>
@@ -1034,6 +1013,34 @@ To validate your cluster.conf against this schema, run:
</element> <!-- cluster end -->
</start>
+<!-- begin node altname definitions -->
+
+ <define name="ALTNAME">
+ <element name="altname" rha:description="Defines a second network
+ interface to use for corosync redundant ring mode. cman(5)">
+
+ <attribute name="name" rha:description="A second hostname or IP
+ address of the node. cman(5)"/>
+
+ <optional>
+ <attribute name="port" rha:description="The network port to use
+ on the second interface. cman(5)"/>
+ </optional>
+
+ <optional>
+ <attribute name="mcast" rha:description="The multicast address
+ to use on the second interface. cman(5)"/>
+ </optional>
+
+ <optional>
+ <attribute name="ttl" rha:description="The multicast TTL
+ to use on the second interface. cman(5)"/>
+ </optional>
+ </element>
+ </define>
+
+<!-- end node altname definitions -->
+
<!-- begin node fence definitions -->
<define name="FENCE">
12 years, 4 months
gfs2-utils: master - libgfs2: Improve rgblocks2bitblocks()
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/gfs2-utils.git?p=gfs2-utils.git;a=commitd...
Commit: 51c8c915e33afd25fea64370b90a31fd51a8f224
Parent: 34c0872f1895924b94fe4ccf502c27ba97880792
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Mon Nov 21 10:20:06 2011 +0000
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Mon Nov 21 10:20:06 2011 +0000
libgfs2: Improve rgblocks2bitblocks()
This patch reworks the rgblocks2bitblocks function which was
inefficient, difficult to read and generally unwieldy.
As this is core code from the days of yore and fsck.gfs2 depends on it,
I made sure to test the new function extensively, comparing its outputs
with the original function over a large range of values for rgblocks (up
to 195312500) and valid block sizes between 512 and 4096.
All call points have been updated and, as a nice side effect, the run
time of the function is greatly reduced.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/fsck/rgrepair.c | 14 +++--------
gfs2/libgfs2/fs_geometry.c | 54 +++++++++++++++++--------------------------
gfs2/libgfs2/libgfs2.h | 4 +-
3 files changed, 27 insertions(+), 45 deletions(-)
diff --git a/gfs2/fsck/rgrepair.c b/gfs2/fsck/rgrepair.c
index 6394546..1ffa2c0 100644
--- a/gfs2/fsck/rgrepair.c
+++ b/gfs2/fsck/rgrepair.c
@@ -507,12 +507,9 @@ static int gfs2_rindex_rebuild(struct gfs2_sbd *sdp, int *num_rgs,
calc_rgd->ri.ri_data0 = calc_rgd->ri.ri_addr +
calc_rgd->ri.ri_length;
if (prev_rgd) {
- uint32_t rgblocks, bitblocks;
+ uint32_t rgblocks;
- rgblocks = block_bump;
- rgblocks2bitblocks(sdp->bsize, &rgblocks, &bitblocks);
-
- prev_rgd->ri.ri_length = bitblocks;
+ prev_rgd->ri.ri_length = rgblocks2bitblocks(sdp->bsize, block_bump, &rgblocks);
prev_rgd->ri.ri_data = rgblocks;
prev_rgd->ri.ri_data0 = prev_rgd->ri.ri_addr +
prev_rgd->ri.ri_length;
@@ -566,12 +563,9 @@ static int gfs2_rindex_rebuild(struct gfs2_sbd *sdp, int *num_rgs,
/* allocation information for the very last RG. */
/* ----------------------------------------------------------------- */
if (prev_rgd && !prev_rgd->ri.ri_data) {
- uint32_t rgblocks, bitblocks;
-
- rgblocks = block_bump;
- rgblocks2bitblocks(sdp->bsize, &rgblocks, &bitblocks);
+ uint32_t rgblocks;
- prev_rgd->ri.ri_length = bitblocks;
+ prev_rgd->ri.ri_length = rgblocks2bitblocks(sdp->bsize, block_bump, &rgblocks);
prev_rgd->ri.ri_data0 = prev_rgd->ri.ri_addr +
prev_rgd->ri.ri_length;
prev_rgd->ri.ri_data = rgblocks;
diff --git a/gfs2/libgfs2/fs_geometry.c b/gfs2/libgfs2/fs_geometry.c
index 130331a..4278bbf 100644
--- a/gfs2/libgfs2/fs_geometry.c
+++ b/gfs2/libgfs2/fs_geometry.c
@@ -34,11 +34,10 @@ uint64_t how_many_rgrps(struct gfs2_sbd *sdp, struct device *dev, int rgsize_spe
nrgrp = DIV_RU(dev->length, (sdp->rgsize << 20) / sdp->bsize);
/* check to see if the rg length overflows max # bitblks */
- rgblocksn = dev->length / nrgrp;
- rgblocks2bitblocks(sdp->bsize, &rgblocksn, &bitblocksn);
+ bitblocksn = rgblocks2bitblocks(sdp->bsize, dev->length / nrgrp, &rgblocksn);
/* calculate size of the first rgrp */
- rgblocks1 = dev->length - (nrgrp - 1) * (dev->length / nrgrp);
- rgblocks2bitblocks(sdp->bsize, &rgblocks1, &bitblocks1);
+ bitblocks1 = rgblocks2bitblocks(sdp->bsize, dev->length - (nrgrp - 1) * (dev->length / nrgrp),
+ &rgblocks1);
if (bitblocks1 > 2149 || bitblocksn > 2149) {
bitmap_overflow = 1;
if (sdp->rgsize <= GFS2_DEFAULT_RGSIZE) {
@@ -158,39 +157,29 @@ void compute_rgrp_layout(struct gfs2_sbd *sdp, struct osi_root *rgtree,
}
/**
- * rgblocks2bitblocks -
- * @bsize:
- * @rgblocks:
- * @bitblocks:
- *
- * Given a number of blocks in a RG, figure out the number of blocks
- * needed for bitmaps.
- *
+ * Given a number of blocks in a resource group, return the number of blocks
+ * needed for bitmaps. Also calculate the adjusted number of free data blocks
+ * in the resource group and store it in *ri_data.
*/
-
-void rgblocks2bitblocks(unsigned int bsize, uint32_t *rgblocks, uint32_t *bitblocks)
+uint32_t rgblocks2bitblocks(const unsigned int bsize, const uint32_t rgblocks, uint32_t *ri_data)
{
- unsigned int bitbytes_provided, last = 0;
- unsigned int bitbytes_needed;
+ uint32_t mappable = 0;
+ uint32_t bitblocks = 0;
+ /* Number of blocks mappable by bitmap blocks with these header types */
+ const uint32_t blks_rgrp = GFS2_NBBY * (bsize - sizeof(struct gfs2_rgrp));
+ const uint32_t blks_meta = GFS2_NBBY * (bsize - sizeof(struct gfs2_meta_header));
- *bitblocks = 1;
- bitbytes_provided = bsize - sizeof(struct gfs2_rgrp);
+ while (blks_rgrp + (blks_meta * bitblocks) < ((rgblocks - bitblocks) & ~(uint32_t)3))
+ bitblocks++;
- for (;;) {
- bitbytes_needed = (*rgblocks - *bitblocks) / GFS2_NBBY;
+ if (bitblocks > 0)
+ mappable = blks_rgrp + (blks_meta * (bitblocks - 1));
- if (bitbytes_provided >= bitbytes_needed) {
- if (last >= bitbytes_needed)
- (*bitblocks)--;
- break;
- }
-
- last = bitbytes_provided;
- (*bitblocks)++;
- bitbytes_provided += bsize - sizeof(struct gfs2_meta_header);
- }
+ *ri_data = (rgblocks - (bitblocks + 1)) & ~(uint32_t)3;
+ if (mappable < *ri_data)
+ bitblocks++;
- *rgblocks = bitbytes_needed * GFS2_NBBY;
+ return bitblocks;
}
/**
@@ -220,8 +209,7 @@ void build_rgrps(struct gfs2_sbd *sdp, int do_write)
rl = (struct rgrp_tree *)n;
ri = &rl->ri;
- rgblocks = rl->length;
- rgblocks2bitblocks(sdp->bsize, &rgblocks, &bitblocks);
+ bitblocks = rgblocks2bitblocks(sdp->bsize, rl->length, &rgblocks);
ri->ri_addr = rl->start;
ri->ri_length = bitblocks;
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 77dfc29..95fd2b4 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -338,8 +338,8 @@ extern int gfs2_get_bitmap(struct gfs2_sbd *sdp, uint64_t blkno,
extern int gfs2_set_bitmap(struct gfs2_sbd *sdp, uint64_t blkno, int state);
/* fs_geometry.c */
-extern void rgblocks2bitblocks(unsigned int bsize, uint32_t *rgblocks,
- uint32_t *bitblocks);
+extern uint32_t rgblocks2bitblocks(const unsigned int bsize, const uint32_t rgblocks,
+ uint32_t *ri_data) __attribute__((nonnull(3)));
extern uint64_t how_many_rgrps(struct gfs2_sbd *sdp, struct device *dev,
int rgsize_specified);
extern void compute_rgrp_layout(struct gfs2_sbd *sdp, struct osi_root *rgtree,
12 years, 4 months