[Cluster-devel] [gfs2-utils PATCH 5/7] fsck.gfs2: convert fsck_bitmap_set to a macro
Bob Peterson
rpeterso at redhat.com
Wed Jun 22 19:26:50 UTC 2016
Before this patch fsck_bitmap_set was a function that was passed
in values for function and line number, but it only used them
if it was in verbose mode. This patch reorganizes it into a macro
that only passes things it needs to.
Signed-off-by: Bob Peterson <rpeterso at redhat.com>
---
gfs2/fsck/metawalk.c | 16 ----------------
gfs2/fsck/metawalk.h | 22 ++++++++++++++--------
gfs2/fsck/pass1.c | 15 +++++++++++----
3 files changed, 25 insertions(+), 28 deletions(-)
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index 6259a66..5adb849 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -163,22 +163,6 @@ int check_n_fix_bitmap(struct gfs2_sbd *sdp, struct rgrp_tree *rgd,
return 0;
}
-/*
- * _fsck_bitmap_set - Mark a block in the bitmap, and adjust free space.
- */
-void _fsck_bitmap_set(struct gfs2_inode *ip, uint64_t bblock,
- const char *btype, int mark,
- int error_on_dinode, const char *caller, int fline)
-{
- int error;
-
- _fsck_bitmap_set_dbg(ip, bblock, btype, mark, caller, fline);
- error = check_n_fix_bitmap(ip->i_sbd, ip->i_rgd, bblock,
- error_on_dinode, mark);
- if (error < 0)
- log_err(_("This block is not represented in the bitmap.\n"));
-}
-
struct duptree *dupfind(uint64_t block)
{
struct osi_node *node = dup_blocks.osi_node;
diff --git a/gfs2/fsck/metawalk.h b/gfs2/fsck/metawalk.h
index 5410775..60059cf 100644
--- a/gfs2/fsck/metawalk.h
+++ b/gfs2/fsck/metawalk.h
@@ -19,9 +19,6 @@ extern int check_linear_dir(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
extern int check_leaf(struct gfs2_inode *ip, int lindex,
struct metawalk_fxns *pass, uint64_t *leaf_no,
struct gfs2_leaf *leaf, int *ref_count);
-extern void _fsck_bitmap_set(struct gfs2_inode *ip, uint64_t bblock,
- const char *btype, int mark, int error_on_dinode,
- const char *caller, int line);
extern int check_n_fix_bitmap(struct gfs2_sbd *sdp, struct rgrp_tree *rgd,
uint64_t blk, int error_on_dinode,
int new_state);
@@ -38,9 +35,6 @@ static inline void _fsck_bitmap_set_dbg(struct gfs2_inode *ip, uint64_t bblock,
static int prevcount = 0;
static const char *prev_caller = NULL;
- if (print_level < MSG_DEBUG)
- return;
-
if ((ip->i_di.di_num.no_addr == prev_ino_addr) &&
(mark == prev_mark) && caller == prev_caller) {
log_info("(0x%llx) ", (unsigned long long)bblock);
@@ -78,8 +72,20 @@ static inline void _fsck_bitmap_set_dbg(struct gfs2_inode *ip, uint64_t bblock,
#define is_duplicate(dblock) ((dupfind(dblock)) ? 1 : 0)
-#define fsck_bitmap_set(ip, b, bt, m) \
- _fsck_bitmap_set(ip, b, bt, m, 0, __FUNCTION__, __LINE__)
+#define fsck_bitmap_set(ip, bblock, btype, mark) \
+ do { \
+ int ret; \
+ \
+ if (print_level >= MSG_DEBUG) \
+ _fsck_bitmap_set_dbg(ip, bblock, btype, mark, \
+ __FUNCTION__, __LINE__); \
+ ret = check_n_fix_bitmap(ip->i_sbd, ip->i_rgd, bblock, \
+ 0, mark); \
+ if (ret < 0) \
+ log_err(_("This block is not represented in " \
+ "the bitmap.\n")); \
+ } while (0)
+
enum meta_check_rc {
meta_error = -1,
meta_is_good = 0,
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index 2a3fbde..2cb5a44 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -117,7 +117,8 @@ static int _fsck_blockmap_set(struct gfs2_inode *ip, uint64_t bblock,
{
int error;
- _fsck_bitmap_set_dbg(ip, bblock, btype, mark, caller, fline);
+ if (print_level >= MSG_DEBUG)
+ _fsck_bitmap_set_dbg(ip, bblock, btype, mark, caller, fline);
error = check_n_fix_bitmap(ip->i_sbd, ip->i_rgd, bblock,
error_on_dinode, mark);
if (error < 0)
@@ -130,8 +131,6 @@ static int _fsck_blockmap_set(struct gfs2_inode *ip, uint64_t bblock,
#define fsck_blockmap_set(ip, b, bt, m) \
_fsck_blockmap_set(ip, b, bt, m, 0, __FUNCTION__, __LINE__)
-#define fsck_blkmap_set_noino(ip, b, bt, m) \
- _fsck_blockmap_set(ip, b, bt, m, 1, __FUNCTION__, __LINE__)
/**
* delete_block - delete a block associated with an inode
@@ -516,7 +515,15 @@ static int blockmap_set_as_data(struct gfs2_inode *ip, uint64_t block)
struct gfs2_buffer_head *bh;
struct gfs2_dinode *di;
- error = fsck_blkmap_set_noino(ip, block, _("data"), GFS2_BLKST_USED);
+ if (print_level >= MSG_DEBUG)
+ _fsck_bitmap_set_dbg(ip, block, _("data"), GFS2_BLKST_USED,
+ __FUNCTION__, __LINE__);
+ error = check_n_fix_bitmap(ip->i_sbd, ip->i_rgd, block, 1,
+ GFS2_BLKST_USED);
+ if (error < 0)
+ log_err(_("This block is not represented in the bitmap.\n"));
+ if (!error)
+ error = gfs2_blockmap_set(block, GFS2_BLKST_USED);
if (!error)
return 0;
--
2.5.5
More information about the Cluster-devel
mailing list