fsck.gfs2: Log to syslog on start and exit
PATCH 1/5 fsck.gfs2: Log to syslog on start and exit
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.
--- gfs2/fsck/main.c | 35 +++++++++++++++++++++++++++++++++++ gfs2/man/fsck.gfs2.8 | 2 ++ 2 files changed, 37 insertions(+)
gfs2/fsck/main.c +35 -0
@@ -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)))
gfs2/man/fsck.gfs2.8 +2 -0
@@ -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
Signature · 1 line
1.9.0
PATCH 2/5 gfs2-utils: Expressly expunge 'expert mode'
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.
--- gfs2/libgfs2/libgfs2.h | 2 -- gfs2/mkfs/main_jadd.c | 15 ++++----------- gfs2/mkfs/main_mkfs.c | 23 +++++++---------------- 3 files changed, 11 insertions(+), 29 deletions(-)
gfs2/libgfs2/libgfs2.h +0 -2
@@ -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)
gfs2/mkfs/main_jadd.c +4 -11
@@ -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);
gfs2/mkfs/main_mkfs.c +7 -16
@@ -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" ));
Signature · 1 line
1.9.0
PATCH 2/5 gfs2-utils: Expressly expunge 'expert mode'
----- Original Message -----
Quoted 4 lines
mkfs.gfs2 and
gfs2_jaddused 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
PATCH 2/5 gfs2-utils: Expressly expunge 'expert mode'
Quoted 11 lines · Bob Peterson
----- Original Message -----
Quoted 4 lines
mkfs.gfs2 and
gfs2_jaddused 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
PATCH 3/5 libgfs2: Remove UI fields from struct gfs2_sbd
In reply to Andrew PriceThe '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.
--- gfs2/libgfs2/libgfs2.h | 2 -- gfs2/mkfs/main_jadd.c | 13 +++++++------ 2 files changed, 7 insertions(+), 8 deletions(-)
gfs2/libgfs2/libgfs2.h +0 -2
@@ -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;
gfs2/mkfs/main_jadd.c +7 -6
@@ -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);
Signature · 1 line
1.9.0
PATCH 4/5 libgfs2: Remove debug field from gfs2_sbd
In reply to Andrew PriceThe 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.
--- 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
gfs2/convert/gfs2_convert.c +0 -5
@@ -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 ; }
gfs2/fsck/rgrepair.c +0 -19
@@ -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 );
gfs2/libgfs2/Makefile.am +2 -2
@@ -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
gfs2/libgfs2/config.c new file +9 -0
@@ -0,0 +1,9 @@ +#include "libgfs2.h" +#include "config.h" + +int cfg_debug =0 ; + +void lgfs2_set_debug (int enable) +{ + cfg_debug = enable; +}
gfs2/libgfs2/config.h new file +6 -0
@@ -0,0 +1,6 @@ +#ifndef __LGFS2_CONFIG_H__ +#define __LGFS2_CONFIG_H__ + +extern int cfg_debug; + +#endif /* __LGFS2_CONFIG_H__ */
gfs2/libgfs2/device_geometry.c +2 -1
@@ -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);
gfs2/libgfs2/fs_geometry.c +3 -2
@@ -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); }
gfs2/libgfs2/libgfs2.h +3 -2
@@ -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);
gfs2/libgfs2/misc.c +4 -3
@@ -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 ; }
gfs2/libgfs2/structures.c +15 -16
@@ -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); }
gfs2/mkfs/main_grow.c +0 -21
@@ -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:
gfs2/mkfs/main_jadd.c +5 -3
@@ -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 ;
gfs2/mkfs/main_mkfs.c +5 -5
@@ -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_rindeperror (_ ("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" ));
Signature · 1 line
1.9.0
PATCH 5/5 libgfs2: Remove logging API
In reply to Andrew Pricelibgfs2 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
--- 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
gfs2/convert/gfs2_convert.c +2 -0
@@ -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. */
gfs2/edit/savemeta.c +2 -0
@@ -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 );
gfs2/fsck/fs_recovery.c +1 -0
@@ -9,6 +9,7 @@#include <libintl.h> #define _ (String) gettext(String) +#include <logging.h> #include "fsck.h" #include "fs_recovery.h" #include "libgfs2.h"
gfs2/fsck/initialize.c +1 -0
@@ -15,6 +15,7 @@#define _ (String) gettext(String) +#include <logging.h> #include "libgfs2.h" #include "fsck.h" #include "util.h"
gfs2/fsck/inode_hash.c +1 -0
@@ -5,6 +5,7 @@#include <libintl.h> #include <string.h> +#include <logging.h> #include "libgfs2.h" #include "osi_list.h" #include "inode_hash.h"
gfs2/fsck/link.c +1 -0
@@ -8,6 +8,7 @@#include <libintl.h> #define _ (String) gettext(String) +#include <logging.h> #include "libgfs2.h" #include "fsck.h" #include "inode_hash.h"
gfs2/fsck/lost_n_found.c +1 -0
@@ -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"
gfs2/fsck/main.c +2 -0
@@ -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, ...)
gfs2/fsck/metawalk.c +1 -0
@@ -12,6 +12,7 @@#include <fcntl.h> #define _ (String) gettext(String) +#include <logging.h> #include "libgfs2.h" #include "osi_tree.h" #include "fsck.h"
gfs2/fsck/pass1.c +1 -0
@@ -20,6 +20,7 @@#include <libintl.h> #define _ (String) gettext(String) +#include <logging.h> #include "libgfs2.h" #include "fsck.h" #include "inode_hash.h"
gfs2/fsck/pass1b.c +1 -0
@@ -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"
gfs2/fsck/pass1c.c +1 -0
@@ -7,6 +7,7 @@#include <libintl.h> #define _ (String) gettext(String) +#include <logging.h> #include "libgfs2.h" #include "fsck.h" #include "util.h"
gfs2/fsck/pass2.c +1 -0
@@ -9,6 +9,7 @@#include <libintl.h> #define _ (String) gettext(String) +#include <logging.h> #include "libgfs2.h" #include "fsck.h" #include "util.h"
gfs2/fsck/pass3.c +1 -0
@@ -8,6 +8,7 @@#include <libintl.h> #define _ (String) gettext(String) +#include <logging.h> #include "libgfs2.h" #include "osi_list.h" #include "fsck.h"
gfs2/fsck/pass4.c +1 -0
@@ -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"
gfs2/fsck/pass5.c +1 -0
@@ -7,6 +7,7 @@#include <libintl.h> #define _ (String) gettext(String) +#include <logging.h> #include "libgfs2.h" #include "fsck.h" #include "util.h"
gfs2/fsck/rgrepair.c +1 -0
@@ -10,6 +10,7 @@#include <libintl.h> #define _ (String) gettext(String) +#include <logging.h> #include "libgfs2.h" #include "osi_list.h" #include "fsck.h"
gfs2/fsck/util.c +1 -0
@@ -12,6 +12,7 @@#include <ctype.h> #define _ (String) gettext(String) +#include <logging.h> #include "libgfs2.h" #include "metawalk.h" #include "util.h"
gfs2/include/Makefile.am +1 -1
@@ -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
gfs2/include/logging.h new file +36 -0
@@ -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__ */
gfs2/libgfs2/Makefile.am +1 -1
@@ -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 \
gfs2/libgfs2/fs_geometry.c +4 -4
@@ -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);
gfs2/libgfs2/gfs2_log.c deleted +0 -24
@@ -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--; -}
gfs2/libgfs2/libgfs2.h +0 -34
@@ -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;
gfs2/mkfs/main_grow.c +2 -0
@@ -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);
Signature · 1 line
1.9.0
PATCH 5/5 libgfs2: Remove logging API
Hi,
Other patches in the series all look good to me,
Steve.
Quoted 471 lines · Andrew Price
libgfs2 was exposing a logging API (
log_info, etc.) but wasn't using it itself. Remove the logging bits and move them intogfs2/include/logging.hSigned-off-by Andrew Price <[email protected]>--- 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 100644gfs2/libgfs2/gfs2_log.cgfs2/convert/gfs2_convert.c +2
-0@@ -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. */ gfs2/edit/savemeta.c +2
-0@@ -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 );gfs2/fsck/fs_recovery.c +1
-0@@ -9,6 +9,7 @@#include <libintl.h> #define _ (String) gettext(String) +#include <logging.h> #include "fsck.h" #include "fs_recovery.h" #include "libgfs2.h" gfs2/fsck/initialize.c +1
-0@@ -15,6 +15,7 @@#define _ (String) gettext(String) +#include <logging.h> #include "libgfs2.h" #include "fsck.h" #include "util.h" gfs2/fsck/inode_hash.c +1
-0@@ -5,6 +5,7 @@#include <libintl.h> #include <string.h> +#include <logging.h> #include "libgfs2.h" #include "osi_list.h" #include "inode_hash.h" gfs2/fsck/link.c +1
-0@@ -8,6 +8,7 @@#include <libintl.h> #define _ (String) gettext(String) +#include <logging.h> #include "libgfs2.h" #include "fsck.h" #include "inode_hash.h" gfs2/fsck/lost_n_found.c +1
-0@@ -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" gfs2/fsck/main.c +2
-0@@ -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, ...)gfs2/fsck/metawalk.c +1
-0@@ -12,6 +12,7 @@#include <fcntl.h> #define _ (String) gettext(String) +#include <logging.h> #include "libgfs2.h" #include "osi_tree.h" #include "fsck.h" gfs2/fsck/pass1.c +1
-0@@ -20,6 +20,7 @@#include <libintl.h> #define _ (String) gettext(String) +#include <logging.h> #include "libgfs2.h" #include "fsck.h" #include "inode_hash.h" gfs2/fsck/pass1b.c +1
-0@@ -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" gfs2/fsck/pass1c.c +1
-0@@ -7,6 +7,7 @@#include <libintl.h> #define _ (String) gettext(String) +#include <logging.h> #include "libgfs2.h" #include "fsck.h" #include "util.h" gfs2/fsck/pass2.c +1
-0@@ -9,6 +9,7 @@#include <libintl.h> #define _ (String) gettext(String) +#include <logging.h> #include "libgfs2.h" #include "fsck.h" #include "util.h" gfs2/fsck/pass3.c +1
-0@@ -8,6 +8,7 @@#include <libintl.h> #define _ (String) gettext(String) +#include <logging.h> #include "libgfs2.h" #include "osi_list.h" #include "fsck.h" gfs2/fsck/pass4.c +1
-0@@ -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" gfs2/fsck/pass5.c +1
-0@@ -7,6 +7,7 @@#include <libintl.h> #define _ (String) gettext(String) +#include <logging.h> #include "libgfs2.h" #include "fsck.h" #include "util.h" gfs2/fsck/rgrepair.c +1
-0@@ -10,6 +10,7 @@#include <libintl.h> #define _ (String) gettext(String) +#include <logging.h> #include "libgfs2.h" #include "osi_list.h" #include "fsck.h" gfs2/fsck/util.c +1
-0@@ -12,6 +12,7 @@#include <ctype.h> #define _ (String) gettext(String) +#include <logging.h> #include "libgfs2.h" #include "metawalk.h" #include "util.h" gfs2/include/Makefile.am +1
-1@@ -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.hgfs2/include/logging.h new file +36
-0@@ -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__ */ gfs2/libgfs2/Makefile.am +1
-1@@ -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 \gfs2/libgfs2/fs_geometry.c +4
-4@@ -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);gfs2/libgfs2/gfs2_log.c deleted +0
-24@@ -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--; -}gfs2/libgfs2/libgfs2.h +0
-34@@ -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;gfs2/mkfs/main_grow.c +2
-0@@ -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);
PATCH 5/5 libgfs2: Remove logging API
In reply to Andrew Price----- Original Message -----
Quoted 5 lines
libgfs2 was exposing a logging API (
log_info, etc.) but wasn't using it itself. Remove the logging bits and move them intogfs2/include/logging.hSigned-off-by Andrew Price <[email protected]>
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
PATCH 5/5 libgfs2: Remove logging API
Quoted 11 lines · Bob Peterson
----- Original Message -----
Quoted 5 lines
libgfs2 was exposing a logging API (
log_info, etc.) but wasn't using it itself. Remove the logging bits and move them intogfs2/include/logging.hSigned-off-by Andrew Price <[email protected]>All five patches look okay to me.
I'm a little apprehensive about removing some of the debug capabilities, like havinggfs2_growshow details about the new rgrps, but we can likely get the same information fromgfs2_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
PATCH 5/5 libgfs2: Remove logging API
Quoted 13 lines · Andrew Price
Quoted 11 lines · Bob Peterson
----- Original Message -----
Quoted 5 lines
libgfs2 was exposing a logging API (
log_info, etc.) but wasn't using it itself. Remove the logging bits and move them intogfs2/include/logging.hSigned-off-by Andrew Price <[email protected]>All five patches look okay to me.
I'm a little apprehensive about removing some of the debug capabilities, like havinggfs2_growshow details about the new rgrps, but we can likely get the same information fromgfs2_edit.
Quoted 4 lines
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
PATCH 1/5 fsck.gfs2: Log to syslog on start and exit
In reply to Andrew PriceHi,
Quoted 24 lines · Andrew Price
In order to piece together the order in which fsck.gfs2 runs and
gfs2_editsavemeta 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 <[email protected]>--- gfs2/fsck/main.c | 35 +++++++++++++++++++++++++++++++++++ gfs2/man/fsck.gfs2.8 | 2 ++ 2 files changed, 37 insertions(+)gfs2/fsck/main.c +1
-0@@ -12,6 +12,7 @@#include <libintl.h> #include <locale.h> #define _ (String) gettext(String) +#include <syslog.h> #include "copyright.cf" #include "libgfs2.h"
gfs2/fsck/main.c static int fsck_pass(const struct fsck_pass *p, struct gfs2_sbd *sdp) · line 269
Quoted 8 lines
gfs2/fsck/main.c +5
-0@@ -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...
Quoted 12 lines
gfs2/fsck/main.c +12
-0+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 ) {
gfs2/fsck/main.c static int fsck_pass(const struct fsck_pass *p, struct gfs2_sbd *sdp) · line 291
Quoted 10 lines
gfs2/fsck/main.c +10
-0+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.
Quoted 30 lines
gfs2/fsck/main.c +7
-0+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)))gfs2/man/fsck.gfs2.8 +2
-0@@ -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
PATCH 1/5 fsck.gfs2: Log to syslog on start and exit
Quoted 27 lines · Steven Whitehouse
Hi,
Quoted 24 lines · Andrew Price
In order to piece together the order in which fsck.gfs2 runs and
gfs2_editsavemeta 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 <[email protected]>--- gfs2/fsck/main.c | 35 +++++++++++++++++++++++++++++++++++ gfs2/man/fsck.gfs2.8 | 2 ++ 2 files changed, 37 insertions(+)gfs2/fsck/main.c +1
-0@@ -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)
Quoted 8 lines
gfs2/fsck/main.c static int fsck_pass(const struct fsck_pass *p, struct gfs2_sbd *sdp) · line 269
Quoted 7 lines
gfs2/fsck/main.c +5
-0return 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.
Quoted 16 lines
Quoted 16 lines
gfs2/fsck/main.c +16
-0+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;
Quoted 8 lines
gfs2/fsck/main.c static int fsck_pass(const struct fsck_pass *p, struct gfs2_sbd *sdp) · line 291
Quoted 6 lines
gfs2/fsck/main.c +6
-0+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