cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* [Cluster-devel] [PATCH 1/5] fsck.gfs2: Log to syslog on start and exit
@ 2014-05-07 14:33 Andrew Price
  2014-05-07 14:33 ` [Cluster-devel] [PATCH 2/5] gfs2-utils: Expressly expunge 'expert mode' Andrew Price
                   ` (4 more replies)
  0 siblings, 5 replies; 13+ messages in thread
From: Andrew Price @ 2014-05-07 14:33 UTC (permalink / raw)
  To: cluster-devel.redhat.com

In order to piece together the order in which fsck.gfs2 runs and
gfs2_edit savemeta were done it's useful to keep a log of the command
line options used and the fsck.gfs2 start and end times. Log these to
syslog.

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 gfs2/fsck/main.c     | 35 +++++++++++++++++++++++++++++++++++
 gfs2/man/fsck.gfs2.8 |  2 ++
 2 files changed, 37 insertions(+)

diff --git a/gfs2/fsck/main.c b/gfs2/fsck/main.c
index 346e580..0031ec0 100644
--- a/gfs2/fsck/main.c
+++ b/gfs2/fsck/main.c
@@ -12,6 +12,7 @@
 #include <libintl.h>
 #include <locale.h>
 #define _(String) gettext(String)
+#include <syslog.h>
 
 #include "copyright.cf"
 #include "libgfs2.h"
@@ -261,6 +262,36 @@ static int fsck_pass(const struct fsck_pass *p, struct gfs2_sbd *sdp)
 	return 0;
 }
 
