gfs2-utils: master - fsck.gfs2: Further performance gains with
function valid_block_ip
by Bob Peterson
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=861f4699...
Commit: 861f4699cbd6c745abbe125629e8bb2e115a8fd9
Parent: a59b70e8d2b1467171ef3200350959079bef8561
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Thu Jun 2 07:04:06 2016 -0500
Committer: Bob Peterson <rpeterso(a)redhat.com>
CommitterDate: Thu Jun 2 10:57:10 2016 -0500
fsck.gfs2: Further performance gains with function valid_block_ip
Before this patch, many functions in fsck.gfs2 checked for blocks
being valid. To check if a block is valid, you really need to check
that it's inside the area covered by a valid resource group. For
example, if a data block is pointing to a rgrp bitmap block, that's
invalid. To achieve this, it does a rgrp search, which traverses
the rgrp tree. This patch optimizes that by allowing functions to
pass in the ip pointer, so like before, we can check if that rgrp
covers the block in question and save ourselves a lot of work
traversing the tree.
Signed-off-by: Bob Peterson <rpeterso(a)redhat.com>
---
gfs2/fsck/afterpass1_common.c | 4 ++--
gfs2/fsck/fsck.h | 18 ++++++++++++++++++
gfs2/fsck/metawalk.c | 8 ++++----
gfs2/fsck/pass1.c | 26 ++++++++++++--------------
gfs2/fsck/pass2.c | 8 ++++----
gfs2/fsck/util.c | 2 +-
6 files changed, 41 insertions(+), 25 deletions(-)
diff --git a/gfs2/fsck/afterpass1_common.c b/gfs2/fsck/afterpass1_common.c
index 0632695..e39bfea 100644
--- a/gfs2/fsck/afterpass1_common.c
+++ b/gfs2/fsck/afterpass1_common.c
@@ -81,7 +81,7 @@ static int delete_block_if_notdup(struct gfs2_inode *ip, uint64_t block,
int q;
int removed_lastmeta;
- if (!valid_block(ip->i_sbd, block))
+ if (!valid_block_ip(ip, block))
return meta_error;
q = bitmap_type(ip->i_sbd, block);
@@ -207,7 +207,7 @@ static int del_eattr_generic(struct gfs2_inode *ip, uint64_t block,
int was_free = 0;
int q;
- if (valid_block(ip->i_sbd, block)) {
+ if (valid_block_ip(ip, block)) {
q = bitmap_type(ip->i_sbd, block);
if (q == GFS2_BLKST_FREE)
was_free = 1;
diff --git a/gfs2/fsck/fsck.h b/gfs2/fsck/fsck.h
index c4e6e3b..73cff4c 100644
--- a/gfs2/fsck/fsck.h
+++ b/gfs2/fsck/fsck.h
@@ -173,4 +173,22 @@ static inline int rgrp_contains_block(struct rgrp_tree *rgd, uint64_t blk)
return 1;
}
+static inline int valid_block_ip(struct gfs2_inode *ip, uint64_t blk)
+{
+ struct gfs2_sbd *sdp = ip->i_sbd;
+ struct rgrp_tree *rgd = ip->i_rgd;
+
+ if (blk > sdp->fssize)
+ return 0;
+ if (blk <= sdp->sb_addr)
+ return 0;
+ if (rgd == NULL || !rgrp_contains_block(rgd, blk)) {
+ rgd = gfs2_blk2rgrpd(sdp, blk);
+ if (rgd == NULL)
+ return 0;
+ }
+
+ return rgrp_contains_block(rgd, blk);
+}
+
#endif /* _FSCK_H */
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index 7261422..c0cc2ab 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -539,7 +539,7 @@ int check_leaf(struct gfs2_inode *ip, int lindex, struct metawalk_fxns *pass,
int di_depth = ip->i_di.di_depth;
/* Make sure the block number is in range. */
- if (!valid_block(ip->i_sbd, *leaf_no)) {
+ if (!valid_block_ip(ip, *leaf_no)) {
log_err( _("Leaf block #%llu (0x%llx) is out of range for "
"directory #%llu (0x%llx) at index %d (0x%x).\n"),
(unsigned long long)*leaf_no,
@@ -698,7 +698,7 @@ static void dir_leaf_reada(struct gfs2_inode *ip, uint64_t *tbl, unsigned hsize)
for (i = 0; i < hsize; i++) {
leaf_no = be64_to_cpu(tbl[i]);
- if (valid_block(ip->i_sbd, leaf_no))
+ if (valid_block_ip(ip, leaf_no))
t[n++] = leaf_no * sdp->bsize;
}
qsort(t, n, sizeof(uint64_t), u64cmp);
@@ -760,7 +760,7 @@ int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
first_ok_leaf = leaf_no = -1;
for (lindex = 0; lindex < hsize; lindex++) {
leaf_no = be64_to_cpu(tbl[lindex]);
- if (valid_block(ip->i_sbd, leaf_no)) {
+ if (valid_block_ip(ip, leaf_no)) {
lbh = bread(sdp, leaf_no);
/* Make sure it's really a valid leaf block. */
if (gfs2_check_meta(lbh, GFS2_METATYPE_LF) == 0) {
@@ -1334,7 +1334,7 @@ static int build_and_check_metalist(struct gfs2_inode *ip, osi_list_t *mlp,
(unsigned long long)block);
continue;
}
- if (!valid_block(ip->i_sbd, block)) {
+ if (!valid_block_ip(ip, block)) {
log_debug( _("Skipping invalid block "
"%lld (0x%llx)\n"),
(unsigned long long)block,
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index 3a1931d..6f04109 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -135,7 +135,7 @@ static int delete_block(struct gfs2_inode *ip, uint64_t block,
struct gfs2_buffer_head **bh, const char *btype,
void *private)
{
- if (valid_block(ip->i_sbd, block)) {
+ if (valid_block_ip(ip, block)) {
fsck_blockmap_set(ip, block, btype, GFS2_BLKST_FREE);
return 0;
}
@@ -233,7 +233,7 @@ static int resuscitate_metalist(struct gfs2_inode *ip, uint64_t block,
*is_valid = 1;
*was_duplicate = 0;
*bh = NULL;
- if (!valid_block(ip->i_sbd, block)){ /* blk outside of FS */
+ if (!valid_block_ip(ip, block)){ /* blk outside of FS */
fsck_blockmap_set(ip, ip->i_di.di_num.no_addr,
_("itself"), GFS2_BLKST_UNLINKED);
log_err( _("Bad indirect block pointer (invalid or out of "
@@ -281,7 +281,7 @@ static int resuscitate_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
strncpy(tmp_name, filename, de->de_name_len);
else
strncpy(tmp_name, filename, sizeof(tmp_name) - 1);
- if (!valid_block(sdp, block)) {
+ if (!valid_block_ip(ip, block)) {
log_err( _("Block # referenced by system directory entry %s "
"in inode %lld (0x%llx) is invalid or out of range;"
" ignored.\n"),
@@ -358,7 +358,7 @@ static int check_metalist(struct gfs2_inode *ip, uint64_t block,
*was_duplicate = 0;
*is_valid = 0;
- if (!valid_block(ip->i_sbd, block)) { /* blk outside of FS */
+ if (!valid_block_ip(ip, block)) { /* blk outside of FS */
/* The bad dinode should be invalidated later due to
"unrecoverable" errors. The inode itself should be
set "free" and removed from the inodetree by
@@ -441,7 +441,7 @@ static int undo_reference(struct gfs2_inode *ip, uint64_t block, int meta,
int old_bitmap_state = 0;
struct rgrp_tree *rgd;
- if (!valid_block(ip->i_sbd, block)) { /* blk outside of FS */
+ if (!valid_block_ip(ip, block)) { /* blk outside of FS */
fsck_blockmap_set(ip, ip->i_di.di_num.no_addr,
_("bad block referencing"), GFS2_BLKST_FREE);
return 1;
@@ -549,7 +549,7 @@ static int check_data(struct gfs2_inode *ip, uint64_t metablock,
int q;
struct block_count *bc = (struct block_count *) private;
- if (!valid_block(ip->i_sbd, block)) {
+ if (!valid_block_ip(ip, block)) {
log_err( _("inode %lld (0x%llx) has a bad data block pointer "
"%lld (0x%llx) (invalid or out of range) "),
(unsigned long long)ip->i_di.di_num.no_addr,
@@ -686,7 +686,7 @@ static int undo_eattr_indir_or_leaf(struct gfs2_inode *ip, uint64_t block,
int error;
struct block_count *bc = (struct block_count *) private;
- if (!valid_block(ip->i_sbd, block))
+ if (!valid_block_ip(ip, block))
return meta_error;
/* Need to check block_type before undoing the reference, which can
@@ -735,7 +735,7 @@ static int check_eattr_indir(struct gfs2_inode *ip, uint64_t indirect,
/* This inode contains an eattr - it may be invalid, but the
* eattr attributes points to a non-zero block */
- if (!valid_block(sdp, indirect)) {
+ if (!valid_block_ip(ip, indirect)) {
/* Doesn't help to mark this here - this gets checked
* in pass1c */
return 1;
@@ -893,7 +893,7 @@ static int check_extended_leaf_eattr(struct gfs2_inode *ip, int i,
struct gfs2_buffer_head *bh = NULL;
int error = 0;
- if (!valid_block(sdp, el_blk)) {
+ if (!valid_block_ip(ip, el_blk)) {
log_err( _("Inode #%llu (0x%llx): Extended Attribute block "
"%llu (0x%llx) has an extended leaf block #%llu "
"(0x%llx) that is invalid or out of range.\n"),
@@ -943,9 +943,7 @@ static int check_eattr_leaf(struct gfs2_inode *ip, uint64_t block,
uint64_t parent, struct gfs2_buffer_head **bh,
void *private)
{
- struct gfs2_sbd *sdp = ip->i_sbd;
-
- if (!valid_block(sdp, block)) {
+ if (!valid_block_ip(ip, block)) {
log_warn( _("Inode #%llu (0x%llx): Extended Attribute leaf "
"block #%llu (0x%llx) is invalid or out of "
"range.\n"),
@@ -1089,7 +1087,7 @@ static int mark_block_invalid(struct gfs2_inode *ip, uint64_t block,
*is_valid = 1;
if (was_duplicate)
*was_duplicate = 0;
- if (!valid_block(ip->i_sbd, block)) {
+ if (!valid_block_ip(ip, block)) {
if (is_valid)
*is_valid = 0;
return meta_is_good;
@@ -1181,7 +1179,7 @@ static int rangecheck_block(struct gfs2_inode *ip, uint64_t block,
long *bad_pointers = (long *)private;
int q;
- if (!valid_block(ip->i_sbd, block)) {
+ if (!valid_block_ip(ip, block)) {
(*bad_pointers)++;
log_info( _("Bad %s block pointer (invalid or out of range "
"#%ld) found in inode %lld (0x%llx).\n"),
diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c
index d072634..f808cea 100644
--- a/gfs2/fsck/pass2.c
+++ b/gfs2/fsck/pass2.c
@@ -461,7 +461,7 @@ static int basic_dentry_checks(struct gfs2_inode *ip, struct gfs2_dirent *dent,
struct gfs2_inum inum = { 0 };
*isdir = 0;
- if (!valid_block(ip->i_sbd, entry->no_addr)) {
+ if (!valid_block_ip(ip, entry->no_addr)) {
log_err( _("Block # referenced by directory entry %s in inode "
"%lld (0x%llx) is invalid\n"),
tmp_name, (unsigned long long)ip->i_di.di_num.no_addr,
@@ -1481,7 +1481,7 @@ static int check_hash_tbl_dups(struct gfs2_inode *ip, uint64_t *tbl,
or the duplicate we found. */
memset(&leaf, 0, sizeof(leaf));
leaf_no = leafblk;
- if (!valid_block(ip->i_sbd, leaf_no)) /* Checked later */
+ if (!valid_block_ip(ip, leaf_no)) /* Checked later */
continue;
lbh = bread(ip->i_sbd, leafblk);
@@ -1614,7 +1614,7 @@ static int check_hash_tbl(struct gfs2_inode *ip, uint64_t *tbl,
/* See if that leaf block is valid. If not, write a new one
that falls on a proper boundary. If it doesn't naturally,
we may need more. */
- if (!valid_block(ip->i_sbd, leafblk)) {
+ if (!valid_block_ip(ip, leafblk)) {
uint64_t new_leafblk;
log_err(_("Dinode %llu (0x%llx) has bad leaf pointers "
@@ -1776,7 +1776,7 @@ static int check_data_qc(struct gfs2_inode *ip, uint64_t metablock,
/* At this point, basic data block checks have already been done,
so we only need to make sure they're QC blocks. */
- if (!valid_block(ip->i_sbd, block))
+ if (!valid_block_ip(ip, block))
return -1;
bh = bread(ip->i_sbd, block);
diff --git a/gfs2/fsck/util.c b/gfs2/fsck/util.c
index 8a8220b..1c3ed9c 100644
--- a/gfs2/fsck/util.c
+++ b/gfs2/fsck/util.c
@@ -335,7 +335,7 @@ int add_duplicate_ref(struct gfs2_inode *ip, uint64_t block,
struct inode_with_dups *id;
struct duptree *dt;
- if (!valid_block(ip->i_sbd, block))
+ if (!valid_block_ip(ip, block))
return meta_is_good;
/* If this is not the first reference (i.e. all calls from pass1) we
need to create the duplicate reference. If this is pass1b, we want
7 years, 11 months
gfs2-utils: master - fsck.gfs2: Speed up fsck.gfs2 with a new inode
rgrp pointer
by Bob Peterson
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=a59b70e8...
Commit: a59b70e8d2b1467171ef3200350959079bef8561
Parent: 433d06c67ada88170ecf500d061383c7ca7a7957
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Wed Jun 1 09:42:27 2016 -0500
Committer: Bob Peterson <rpeterso(a)redhat.com>
CommitterDate: Thu Jun 2 10:57:10 2016 -0500
fsck.gfs2: Speed up fsck.gfs2 with a new inode rgrp pointer
This patch tries to speed up fsck.gfs2 by adding a new field in the
in-core inode which points to the inode's rgrp. Most blocks will be
contained within the rgrp, so we save time looking up the rgrp by
first checking if the desired inode block falls within the inode's
rgrp.
Signed-off-by: Bob Peterson <rpeterso(a)redhat.com>
---
gfs2/fsck/afterpass1_common.c | 3 ++-
gfs2/fsck/fsck.h | 12 +++++++++++-
gfs2/fsck/initialize.c | 2 +-
gfs2/fsck/metawalk.c | 23 +++++++++++++++--------
gfs2/fsck/metawalk.h | 5 +++--
gfs2/fsck/pass1.c | 25 +++++++++++++++----------
gfs2/fsck/pass1b.c | 3 ++-
gfs2/fsck/pass2.c | 2 +-
gfs2/fsck/pass3.c | 6 ++++--
gfs2/libgfs2/libgfs2.h | 1 +
10 files changed, 55 insertions(+), 27 deletions(-)
diff --git a/gfs2/fsck/afterpass1_common.c b/gfs2/fsck/afterpass1_common.c
index 95fdbf8..0632695 100644
--- a/gfs2/fsck/afterpass1_common.c
+++ b/gfs2/fsck/afterpass1_common.c
@@ -108,7 +108,8 @@ static int delete_block_if_notdup(struct gfs2_inode *ip, uint64_t block,
(unsigned long long)ip->i_di.di_num.no_addr,
(unsigned long long)block, (unsigned long long)block);
} else {
- check_n_fix_bitmap(ip->i_sbd, block, 0, GFS2_BLKST_FREE);
+ check_n_fix_bitmap(ip->i_sbd, ip->i_rgd, block, 0,
+ GFS2_BLKST_FREE);
}
return meta_is_good;
}
diff --git a/gfs2/fsck/fsck.h b/gfs2/fsck/fsck.h
index 09b96ed..c4e6e3b 100644
--- a/gfs2/fsck/fsck.h
+++ b/gfs2/fsck/fsck.h
@@ -108,7 +108,8 @@ enum rgindex_trust_level { /* how far can we trust our RG index? */
extern struct gfs2_inode *fsck_load_inode(struct gfs2_sbd *sdp, uint64_t block);
extern struct gfs2_inode *fsck_inode_get(struct gfs2_sbd *sdp,
- struct gfs2_buffer_head *bh);
+ struct rgrp_tree *rgd,
+ struct gfs2_buffer_head *bh);
extern void fsck_inode_put(struct gfs2_inode **ip);
extern int initialize(struct gfs2_sbd *sdp, int force_check, int preen,
@@ -163,4 +164,13 @@ static inline int valid_block(struct gfs2_sbd *sdp, uint64_t blkno)
(lgfs2_get_bitmap(sdp, blkno, NULL) < 0));
}
+static inline int rgrp_contains_block(struct rgrp_tree *rgd, uint64_t blk)
+{
+ if (blk < rgd->ri.ri_addr)
+ return 0;
+ if (blk >= rgd->ri.ri_data0 + rgd->ri.ri_data)
+ return 0;
+ return 1;
+}
+
#endif /* _FSCK_H */
diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c
index 652eec3..75f050b 100644
--- a/gfs2/fsck/initialize.c
+++ b/gfs2/fsck/initialize.c
@@ -300,7 +300,7 @@ static void check_rgrp_integrity(struct gfs2_sbd *sdp, struct rgrp_tree *rgd,
bh = bread(sdp, diblock);
if (!gfs2_check_meta(bh, GFS2_METATYPE_DI)) {
struct gfs2_inode *ip =
- fsck_inode_get(sdp, bh);
+ fsck_inode_get(sdp, rgd, bh);
if (ip->i_di.di_blocks > 1) {
blks_2free +=
ip->i_di.di_blocks - 1;
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index 0e279e5..7261422 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -29,11 +29,10 @@
is used to set the latter. The two must be kept in sync, otherwise
you'll get bitmap mismatches. This function checks the status of the
bitmap whenever the blockmap changes, and fixes it accordingly. */
-int check_n_fix_bitmap(struct gfs2_sbd *sdp, uint64_t blk, int error_on_dinode,
- int new_state)
+int check_n_fix_bitmap(struct gfs2_sbd *sdp, struct rgrp_tree *rgd,
+ uint64_t blk, int error_on_dinode, int new_state)
{
int old_state;
- struct rgrp_tree *rgd;
int treat_as_inode = 0;
int rewrite_rgrp = 0;
struct gfs_rgrp *gfs1rg;
@@ -42,7 +41,9 @@ int check_n_fix_bitmap(struct gfs2_sbd *sdp, uint64_t blk, int error_on_dinode,
/* gfs1 descriptions: */
{"free", "data", "free meta", "metadata", "reserved"}};
- rgd = gfs2_blk2rgrpd(sdp, blk);
+ if (rgd == NULL || !rgrp_contains_block(rgd, blk))
+ rgd = gfs2_blk2rgrpd(sdp, blk);
+
gfs1rg = (struct gfs_rgrp *)&rgd->rg;
old_state = lgfs2_get_bitmap(sdp, blk, rgd);
@@ -208,7 +209,8 @@ int _fsck_bitmap_set(struct gfs2_inode *ip, uint64_t bblock,
prev_mark = mark;
prev_caller = caller;
}
- error = check_n_fix_bitmap(ip->i_sbd, bblock, error_on_dinode, mark);
+ 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"));
return error;
@@ -273,18 +275,23 @@ struct gfs2_inode *fsck_load_inode(struct gfs2_sbd *sdp, uint64_t block)
/* fsck_inode_get - same as inode_get() in libgfs2 but system inodes
get special treatment. */
-struct gfs2_inode *fsck_inode_get(struct gfs2_sbd *sdp,
+struct gfs2_inode *fsck_inode_get(struct gfs2_sbd *sdp, struct rgrp_tree *rgd,
struct gfs2_buffer_head *bh)
{
struct gfs2_inode *sysip;
+ struct gfs2_inode *ip;
sysip = fsck_system_inode(sdp, bh->b_blocknr);
if (sysip)
return sysip;
if (sdp->gfs1)
- return lgfs2_gfs_inode_get(sdp, bh);
- return lgfs2_inode_get(sdp, bh);
+ ip = lgfs2_gfs_inode_get(sdp, bh);
+ else
+ ip = lgfs2_inode_get(sdp, bh);
+ if (ip)
+ ip->i_rgd = rgd;
+ return ip;
}
/* fsck_inode_put - same as inode_put() in libgfs2 but system inodes
diff --git a/gfs2/fsck/metawalk.h b/gfs2/fsck/metawalk.h
index b16e57d..119efee 100644
--- a/gfs2/fsck/metawalk.h
+++ b/gfs2/fsck/metawalk.h
@@ -22,8 +22,9 @@ extern int check_leaf(struct gfs2_inode *ip, int lindex,
extern int _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, uint64_t blk,
- int error_on_dinode, int new_state);
+extern int check_n_fix_bitmap(struct gfs2_sbd *sdp, struct rgrp_tree *rgd,
+ uint64_t blk, int error_on_dinode,
+ int new_state);
extern struct duptree *dupfind(uint64_t block);
extern struct gfs2_inode *fsck_system_inode(struct gfs2_sbd *sdp,
uint64_t block);
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index 6908ac7..3a1931d 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -248,8 +248,9 @@ static int resuscitate_metalist(struct gfs2_inode *ip, uint64_t block,
ip->i_sbd->gfs1 ?
GFS2_BLKST_DINODE : GFS2_BLKST_USED);
else
- check_n_fix_bitmap(ip->i_sbd, block, 0, ip->i_sbd->gfs1 ?
- GFS2_BLKST_DINODE : GFS2_BLKST_USED);
+ check_n_fix_bitmap(ip->i_sbd, ip->i_rgd, block, 0,
+ ip->i_sbd->gfs1 ?
+ GFS2_BLKST_DINODE : GFS2_BLKST_USED);
bc->indir_count++;
return meta_is_good;
}
@@ -296,7 +297,8 @@ static int resuscitate_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
fsck_blockmap_set(ip, block, _("system file"),
GFS2_BLKST_DINODE);
else
- check_n_fix_bitmap(sdp, block, 0, GFS2_BLKST_DINODE);
+ check_n_fix_bitmap(sdp, ip->i_rgd, block, 0,
+ GFS2_BLKST_DINODE);
/* Return the number of leaf entries so metawalk doesn't flag this
leaf as having none. */
*count = be16_to_cpu(((struct gfs2_leaf *)bh->b_data)->lf_entries);
@@ -1594,13 +1596,14 @@ static void check_i_goal(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
* handle_di - This is now a wrapper function that takes a gfs2_buffer_head
* and calls handle_ip, which takes an in-code dinode structure.
*/
-static int handle_di(struct gfs2_sbd *sdp, struct gfs2_buffer_head *bh)
+static int handle_di(struct gfs2_sbd *sdp, struct rgrp_tree *rgd,
+ struct gfs2_buffer_head *bh)
{
int error = 0;
uint64_t block = bh->b_blocknr;
struct gfs2_inode *ip;
- ip = fsck_inode_get(sdp, bh);
+ ip = fsck_inode_get(sdp, rgd, bh);
if (ip->i_di.di_num.no_addr != block) {
log_err( _("Inode #%llu (0x%llx): Bad inode address found: %llu "
@@ -1671,7 +1674,8 @@ static int check_system_inode(struct gfs2_sbd *sdp,
(unsigned long long)iblock,
(unsigned long long)iblock);
gfs2_blockmap_set(bl, iblock, GFS2_BLKST_FREE);
- check_n_fix_bitmap(sdp, iblock, 0, GFS2_BLKST_FREE);
+ check_n_fix_bitmap(sdp, (*sysinode)->i_rgd, iblock, 0,
+ GFS2_BLKST_FREE);
inode_put(sysinode);
}
}
@@ -1955,7 +1959,7 @@ static int pass1_process_bitmap(struct gfs2_sbd *sdp, struct rgrp_tree *rgd, uin
(unsigned long long)block,
(unsigned long long)block,
block_type_string(q));
- ip = fsck_inode_get(sdp, bh);
+ ip = fsck_inode_get(sdp, rgd, bh);
if (is_inode && ip->i_di.di_num.no_addr == block)
add_duplicate_ref(ip, block, ref_is_inode, 0,
INODE_VALID);
@@ -1991,8 +1995,9 @@ static int pass1_process_bitmap(struct gfs2_sbd *sdp, struct rgrp_tree *rgd, uin
"%llu (0x%llx)\n"),
(unsigned long long)block,
(unsigned long long)block);
- check_n_fix_bitmap(sdp, block, 0, GFS2_BLKST_FREE);
- } else if (handle_di(sdp, bh) < 0) {
+ check_n_fix_bitmap(sdp, rgd, block, 0,
+ GFS2_BLKST_FREE);
+ } else if (handle_di(sdp, rgd, bh) < 0) {
stack;
brelse(bh);
gfs2_special_free(&gfs1_rindex_blks);
@@ -2206,7 +2211,7 @@ int pass1(struct gfs2_sbd *sdp)
}
/* rgrps and bitmaps don't have bits to represent
their blocks, so don't do this:
- check_n_fix_bitmap(sdp, rgd->ri.ri_addr + i, 0,
+ check_n_fix_bitmap(sdp, rgd, rgd->ri.ri_addr + i, 0,
gfs2_meta_rgrp);*/
}
diff --git a/gfs2/fsck/pass1b.c b/gfs2/fsck/pass1b.c
index 6dec193..62686fe 100644
--- a/gfs2/fsck/pass1b.c
+++ b/gfs2/fsck/pass1b.c
@@ -775,7 +775,8 @@ static int handle_dup_blk(struct gfs2_sbd *sdp, struct duptree *dt)
(unsigned long long)dup_blk);
if (dh.dt)
dup_delete(dh.dt);
- check_n_fix_bitmap(sdp, dup_blk, 0, GFS2_BLKST_FREE);
+ check_n_fix_bitmap(sdp, NULL, dup_blk, 0,
+ GFS2_BLKST_FREE);
}
}
return 0;
diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c
index ffd58dc..d072634 100644
--- a/gfs2/fsck/pass2.c
+++ b/gfs2/fsck/pass2.c
@@ -2036,7 +2036,7 @@ static int pass2_check_dir(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
log_debug(_("Directory block %lld (0x%llx) is now marked as 'invalid'\n"),
(unsigned long long)dirblk, (unsigned long long)dirblk);
- check_n_fix_bitmap(sdp, dirblk, 0, GFS2_BLKST_FREE);
+ check_n_fix_bitmap(sdp, ip->i_rgd, dirblk, 0, GFS2_BLKST_FREE);
}
if (!ds.dotdir) {
diff --git a/gfs2/fsck/pass3.c b/gfs2/fsck/pass3.c
index 85d7e36..4b9c54d 100644
--- a/gfs2/fsck/pass3.c
+++ b/gfs2/fsck/pass3.c
@@ -253,7 +253,8 @@ int pass3(struct gfs2_sbd *sdp)
di->dinode.no_addr,
(unsigned long long)
di->dinode.no_addr);
- check_n_fix_bitmap(sdp, di->dinode.no_addr,
+ check_n_fix_bitmap(sdp, ip->i_rgd,
+ di->dinode.no_addr,
0, GFS2_BLKST_FREE);
fsck_inode_put(&ip);
break;
@@ -274,7 +275,8 @@ int pass3(struct gfs2_sbd *sdp)
"marked as free\n"),
(unsigned long long)di->dinode.no_addr,
(unsigned long long)di->dinode.no_addr);
- check_n_fix_bitmap(sdp, di->dinode.no_addr, 0,
+ check_n_fix_bitmap(sdp, ip->i_rgd,
+ di->dinode.no_addr, 0,
GFS2_BLKST_FREE);
log_err( _("The block was cleared\n"));
fsck_inode_put(&ip);
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index d6c54b3..5414a20 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -235,6 +235,7 @@ struct gfs2_inode {
struct gfs2_dinode i_di;
struct gfs2_buffer_head *i_bh;
struct gfs2_sbd *i_sbd;
+ struct rgrp_tree *i_rgd; /* performance hint */
};
struct master_dir
7 years, 11 months
gfs2-utils: master - fsck.gfs2: shorten bitmap state variable names
by Bob Peterson
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=433d06c6...
Commit: 433d06c67ada88170ecf500d061383c7ca7a7957
Parent: 69b90626f1a1d800cfc1c5ba63ea1b4426d71fba
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Wed Jun 1 09:25:52 2016 -0500
Committer: Bob Peterson <rpeterso(a)redhat.com>
CommitterDate: Thu Jun 2 10:57:10 2016 -0500
fsck.gfs2: shorten bitmap state variable names
Since bitmap state and blockmap state are now the same, this patch
shortens the variable names to make it more readable.
Signed-off-by: Bob Peterson <rpeterso(a)redhat.com>
---
gfs2/fsck/metawalk.c | 34 +++++++++++++++++-----------------
gfs2/fsck/metawalk.h | 2 +-
2 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index 253ebcb..0e279e5 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -30,9 +30,9 @@
you'll get bitmap mismatches. This function checks the status of the
bitmap whenever the blockmap changes, and fixes it accordingly. */
int check_n_fix_bitmap(struct gfs2_sbd *sdp, uint64_t blk, int error_on_dinode,
- int new_blockmap_state)
+ int new_state)
{
- int old_bitmap_state;
+ int old_state;
struct rgrp_tree *rgd;
int treat_as_inode = 0;
int rewrite_rgrp = 0;
@@ -45,22 +45,22 @@ int check_n_fix_bitmap(struct gfs2_sbd *sdp, uint64_t blk, int error_on_dinode,
rgd = gfs2_blk2rgrpd(sdp, blk);
gfs1rg = (struct gfs_rgrp *)&rgd->rg;
- old_bitmap_state = lgfs2_get_bitmap(sdp, blk, rgd);
- if (old_bitmap_state < 0) {
+ old_state = lgfs2_get_bitmap(sdp, blk, rgd);
+ if (old_state < 0) {
log_err( _("Block %llu (0x%llx) is not represented in the "
"system bitmap; part of an rgrp or superblock.\n"),
(unsigned long long)blk, (unsigned long long)blk);
return -1;
}
- if (old_bitmap_state == new_blockmap_state)
+ if (old_state == new_state)
return 0;
- if (error_on_dinode && old_bitmap_state == GFS2_BLKST_DINODE &&
- new_blockmap_state != GFS2_BLKST_FREE) {
+ if (error_on_dinode && old_state == GFS2_BLKST_DINODE &&
+ new_state != GFS2_BLKST_FREE) {
log_debug(_("Reference as '%s' to block %llu (0x%llx) which "
"was marked as dinode. Needs further "
"investigation.\n"),
- allocdesc[sdp->gfs1][new_blockmap_state],
+ allocdesc[sdp->gfs1][new_state],
(unsigned long long)blk, (unsigned long long)blk);
return 1;
}
@@ -68,8 +68,8 @@ int check_n_fix_bitmap(struct gfs2_sbd *sdp, uint64_t blk, int error_on_dinode,
huge and unmanageable. */
log_err( _("Block %llu (0x%llx) was '%s', should be %s.\n"),
(unsigned long long)blk, (unsigned long long)blk,
- allocdesc[sdp->gfs1][old_bitmap_state],
- allocdesc[sdp->gfs1][new_blockmap_state]);
+ allocdesc[sdp->gfs1][old_state],
+ allocdesc[sdp->gfs1][new_state]);
if (!query( _("Fix the bitmap? (y/n)"))) {
log_err( _("The bitmap inconsistency was ignored.\n"));
return 0;
@@ -79,17 +79,17 @@ int check_n_fix_bitmap(struct gfs2_sbd *sdp, uint64_t blk, int error_on_dinode,
bitmap state was free (and therefore it no longer is) we have to
subtract to the free space. If the type changed from dinode to
data or data to dinode, no change in free space. */
- gfs2_set_bitmap(rgd, blk, new_blockmap_state);
- if (new_blockmap_state == GFS2_BLKST_FREE) {
+ gfs2_set_bitmap(rgd, blk, new_state);
+ if (new_state == GFS2_BLKST_FREE) {
rgd->rg.rg_free++;
rewrite_rgrp = 1;
- } else if (old_bitmap_state == GFS2_BLKST_FREE) {
+ } else if (old_state == GFS2_BLKST_FREE) {
rgd->rg.rg_free--;
rewrite_rgrp = 1;
}
/* If we're freeing a dinode, get rid of the data structs for it. */
- if (old_bitmap_state == GFS2_BLKST_DINODE ||
- old_bitmap_state == GFS2_BLKST_UNLINKED) {
+ if (old_state == GFS2_BLKST_DINODE ||
+ old_state == GFS2_BLKST_UNLINKED) {
struct dir_info *dt;
struct inode_info *ii;
@@ -110,7 +110,7 @@ int check_n_fix_bitmap(struct gfs2_sbd *sdp, uint64_t blk, int error_on_dinode,
the rgrp inode count. */
treat_as_inode = 1;
}
- if (old_bitmap_state == GFS2_BLKST_DINODE) {
+ if (old_state == GFS2_BLKST_DINODE) {
if (treat_as_inode && rgd->rg.rg_dinodes > 0)
rgd->rg.rg_dinodes--;
else if (sdp->gfs1 && gfs1rg->rg_usedmeta > 0)
@@ -118,7 +118,7 @@ int check_n_fix_bitmap(struct gfs2_sbd *sdp, uint64_t blk, int error_on_dinode,
rewrite_rgrp = 1;
}
link1_set(&nlink1map, blk, 0);
- } else if (new_blockmap_state == GFS2_BLKST_DINODE) {
+ } else if (new_state == GFS2_BLKST_DINODE) {
if (!sdp->gfs1) {
treat_as_inode = 1;
} else {
diff --git a/gfs2/fsck/metawalk.h b/gfs2/fsck/metawalk.h
index 813736a..b16e57d 100644
--- a/gfs2/fsck/metawalk.h
+++ b/gfs2/fsck/metawalk.h
@@ -23,7 +23,7 @@ extern int _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, uint64_t blk,
- int error_on_dinode, int new_blockmap_state);
+ int error_on_dinode, int new_state);
extern struct duptree *dupfind(uint64_t block);
extern struct gfs2_inode *fsck_system_inode(struct gfs2_sbd *sdp,
uint64_t block);
7 years, 11 months