From: Steven Whitehouse <swhiteho@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 3/6] libgfs2: Prepare to remove log_xxx() macros from library
Date: Wed, 30 Nov 2011 15:04:39 +0000 [thread overview]
Message-ID: <1322665482-28435-4-git-send-email-swhiteho@redhat.com> (raw)
In-Reply-To: <1322665482-28435-1-git-send-email-swhiteho@redhat.com>
This will need to be done in stages. The first stage is to
clean up what is there. There are calls to the log_ functions
in the library itself, and those will need to be removed
in later patches.
This patch moves the gfs2_options structure into the two
utils which actually require it, removes the print_fsck_log
function, replacing the 3 calls to it from fsck with
the equivalent printf functions - it looks like those could
be merged in future as they all look very similar.
The log_ macros are also updated, so that they will do excatly
the same as before, but now don't depend on any code in libgfs2
itself.
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
---
gfs2/convert/gfs2_convert.c | 7 +++++++
gfs2/fsck/fsck.h | 7 +++++++
gfs2/fsck/metawalk.c | 40 ++++++++++++++++++----------------------
gfs2/fsck/util.h | 1 +
gfs2/libgfs2/gfs2_log.c | 34 ----------------------------------
gfs2/libgfs2/libgfs2.h | 29 +++++++++--------------------
gfs2/libgfs2/super.c | 2 +-
7 files changed, 43 insertions(+), 77 deletions(-)
diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index 9f24137..09a689c 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -139,6 +139,13 @@ struct blocklist {
char *ptrbuf;
};
+struct gfs2_options {
+ char *device;
+ unsigned int yes:1;
+ unsigned int no:1;
+ unsigned int query:1;
+};
+
struct gfs1_sb raw_gfs1_ondisk_sb;
struct gfs2_sbd sb2;
char device[256];
diff --git a/gfs2/fsck/fsck.h b/gfs2/fsck/fsck.h
index edd73d7..70fc3d7 100644
--- a/gfs2/fsck/fsck.h
+++ b/gfs2/fsck/fsck.h
@@ -124,6 +124,13 @@ extern void dirtree_delete(struct dir_info *b);
* of pass1 and put somewhere else... */
struct dir_info *dirtree_insert(uint64_t dblock);
+struct gfs2_options {
+ char *device;
+ unsigned int yes:1;
+ unsigned int no:1;
+ unsigned int query:1;
+};
+
extern struct gfs2_options opts;
extern struct gfs2_inode *lf_dip; /* Lost and found directory inode */
extern struct gfs2_bmap *bl;
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index ef7f05d..d78df72 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -129,38 +129,34 @@ int _fsck_blockmap_set(struct gfs2_inode *ip, uint64_t bblock,
log_info("\n");
prevcount = 0;
}
- print_fsck_log(MSG_DEBUG, caller, fline,
- _("%s inode found at block "
- "(0x%llx): marking as '%s'\n"),
- btype, (unsigned long long)
- ip->i_di.di_num.no_addr,
- block_type_string(mark));
+ printf( _("(%s:%d) %s inode found at block "
+ "(0x%llx): marking as '%s'\n"), caller, fline,
+ btype,
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ block_type_string(mark));
+
} else if (mark == gfs2_bad_block || mark == gfs2_meta_inval) {
if (prevcount) {
log_info("\n");
prevcount = 0;
}
- print_fsck_log(MSG_DEBUG, caller, fline,
- _("inode (0x%llx) references "
- "%s block (0x%llx): "
- "marking as '%s'\n"),
- (unsigned long long)
- ip->i_di.di_num.no_addr,
- btype, (unsigned long long)bblock,
- block_type_string(mark));
+ printf( _("(%s:%d) inode (0x%llx) references %s block"
+ " (0x%llx): marking as '%s'\n"),
+ caller, fline,
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ btype, (unsigned long long)bblock,
+ block_type_string(mark));
} else {
if (prevcount) {
log_info("\n");
prevcount = 0;
}
- print_fsck_log(MSG_DEBUG, caller, fline,
- _("inode (0x%llx) references "
- "%s block (0x%llx): "
- "marking as '%s'\n"),
- (unsigned long long)
- ip->i_di.di_num.no_addr, btype,
- (unsigned long long)bblock,
- block_type_string(mark));
+ printf( _("(%s:%d) inode (0x%llx) references %s block"
+ " (0x%llx): marking as '%s'\n"),
+ caller, fline,
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ btype, (unsigned long long)bblock,
+ block_type_string(mark));
}
prev_ino_addr = ip->i_di.di_num.no_addr;
prev_mark = mark;
diff --git a/gfs2/fsck/util.h b/gfs2/fsck/util.h
index 6de61e2..80ed0c4 100644
--- a/gfs2/fsck/util.h
+++ b/gfs2/fsck/util.h
@@ -184,5 +184,6 @@ extern char generic_interrupt(const char *caller, const char *where,
const char *progress, const char *question,
const char *answers);
extern char gfs2_getch(void);
+#define stack log_debug("<backtrace> - %s()\n", __func__)
#endif /* __UTIL_H__ */
diff --git a/gfs2/libgfs2/gfs2_log.c b/gfs2/libgfs2/gfs2_log.c
index a1ceaeb..da5f489 100644
--- a/gfs2/libgfs2/gfs2_log.c
+++ b/gfs2/libgfs2/gfs2_log.c
@@ -22,37 +22,3 @@ void decrease_verbosity(void)
{
print_level--;
}
-
-static __attribute__((format (printf, 4, 0)))
-void print_msg(int priority, const char *file, int line,
- const char *format, va_list args) {
-
- switch (priority) {
-
- case MSG_DEBUG:
- printf("(%s:%d) ", file, line);
- vprintf(format, args);
- break;
- case MSG_INFO:
- case MSG_NOTICE:
- case MSG_WARN:
- vprintf(format, args);
- fflush(NULL);
- break;
- case MSG_ERROR:
- case MSG_CRITICAL:
- default:
- vfprintf(stderr, format, args);
- break;
- }
-}
-
-
-void print_fsck_log(int priority, const char *file, int line,
- const char *format, ...)
-{
- va_list args;
- va_start(args, format);
- print_msg(priority, file, line, format, args);
- va_end(args);
-}
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index d02d63e..04169bf 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -617,12 +617,6 @@ extern void gfs_put_leaf_nr(struct gfs2_inode *dip, uint32_t inx,
uint64_t leaf_out);
/* gfs2_log.c */
-struct gfs2_options {
- char *device;
- unsigned int yes:1;
- unsigned int no:1;
- unsigned int query:1;
-};
extern int print_level;
@@ -634,33 +628,28 @@ extern int print_level;
#define MSG_CRITICAL 2
#define MSG_NULL 1
-#define print_log(priority, format...) \
- do { print_fsck_log(priority, __FUNCTION__, __LINE__, ## format); } while(0)
-
#define log_debug(format...) \
- do { if(print_level >= MSG_DEBUG) print_log(MSG_DEBUG, format); } while(0)
+ do { if (print_level >= MSG_DEBUG) { \
+ printf("(%s:%d) ", __FUNCTION__, __LINE__); \
+ printf(format); } } while(0)
+
#define log_info(format...) \
- do { if(print_level >= MSG_INFO) print_log(MSG_INFO, format); } while(0)
+ do { if (print_level >= MSG_INFO) printf(format); } while(0)
#define log_notice(format...) \
- do { if(print_level >= MSG_NOTICE) print_log(MSG_NOTICE, format); } while(0)
+ do { if (print_level >= MSG_NOTICE) printf(format); } while(0)
#define log_warn(format...) \
- do { if(print_level >= MSG_WARN) print_log(MSG_WARN, format); } while(0)
+ do { if (print_level >= MSG_WARN) printf(format); } while(0)
#define log_err(format...) \
- do { if(print_level >= MSG_ERROR) print_log(MSG_ERROR, format); } while(0)
+ do { if (print_level >= MSG_ERROR) fprintf(stderr, format); } while(0)
#define log_crit(format...) \
- do { if(print_level >= MSG_CRITICAL) print_log(MSG_CRITICAL, format); } while(0)
-
-#define stack log_debug("<backtrace> - %s()\n", __func__)
+ do { if (print_level >= MSG_CRITICAL) fprintf(stderr, format); } while(0)
extern void increase_verbosity(void);
extern void decrease_verbosity(void);
-extern void print_fsck_log(int priority, const char *file, int line,
- const char *format, ...)
- __attribute__((format(printf,4,5)));
/* misc.c */
extern int compute_heightsize(struct gfs2_sbd *sdp, uint64_t *heightsize,
diff --git a/gfs2/libgfs2/super.c b/gfs2/libgfs2/super.c
index c844287..2f544ab 100644
--- a/gfs2/libgfs2/super.c
+++ b/gfs2/libgfs2/super.c
@@ -28,7 +28,7 @@ int check_sb(struct gfs2_sb *sb, int allow_gfs)
sb->sb_header.mh_type != GFS2_METATYPE_SB) {
log_crit("Either the super block is corrupted, or this "
"is not a GFS2 filesystem\n");
- log_debug("Header magic: %X Header Type: %X\n",
+ log_crit("Header magic: %X Header Type: %X\n",
sb->sb_header.mh_magic,
sb->sb_header.mh_type);
return -EINVAL;
--
1.7.4.4
next prev parent reply other threads:[~2011-11-30 15:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-30 15:04 [Cluster-devel] libgfs2 cleanups Steven Whitehouse
2011-11-30 15:04 ` [Cluster-devel] [PATCH 1/6] libgfs2: Move generic_interrupt() into utils Steven Whitehouse
2011-11-30 15:04 ` [Cluster-devel] [PATCH 2/6] libgfs2: Move gfs2_getch " Steven Whitehouse
2011-11-30 15:04 ` Steven Whitehouse [this message]
2011-11-30 15:04 ` [Cluster-devel] [PATCH 4/6] libgfs2: Move some debug messages out into mkfs/fsck Steven Whitehouse
2011-11-30 15:04 ` [Cluster-devel] [PATCH 5/6] libgfs2: Clean up sb read/check functions Steven Whitehouse
2011-11-30 15:04 ` [Cluster-devel] [PATCH 6/6] libgfs2: Remove some more log_xxx calls Steven Whitehouse
2011-11-30 15:55 ` [Cluster-devel] libgfs2 cleanups Bob Peterson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1322665482-28435-4-git-send-email-swhiteho@redhat.com \
--to=swhiteho@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).