+static void exitlog(void)
+{
+	syslog(LOG_INFO, "exiting.");
+}
+
+static void startlog(int argc, char **argv)
+{
+	int i;
+	char *cmd, *p;
+	size_t len;
+
+	for (len = i = 0; i < argc; i++)
+		len += strlen(argv[i]);
+	len += argc; /* Add spaces and '\0' */
+
+	cmd = malloc(len);
+	if (cmd == NULL) {
+		perror(argv[0]);
+		exit(FSCK_ERROR);
+	}
+	p = cmd;
+	for (i = 0; i < argc; i++, p++) {
+		p = stpcpy(p, argv[i]);
+		*p = ' ';
+	}
+	*(--p) = '\0';
+	syslog(LOG_INFO, "started: %s", cmd);
+	free(cmd);
+}
+
 int main(int argc, char **argv)
 {
 	struct gfs2_sbd sb;
@@ -274,6 +305,10 @@ int main(int argc, char **argv)
 	setlocale(LC_ALL, "");
 	textdomain("gfs2-utils");
 
+	openlog("fsck.gfs2", LOG_CONS|LOG_PID, LOG_USER);
+	startlog(argc - 1, &argv[1]);
+	atexit(exitlog);
+
 	memset(sdp, 0, sizeof(*sdp));
 
 	if ((error = read_cmdline(argc, argv, &opts)))
diff --git a/gfs2/man/fsck.gfs2.8 b/gfs2/man/fsck.gfs2.8
index 3ecfbe3..56dcddc 100644
--- a/gfs2/man/fsck.gfs2.8
+++ b/gfs2/man/fsck.gfs2.8
@@ -35,6 +35,8 @@ computer.  Therefore, fsck.gfs2 will always check the file system unless
 the -p (preen) option is used, in which case it follows special rules
 (see below).
 
+fsck.gfs2 will log to the system log on start and exit to aid debugging and
+administration.
 .SH OPTIONS
 .TP
 \fB-a\fP
-- 
1.9.0



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [Cluster-devel] [PATCH 2/5] gfs2-utils: Expressly expunge 'expert mode'
  2014-05-07 14:33 [Cluster-devel] [PATCH 1/5] fsck.gfs2: Log to syslog on start and exit Andrew Price
@ 2014-05-07 14:33 ` Andrew Price
  2014-05-07 14:48   ` Bob Peterson
  2014-05-07 14:33 ` [Cluster-devel] [PATCH 3/5] libgfs2: Remove UI fields from struct gfs2_sbd Andrew Price
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 13+ messages in thread
From: Andrew Price @ 2014-05-07 14:33 UTC (permalink / raw)
  To: cluster-devel.redhat.com

mkfs.gfs2 and gfs2_jadd used struct gfs2_sbd.expert to put them into an
undocumented 'expert mode' but didn't really do anything useful in that
mode. Remove that field and other 'expert' references.

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 gfs2/libgfs2/libgfs2.h |  2 --
 gfs2/mkfs/main_jadd.c  | 15 ++++-----------
 gfs2/mkfs/main_mkfs.c  | 23 +++++++----------------
 3 files changed, 11 insertions(+), 29 deletions(-)

diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 3353f5f..b98d314 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -278,7 +278,6 @@ struct gfs2_sbd {
 
 	int debug;
 	int quiet;
-	int expert;
 	int override;
 
 	char device_name[PATH_MAX];
@@ -352,7 +351,6 @@ struct metapath {
 #define GFS2_MIN_GROW_SIZE          (10)
 #define GFS2_EXCESSIVE_RGS          (10000)
 
-#define GFS2_EXP_MIN_RGSIZE         (1)
 #define GFS2_MIN_RGSIZE             (32)
 #define GFS2_MAX_RGSIZE             (2048)
 
diff --git a/gfs2/mkfs/main_jadd.c b/gfs2/mkfs/main_jadd.c
index 815dd52..47af055 100644
--- a/gfs2/mkfs/main_jadd.c
+++ b/gfs2/mkfs/main_jadd.c
@@ -117,10 +117,10 @@ static void decode_arguments(int argc, char *argv[], struct gfs2_sbd *sdp)
 {
 	int cont = TRUE;
 	int optchar;
-	
+
 	while (cont) {
-		optchar = getopt(argc, argv, "c:DhJ:j:qu:VX");
-		
+		optchar = getopt(argc, argv, "c:DhJ:j:qu:V");
+
 		switch (optchar) {
 		case 'c':
 			sdp->qcsize = atoi(optarg);
@@ -147,9 +147,6 @@ static void decode_arguments(int argc, char *argv[], struct gfs2_sbd *sdp)
 			printf(REDHAT_COPYRIGHT "\n");
 			exit(0);
 			break;
-		case 'X':
-			sdp->expert = TRUE;
-			break;
 		case ':':
 		case '?':
 			fprintf(stderr, _("Please use '-h' for help.\n"));
@@ -200,17 +197,13 @@ verify_arguments(struct gfs2_sbd *sdp)
  *
  */
 
-static void 
-print_results(struct gfs2_sbd *sdp)
+static void print_results(struct gfs2_sbd *sdp)
 {
 	if (sdp->debug)
 		printf("\n");
 	else if (sdp->quiet)
 		return;
 
-	if (sdp->expert)
-		printf(_("Expert mode:            on\n"));
-
 	printf( _("Filesystem: %s\n"), sdp->path_name);
 	printf( _("Old Journals: %u\n"), sdp->orig_journals);
 	printf( _("New Journals: %u\n"), sdp->md.journals);
diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c
index 26aeba2..31b1e62 100644
--- a/gfs2/mkfs/main_mkfs.c
+++ b/gfs2/mkfs/main_mkfs.c
@@ -146,7 +146,6 @@ struct mkfs_opts {
 
 	unsigned override:1;
 	unsigned quiet:1;
-	unsigned expert:1;
 	unsigned debug:1;
 	unsigned confirm:1;
 	unsigned align:1;
@@ -294,7 +293,7 @@ static void opts_get(int argc, char *argv[], struct mkfs_opts *opts)
 {
 	int c;
 	while (1) {
-		c = getopt(argc, argv, "-b:c:DhJ:j:KOo:p:qr:t:VX");
+		c = getopt(argc, argv, "-b:c:DhJ:j:KOo:p:qr:t:V");
 		if (c == -1)
 			break;
 
@@ -351,9 +350,6 @@ static void opts_get(int argc, char *argv[], struct mkfs_opts *opts)
 			printf(REDHAT_COPYRIGHT "\n");
 			exit(EXIT_SUCCESS);
 			break;
-		case 'X':
-			opts->expert = 1;
-			break;
 		case ':':
 		case '?':
 			fprintf(stderr, _("Please use '-h' for help.\n"));
@@ -511,17 +507,12 @@ static void opts_check(struct mkfs_opts *opts)
 		exit(1);
 	}
 
-	if (!opts->expert)
-		test_locking(opts->lockproto, opts->locktable);
-	if (opts->expert) {
-		if (GFS2_EXP_MIN_RGSIZE > opts->rgsize || opts->rgsize > GFS2_MAX_RGSIZE)
-			/* Translators: gfs2 file systems are split into equal sized chunks called
-			   resource groups. We're checking that the user gave a valid size for them. */
-			die( _("bad resource group size\n"));
-	} else {
-		if (GFS2_MIN_RGSIZE > opts->rgsize || opts->rgsize > GFS2_MAX_RGSIZE)
-			die( _("bad resource group size\n"));
-	}
+	test_locking(opts->lockproto, opts->locktable);
+
+	if (GFS2_MIN_RGSIZE > opts->rgsize || opts->rgsize > GFS2_MAX_RGSIZE)
+		/* Translators: gfs2 file systems are split into equal sized chunks called
+		   resource groups. We're checking that the user gave a valid size for them. */
+		die( _("bad resource group size\n"));
 
 	if (!opts->journals)
 		die( _("no journals specified\n"));
-- 
1.9.0



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [Cluster-devel] [PATCH 3/5] libgfs2: Remove UI fields from struct gfs2_sbd
  2014-05-07 14:33 [Cluster-devel] [PATCH 1/5] fsck.gfs2: Log to syslog on start and exit Andrew Price
  2014-05-07 14:33 ` [Cluster-devel] [PATCH 2/5] gfs2-utils: Expressly expunge 'expert mode' Andrew Price
@ 2014-05-07 14:33 ` Andrew Price
  2014-05-07 14:33 ` [Cluster-devel] [PATCH 4/5] libgfs2: Remove debug field from gfs2_sbd Andrew Price
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 13+ messages in thread
From: Andrew Price @ 2014-05-07 14:33 UTC (permalink / raw)
  To: cluster-devel.redhat.com

The 'override' field wasn't being used at all and the 'quiet' field was
only being used by gfs2_jadd. Remove them in favour of keeping user
interface options in the apps themselves.

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 gfs2/libgfs2/libgfs2.h |  2 --
 gfs2/mkfs/main_jadd.c  | 13 +++++++------
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index b98d314..5fdf9af 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -277,8 +277,6 @@ struct gfs2_sbd {
 	unsigned int qcsize;     /* Size of quota change files (in MB) */
 
 	int debug;
-	int quiet;
-	int override;
 
 	char device_name[PATH_MAX];
 	char *path_name;
diff --git a/gfs2/mkfs/main_jadd.c b/gfs2/mkfs/main_jadd.c
index 47af055..d01e3b3 100644
--- a/gfs2/mkfs/main_jadd.c
+++ b/gfs2/mkfs/main_jadd.c
@@ -27,6 +27,8 @@
 #define BUF_SIZE 4096
 #define RANDOM(values) ((values) * (random() / (RAND_MAX + 1.0)))
 
+static int quiet = 0;
+
 static void
 make_jdata(int fd, const char *value)
 {
@@ -139,7 +141,7 @@ static void decode_arguments(int argc, char *argv[], struct gfs2_sbd *sdp)
 			sdp->md.journals = atoi(optarg);
 			break;
 		case 'q':
-			sdp->quiet = TRUE;
+			quiet = 1;
 			break;
 		case 'V':
 			printf("gfs2_jadd %s (built %s %s)\n", VERSION,
@@ -166,7 +168,7 @@ static void decode_arguments(int argc, char *argv[], struct gfs2_sbd *sdp)
 		optind++;
 	} else
 		die( _("no path specified (try -h for help)\n"));
-	
+
 	if (optind < argc)
 		die( _("Unrecognized argument: %s\n"), argv[optind]);
 
@@ -175,13 +177,12 @@ static void decode_arguments(int argc, char *argv[], struct gfs2_sbd *sdp)
 		printf("  qcsize = %u\n", sdp->qcsize);
 		printf("  jsize = %u\n", sdp->jsize);
 		printf("  journals = %u\n", sdp->md.journals);
-		printf("  quiet = %d\n", sdp->quiet);
+		printf("  quiet = %d\n", quiet);
 		printf("  path = %s\n", sdp->path_name);
 	}
 }
 
-static void 
-verify_arguments(struct gfs2_sbd *sdp)
+static void verify_arguments(struct gfs2_sbd *sdp)
 {
 	if (!sdp->md.journals)
 		die( _("no journals specified\n"));
@@ -201,7 +202,7 @@ static void print_results(struct gfs2_sbd *sdp)
 {
 	if (sdp->debug)
 		printf("\n");
-	else if (sdp->quiet)
+	else if (quiet)
 		return;
 
 	printf( _("Filesystem: %s\n"), sdp->path_name);
-- 
1.9.0



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [Cluster-devel] [PATCH 4/5] libgfs2: Remove debug field from gfs2_sbd
  2014-05-07 14:33 [Cluster-devel] [PATCH 1/5] fsck.gfs2: Log to syslog on start and exit Andrew Price
  2014-05-07 14:33 ` [Cluster-devel] [PATCH 2/5] gfs2-utils: Expressly expunge 'expert mode' Andrew Price
  2014-05-07 14:33 ` [Cluster-devel] [PATCH 3/5] libgfs2: Remove UI fields from struct gfs2_sbd Andrew Price
@ 2014-05-07 14:33 ` Andrew Price
  2014-05-07 14:33 ` [Cluster-devel] [PATCH 5/5] libgfs2: Remove logging API Andrew Price
  2014-05-07 14:39 ` [Cluster-devel] [PATCH 1/5] fsck.gfs2: Log to syslog on start and exit Steven Whitehouse
  4 siblings, 0 replies; 13+ messages in thread
From: Andrew Price @ 2014-05-07 14:33 UTC (permalink / raw)
  To: cluster-devel.redhat.com

The utils were using the debug field to store their debug printing
options.  Hide the debug field in a libgfs2-internal header to allow
switching on libgfs2 debugging output separately and switch the apps to
use their own debug options. In cases where apps were using sdp->debug
but not actually setting it, remove the code which depends on it being
set.

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 gfs2/convert/gfs2_convert.c    |  5 -----
 gfs2/fsck/rgrepair.c           | 19 -------------------
 gfs2/libgfs2/Makefile.am       |  4 ++--
 gfs2/libgfs2/config.c          |  9 +++++++++
 gfs2/libgfs2/config.h          |  6 ++++++
 gfs2/libgfs2/device_geometry.c |  3 ++-
 gfs2/libgfs2/fs_geometry.c     |  5 +++--
 gfs2/libgfs2/libgfs2.h         |  5 +++--
 gfs2/libgfs2/misc.c            |  7 ++++---
 gfs2/libgfs2/structures.c      | 31 +++++++++++++++----------------
 gfs2/mkfs/main_grow.c          | 21 ---------------------
 gfs2/mkfs/main_jadd.c          |  8 +++++---
 gfs2/mkfs/main_mkfs.c          | 10 +++++-----
 13 files changed, 54 insertions(+), 79 deletions(-)
 create mode 100644 gfs2/libgfs2/config.c
 create mode 100644 gfs2/libgfs2/config.h

diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index 9f7fa17..15a16ef 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -1981,11 +1981,6 @@ static int conv_build_jindex(struct gfs2_sbd *sdp)
 	}
 
 	free(sdp->md.journal);
-	if (sdp->debug) {
-		printf("\nJindex:\n");
-		gfs2_dinode_print(&sdp->md.jiinode->i_di);
-	}
-
 	inode_put(&sdp->md.jiinode);
 	return 0;
 }
diff --git a/gfs2/fsck/rgrepair.c b/gfs2/fsck/rgrepair.c
index 4fdbcf7..cb39541 100644
--- a/gfs2/fsck/rgrepair.c
+++ b/gfs2/fsck/rgrepair.c
@@ -589,24 +589,6 @@ 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)
@@ -649,7 +631,6 @@ 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);
 	if (build_rgrps(sdp, FALSE)) { /* FALSE = calc but don't write to disk. */
 		fprintf(stderr, _("Failed to build resource groups\n"));
 		exit(-1);
diff --git a/gfs2/libgfs2/Makefile.am b/gfs2/libgfs2/Makefile.am
index c5cb288..2d197f0 100644
--- a/gfs2/libgfs2/Makefile.am
+++ b/gfs2/libgfs2/Makefile.am
@@ -5,14 +5,14 @@ BUILT_SOURCES		= parser.h lexer.h
 AM_LFLAGS		= --header-file=lexer.h
 AM_YFLAGS		= -d
 
-noinst_HEADERS		= libgfs2.h lang.h
+noinst_HEADERS		= libgfs2.h lang.h config.h
 
 noinst_LTLIBRARIES	= libgfs2.la
 
 noinst_PROGRAMS		= gfs2l
 
 libgfs2_la_SOURCES	= block_list.c fs_bits.c gfs1.c misc.c rgrp.c super.c \
-			  buf.c fs_geometry.c gfs2_disk_hash.c ondisk.c \
+			  buf.c fs_geometry.c gfs2_disk_hash.c ondisk.c config.c \
 			  device_geometry.c fs_ops.c gfs2_log.c recovery.c \
 			  structures.c meta.c lang.c parser.y lexer.l
 
diff --git a/gfs2/libgfs2/config.c b/gfs2/libgfs2/config.c
new file mode 100644
index 0000000..d2431e4
--- /dev/null
+++ b/gfs2/libgfs2/config.c
@@ -0,0 +1,9 @@
+#include "libgfs2.h"
+#include "config.h"
+
+int cfg_debug = 0;
+
+void lgfs2_set_debug(int enable)
+{
+	cfg_debug = enable;
+}
diff --git a/gfs2/libgfs2/config.h b/gfs2/libgfs2/config.h
new file mode 100644
index 0000000..7c1eb3c
--- /dev/null
+++ b/gfs2/libgfs2/config.h
@@ -0,0 +1,6 @@
+#ifndef __LGFS2_CONFIG_H__
+#define __LGFS2_CONFIG_H__
+
+extern int cfg_debug;
+
+#endif /* __LGFS2_CONFIG_H__ */
diff --git a/gfs2/libgfs2/device_geometry.c b/gfs2/libgfs2/device_geometry.c
index 1bee9c2..27e846d 100644
--- a/gfs2/libgfs2/device_geometry.c
+++ b/gfs2/libgfs2/device_geometry.c
@@ -15,6 +15,7 @@
 #include <linux/fs.h>
 
 #include "libgfs2.h"
+#include "config.h"
 
 #ifndef BLKSSZGET
 #define BLKSSZGET _IO(0x12,104)   /* logical_block_size */
@@ -99,7 +100,7 @@ void fix_device_geometry(struct gfs2_sbd *sdp)
 
 	device->length = sdp->dinfo.size / sdp->bsize;
 
-	if (sdp->debug) {
+	if (cfg_debug) {
 		printf("\nDevice Geometry:  (in FS blocks)\n");
 		printf("  length = %"PRIu64"\n", device->length);
 		printf("\nDevice Size: %"PRIu64"\n", sdp->dinfo.size);
diff --git a/gfs2/libgfs2/fs_geometry.c b/gfs2/libgfs2/fs_geometry.c
index 4bdb64a..9c9085f 100644
--- a/gfs2/libgfs2/fs_geometry.c
+++ b/gfs2/libgfs2/fs_geometry.c
@@ -13,6 +13,7 @@
 
 #include <linux/types.h>
 #include "libgfs2.h"
+#include "config.h"
 
 #define DIV_RU(x, y) (((x) + (y) - 1) / (y))
 
@@ -59,7 +60,7 @@ uint64_t how_many_rgrps(struct gfs2_sbd *sdp, struct device *dev, int rgsize_spe
 		sdp->rgsize += GFS2_DEFAULT_RGSIZE; /* bigger rgs */
 	}
 
-	if (sdp->debug)
+	if (cfg_debug)
 		printf("  rg sz = %"PRIu32"\n  nrgrp = %"PRIu64"\n",
 		       sdp->rgsize, nrgrp);
 
@@ -220,7 +221,7 @@ int build_rgrps(struct gfs2_sbd *sdp, int do_write)
 			}
 		}
 
-		if (sdp->debug) {
+		if (cfg_debug) {
 			printf("\n");
 			gfs2_rindex_print(ri);
 		}
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 5fdf9af..b269357 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -276,8 +276,6 @@ struct gfs2_sbd {
 	unsigned int rgsize;     /* Size of resource groups (in MB) */
 	unsigned int qcsize;     /* Size of quota change files (in MB) */
 
-	int debug;
-
 	char device_name[PATH_MAX];
 	char *path_name;
 
@@ -401,6 +399,9 @@ extern uint32_t lgfs2_get_block_type(const struct gfs2_buffer_head *lbh);
 #define bread(bl, num) __bread(bl, num, __LINE__, __FUNCTION__)
 #define breadm(bl, bhs, n, block) __breadm(bl, bhs, n, block, __LINE__, __FUNCTION__)
 
+/* config.c */
+extern void lgfs2_set_debug(int enable);
+
 /* device_geometry.c */
 extern int lgfs2_get_dev_info(int fd, struct lgfs2_dev_info *i);
 extern void fix_device_geometry(struct gfs2_sbd *sdp);
diff --git a/gfs2/libgfs2/misc.c b/gfs2/libgfs2/misc.c
index 4cdd6e0..9eca24c 100644
--- a/gfs2/libgfs2/misc.c
+++ b/gfs2/libgfs2/misc.c
@@ -20,6 +20,7 @@
 #include <signal.h>
 
 #include "libgfs2.h"
+#include "config.h"
 
 #define PAGE_SIZE (4096)
 #define DIV_RU(x, y) (((x) + (y) - 1) / (y))
@@ -198,17 +199,17 @@ static int lock_for_admin(struct gfs2_sbd *sdp)
 {
 	int error;
 
-	if (sdp->debug)
+	if (cfg_debug)
 		printf("\nTrying to get admin lock...\n");
 
 	sdp->metafs_fd = open(sdp->metafs_path, O_RDONLY | O_NOFOLLOW);
 	if (sdp->metafs_fd < 0)
 		return -1;
-	
+
 	error = flock(sdp->metafs_fd, LOCK_EX);
 	if (error)
 		return -1;
-	if (sdp->debug)
+	if (cfg_debug)
 		printf("Got it.\n");
 	return 0;
 }
diff --git a/gfs2/libgfs2/structures.c b/gfs2/libgfs2/structures.c
index 2cc9a98..ee49dce 100644
--- a/gfs2/libgfs2/structures.c
+++ b/gfs2/libgfs2/structures.c
@@ -14,6 +14,7 @@
 #include <sys/time.h>
 
 #include "libgfs2.h"
+#include "config.h"
 
 int build_master(struct gfs2_sbd *sdp)
 {
@@ -29,12 +30,12 @@ int build_master(struct gfs2_sbd *sdp)
 	inum.no_addr = bn;
 
 	bh = init_dinode(sdp, &inum, S_IFDIR | 0755, GFS2_DIF_SYSTEM, &inum);
-	
+
 	sdp->master_dir = lgfs2_inode_get(sdp, bh);
 	if (sdp->master_dir == NULL)
 		return -1;
 
-	if (sdp->debug) {
+	if (cfg_debug) {
 		printf("\nMaster dir:\n");
 		gfs2_dinode_print(&sdp->master_dir->i_di);
 	}
@@ -223,7 +224,7 @@ int build_jindex(struct gfs2_sbd *sdp)
 			return ret;
 		inode_put(&sdp->md.journal[j]);
 	}
-	if (sdp->debug) {
+	if (cfg_debug) {
 		printf("\nJindex:\n");
 		gfs2_dinode_print(&jindex->i_di);
 	}
@@ -235,7 +236,6 @@ int build_jindex(struct gfs2_sbd *sdp)
 
 int build_inum_range(struct gfs2_inode *per_node, unsigned int j)
 {
-	struct gfs2_sbd *sdp = per_node->i_sbd;
 	char name[256];
 	struct gfs2_inode *ip;
 
@@ -248,7 +248,7 @@ int build_inum_range(struct gfs2_inode *per_node, unsigned int j)
 	ip->i_di.di_size = sizeof(struct gfs2_inum_range);
 	gfs2_dinode_out(&ip->i_di, ip->i_bh);
 
-	if (sdp->debug) {
+	if (cfg_debug) {
 		printf("\nInum Range %u:\n", j);
 		gfs2_dinode_print(&ip->i_di);
 	}
@@ -259,7 +259,6 @@ int build_inum_range(struct gfs2_inode *per_node, unsigned int j)
 
 int build_statfs_change(struct gfs2_inode *per_node, unsigned int j)
 {
-	struct gfs2_sbd *sdp = per_node->i_sbd;
 	char name[256];
 	struct gfs2_inode *ip;
 
@@ -272,7 +271,7 @@ int build_statfs_change(struct gfs2_inode *per_node, unsigned int j)
 	ip->i_di.di_size = sizeof(struct gfs2_statfs_change);
 	gfs2_dinode_out(&ip->i_di, ip->i_bh);
 
-	if (sdp->debug) {
+	if (cfg_debug) {
 		printf("\nStatFS Change %u:\n", j);
 		gfs2_dinode_print(&ip->i_di);
 	}
@@ -316,7 +315,7 @@ int build_quota_change(struct gfs2_inode *per_node, unsigned int j)
 		brelse(bh);
 	}
 
-	if (sdp->debug) {
+	if (cfg_debug) {
 		printf("\nQuota Change %u:\n", j);
 		gfs2_dinode_print(&ip->i_di);
 	}
@@ -352,7 +351,7 @@ int build_per_node(struct gfs2_sbd *sdp)
 		}
 	}
 
-	if (sdp->debug) {
+	if (cfg_debug) {
 		printf("\nper_node:\n");
 		gfs2_dinode_print(&per_node->i_di);
 	}
@@ -371,7 +370,7 @@ int build_inum(struct gfs2_sbd *sdp)
 		return errno;
 	}
 
-	if (sdp->debug) {
+	if (cfg_debug) {
 		printf("\nInum Inode:\n");
 		gfs2_dinode_print(&ip->i_di);
 	}
@@ -390,7 +389,7 @@ int build_statfs(struct gfs2_sbd *sdp)
 		return errno;
 	}
 
-	if (sdp->debug) {
+	if (cfg_debug) {
 		printf("\nStatFS Inode:\n");
 		gfs2_dinode_print(&ip->i_di);
 	}
@@ -432,7 +431,7 @@ int build_rindex(struct gfs2_sbd *sdp)
 	if (count != sizeof(struct gfs2_rindex))
 		return -1;
 
-	if (sdp->debug) {
+	if (cfg_debug) {
 		printf("\nResource Index:\n");
 		gfs2_dinode_print(&ip->i_di);
 	}
@@ -467,7 +466,7 @@ int build_quota(struct gfs2_sbd *sdp)
 	if (count != sizeof(struct gfs2_quota))
 		return -1;
 
-	if (sdp->debug) {
+	if (cfg_debug) {
 		printf("\nRoot quota:\n");
 		gfs2_quota_print(&qu);
 	}
@@ -494,7 +493,7 @@ int build_root(struct gfs2_sbd *sdp)
 	if (sdp->md.rooti == NULL)
 		return -1;
 
-	if (sdp->debug) {
+	if (cfg_debug) {
 		printf("\nRoot directory:\n");
 		gfs2_dinode_print(&sdp->md.rooti->i_di);
 	}
@@ -513,7 +512,7 @@ int do_init_inum(struct gfs2_sbd *sdp)
 	if (count != sizeof(uint64_t))
 		return -1;
 
-	if (sdp->debug)
+	if (cfg_debug)
 		printf("\nNext Inum: %"PRIu64"\n",
 		       sdp->md.next_inum);
 	return 0;
@@ -535,7 +534,7 @@ int do_init_statfs(struct gfs2_sbd *sdp)
 	if (count != sizeof(struct gfs2_statfs_change))
 		return -1;
 
-	if (sdp->debug) {
+	if (cfg_debug) {
 		printf("\nStatfs:\n");
 		gfs2_statfs_change_print(&sc);
 	}
diff --git a/gfs2/mkfs/main_grow.c b/gfs2/mkfs/main_grow.c
index adceeef..7e005e9 100644
--- a/gfs2/mkfs/main_grow.c
+++ b/gfs2/mkfs/main_grow.c
@@ -216,9 +216,6 @@ static unsigned initialize_new_portion(struct gfs2_sbd *sdp, lgfs2_rgrps_t rgs)
 		}
 		if (metafs_interrupted)
 			return 0;
-		if (sdp->debug)
-			printf(_("Writing resource group at %llu with size %"PRIu32"\n"),
-			       ri.ri_addr, ri.ri_length + ri.ri_data);
 		if (!test)
 			err = lgfs2_rgrp_write(rgs, sdp->device_fd, rg);
 		if (err != 0) {
@@ -322,22 +319,6 @@ static void print_info(struct gfs2_sbd *sdp)
 		   (unsigned long long)(fsgrowth * sdp->bsize) / MB);
 }
 
-static void debug_print_rgrps(const char *banner, struct gfs2_sbd *sdp, lgfs2_rgrps_t rgs)
-{
-	lgfs2_rgrp_t r;
-
-	if (sdp->debug) {
-		log_info("%s\n", banner);
-
-		for (r = lgfs2_rgrp_first(rgs); r; r = lgfs2_rgrp_next(r)) {
-			const struct gfs2_rindex *ri = lgfs2_rgrp_index(r);
-			log_info("ri_addr = %llu, size = %llu\n",
-				 (unsigned long long)ri->ri_addr,
-				 (unsigned long long)(ri->ri_data0 + ri->ri_data - ri->ri_addr));
-		}
-	}
-}
-
 void main_grow(int argc, char *argv[])
 {
 	struct gfs2_sbd sbd, *sdp = &sbd;
@@ -431,7 +412,6 @@ void main_grow(int argc, char *argv[])
 		if (metafs_interrupted)
 			goto out;
 		fssize = lgfs2_rgrp_align_addr(rgs, filesystem_size(rgs) + 1);
-		debug_print_rgrps(_("Existing resource groups"), sdp, rgs);
 		/* We're done with the old rgs now that we have the fssize and rg count */
 		lgfs2_rgrps_free(&rgs);
 		/* Now lets set up the new ones with alignment and all */
@@ -453,7 +433,6 @@ void main_grow(int argc, char *argv[])
 		rgcount = initialize_new_portion(sdp, rgs);
 		if (rgcount == 0 || metafs_interrupted)
 			goto out;
-		debug_print_rgrps(_("New resource groups"), sdp, rgs);
 		fsync(sdp->device_fd);
 		fix_rindex(rindex_fd, rgs, old_rg_count, rgcount);
 	out:
diff --git a/gfs2/mkfs/main_jadd.c b/gfs2/mkfs/main_jadd.c
index d01e3b3..4338e8d 100644
--- a/gfs2/mkfs/main_jadd.c
+++ b/gfs2/mkfs/main_jadd.c
@@ -28,6 +28,7 @@
 #define RANDOM(values) ((values) * (random() / (RAND_MAX + 1.0)))
 
 static int quiet = 0;
+static int debug = 0;
 
 static void
 make_jdata(int fd, const char *value)
@@ -128,7 +129,8 @@ static void decode_arguments(int argc, char *argv[], struct gfs2_sbd *sdp)
 			sdp->qcsize = atoi(optarg);
 			break;
 		case 'D':
-			sdp->debug = TRUE;
+			debug = 1;
+			lgfs2_set_debug(1);
 			break;
 		case 'h':
 			print_usage(argv[0]);
@@ -172,7 +174,7 @@ static void decode_arguments(int argc, char *argv[], struct gfs2_sbd *sdp)
 	if (optind < argc)
 		die( _("Unrecognized argument: %s\n"), argv[optind]);
 
-	if (sdp->debug) {
+	if (debug) {
 		printf( _("Command Line Arguments:\n"));
 		printf("  qcsize = %u\n", sdp->qcsize);
 		printf("  jsize = %u\n", sdp->jsize);
@@ -200,7 +202,7 @@ static void verify_arguments(struct gfs2_sbd *sdp)
 
 static void print_results(struct gfs2_sbd *sdp)
 {
-	if (sdp->debug)
+	if (debug)
 		printf("\n");
 	else if (quiet)
 		return;
diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c
index 31b1e62..f778e8d 100644
--- a/gfs2/mkfs/main_mkfs.c
+++ b/gfs2/mkfs/main_mkfs.c
@@ -308,6 +308,7 @@ static void opts_get(int argc, char *argv[], struct mkfs_opts *opts)
 			break;
 		case 'D':
 			opts->debug = 1;
+			lgfs2_set_debug(1);
 			break;
 		case 'h':
 			print_usage(argv[0]);
@@ -616,7 +617,7 @@ static lgfs2_rgrps_t rgs_init(struct mkfs_opts *opts, struct gfs2_sbd *sdp)
 	return rgs;
 }
 
-static int place_rgrp(struct gfs2_sbd *sdp, lgfs2_rgrps_t rgs, struct gfs2_rindex *ri)
+static int place_rgrp(struct gfs2_sbd *sdp, lgfs2_rgrps_t rgs, struct gfs2_rindex *ri, int debug)
 {
 	int err = 0;
 	lgfs2_rgrp_t rg = NULL;
@@ -631,7 +632,7 @@ static int place_rgrp(struct gfs2_sbd *sdp, lgfs2_rgrps_t rgs, struct gfs2_rinde
 		perror(_("Failed to write resource group"));
 		return -1;
 	}
-	if (sdp->debug) {
+	if (debug) {
 		gfs2_rindex_print(ri);
 		printf("\n");
 	}
@@ -665,7 +666,7 @@ static int place_rgrps(struct gfs2_sbd *sdp, lgfs2_rgrps_t rgs, struct mkfs_opts
 		rgaddr = lgfs2_rindex_entry_new(rgs, &ri, rgaddr, jrgsize);
 		if (rgaddr == 0) /* Reached the end when we still have journals to write */
 			return 1;
-		result = place_rgrp(sdp, rgs, &ri);
+		result = place_rgrp(sdp, rgs, &ri, opts->debug);
 		if (result != 0)
 			return result;
 	}
@@ -678,7 +679,7 @@ static int place_rgrps(struct gfs2_sbd *sdp, lgfs2_rgrps_t rgs, struct mkfs_opts
 		rgaddr = lgfs2_rindex_entry_new(rgs, &ri, rgaddr, 0);
 		if (rgaddr == 0)
 			break; /* Done */
-		result = place_rgrp(sdp, rgs, &ri);
+		result = place_rgrp(sdp, rgs, &ri, opts->debug);
 		if (result)
 			return result;
 	}
@@ -696,7 +697,6 @@ static void sbd_init(struct gfs2_sbd *sdp, struct mkfs_opts *opts, unsigned bsiz
 	sdp->md.journals = opts->journals;
 	sdp->device_fd = opts->dev.fd;
 	sdp->bsize = bsize;
-	sdp->debug = opts->debug;
 
 	if (compute_constants(sdp)) {
 		perror(_("Failed to compute file system constants"));
-- 
1.9.0



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [Cluster-devel] [PATCH 5/5] libgfs2: Remove logging API
  2014-05-07 14:33 [Cluster-devel] [PATCH 1/5] fsck.gfs2: Log to syslog on start and exit Andrew Price
                   ` (2 preceding siblings ...)
  2014-05-07 14:33 ` [Cluster-devel] [PATCH 4/5] libgfs2: Remove debug field from gfs2_sbd Andrew Price
@ 2014-05-07 14:33 ` Andrew Price
  2014-05-07 14:48   ` Steven Whitehouse
  2014-05-07 14:55   ` Bob Peterson
  2014-05-07 14:39 ` [Cluster-devel] [PATCH 1/5] fsck.gfs2: Log to syslog on start and exit Steven Whitehouse
  4 siblings, 2 replies; 13+ messages in thread
From: Andrew Price @ 2014-05-07 14:33 UTC (permalink / raw)
  To: cluster-devel.redhat.com

libgfs2 was exposing a logging API (log_info, etc.) but wasn't using it
itself. Remove the logging bits and move them into
gfs2/include/logging.h

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 gfs2/convert/gfs2_convert.c |  2 ++
 gfs2/edit/savemeta.c        |  2 ++
 gfs2/fsck/fs_recovery.c     |  1 +
 gfs2/fsck/initialize.c      |  1 +
 gfs2/fsck/inode_hash.c      |  1 +
 gfs2/fsck/link.c            |  1 +
 gfs2/fsck/lost_n_found.c    |  1 +
 gfs2/fsck/main.c            |  2 ++
 gfs2/fsck/metawalk.c        |  1 +
 gfs2/fsck/pass1.c           |  1 +
 gfs2/fsck/pass1b.c          |  1 +
 gfs2/fsck/pass1c.c          |  1 +
 gfs2/fsck/pass2.c           |  1 +
 gfs2/fsck/pass3.c           |  1 +
 gfs2/fsck/pass4.c           |  1 +
 gfs2/fsck/pass5.c           |  1 +
 gfs2/fsck/rgrepair.c        |  1 +
 gfs2/fsck/util.c            |  1 +
 gfs2/include/Makefile.am    |  2 +-
 gfs2/include/logging.h      | 36 ++++++++++++++++++++++++++++++++++++
 gfs2/libgfs2/Makefile.am    |  2 +-
 gfs2/libgfs2/fs_geometry.c  |  8 ++++----
 gfs2/libgfs2/gfs2_log.c     | 24 ------------------------
 gfs2/libgfs2/libgfs2.h      | 34 ----------------------------------
 gfs2/mkfs/main_grow.c       |  2 ++
 25 files changed, 65 insertions(+), 64 deletions(-)
 create mode 100644 gfs2/include/logging.h
 delete mode 100644 gfs2/libgfs2/gfs2_log.c

diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index 15a16ef..87bec8c 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -30,6 +30,7 @@
 
 #include <linux/types.h>
 #include <linux/gfs2_ondisk.h>
+#include <logging.h>
 #include "osi_list.h"
 #include "copyright.cf"
 #include "libgfs2.h"
@@ -112,6 +113,7 @@ uint64_t gfs2_jheightsize[GFS2_MAX_META_HEIGHT];
 uint32_t gfs2_max_height;
 uint32_t gfs2_max_jheight;
 uint64_t jindex_addr = 0, rindex_addr = 0;
+int print_level = MSG_NOTICE;
 
 /* ------------------------------------------------------------------------- */
 /* This function is for libgfs's sake.                                       */
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index c9f2d0a..ab7f86f 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -20,6 +20,7 @@
 #include <linux/gfs2_ondisk.h>
 #include <zlib.h>
 
+#include <logging.h>
 #include "osi_list.h"
 #include "gfs2hex.h"
 #include "hexedit.h"
@@ -47,6 +48,7 @@ uint64_t last_reported_block, blks_saved, total_out, pct;
 uint64_t journal_blocks[MAX_JOURNALS_SAVED];
 uint64_t gfs1_journal_size = 0; /* in blocks */
 int journals_found = 0;
+int print_level = MSG_NOTICE;
 
 extern void read_superblock(void);
 
diff --git a/gfs2/fsck/fs_recovery.c b/gfs2/fsck/fs_recovery.c
index 54a8c5f..a052487 100644
--- a/gfs2/fsck/fs_recovery.c
+++ b/gfs2/fsck/fs_recovery.c
@@ -9,6 +9,7 @@
 #include <libintl.h>
 #define _(String) gettext(String)
 
+#include <logging.h>
 #include "fsck.h"
 #include "fs_recovery.h"
 #include "libgfs2.h"
diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c
index 9ada7d2..f7ea45f 100644
--- a/gfs2/fsck/initialize.c
+++ b/gfs2/fsck/initialize.c
@@ -15,6 +15,7 @@
 
 #define _(String) gettext(String)
 
+#include <logging.h>
 #include "libgfs2.h"
 #include "fsck.h"
 #include "util.h"
diff --git a/gfs2/fsck/inode_hash.c b/gfs2/fsck/inode_hash.c
index aca5e61..eeb0a84 100644
--- a/gfs2/fsck/inode_hash.c
+++ b/gfs2/fsck/inode_hash.c
@@ -5,6 +5,7 @@
 #include <libintl.h>
 #include <string.h>
 
+#include <logging.h>
 #include "libgfs2.h"
 #include "osi_list.h"
 #include "inode_hash.h"
diff --git a/gfs2/fsck/link.c b/gfs2/fsck/link.c
index 72fe7d5..9a958b4 100644
--- a/gfs2/fsck/link.c
+++ b/gfs2/fsck/link.c
@@ -8,6 +8,7 @@
 #include <libintl.h>
 #define _(String) gettext(String)
 
+#include <logging.h>
 #include "libgfs2.h"
 #include "fsck.h"
 #include "inode_hash.h"
diff --git a/gfs2/fsck/lost_n_found.c b/gfs2/fsck/lost_n_found.c
index 919cb2f..9672c7a 100644
--- a/gfs2/fsck/lost_n_found.c
+++ b/gfs2/fsck/lost_n_found.c
@@ -10,6 +10,7 @@
 #include <libintl.h>
 #define _(String) gettext(String)
 
+#include <logging.h>
 #include "fsck.h"
 #include "libgfs2.h"
 #include "lost_n_found.h"
diff --git a/gfs2/fsck/main.c b/gfs2/fsck/main.c
index 0031ec0..05979dc 100644
--- a/gfs2/fsck/main.c
+++ b/gfs2/fsck/main.c
@@ -14,6 +14,7 @@
 #define _(String) gettext(String)
 #include <syslog.h>
 
+#include <logging.h>
 #include "copyright.cf"
 #include "libgfs2.h"
 #include "fsck.h"
@@ -39,6 +40,7 @@ struct osi_root inodetree = (struct osi_root) { NULL, };
 int dups_found = 0, dups_found_first = 0;
 struct gfs_sb *sbd1 = NULL;
 int sb_fixed = 0;
+int print_level = MSG_NOTICE;
 
 /* This function is for libgfs2's sake.                                      */
 void print_it(const char *label, const char *fmt, const char *fmt2, ...)
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index 594fbfa..659af4e 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -12,6 +12,7 @@
 #include <fcntl.h>
 #define _(String) gettext(String)
 
+#include <logging.h>
 #include "libgfs2.h"
 #include "osi_tree.h"
 #include "fsck.h"
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index df778ef..4f1b77a 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -20,6 +20,7 @@
 #include <libintl.h>
 #define _(String) gettext(String)
 
+#include <logging.h>
 #include "libgfs2.h"
 #include "fsck.h"
 #include "inode_hash.h"
diff --git a/gfs2/fsck/pass1b.c b/gfs2/fsck/pass1b.c
index e3da20a..f82f43b 100644
--- a/gfs2/fsck/pass1b.c
+++ b/gfs2/fsck/pass1b.c
@@ -8,6 +8,7 @@
 #include <sys/stat.h>
 #define _(String) gettext(String)
 
+#include <logging.h>
 #include "libgfs2.h"
 #include "fsck.h"
 #include "osi_list.h"
diff --git a/gfs2/fsck/pass1c.c b/gfs2/fsck/pass1c.c
index b918de1..ce9ca96 100644
--- a/gfs2/fsck/pass1c.c
+++ b/gfs2/fsck/pass1c.c
@@ -7,6 +7,7 @@
 #include <libintl.h>
 #define _(String) gettext(String)
 
+#include <logging.h>
 #include "libgfs2.h"
 #include "fsck.h"
 #include "util.h"
diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c
index c8c047e..2474ccb 100644
--- a/gfs2/fsck/pass2.c
+++ b/gfs2/fsck/pass2.c
@@ -9,6 +9,7 @@
 #include <libintl.h>
 #define _(String) gettext(String)
 
+#include <logging.h>
 #include "libgfs2.h"
 #include "fsck.h"
 #include "util.h"
diff --git a/gfs2/fsck/pass3.c b/gfs2/fsck/pass3.c
index 6448da3..9582b5b 100644
--- a/gfs2/fsck/pass3.c
+++ b/gfs2/fsck/pass3.c
@@ -8,6 +8,7 @@
 #include <libintl.h>
 #define _(String) gettext(String)
 
+#include <logging.h>
 #include "libgfs2.h"
 #include "osi_list.h"
 #include "fsck.h"
diff --git a/gfs2/fsck/pass4.c b/gfs2/fsck/pass4.c
index 311b96b..7b3cb87 100644
--- a/gfs2/fsck/pass4.c
+++ b/gfs2/fsck/pass4.c
@@ -6,6 +6,7 @@
 #include <libintl.h>
 #define _(String) gettext(String)
 
+#include <logging.h>
 #include "libgfs2.h"
 #include "fsck.h"
 #include "lost_n_found.h"
diff --git a/gfs2/fsck/pass5.c b/gfs2/fsck/pass5.c
index 49ab682..68b1373 100644
--- a/gfs2/fsck/pass5.c
+++ b/gfs2/fsck/pass5.c
@@ -7,6 +7,7 @@
 #include <libintl.h>
 #define _(String) gettext(String)
 
+#include <logging.h>
 #include "libgfs2.h"
 #include "fsck.h"
 #include "util.h"
diff --git a/gfs2/fsck/rgrepair.c b/gfs2/fsck/rgrepair.c
index cb39541..0466dd8 100644
--- a/gfs2/fsck/rgrepair.c
+++ b/gfs2/fsck/rgrepair.c
@@ -10,6 +10,7 @@
 #include <libintl.h>
 #define _(String) gettext(String)
 
+#include <logging.h>
 #include "libgfs2.h"
 #include "osi_list.h"
 #include "fsck.h"
diff --git a/gfs2/fsck/util.c b/gfs2/fsck/util.c
index f8ccb3e..8b439a9 100644
--- a/gfs2/fsck/util.c
+++ b/gfs2/fsck/util.c
@@ -12,6 +12,7 @@
 #include <ctype.h>
 #define _(String) gettext(String)
 
+#include <logging.h>
 #include "libgfs2.h"
 #include "metawalk.h"
 #include "util.h"
diff --git a/gfs2/include/Makefile.am b/gfs2/include/Makefile.am
index a017cb3..c755181 100644
--- a/gfs2/include/Makefile.am
+++ b/gfs2/include/Makefile.am
@@ -1,3 +1,3 @@
 MAINTAINERCLEANFILES	= Makefile.in
 
-noinst_HEADERS		= osi_list.h osi_tree.h linux_endian.h
+noinst_HEADERS		= osi_list.h osi_tree.h linux_endian.h logging.h
diff --git a/gfs2/include/logging.h b/gfs2/include/logging.h
new file mode 100644
index 0000000..18b5832
--- /dev/null
+++ b/gfs2/include/logging.h
@@ -0,0 +1,36 @@
+#ifndef __LOGGING_H__
+#define __LOGGING_H__
+
+extern int print_level;
+#define increase_verbosity() do { print_level++; } while(0)
+#define decrease_verbosity() do { print_level--; } while(0)
+
+#define MSG_DEBUG       7
+#define MSG_INFO        6
+#define MSG_NOTICE      5
+#define MSG_WARN        4
+#define MSG_ERROR       3
+#define MSG_CRITICAL    2
+#define MSG_NULL        1
+
+#define log_debug(format...) \
+	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) printf(format); } while(0)
+
+#define log_notice(format...) \
+	do { if (print_level >= MSG_NOTICE) printf(format); } while(0)
+
+#define log_warn(format...) \
+	do { if (print_level >= MSG_WARN) printf(format); } while(0)
+
+#define log_err(format...) \
+	do { if (print_level >= MSG_ERROR) fprintf(stderr, format); } while(0)
+
+#define log_crit(format...) \
+	do { if (print_level >= MSG_CRITICAL) fprintf(stderr, format); } while(0)
+
+#endif /* __LOGGING_H__ */
diff --git a/gfs2/libgfs2/Makefile.am b/gfs2/libgfs2/Makefile.am
index 2d197f0..4af27be 100644
--- a/gfs2/libgfs2/Makefile.am
+++ b/gfs2/libgfs2/Makefile.am
@@ -13,7 +13,7 @@ noinst_PROGRAMS		= gfs2l
 
 libgfs2_la_SOURCES	= block_list.c fs_bits.c gfs1.c misc.c rgrp.c super.c \
 			  buf.c fs_geometry.c gfs2_disk_hash.c ondisk.c config.c \
-			  device_geometry.c fs_ops.c gfs2_log.c recovery.c \
+			  device_geometry.c fs_ops.c recovery.c \
 			  structures.c meta.c lang.c parser.y lexer.l
 
 libgfs2_la_CPPFLAGS	= -D_FILE_OFFSET_BITS=64 \
diff --git a/gfs2/libgfs2/fs_geometry.c b/gfs2/libgfs2/fs_geometry.c
index 9c9085f..587ceb8 100644
--- a/gfs2/libgfs2/fs_geometry.c
+++ b/gfs2/libgfs2/fs_geometry.c
@@ -97,12 +97,12 @@ void compute_rgrp_layout(struct gfs2_sbd *sdp, struct osi_root *rgtree,
 	} else {
 		uint64_t old_length, new_chunk;
 
-		log_info("Existing resource groups:\n");
+		printf("Existing resource groups:\n");
 		for (rgrp = 0, n = osi_first(rgtree); n; n = next, rgrp++) {
 			next = osi_next(n);
 			rl = (struct rgrp_tree *)n;
 
-			log_info("%d: start: %" PRIu64 " (0x%"
+			printf("%d: start: %" PRIu64 " (0x%"
 				 PRIx64 "), length = %"PRIu64" (0x%"
 				 PRIx64 ")\n", rgrp + 1, rl->start, rl->start,
 				 rl->length, rl->length);
@@ -118,7 +118,7 @@ void compute_rgrp_layout(struct gfs2_sbd *sdp, struct osi_root *rgtree,
 	}
 
 	if (rgrp < nrgrp)
-		log_info("\nNew resource groups:\n");
+		printf("\nNew resource groups:\n");
 	for (; rgrp < nrgrp; rgrp++) {
 		if (rgrp) {
 			rgaddr = rlast->start + rlast->length;
@@ -131,7 +131,7 @@ void compute_rgrp_layout(struct gfs2_sbd *sdp, struct osi_root *rgtree,
 				(nrgrp - 1) * (dev->length / nrgrp);
 		}
 		rl->start = rgaddr;
-		log_info("%d: start: %" PRIu64 " (0x%"
+		printf("%d: start: %" PRIu64 " (0x%"
 			 PRIx64 "), length = %"PRIu64" (0x%"
 			 PRIx64 ")\n", rgrp + 1, rl->start, rl->start,
 			 rl->length, rl->length);
diff --git a/gfs2/libgfs2/gfs2_log.c b/gfs2/libgfs2/gfs2_log.c
deleted file mode 100644
index da5f489..0000000
--- a/gfs2/libgfs2/gfs2_log.c
+++ /dev/null
@@ -1,24 +0,0 @@
-#include "clusterautoconfig.h"
-
-#include <stdio.h>
-#include <stdarg.h>
-#include <ctype.h>
-#include <sys/select.h>
-#include <signal.h>
-#include <string.h>
-#include <termios.h>
-#include <unistd.h>
-
-#include "libgfs2.h"
-
-int print_level = MSG_NOTICE;
-
-void increase_verbosity(void)
-{
-	print_level++;
-}
-
-void decrease_verbosity(void)
-{
-	print_level--;
-}
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index b269357..041e5fd 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -671,40 +671,6 @@ extern void gfs_jindex_in(struct gfs_jindex *jindex, char *buf);
 extern void gfs_rgrp_in(struct gfs_rgrp *rg, struct gfs2_buffer_head *bh);
 extern void gfs_rgrp_out(struct gfs_rgrp *rg, struct gfs2_buffer_head *bh);
 
-/* gfs2_log.c */
-
-extern int print_level;
-
-#define MSG_DEBUG       7
-#define MSG_INFO        6
-#define MSG_NOTICE      5
-#define MSG_WARN        4
-#define MSG_ERROR       3
-#define MSG_CRITICAL    2
-#define MSG_NULL        1
-
-#define log_debug(format...) \
-	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) printf(format); } while(0)
-
-#define log_notice(format...) \
-	do { if (print_level >= MSG_NOTICE) printf(format); } while(0)
-
-#define log_warn(format...) \
-	do { if (print_level >= MSG_WARN) printf(format); } while(0)
-
-#define log_err(format...) \
-	do { if (print_level >= MSG_ERROR) fprintf(stderr, format); } while(0)
-
-#define log_crit(format...) \
-	do { if (print_level >= MSG_CRITICAL) fprintf(stderr, format); } while(0)
-
-extern void increase_verbosity(void);
-extern void decrease_verbosity(void);
 /* misc.c */
 
 extern int metafs_interrupted;
diff --git a/gfs2/mkfs/main_grow.c b/gfs2/mkfs/main_grow.c
index 7e005e9..5da809a 100644
--- a/gfs2/mkfs/main_grow.c
+++ b/gfs2/mkfs/main_grow.c
@@ -23,6 +23,7 @@
 #include <libintl.h>
 #define _(String) gettext(String)
 
+#include <logging.h>
 #include "libgfs2.h"
 #include "gfs2_mkfs.h"
 
@@ -33,6 +34,7 @@ static uint64_t override_device_size = 0;
 static int test = 0;
 static uint64_t fssize = 0, fsgrowth;
 static unsigned int rgsize = 0;
+int print_level = MSG_NOTICE;
 
 extern int create_new_inode(struct gfs2_sbd *sdp);
 extern int rename2system(struct gfs2_sbd *sdp, char *new_dir, char *new_name);
-- 
1.9.0



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [Cluster-devel] [PATCH 1/5] fsck.gfs2: Log to syslog on start and exit
  2014-05-07 14:33 [Cluster-devel] [PATCH 1/5] fsck.gfs2: Log to syslog on start and exit Andrew Price
                   ` (3 preceding siblings ...)
  2014-05-07 14:33 ` [Cluster-devel] [PATCH 5/5] libgfs2: Remove logging API Andrew Price
@ 2014-05-07 14:39 ` Steven Whitehouse
  2014-05-07 15:15   ` Andrew Price
  4 siblings, 1 reply; 13+ messages in thread
From: Steven Whitehouse @ 2014-05-07 14:39 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Hi,

On 07/05/14 15:33, Andrew Price wrote:
> In order to piece together the order in which fsck.gfs2 runs and
> gfs2_edit savemeta were done it's useful to keep a log of the command
> line options used and the fsck.gfs2 start and end times. Log these to
> syslog.
>
> Signed-off-by: Andrew Price <anprice@redhat.com>
> ---
>   gfs2/fsck/main.c     | 35 +++++++++++++++++++++++++++++++++++
>   gfs2/man/fsck.gfs2.8 |  2 ++
>   2 files changed, 37 insertions(+)
>
> diff --git a/gfs2/fsck/main.c b/gfs2/fsck/main.c
> index 346e580..0031ec0 100644
> --- a/gfs2/fsck/main.c
> +++ b/gfs2/fsck/main.c
> @@ -12,6 +12,7 @@
>   #include <libintl.h>
>   #include <locale.h>
>   #define _(String) gettext(String)
> +#include <syslog.h>
>   
>   #include "copyright.cf"
>   #include "libgfs2.h"
> @@ -261,6 +262,36 @@ static int fsck_pass(const struct fsck_pass *p, struct gfs2_sbd *sdp)
>   	return 0;
>   }
>   
> +static void exitlog(void)
> +{
> +	syslog(LOG_INFO, "exiting.");
> +}
> +
Would be nice if it was possible to log the exit status too here...

> +static void startlog(int argc, char **argv)
> +{
> +	int i;
> +	char *cmd, *p;
> +	size_t len;
> +
> +	for (len = i = 0; i < argc; i++)
> +		len += strlen(argv[i]);
> +	len += argc; /* Add spaces and '\0' */
> +
> +	cmd = malloc(len);
> +	if (cmd == NULL) {
> +		perror(argv[0]);
> +		exit(FSCK_ERROR);
> +	}
> +	p = cmd;
> +	for (i = 0; i < argc; i++, p++) {
> +		p = stpcpy(p, argv[i]);
> +		*p = ' ';
> +	}
> +	*(--p) = '\0';
> +	syslog(LOG_INFO, "started: %s", cmd);
If you use vsyslog rather than syslog I wonder if its possible to make 
this a bit neater?

Steve.

> +	free(cmd);
> +}
> +
>   int main(int argc, char **argv)
>   {
>   	struct gfs2_sbd sb;
> @@ -274,6 +305,10 @@ int main(int argc, char **argv)
>   	setlocale(LC_ALL, "");
>   	textdomain("gfs2-utils");
>   
> +	openlog("fsck.gfs2", LOG_CONS|LOG_PID, LOG_USER);
> +	startlog(argc - 1, &argv[1]);
> +	atexit(exitlog);
> +
>   	memset(sdp, 0, sizeof(*sdp));
>   
>   	if ((error = read_cmdline(argc, argv, &opts)))
> diff --git a/gfs2/man/fsck.gfs2.8 b/gfs2/man/fsck.gfs2.8
> index 3ecfbe3..56dcddc 100644
> --- a/gfs2/man/fsck.gfs2.8
> +++ b/gfs2/man/fsck.gfs2.8
> @@ -35,6 +35,8 @@ computer.  Therefore, fsck.gfs2 will always check the file system unless
>   the -p (preen) option is used, in which case it follows special rules
>   (see below).
>   
> +fsck.gfs2 will log to the system log on start and exit to aid debugging and
> +administration.
>   .SH OPTIONS
>   .TP
>   \fB-a\fP



^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Cluster-devel] [PATCH 2/5] gfs2-utils: Expressly expunge 'expert mode'
  2014-05-07 14:33 ` [Cluster-devel] [PATCH 2/5] gfs2-utils: Expressly expunge 'expert mode' Andrew Price
@ 2014-05-07 14:48   ` Bob Peterson
  2014-05-07 15:01     ` Andrew Price
  0 siblings, 1 reply; 13+ messages in thread
From: Bob Peterson @ 2014-05-07 14:48 UTC (permalink / raw)
  To: cluster-devel.redhat.com

----- Original Message -----
> mkfs.gfs2 and gfs2_jadd used struct gfs2_sbd.expert to put them into an
> undocumented 'expert mode' but didn't really do anything useful in that
> mode. Remove that field and other 'expert' references.
> 

In the past, we've used mkfs.gfs2 expert mode to create certain test
conditions, like very small resource groups. I don't think Nate uses
this in any of his tests, but it might be worth asking.
I've used it to try to recreate certain failing scenarios, but I haven't
needed it in years. Are we sure we want to get rid of it?

Regards,

Bob Peterson
Red Hat File Systems



^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Cluster-devel] [PATCH 5/5] libgfs2: Remove logging API
  2014-05-07 14:33 ` [Cluster-devel] [PATCH 5/5] libgfs2: Remove logging API Andrew Price
@ 2014-05-07 14:48   ` Steven Whitehouse
  2014-05-07 14:55   ` Bob Peterson
  1 sibling, 0 replies; 13+ messages in thread
From: Steven Whitehouse @ 2014-05-07 14:48 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Hi,

Other patches in the series all look good to me,

Steve.

On 07/05/14 15:33, Andrew Price wrote:
> libgfs2 was exposing a logging API (log_info, etc.) but wasn't using it
> itself. Remove the logging bits and move them into
> gfs2/include/logging.h
>
> Signed-off-by: Andrew Price <anprice@redhat.com>
> ---
>   gfs2/convert/gfs2_convert.c |  2 ++
>   gfs2/edit/savemeta.c        |  2 ++
>   gfs2/fsck/fs_recovery.c     |  1 +
>   gfs2/fsck/initialize.c      |  1 +
>   gfs2/fsck/inode_hash.c      |  1 +
>   gfs2/fsck/link.c            |  1 +
>   gfs2/fsck/lost_n_found.c    |  1 +
>   gfs2/fsck/main.c            |  2 ++
>   gfs2/fsck/metawalk.c        |  1 +
>   gfs2/fsck/pass1.c           |  1 +
>   gfs2/fsck/pass1b.c          |  1 +
>   gfs2/fsck/pass1c.c          |  1 +
>   gfs2/fsck/pass2.c           |  1 +
>   gfs2/fsck/pass3.c           |  1 +
>   gfs2/fsck/pass4.c           |  1 +
>   gfs2/fsck/pass5.c           |  1 +
>   gfs2/fsck/rgrepair.c        |  1 +
>   gfs2/fsck/util.c            |  1 +
>   gfs2/include/Makefile.am    |  2 +-
>   gfs2/include/logging.h      | 36 ++++++++++++++++++++++++++++++++++++
>   gfs2/libgfs2/Makefile.am    |  2 +-
>   gfs2/libgfs2/fs_geometry.c  |  8 ++++----
>   gfs2/libgfs2/gfs2_log.c     | 24 ------------------------
>   gfs2/libgfs2/libgfs2.h      | 34 ----------------------------------
>   gfs2/mkfs/main_grow.c       |  2 ++
>   25 files changed, 65 insertions(+), 64 deletions(-)
>   create mode 100644 gfs2/include/logging.h
>   delete mode 100644 gfs2/libgfs2/gfs2_log.c
>
> diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
> index 15a16ef..87bec8c 100644
> --- a/gfs2/convert/gfs2_convert.c
> +++ b/gfs2/convert/gfs2_convert.c
> @@ -30,6 +30,7 @@
>   
>   #include <linux/types.h>
>   #include <linux/gfs2_ondisk.h>
> +#include <logging.h>
>   #include "osi_list.h"
>   #include "copyright.cf"
>   #include "libgfs2.h"
> @@ -112,6 +113,7 @@ uint64_t gfs2_jheightsize[GFS2_MAX_META_HEIGHT];
>   uint32_t gfs2_max_height;
>   uint32_t gfs2_max_jheight;
>   uint64_t jindex_addr = 0, rindex_addr = 0;
> +int print_level = MSG_NOTICE;
>   
>   /* ------------------------------------------------------------------------- */
>   /* This function is for libgfs's sake.                                       */
> diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
> index c9f2d0a..ab7f86f 100644
> --- a/gfs2/edit/savemeta.c
> +++ b/gfs2/edit/savemeta.c
> @@ -20,6 +20,7 @@
>   #include <linux/gfs2_ondisk.h>
>   #include <zlib.h>
>   
> +#include <logging.h>
>   #include "osi_list.h"
>   #include "gfs2hex.h"
>   #include "hexedit.h"
> @@ -47,6 +48,7 @@ uint64_t last_reported_block, blks_saved, total_out, pct;
>   uint64_t journal_blocks[MAX_JOURNALS_SAVED];
>   uint64_t gfs1_journal_size = 0; /* in blocks */
>   int journals_found = 0;
> +int print_level = MSG_NOTICE;
>   
>   extern void read_superblock(void);
>   
> diff --git a/gfs2/fsck/fs_recovery.c b/gfs2/fsck/fs_recovery.c
> index 54a8c5f..a052487 100644
> --- a/gfs2/fsck/fs_recovery.c
> +++ b/gfs2/fsck/fs_recovery.c
> @@ -9,6 +9,7 @@
>   #include <libintl.h>
>   #define _(String) gettext(String)
>   
> +#include <logging.h>
>   #include "fsck.h"
>   #include "fs_recovery.h"
>   #include "libgfs2.h"
> diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c
> index 9ada7d2..f7ea45f 100644
> --- a/gfs2/fsck/initialize.c
> +++ b/gfs2/fsck/initialize.c
> @@ -15,6 +15,7 @@
>   
>   #define _(String) gettext(String)
>   
> +#include <logging.h>
>   #include "libgfs2.h"
>   #include "fsck.h"
>   #include "util.h"
> diff --git a/gfs2/fsck/inode_hash.c b/gfs2/fsck/inode_hash.c
> index aca5e61..eeb0a84 100644
> --- a/gfs2/fsck/inode_hash.c
> +++ b/gfs2/fsck/inode_hash.c
> @@ -5,6 +5,7 @@
>   #include <libintl.h>
>   #include <string.h>
>   
> +#include <logging.h>
>   #include "libgfs2.h"
>   #include "osi_list.h"
>   #include "inode_hash.h"
> diff --git a/gfs2/fsck/link.c b/gfs2/fsck/link.c
> index 72fe7d5..9a958b4 100644
> --- a/gfs2/fsck/link.c
> +++ b/gfs2/fsck/link.c
> @@ -8,6 +8,7 @@
>   #include <libintl.h>
>   #define _(String) gettext(String)
>   
> +#include <logging.h>
>   #include "libgfs2.h"
>   #include "fsck.h"
>   #include "inode_hash.h"
> diff --git a/gfs2/fsck/lost_n_found.c b/gfs2/fsck/lost_n_found.c
> index 919cb2f..9672c7a 100644
> --- a/gfs2/fsck/lost_n_found.c
> +++ b/gfs2/fsck/lost_n_found.c
> @@ -10,6 +10,7 @@
>   #include <libintl.h>
>   #define _(String) gettext(String)
>   
> +#include <logging.h>
>   #include "fsck.h"
>   #include "libgfs2.h"
>   #include "lost_n_found.h"
> diff --git a/gfs2/fsck/main.c b/gfs2/fsck/main.c
> index 0031ec0..05979dc 100644
> --- a/gfs2/fsck/main.c
> +++ b/gfs2/fsck/main.c
> @@ -14,6 +14,7 @@
>   #define _(String) gettext(String)
>   #include <syslog.h>
>   
> +#include <logging.h>
>   #include "copyright.cf"
>   #include "libgfs2.h"
>   #include "fsck.h"
> @@ -39,6 +40,7 @@ struct osi_root inodetree = (struct osi_root) { NULL, };
>   int dups_found = 0, dups_found_first = 0;
>   struct gfs_sb *sbd1 = NULL;
>   int sb_fixed = 0;
> +int print_level = MSG_NOTICE;
>   
>   /* This function is for libgfs2's sake.                                      */
>   void print_it(const char *label, const char *fmt, const char *fmt2, ...)
> diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
> index 594fbfa..659af4e 100644
> --- a/gfs2/fsck/metawalk.c
> +++ b/gfs2/fsck/metawalk.c
> @@ -12,6 +12,7 @@
>   #include <fcntl.h>
>   #define _(String) gettext(String)
>   
> +#include <logging.h>
>   #include "libgfs2.h"
>   #include "osi_tree.h"
>   #include "fsck.h"
> diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
> index df778ef..4f1b77a 100644
> --- a/gfs2/fsck/pass1.c
> +++ b/gfs2/fsck/pass1.c
> @@ -20,6 +20,7 @@
>   #include <libintl.h>
>   #define _(String) gettext(String)
>   
> +#include <logging.h>
>   #include "libgfs2.h"
>   #include "fsck.h"
>   #include "inode_hash.h"
> diff --git a/gfs2/fsck/pass1b.c b/gfs2/fsck/pass1b.c
> index e3da20a..f82f43b 100644
> --- a/gfs2/fsck/pass1b.c
> +++ b/gfs2/fsck/pass1b.c
> @@ -8,6 +8,7 @@
>   #include <sys/stat.h>
>   #define _(String) gettext(String)
>   
> +#include <logging.h>
>   #include "libgfs2.h"
>   #include "fsck.h"
>   #include "osi_list.h"
> diff --git a/gfs2/fsck/pass1c.c b/gfs2/fsck/pass1c.c
> index b918de1..ce9ca96 100644
> --- a/gfs2/fsck/pass1c.c
> +++ b/gfs2/fsck/pass1c.c
> @@ -7,6 +7,7 @@
>   #include <libintl.h>
>   #define _(String) gettext(String)
>   
> +#include <logging.h>
>   #include "libgfs2.h"
>   #include "fsck.h"
>   #include "util.h"
> diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c
> index c8c047e..2474ccb 100644
> --- a/gfs2/fsck/pass2.c
> +++ b/gfs2/fsck/pass2.c
> @@ -9,6 +9,7 @@
>   #include <libintl.h>
>   #define _(String) gettext(String)
>   
> +#include <logging.h>
>   #include "libgfs2.h"
>   #include "fsck.h"
>   #include "util.h"
> diff --git a/gfs2/fsck/pass3.c b/gfs2/fsck/pass3.c
> index 6448da3..9582b5b 100644
> --- a/gfs2/fsck/pass3.c
> +++ b/gfs2/fsck/pass3.c
> @@ -8,6 +8,7 @@
>   #include <libintl.h>
>   #define _(String) gettext(String)
>   
> +#include <logging.h>
>   #include "libgfs2.h"
>   #include "osi_list.h"
>   #include "fsck.h"
> diff --git a/gfs2/fsck/pass4.c b/gfs2/fsck/pass4.c
> index 311b96b..7b3cb87 100644
> --- a/gfs2/fsck/pass4.c
> +++ b/gfs2/fsck/pass4.c
> @@ -6,6 +6,7 @@
>   #include <libintl.h>
>   #define _(String) gettext(String)
>   
> +#include <logging.h>
>   #include "libgfs2.h"
>   #include "fsck.h"
>   #include "lost_n_found.h"
> diff --git a/gfs2/fsck/pass5.c b/gfs2/fsck/pass5.c
> index 49ab682..68b1373 100644
> --- a/gfs2/fsck/pass5.c
> +++ b/gfs2/fsck/pass5.c
> @@ -7,6 +7,7 @@
>   #include <libintl.h>
>   #define _(String) gettext(String)
>   
> +#include <logging.h>
>   #include "libgfs2.h"
>   #include "fsck.h"
>   #include "util.h"
> diff --git a/gfs2/fsck/rgrepair.c b/gfs2/fsck/rgrepair.c
> index cb39541..0466dd8 100644
> --- a/gfs2/fsck/rgrepair.c
> +++ b/gfs2/fsck/rgrepair.c
> @@ -10,6 +10,7 @@
>   #include <libintl.h>
>   #define _(String) gettext(String)
>   
> +#include <logging.h>
>   #include "libgfs2.h"
>   #include "osi_list.h"
>   #include "fsck.h"
> diff --git a/gfs2/fsck/util.c b/gfs2/fsck/util.c
> index f8ccb3e..8b439a9 100644
> --- a/gfs2/fsck/util.c
> +++ b/gfs2/fsck/util.c
> @@ -12,6 +12,7 @@
>   #include <ctype.h>
>   #define _(String) gettext(String)
>   
> +#include <logging.h>
>   #include "libgfs2.h"
>   #include "metawalk.h"
>   #include "util.h"
> diff --git a/gfs2/include/Makefile.am b/gfs2/include/Makefile.am
> index a017cb3..c755181 100644
> --- a/gfs2/include/Makefile.am
> +++ b/gfs2/include/Makefile.am
> @@ -1,3 +1,3 @@
>   MAINTAINERCLEANFILES	= Makefile.in
>   
> -noinst_HEADERS		= osi_list.h osi_tree.h linux_endian.h
> +noinst_HEADERS		= osi_list.h osi_tree.h linux_endian.h logging.h
> diff --git a/gfs2/include/logging.h b/gfs2/include/logging.h
> new file mode 100644
> index 0000000..18b5832
> --- /dev/null
> +++ b/gfs2/include/logging.h
> @@ -0,0 +1,36 @@
> +#ifndef __LOGGING_H__
> +#define __LOGGING_H__
> +
> +extern int print_level;
> +#define increase_verbosity() do { print_level++; } while(0)
> +#define decrease_verbosity() do { print_level--; } while(0)
> +
> +#define MSG_DEBUG       7
> +#define MSG_INFO        6
> +#define MSG_NOTICE      5
> +#define MSG_WARN        4
> +#define MSG_ERROR       3
> +#define MSG_CRITICAL    2
> +#define MSG_NULL        1
> +
> +#define log_debug(format...) \
> +	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) printf(format); } while(0)
> +
> +#define log_notice(format...) \
> +	do { if (print_level >= MSG_NOTICE) printf(format); } while(0)
> +
> +#define log_warn(format...) \
> +	do { if (print_level >= MSG_WARN) printf(format); } while(0)
> +
> +#define log_err(format...) \
> +	do { if (print_level >= MSG_ERROR) fprintf(stderr, format); } while(0)
> +
> +#define log_crit(format...) \
> +	do { if (print_level >= MSG_CRITICAL) fprintf(stderr, format); } while(0)
> +
> +#endif /* __LOGGING_H__ */
> diff --git a/gfs2/libgfs2/Makefile.am b/gfs2/libgfs2/Makefile.am
> index 2d197f0..4af27be 100644
> --- a/gfs2/libgfs2/Makefile.am
> +++ b/gfs2/libgfs2/Makefile.am
> @@ -13,7 +13,7 @@ noinst_PROGRAMS		= gfs2l
>   
>   libgfs2_la_SOURCES	= block_list.c fs_bits.c gfs1.c misc.c rgrp.c super.c \
>   			  buf.c fs_geometry.c gfs2_disk_hash.c ondisk.c config.c \
> -			  device_geometry.c fs_ops.c gfs2_log.c recovery.c \
> +			  device_geometry.c fs_ops.c recovery.c \
>   			  structures.c meta.c lang.c parser.y lexer.l
>   
>   libgfs2_la_CPPFLAGS	= -D_FILE_OFFSET_BITS=64 \
> diff --git a/gfs2/libgfs2/fs_geometry.c b/gfs2/libgfs2/fs_geometry.c
> index 9c9085f..587ceb8 100644
> --- a/gfs2/libgfs2/fs_geometry.c
> +++ b/gfs2/libgfs2/fs_geometry.c
> @@ -97,12 +97,12 @@ void compute_rgrp_layout(struct gfs2_sbd *sdp, struct osi_root *rgtree,
>   	} else {
>   		uint64_t old_length, new_chunk;
>   
> -		log_info("Existing resource groups:\n");
> +		printf("Existing resource groups:\n");
>   		for (rgrp = 0, n = osi_first(rgtree); n; n = next, rgrp++) {
>   			next = osi_next(n);
>   			rl = (struct rgrp_tree *)n;
>   
> -			log_info("%d: start: %" PRIu64 " (0x%"
> +			printf("%d: start: %" PRIu64 " (0x%"
>   				 PRIx64 "), length = %"PRIu64" (0x%"
>   				 PRIx64 ")\n", rgrp + 1, rl->start, rl->start,
>   				 rl->length, rl->length);
> @@ -118,7 +118,7 @@ void compute_rgrp_layout(struct gfs2_sbd *sdp, struct osi_root *rgtree,
>   	}
>   
>   	if (rgrp < nrgrp)
> -		log_info("\nNew resource groups:\n");
> +		printf("\nNew resource groups:\n");
>   	for (; rgrp < nrgrp; rgrp++) {
>   		if (rgrp) {
>   			rgaddr = rlast->start + rlast->length;
> @@ -131,7 +131,7 @@ void compute_rgrp_layout(struct gfs2_sbd *sdp, struct osi_root *rgtree,
>   				(nrgrp - 1) * (dev->length / nrgrp);
>   		}
>   		rl->start = rgaddr;
> -		log_info("%d: start: %" PRIu64 " (0x%"
> +		printf("%d: start: %" PRIu64 " (0x%"
>   			 PRIx64 "), length = %"PRIu64" (0x%"
>   			 PRIx64 ")\n", rgrp + 1, rl->start, rl->start,
>   			 rl->length, rl->length);
> diff --git a/gfs2/libgfs2/gfs2_log.c b/gfs2/libgfs2/gfs2_log.c
> deleted file mode 100644
> index da5f489..0000000
> --- a/gfs2/libgfs2/gfs2_log.c
> +++ /dev/null
> @@ -1,24 +0,0 @@
> -#include "clusterautoconfig.h"
> -
> -#include <stdio.h>
> -#include <stdarg.h>
> -#include <ctype.h>
> -#include <sys/select.h>
> -#include <signal.h>
> -#include <string.h>
> -#include <termios.h>
> -#include <unistd.h>
> -
> -#include "libgfs2.h"
> -
> -int print_level = MSG_NOTICE;
> -
> -void increase_verbosity(void)
> -{
> -	print_level++;
> -}
> -
> -void decrease_verbosity(void)
> -{
> -	print_level--;
> -}
> diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
> index b269357..041e5fd 100644
> --- a/gfs2/libgfs2/libgfs2.h
> +++ b/gfs2/libgfs2/libgfs2.h
> @@ -671,40 +671,6 @@ extern void gfs_jindex_in(struct gfs_jindex *jindex, char *buf);
>   extern void gfs_rgrp_in(struct gfs_rgrp *rg, struct gfs2_buffer_head *bh);
>   extern void gfs_rgrp_out(struct gfs_rgrp *rg, struct gfs2_buffer_head *bh);
>   
> -/* gfs2_log.c */
> -
> -extern int print_level;
> -
> -#define MSG_DEBUG       7
> -#define MSG_INFO        6
> -#define MSG_NOTICE      5
> -#define MSG_WARN        4
> -#define MSG_ERROR       3
> -#define MSG_CRITICAL    2
> -#define MSG_NULL        1
> -
> -#define log_debug(format...) \
> -	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) printf(format); } while(0)
> -
> -#define log_notice(format...) \
> -	do { if (print_level >= MSG_NOTICE) printf(format); } while(0)
> -
> -#define log_warn(format...) \
> -	do { if (print_level >= MSG_WARN) printf(format); } while(0)
> -
> -#define log_err(format...) \
> -	do { if (print_level >= MSG_ERROR) fprintf(stderr, format); } while(0)
> -
> -#define log_crit(format...) \
> -	do { if (print_level >= MSG_CRITICAL) fprintf(stderr, format); } while(0)
> -
> -extern void increase_verbosity(void);
> -extern void decrease_verbosity(void);
>   /* misc.c */
>   
>   extern int metafs_interrupted;
> diff --git a/gfs2/mkfs/main_grow.c b/gfs2/mkfs/main_grow.c
> index 7e005e9..5da809a 100644
> --- a/gfs2/mkfs/main_grow.c
> +++ b/gfs2/mkfs/main_grow.c
> @@ -23,6 +23,7 @@
>   #include <libintl.h>
>   #define _(String) gettext(String)
>   
> +#include <logging.h>
>   #include "libgfs2.h"
>   #include "gfs2_mkfs.h"
>   
> @@ -33,6 +34,7 @@ static uint64_t override_device_size = 0;
>   static int test = 0;
>   static uint64_t fssize = 0, fsgrowth;
>   static unsigned int rgsize = 0;
> +int print_level = MSG_NOTICE;
>   
>   extern int create_new_inode(struct gfs2_sbd *sdp);
>   extern int rename2system(struct gfs2_sbd *sdp, char *new_dir, char *new_name);



^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Cluster-devel] [PATCH 5/5] libgfs2: Remove logging API
  2014-05-07 14:33 ` [Cluster-devel] [PATCH 5/5] libgfs2: Remove logging API Andrew Price
  2014-05-07 14:48   ` Steven Whitehouse
@ 2014-05-07 14:55   ` Bob Peterson
  2014-05-07 15:07     ` Andrew Price
  1 sibling, 1 reply; 13+ messages in thread
From: Bob Peterson @ 2014-05-07 14:55 UTC (permalink / raw)
  To: cluster-devel.redhat.com

----- Original Message -----
> libgfs2 was exposing a logging API (log_info, etc.) but wasn't using it
> itself. Remove the logging bits and move them into
> gfs2/include/logging.h
> 
> Signed-off-by: Andrew Price <anprice@redhat.com>

All five patches look okay to me.
I'm a little apprehensive about removing some of the debug capabilities,
like having gfs2_grow show details about the new rgrps, but we can
likely get the same information from gfs2_edit.

Regards,

Bob Peterson
Red Hat File Systems



^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Cluster-devel] [PATCH 2/5] gfs2-utils: Expressly expunge 'expert mode'
  2014-05-07 14:48   ` Bob Peterson
@ 2014-05-07 15:01     ` Andrew Price
  0 siblings, 0 replies; 13+ messages in thread
From: Andrew Price @ 2014-05-07 15:01 UTC (permalink / raw)
  To: cluster-devel.redhat.com

On 07/05/14 15:48, Bob Peterson wrote:
> ----- Original Message -----
>> mkfs.gfs2 and gfs2_jadd used struct gfs2_sbd.expert to put them into an
>> undocumented 'expert mode' but didn't really do anything useful in that
>> mode. Remove that field and other 'expert' references.
>>
>
> In the past, we've used mkfs.gfs2 expert mode to create certain test
> conditions, like very small resource groups. I don't think Nate uses
> this in any of his tests, but it might be worth asking.
> I've used it to try to recreate certain failing scenarios, but I haven't
> needed it in years. Are we sure we want to get rid of it?

I don't think we'd get much value out of testing resource group sizes 
which are technically unsupported. The resource group size validation 
and selection bits have all changed anyway and it doesn't really make 
sense any more. If it turns out there's a real use case for something 
like this then maybe we can add it back or implement a more focused 
solution.

Andy



^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Cluster-devel] [PATCH 5/5] libgfs2: Remove logging API
  2014-05-07 14:55   ` Bob Peterson
@ 2014-05-07 15:07     ` Andrew Price
  2014-05-07 15:17       ` Andrew Price
  0 siblings, 1 reply; 13+ messages in thread
From: Andrew Price @ 2014-05-07 15:07 UTC (permalink / raw)
  To: cluster-devel.redhat.com

On 07/05/14 15:55, Bob Peterson wrote:
> ----- Original Message -----
>> libgfs2 was exposing a logging API (log_info, etc.) but wasn't using it
>> itself. Remove the logging bits and move them into
>> gfs2/include/logging.h
>>
>> Signed-off-by: Andrew Price <anprice@redhat.com>
>
> All five patches look okay to me.
> I'm a little apprehensive about removing some of the debug capabilities,
> like having gfs2_grow show details about the new rgrps, but we can
> likely get the same information from gfs2_edit.

Yes, I've been thinking a bit about increasing the amount of debugging 
output we can get from libgfs2 now that the logging bits are less 
entangled. One tempting idea is to be able to switch on debug output 
with an environment variable, e.g. LGFS2_DEBUG=1 gfs2_grow /delibgfs2 v/foo

Andy



^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Cluster-devel] [PATCH 1/5] fsck.gfs2: Log to syslog on start and exit
  2014-05-07 14:39 ` [Cluster-devel] [PATCH 1/5] fsck.gfs2: Log to syslog on start and exit Steven Whitehouse
@ 2014-05-07 15:15   ` Andrew Price
  0 siblings, 0 replies; 13+ messages in thread
From: Andrew Price @ 2014-05-07 15:15 UTC (permalink / raw)
  To: cluster-devel.redhat.com

On 07/05/14 15:39, Steven Whitehouse wrote:
> Hi,
>
> On 07/05/14 15:33, Andrew Price wrote:
>> In order to piece together the order in which fsck.gfs2 runs and
>> gfs2_edit savemeta were done it's useful to keep a log of the command
>> line options used and the fsck.gfs2 start and end times. Log these to
>> syslog.
>>
>> Signed-off-by: Andrew Price <anprice@redhat.com>
>> ---
>>   gfs2/fsck/main.c     | 35 +++++++++++++++++++++++++++++++++++
>>   gfs2/man/fsck.gfs2.8 |  2 ++
>>   2 files changed, 37 insertions(+)
>>
>> diff --git a/gfs2/fsck/main.c b/gfs2/fsck/main.c
>> index 346e580..0031ec0 100644
>> --- a/gfs2/fsck/main.c
>> +++ b/gfs2/fsck/main.c
>> @@ -12,6 +12,7 @@
>>   #include <libintl.h>
>>   #include <locale.h>
>>   #define _(String) gettext(String)
>> +#include <syslog.h>
>>   #include "copyright.cf"
>>   #include "libgfs2.h"
>> @@ -261,6 +262,36 @@ static int fsck_pass(const struct fsck_pass *p,
>> struct gfs2_sbd *sdp)
>>       return 0;
>>   }
>> +static void exitlog(void)
>> +{
>> +    syslog(LOG_INFO, "exiting.");
>> +}
>> +
> Would be nice if it was possible to log the exit status too here...

Agreed. It's a shame the exit handlers don't take a status argument 
really. We're going to have to do something like

   extern int fsck_status;
   #define fsck_exit(s) exit(fsck_status = (s))

and then change all the exit() callers to make it work. There might be a 
lot of churn but it should be fairly mechanical so I'll whip up a patch 
for that shortly.

>> +static void startlog(int argc, char **argv)
>> +{
>> +    int i;
>> +    char *cmd, *p;
>> +    size_t len;
>> +
>> +    for (len = i = 0; i < argc; i++)
>> +        len += strlen(argv[i]);
>> +    len += argc; /* Add spaces and '\0' */
>> +
>> +    cmd = malloc(len);
>> +    if (cmd == NULL) {
>> +        perror(argv[0]);
>> +        exit(FSCK_ERROR);
>> +    }
>> +    p = cmd;
>> +    for (i = 0; i < argc; i++, p++) {
>> +        p = stpcpy(p, argv[i]);
>> +        *p = ' ';
>> +    }
>> +    *(--p) = '\0';
>> +    syslog(LOG_INFO, "started: %s", cmd);
> If you use vsyslog rather than syslog I wonder if its possible to make
> this a bit neater?

I've looked into it but I can't see an obvious way to do this. vsyslog 
would be useful if we knew how many format specifiers to use beforehand 
but in this case I think we're stuck with "%s".

Andy



^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Cluster-devel] [PATCH 5/5] libgfs2: Remove logging API
  2014-05-07 15:07     ` Andrew Price
@ 2014-05-07 15:17       ` Andrew Price
  0 siblings, 0 replies; 13+ messages in thread
From: Andrew Price @ 2014-05-07 15:17 UTC (permalink / raw)
  To: cluster-devel.redhat.com

On 07/05/14 16:07, Andrew Price wrote:
> On 07/05/14 15:55, Bob Peterson wrote:
>> ----- Original Message -----
>>> libgfs2 was exposing a logging API (log_info, etc.) but wasn't using it
>>> itself. Remove the logging bits and move them into
>>> gfs2/include/logging.h
>>>
>>> Signed-off-by: Andrew Price <anprice@redhat.com>
>>
>> All five patches look okay to me.
>> I'm a little apprehensive about removing some of the debug capabilities,
>> like having gfs2_grow show details about the new rgrps, but we can
>> likely get the same information from gfs2_edit.
>
> Yes, I've been thinking a bit about increasing the amount of debugging
> output we can get from libgfs2 now that the logging bits are less
> entangled. One tempting idea is to be able to switch on debug output
> with an environment variable, e.g. LGFS2_DEBUG=1 gfs2_grow /delibgfs2 v/foo

Hm, not sure what happened there. It should have been "LGFS2_DEBUG=1 
gfs2_grow /dev/foo"

Andy



^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2014-05-07 15:17 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-07 14:33 [Cluster-devel] [PATCH 1/5] fsck.gfs2: Log to syslog on start and exit Andrew Price
2014-05-07 14:33 ` [Cluster-devel] [PATCH 2/5] gfs2-utils: Expressly expunge 'expert mode' Andrew Price
2014-05-07 14:48   ` Bob Peterson
2014-05-07 15:01     ` Andrew Price
2014-05-07 14:33 ` [Cluster-devel] [PATCH 3/5] libgfs2: Remove UI fields from struct gfs2_sbd Andrew Price
2014-05-07 14:33 ` [Cluster-devel] [PATCH 4/5] libgfs2: Remove debug field from gfs2_sbd Andrew Price
2014-05-07 14:33 ` [Cluster-devel] [PATCH 5/5] libgfs2: Remove logging API Andrew Price
2014-05-07 14:48   ` Steven Whitehouse
2014-05-07 14:55   ` Bob Peterson
2014-05-07 15:07     ` Andrew Price
2014-05-07 15:17       ` Andrew Price
2014-05-07 14:39 ` [Cluster-devel] [PATCH 1/5] fsck.gfs2: Log to syslog on start and exit Steven Whitehouse
2014-05-07 15:15   ` Andrew Price

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).