[gfs2-utils] branch agruenba-extents updated: fsck.gfs2: Convert enum
values to upper-case
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
agruenba pushed a commit to branch agruenba-extents
in repository gfs2-utils.
The following commit(s) were added to refs/heads/agruenba-extents by this push:
new 1da6566a fsck.gfs2: Convert enum values to upper-case
1da6566a is described below
commit 1da6566a6c98f754dbb319fa42474327567212e4
Author: Andreas Gruenbacher <agruenba(a)redhat.com>
AuthorDate: Thu Apr 22 20:45:01 2021 +0200
fsck.gfs2: Convert enum values to upper-case
Several of the enums in the fsck.gfs2 code use lower-case enum values, which
makes the code harder to read than necessary. Convert those to upper-case
with:
toupper() {
printf '%s\n' "$@" |
awk '{ print "s/\\<" $1 "\\>/" toupper($1) "/g" }'
}
toupper \
ref_as_data ref_as_meta ref_as_ea ref_is_inode ref_types \
blind_faith ye_of_little_faith open_minded distrust indignation \
incr_link_bad incr_link_good incr_link_ino_mismatch incr_link_check_orig \
meta_error meta_is_good meta_skip_further meta_skip_one \
btype_meta btype_leaf btype_data btype_ieattr btype_eattr \
| sed -i -f /dev/stdin $(git ls-files gfs2/fsck)
Signed-off-by: Andreas Gruenbacher <agruenba(a)redhat.com>
---
gfs2/fsck/afterpass1_common.c | 8 ++---
gfs2/fsck/fs_recovery.c | 8 ++---
gfs2/fsck/fsck.h | 22 ++++++------
gfs2/fsck/initialize.c | 4 +--
gfs2/fsck/link.c | 16 ++++-----
gfs2/fsck/link.h | 8 ++---
gfs2/fsck/metawalk.c | 28 ++++++++--------
gfs2/fsck/metawalk.h | 8 ++---
gfs2/fsck/pass1.c | 78 +++++++++++++++++++++----------------------
gfs2/fsck/pass1b.c | 68 ++++++++++++++++++-------------------
gfs2/fsck/pass2.c | 6 ++--
gfs2/fsck/rgrepair.c | 28 ++++++++--------
gfs2/fsck/util.c | 24 ++++++-------
gfs2/fsck/util.h | 2 +-
14 files changed, 154 insertions(+), 154 deletions(-)
diff --git a/gfs2/fsck/afterpass1_common.c b/gfs2/fsck/afterpass1_common.c
index 646e4010..82b9a54c 100644
--- a/gfs2/fsck/afterpass1_common.c
+++ b/gfs2/fsck/afterpass1_common.c
@@ -39,7 +39,7 @@ static int find_remove_dup(struct gfs2_inode *ip, uint64_t block,
if (!id)
goto more_refs;
- if (id->reftypecount[ref_as_meta])
+ if (id->reftypecount[REF_AS_META])
deleted_a_meta_ref = 1;
dup_listent_delete(dt, id);
if (dt->refs == 0) {
@@ -82,7 +82,7 @@ static int delete_block_if_notdup(struct gfs2_inode *ip, uint64_t block,
int removed_lastmeta = 0;
if (!valid_block_ip(ip, block))
- return meta_error;
+ return META_ERROR;
q = bitmap_type(ip->i_sbd, block);
if (q == GFS2_BLKST_FREE) {
@@ -92,7 +92,7 @@ static int delete_block_if_notdup(struct gfs2_inode *ip, uint64_t block,
(unsigned long long)block,
(unsigned long long)ip->i_di.di_num.no_addr,
(unsigned long long)ip->i_di.di_num.no_addr);
- return meta_is_good;
+ return META_IS_GOOD;
}
if (find_remove_dup(ip, block, btype, &removed_lastmeta)) { /* a dup */
if (was_duplicate) {
@@ -111,7 +111,7 @@ static int delete_block_if_notdup(struct gfs2_inode *ip, uint64_t block,
check_n_fix_bitmap(ip->i_sbd, ip->i_rgd, block, 0,
GFS2_BLKST_FREE);
}
- return meta_is_good;
+ return META_IS_GOOD;
}
static int remove_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
diff --git a/gfs2/fsck/fs_recovery.c b/gfs2/fsck/fs_recovery.c
index 7bfddbfd..c7704b0e 100644
--- a/gfs2/fsck/fs_recovery.c
+++ b/gfs2/fsck/fs_recovery.c
@@ -628,9 +628,9 @@ static int rangecheck_jblock(struct gfs2_inode *ip, uint64_t block)
"journal inode %lld (0x%llx).\n"),
(unsigned long long)ip->i_di.di_num.no_addr,
(unsigned long long)ip->i_di.di_num.no_addr);
- return meta_error; /* Exits check_metatree quicker */
+ return META_ERROR; /* Exits check_metatree quicker */
}
- return meta_is_good;
+ return META_IS_GOOD;
}
static int rangecheck_jmeta(struct iptr iptr, struct gfs2_buffer_head **bh, int h,
@@ -644,7 +644,7 @@ static int rangecheck_jmeta(struct iptr iptr, struct gfs2_buffer_head **bh, int
*was_duplicate = 0;
*is_valid = 0;
rc = rangecheck_jblock(ip, block);
- if (rc == meta_is_good) {
+ if (rc == META_IS_GOOD) {
*bh = bread(ip->i_sbd, block);
*is_valid = (gfs2_check_meta((*bh)->b_data, GFS2_METATYPE_IN) == 0);
if (!(*is_valid)) {
@@ -658,7 +658,7 @@ static int rangecheck_jmeta(struct iptr iptr, struct gfs2_buffer_head **bh, int
(unsigned long long)block);
brelse(*bh);
*bh = NULL;
- return meta_skip_further;
+ return META_SKIP_FURTHER;
}
}
return rc;
diff --git a/gfs2/fsck/fsck.h b/gfs2/fsck/fsck.h
index aad9a360..16aab67d 100644
--- a/gfs2/fsck/fsck.h
+++ b/gfs2/fsck/fsck.h
@@ -74,36 +74,36 @@ struct duptree {
};
enum dup_ref_type {
- ref_as_data = 0, /* dinode references this block as a data block */
- ref_as_meta = 1, /* dinode references this block as a metadata block */
- ref_as_ea = 2, /* dinode references this block as an extended attr */
- ref_is_inode= 3, /* The reference is itself a dinode. In other words,
+ REF_AS_DATA = 0, /* dinode references this block as a data block */
+ REF_AS_META = 1, /* dinode references this block as a metadata block */
+ REF_AS_EA = 2, /* dinode references this block as an extended attr */
+ REF_IS_INODE= 3, /* The reference is itself a dinode. In other words,
it's a dinode, not pointed to as data or
metadata */
- ref_types = 4,
+ REF_TYPES = 4,
};
struct inode_with_dups {
osi_list_t list;
uint64_t block_no;
int dup_count;
- int reftypecount[ref_types];
+ int reftypecount[REF_TYPES];
uint64_t parent;
char *name;
};
enum rgindex_trust_level { /* how far can we trust our RG index? */
- blind_faith = 0, /* We'd like to trust the rgindex. We always used to
+ BLIND_FAITH = 0, /* We'd like to trust the rgindex. We always used to
before bz 179069. This should cover most cases. */
- ye_of_little_faith = 1, /* The rindex seems trustworthy but there's
+ YE_OF_LITTLE_FAITH = 1, /* The rindex seems trustworthy but there's
rg damage that need to be fixed. */
- open_minded = 2, /* At least 1 RG is corrupt. Try to calculate what it
+ OPEN_MINDED = 2, /* At least 1 RG is corrupt. Try to calculate what it
should be, in a perfect world where our RGs are all
on even boundaries. Blue sky. Chirping birds. */
- distrust = 3, /* The world isn't perfect, our RGs are not on nice neat
+ DISTRUST = 3, /* The world isn't perfect, our RGs are not on nice neat
boundaries. The fs must have been messed with by
gfs2_grow or something. Count the RGs by hand. */
- indignation = 4 /* Not only do we have corruption, but the rgrps
+ INDIGNATION = 4 /* Not only do we have corruption, but the rgrps
aren't on even boundaries, so this file system
must have been converted from gfs2_convert. */
};
diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c
index 17f2d6cd..e35cf0a9 100644
--- a/gfs2/fsck/initialize.c
+++ b/gfs2/fsck/initialize.c
@@ -779,7 +779,7 @@ static int fetch_rgrps(struct gfs2_sbd *sdp)
int ok = 1;
log_notice(_("Validating resource group index.\n"));
- for (trust_lvl = blind_faith; trust_lvl <= indignation; trust_lvl++) {
+ for (trust_lvl = BLIND_FAITH; trust_lvl <= INDIGNATION; trust_lvl++) {
int ret = 0;
ret = fetch_rgrps_level(sdp, trust_lvl, &rgcount, &ok);
@@ -788,7 +788,7 @@ static int fetch_rgrps(struct gfs2_sbd *sdp)
if (fsck_abort)
break;
}
- if (trust_lvl > indignation) {
+ if (trust_lvl > INDIGNATION) {
log_err( _("Resource group recovery impossible; I can't fix "
"this file system.\n"));
return -1;
diff --git a/gfs2/fsck/link.c b/gfs2/fsck/link.c
index 8ea09c75..08118e8a 100644
--- a/gfs2/fsck/link.c
+++ b/gfs2/fsck/link.c
@@ -88,33 +88,33 @@ int incr_link_count(struct gfs2_inum no, struct gfs2_inode *ip,
di = dirtree_find(no.no_addr);
if (di) {
if (di->dinode.no_formal_ino != no.no_formal_ino)
- return incr_link_ino_mismatch;
+ return INCR_LINK_INO_MISMATCH;
di->counted_links++;
whyincr(no.no_addr, why, referenced_from, di->counted_links);
- return incr_link_good;
+ return INCR_LINK_GOOD;
}
ii = inodetree_find(no.no_addr);
/* If the list has entries, look for one that matches inode_no */
if (ii) {
if (ii->di_num.no_formal_ino != no.no_formal_ino)
- return incr_link_ino_mismatch;
+ return INCR_LINK_INO_MISMATCH;
ii->counted_links++;
whyincr(no.no_addr, why, referenced_from, ii->counted_links);
- return incr_link_good;
+ return INCR_LINK_GOOD;
}
if (link1_type(&clink1map, no.no_addr) != 1) {
link1_set(&clink1map, no.no_addr, 1);
whyincr(no.no_addr, why, referenced_from, 1);
- return incr_link_good;
+ return INCR_LINK_GOOD;
}
link_ip = fsck_load_inode(ip->i_sbd, no.no_addr);
/* Check formal ino against dinode before adding to inode tree. */
if (no.no_formal_ino != link_ip->i_di.di_num.no_formal_ino) {
fsck_inode_put(&link_ip);
- return incr_link_ino_mismatch; /* inode mismatch */
+ return INCR_LINK_INO_MISMATCH; /* inode mismatch */
}
/* Move it from the link1 maps to a real inode tree entry */
link1_set(&nlink1map, no.no_addr, 0);
@@ -130,7 +130,7 @@ int incr_link_count(struct gfs2_inum no, struct gfs2_inode *ip,
(unsigned long long)referenced_from,
(unsigned long long)no.no_addr);
fsck_inode_put(&link_ip);
- return incr_link_bad;
+ return INCR_LINK_BAD;
}
ii->di_num = link_ip->i_di.di_num;
fsck_inode_put(&link_ip);
@@ -142,7 +142,7 @@ int incr_link_count(struct gfs2_inum no, struct gfs2_inode *ip,
not a directory. But the new reference has the correct formal
inode number, so the first reference is suspect: we need to
check it in case it's a bad reference, and not just a hard link. */
- return incr_link_check_orig;
+ return INCR_LINK_CHECK_ORIG;
}
#define whydecr(no_addr, why, referenced_from, counted_links) \
diff --git a/gfs2/fsck/link.h b/gfs2/fsck/link.h
index a5dd1c85..0b300225 100644
--- a/gfs2/fsck/link.h
+++ b/gfs2/fsck/link.h
@@ -5,10 +5,10 @@ extern struct gfs2_bmap nlink1map; /* map of dinodes with nlink == 1 */
extern struct gfs2_bmap clink1map; /* map of dinodes w/counted links == 1 */
enum {
- incr_link_bad = -1,
- incr_link_good = 0,
- incr_link_ino_mismatch = 1,
- incr_link_check_orig = 2,
+ INCR_LINK_BAD = -1,
+ INCR_LINK_GOOD = 0,
+ INCR_LINK_INO_MISMATCH = 1,
+ INCR_LINK_CHECK_ORIG = 2,
};
int link1_set(struct gfs2_bmap *bmap, uint64_t bblock, int mark);
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index 59aea1d6..62476ab8 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -1225,14 +1225,14 @@ static int do_check_metalist(struct iptr iptr, int height, struct gfs2_buffer_he
error = pass->check_metalist(iptr, bhp, height, &is_valid,
&was_duplicate, pass->private);
- if (error == meta_error) {
+ if (error == META_ERROR) {
stack;
log_info("\n");
log_info(_("Serious metadata error on block %"PRIu64" (0x%"PRIx64").\n"),
block, block);
return error;
}
- if (error == meta_skip_further) {
+ if (error == META_SKIP_FURTHER) {
log_info("\n");
log_info(_("Unrecoverable metadata error on block %"PRIu64" (0x%"PRIx64")\n"),
block, block);
@@ -1242,18 +1242,18 @@ static int do_check_metalist(struct iptr iptr, int height, struct gfs2_buffer_he
if (!is_valid) {
log_debug("Skipping rejected block %"PRIu64" (0x%"PRIx64")\n", block, block);
if (pass->invalid_meta_is_fatal)
- return meta_error;
- return meta_skip_one;
+ return META_ERROR;
+ return META_SKIP_ONE;
}
if (was_duplicate) {
log_debug("Skipping duplicate %"PRIu64" (0x%"PRIx64")\n", block, block);
- return meta_skip_one;
+ return META_SKIP_ONE;
}
if (!valid_block_ip(ip, block)) {
log_debug("Skipping invalid block %"PRIu64" (0x%"PRIx64")\n", block, block);
if (pass->invalid_meta_is_fatal)
- return meta_error;
- return meta_skip_one;
+ return META_ERROR;
+ return META_SKIP_ONE;
}
return error;
}
@@ -1293,7 +1293,7 @@ static int build_and_check_metalist(struct gfs2_inode *ip, osi_list_t *mlp,
/* if (<there are no indirect blocks to check>) */
if (height < 2)
- return meta_is_good;
+ return META_IS_GOOD;
for (h = 1; h < height; h++) {
if (h > 1) {
if (is_dir(&ip->i_di, ip->i_sbd->gfs1) &&
@@ -1323,7 +1323,7 @@ static int build_and_check_metalist(struct gfs2_inode *ip, osi_list_t *mlp,
if (gfs2_check_meta(iptr_buf(iptr), iblk_type)) {
if (pass->invalid_meta_is_fatal)
- return meta_error;
+ return META_ERROR;
continue;
}
@@ -1335,14 +1335,14 @@ static int build_and_check_metalist(struct gfs2_inode *ip, osi_list_t *mlp,
struct gfs2_buffer_head *nbh = NULL;
if (skip_this_pass || fsck_abort)
- return meta_is_good;
+ return META_IS_GOOD;
if (!iptr_block(iptr))
continue;
error = do_check_metalist(iptr, h, &nbh, pass);
- if (error == meta_error || error == meta_skip_further)
+ if (error == META_ERROR || error == META_SKIP_FURTHER)
goto error_undo;
- if (error == meta_skip_one)
+ if (error == META_SKIP_ONE)
continue;
if (!nbh)
nbh = bread(ip->i_sbd, iptr_block(iptr));
@@ -1476,7 +1476,7 @@ static int metawalk_check_data(struct gfs2_inode *ip, struct metawalk_fxns *pass
ip->i_di.di_num.no_addr,
ip->i_di.di_num.no_addr,
max_extents);
- return meta_error;
+ return META_ERROR;
}
for (ex = first_ex; ex != first_ex + extents && !fsck_abort; ex++) {
@@ -1662,7 +1662,7 @@ int check_metatree(struct gfs2_inode *ip, struct metawalk_fxns *pass)
ip->i_di.di_num.no_addr,
ip->i_di.di_num.no_addr,
1);
- error = meta_error;
+ error = META_ERROR;
goto undo_metalist;
}
/* make sure we check the inode below */
diff --git a/gfs2/fsck/metawalk.h b/gfs2/fsck/metawalk.h
index 88c7d9c1..f63ed5cf 100644
--- a/gfs2/fsck/metawalk.h
+++ b/gfs2/fsck/metawalk.h
@@ -36,10 +36,10 @@ extern struct gfs2_inode *fsck_system_inode(struct gfs2_sbd *sdp,
#define fsck_bitmap_set_noino(ip, b, bt, m) \
_fsck_bitmap_set(ip, b, bt, m, 1, __FUNCTION__, __LINE__)
enum meta_check_rc {
- meta_error = -1,
- meta_is_good = 0,
- meta_skip_further = 1,
- meta_skip_one = 2,
+ META_ERROR = -1,
+ META_IS_GOOD = 0,
+ META_SKIP_FURTHER = 1,
+ META_SKIP_ONE = 2,
};
struct iptr {
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index 27a7d6dc..71d6a46d 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -238,7 +238,7 @@ static int resuscitate_metalist(struct iptr iptr, struct gfs2_buffer_head **bh,
(unsigned long long)ip->i_di.di_num.no_addr,
(unsigned long long)ip->i_di.di_num.no_addr);
*is_valid = 0;
- return meta_is_good;
+ return META_IS_GOOD;
}
if (fsck_system_inode(ip->i_sbd, block))
fsck_blockmap_set(ip, block, _("system file"),
@@ -249,7 +249,7 @@ static int resuscitate_metalist(struct iptr iptr, struct gfs2_buffer_head **bh,
ip->i_sbd->gfs1 ?
GFS2_BLKST_DINODE : GFS2_BLKST_USED);
bc->indir_count++;
- return meta_is_good;
+ return META_IS_GOOD;
}
/*
@@ -328,7 +328,7 @@ static int p1check_leaf(struct gfs2_inode *ip, uint64_t block, void *private)
(unsigned long long)ip->i_di.di_num.no_addr,
(unsigned long long)ip->i_di.di_num.no_addr, q,
block_type_string(q));
- add_duplicate_ref(ip, block, ref_as_meta, 0, INODE_VALID);
+ add_duplicate_ref(ip, block, REF_AS_META, 0, INODE_VALID);
if (q == (ip->i_sbd->gfs1 ? GFS2_BLKST_DINODE :
GFS2_BLKST_USED))
/* If the previous reference also saw this as a leaf,
@@ -368,7 +368,7 @@ static int pass1_check_metalist(struct iptr iptr, struct gfs2_buffer_head **bh,
(unsigned long long)ip->i_di.di_num.no_addr,
(unsigned long long)ip->i_di.di_num.no_addr);
- return meta_skip_further;
+ return META_SKIP_FURTHER;
}
if (is_dir(&ip->i_di, ip->i_sbd->gfs1) && h == ip->i_di.di_height) {
iblk_type = GFS2_METATYPE_JD;
@@ -405,16 +405,16 @@ static int pass1_check_metalist(struct iptr iptr, struct gfs2_buffer_head **bh,
*iptr_ptr(iptr) = 0;
bmodified(iptr.ipt_bh);
*is_valid = 1;
- return meta_skip_one;
+ return META_SKIP_ONE;
} else {
brelse(nbh);
- return meta_skip_further;
+ return META_SKIP_FURTHER;
}
}
bc->indir_count++;
if (*was_duplicate) {
- add_duplicate_ref(ip, block, ref_as_meta, 0,
+ add_duplicate_ref(ip, block, REF_AS_META, 0,
*is_valid ? INODE_VALID : INODE_INVALID);
brelse(nbh);
} else {
@@ -424,8 +424,8 @@ static int pass1_check_metalist(struct iptr iptr, struct gfs2_buffer_head **bh,
}
if (*is_valid)
- return meta_is_good;
- return meta_skip_further;
+ return META_IS_GOOD;
+ return META_SKIP_FURTHER;
}
/* undo_reference - undo previously processed data or metadata
@@ -602,7 +602,7 @@ static int pass1_check_data(struct gfs2_inode *ip, uint64_t metablock,
when check_metatree tries to delete the inode, we
can't have the "undo" functions freeing the block
out from other the original referencing inode. */
- add_duplicate_ref(ip, block, ref_as_data, 0,
+ add_duplicate_ref(ip, block, REF_AS_DATA, 0,
INODE_VALID);
return 1;
case GFS2_BLKST_USED: /* tough decision: May be data or meta */
@@ -622,13 +622,13 @@ static int pass1_check_data(struct gfs2_inode *ip, uint64_t metablock,
the inode, we can't have the "undo"
functions freeing the block out from other
the original referencing inode. */
- add_duplicate_ref(ip, block, ref_as_data, 0,
+ add_duplicate_ref(ip, block, REF_AS_DATA, 0,
INODE_VALID);
return 1;
}
log_info( _("Seems to be a normal duplicate; I'll "
"sort it out in pass1b.\n"));
- add_duplicate_ref(ip, block, ref_as_data, 0,
+ add_duplicate_ref(ip, block, REF_AS_DATA, 0,
INODE_VALID);
/* This inode references the block as data. So if this
all is validated, we want to keep this count. */
@@ -636,7 +636,7 @@ static int pass1_check_data(struct gfs2_inode *ip, uint64_t metablock,
case GFS2_BLKST_UNLINKED:
log_info( _("The block was invalid as metadata but might be "
"okay as data. I'll sort it out in pass1b.\n"));
- add_duplicate_ref(ip, block, ref_as_data, 0, INODE_VALID);
+ add_duplicate_ref(ip, block, REF_AS_DATA, 0, INODE_VALID);
return 0;
}
}
@@ -692,7 +692,7 @@ static int undo_eattr_indir_or_leaf(struct gfs2_inode *ip, uint64_t block,
struct block_count *bc = (struct block_count *) private;
if (!valid_block_ip(ip, block))
- return meta_error;
+ return META_ERROR;
/* Need to check block_type before undoing the reference, which can
set it to free, which would cause the test below to fail. */
@@ -755,7 +755,7 @@ static int check_eattr_indir(struct gfs2_inode *ip, uint64_t indirect,
if (gfs2_check_meta((*bh)->b_data, GFS2_METATYPE_IN)) {
bc->ea_count++;
if (q != GFS2_BLKST_FREE) { /* Duplicate? */
- add_duplicate_ref(ip, indirect, ref_as_ea, 0,
+ add_duplicate_ref(ip, indirect, REF_AS_EA, 0,
INODE_VALID);
complain_eas(ip, indirect,
_("Bad indirect Extended Attribute "
@@ -772,7 +772,7 @@ static int check_eattr_indir(struct gfs2_inode *ip, uint64_t indirect,
return 1;
}
if (q != GFS2_BLKST_FREE) { /* Duplicate? */
- add_duplicate_ref(ip, indirect, ref_as_ea, 0, INODE_VALID);
+ add_duplicate_ref(ip, indirect, REF_AS_EA, 0, INODE_VALID);
complain_eas(ip, indirect,
_("Duplicate Extended Attribute indirect block"));
bc->ea_count++;
@@ -837,7 +837,7 @@ static int check_ealeaf_block(struct gfs2_inode *ip, uint64_t block, int btype,
if (gfs2_check_meta(leaf_bh->b_data, btype)) {
bc->ea_count++;
if (q != GFS2_BLKST_FREE) { /* Duplicate? */
- add_duplicate_ref(ip, block, ref_as_ea, 0,
+ add_duplicate_ref(ip, block, REF_AS_EA, 0,
INODE_VALID);
complain_eas(ip, block, _("Extended attribute leaf "
"duplicate found"));
@@ -855,7 +855,7 @@ static int check_ealeaf_block(struct gfs2_inode *ip, uint64_t block, int btype,
if (q != GFS2_BLKST_FREE) { /* Duplicate? */
complain_eas(ip, block, _("Extended Attribute leaf "
"duplicate found"));
- add_duplicate_ref(ip, block, ref_as_data, 0, INODE_VALID);
+ add_duplicate_ref(ip, block, REF_AS_DATA, 0, INODE_VALID);
bc->ea_count++;
brelse(leaf_bh);
/* Return 0 here because if all that's wrong is a duplicate
@@ -1103,7 +1103,7 @@ static int mark_block_invalid(struct gfs2_inode *ip, uint64_t block,
if (!valid_block_ip(ip, block)) {
if (is_valid)
*is_valid = 0;
- return meta_is_good;
+ return META_IS_GOOD;
}
q = block_type(bl, block);
@@ -1118,10 +1118,10 @@ static int mark_block_invalid(struct gfs2_inode *ip, uint64_t block,
(unsigned long long)block,
(unsigned long long)ip->i_di.di_num.no_addr,
(unsigned long long)ip->i_di.di_num.no_addr);
- return meta_is_good;
+ return META_IS_GOOD;
}
fsck_blockmap_set(ip, block, btype, GFS2_BLKST_UNLINKED);
- return meta_is_good;
+ return META_IS_GOOD;
}
static int invalidate_metadata(struct iptr iptr, struct gfs2_buffer_head **bh, int h,
@@ -1132,14 +1132,14 @@ static int invalidate_metadata(struct iptr iptr, struct gfs2_buffer_head **bh, i
*is_valid = 1;
*was_duplicate = 0;
- return mark_block_invalid(ip, block, ref_as_meta, _("metadata"),
+ return mark_block_invalid(ip, block, REF_AS_META, _("metadata"),
is_valid, was_duplicate);
}
static int invalidate_leaf(struct gfs2_inode *ip, uint64_t block,
void *private)
{
- return mark_block_invalid(ip, block, ref_as_meta, _("leaf"),
+ return mark_block_invalid(ip, block, REF_AS_META, _("leaf"),
NULL, NULL);
}
@@ -1147,7 +1147,7 @@ static int invalidate_data(struct gfs2_inode *ip, uint64_t metablock,
uint64_t block, void *private,
struct gfs2_buffer_head *bh, __be64 *ptr)
{
- return mark_block_invalid(ip, block, ref_as_data, _("data"),
+ return mark_block_invalid(ip, block, REF_AS_DATA, _("data"),
NULL, NULL);
}
@@ -1155,7 +1155,7 @@ static int invalidate_eattr_indir(struct gfs2_inode *ip, uint64_t block,
uint64_t parent,
struct gfs2_buffer_head **bh, void *private)
{
- return mark_block_invalid(ip, block, ref_as_ea,
+ return mark_block_invalid(ip, block, REF_AS_EA,
_("indirect extended attribute"),
NULL, NULL);
}
@@ -1164,7 +1164,7 @@ static int invalidate_eattr_leaf(struct gfs2_inode *ip, uint64_t block,
uint64_t parent, struct gfs2_buffer_head **bh,
void *private)
{
- return mark_block_invalid(ip, block, ref_as_ea,
+ return mark_block_invalid(ip, block, REF_AS_EA,
_("extended attribute"),
NULL, NULL);
}
@@ -1181,7 +1181,7 @@ static int invalidate_eattr_leaf(struct gfs2_inode *ip, uint64_t block,
* be trusted. Thus it needs to be in a separate loop.
* Returns: 0 if good range, otherwise != 0
*/
-enum b_types { btype_meta, btype_leaf, btype_data, btype_ieattr, btype_eattr};
+enum b_types { BTYPE_META, BTYPE_LEAF, BTYPE_DATA, BTYPE_IEATTR, BTYPE_EATTR};
const char *btypes[5] = {
"metadata", "leaf", "data", "indirect extended attribute",
"extended attribute" };
@@ -1201,9 +1201,9 @@ static int rangecheck_block(struct gfs2_inode *ip, uint64_t block,
(unsigned long long)ip->i_di.di_num.no_addr,
(unsigned long long)ip->i_di.di_num.no_addr);
if ((*bad_pointers) <= BAD_POINTER_TOLERANCE)
- return meta_is_good;
+ return META_IS_GOOD;
else
- return meta_error; /* Exits check_metatree quicker */
+ return META_ERROR; /* Exits check_metatree quicker */
}
/* See how many duplicate blocks it has */
q = block_type(bl, block);
@@ -1216,16 +1216,16 @@ static int rangecheck_block(struct gfs2_inode *ip, uint64_t block,
(unsigned long long)ip->i_di.di_num.no_addr,
(unsigned long long)ip->i_di.di_num.no_addr);
if ((*bad_pointers) <= BAD_POINTER_TOLERANCE)
- return meta_is_good;
+ return META_IS_GOOD;
else {
log_debug(_("Inode 0x%llx bad pointer tolerance "
"exceeded: block 0x%llx.\n"),
(unsigned long long)ip->i_di.di_num.no_addr,
(unsigned long long)block);
- return meta_error; /* Exits check_metatree quicker */
+ return META_ERROR; /* Exits check_metatree quicker */
}
}
- return meta_is_good;
+ return META_IS_GOOD;
}
static int rangecheck_metadata(struct iptr iptr, struct gfs2_buffer_head **bh, int h,
@@ -1236,34 +1236,34 @@ static int rangecheck_metadata(struct iptr iptr, struct gfs2_buffer_head **bh, i
*is_valid = 1;
*was_duplicate = 0;
- return rangecheck_block(ip, block, bh, btype_meta, private);
+ return rangecheck_block(ip, block, bh, BTYPE_META, private);
}
static int rangecheck_leaf(struct gfs2_inode *ip, uint64_t block,
void *private)
{
- return rangecheck_block(ip, block, NULL, btype_leaf, private);
+ return rangecheck_block(ip, block, NULL, BTYPE_LEAF, private);
}
static int rangecheck_data(struct gfs2_inode *ip, uint64_t metablock,
uint64_t block, void *private,
struct gfs2_buffer_head *bh, __be64 *ptr)
{
- return rangecheck_block(ip, block, NULL, btype_data, private);
+ return rangecheck_block(ip, block, NULL, BTYPE_DATA, private);
}
static int rangecheck_eattr_indir(struct gfs2_inode *ip, uint64_t block,
uint64_t parent,
struct gfs2_buffer_head **bh, void *private)
{
- return rangecheck_block(ip, block, NULL, btype_ieattr, private);
+ return rangecheck_block(ip, block, NULL, BTYPE_IEATTR, private);
}
static int rangecheck_eattr_leaf(struct gfs2_inode *ip, uint64_t block,
uint64_t parent, struct gfs2_buffer_head **bh,
void *private)
{
- return rangecheck_block(ip, block, NULL, btype_eattr, private);
+ return rangecheck_block(ip, block, NULL, BTYPE_EATTR, private);
}
struct metawalk_fxns rangecheck_fxns = {
@@ -1355,7 +1355,7 @@ static int alloc_metalist(struct iptr iptr, struct gfs2_buffer_head **bh, int h,
gfs2_blockmap_set(bl, block, ip->i_sbd->gfs1 ?
GFS2_BLKST_DINODE : GFS2_BLKST_USED);
}
- return meta_is_good;
+ return META_IS_GOOD;
}
static int alloc_data(struct gfs2_inode *ip, uint64_t metablock,
@@ -1975,7 +1975,7 @@ static int pass1_process_bitmap(struct gfs2_sbd *sdp, struct rgrp_tree *rgd, uin
block_type_string(q));
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,
+ add_duplicate_ref(ip, block, REF_IS_INODE, 0,
INODE_VALID);
else
log_info(_("dinum.no_addr is wrong, so I "
diff --git a/gfs2/fsck/pass1b.c b/gfs2/fsck/pass1b.c
index ae5a2c49..a6f06ade 100644
--- a/gfs2/fsck/pass1b.c
+++ b/gfs2/fsck/pass1b.c
@@ -55,10 +55,10 @@ static void log_inode_reference(struct duptree *dt, osi_list_t *tmp, int inval)
sprintf(reftypestring, "as %s", reftypes[get_ref_type(id)]);
else
sprintf(reftypestring, "%d/%d/%d/%d",
- id->reftypecount[ref_is_inode],
- id->reftypecount[ref_as_data],
- id->reftypecount[ref_as_meta],
- id->reftypecount[ref_as_ea]);
+ id->reftypecount[REF_IS_INODE],
+ id->reftypecount[REF_AS_DATA],
+ id->reftypecount[REF_AS_META],
+ id->reftypecount[REF_AS_EA]);
if (inval)
log_warn( _("Invalid "));
log_warn( _("Inode %s (%lld/0x%llx) has %d reference(s) to "
@@ -74,7 +74,7 @@ static int findref_meta(struct iptr iptr, struct gfs2_buffer_head **bh, int h,
{
*is_valid = 1;
*was_duplicate = 0;
- return meta_is_good;
+ return META_IS_GOOD;
}
static int findref_data(struct gfs2_inode *ip, uint64_t metablock,
@@ -90,7 +90,7 @@ static int findref_data(struct gfs2_inode *ip, uint64_t metablock,
"block 0x%llx, offset 0x%x\n",
(unsigned long long)mbr->metablock, mbr->off);
}
- return meta_is_good;
+ return META_IS_GOOD;
}
static void clone_data_block(struct gfs2_sbd *sdp, struct duptree *dt,
@@ -225,7 +225,7 @@ static void resolve_dup_references(struct gfs2_sbd *sdp, struct duptree *dt,
* block, we should really duplicate the block and fix all
* references to it in this inode. Unfortunately, we would
* have to traverse the entire metadata tree to do that. */
- if (acceptable_ref != ref_types && /* If we're nuking all but
+ if (acceptable_ref != REF_TYPES && /* If we're nuking all but
an acceptable reference
type and */
this_ref == acceptable_ref) { /* this ref is acceptable */
@@ -261,7 +261,7 @@ static void resolve_dup_references(struct gfs2_sbd *sdp, struct duptree *dt,
(unsigned long long)dt->block,
(unsigned long long)dt->block,
reftypes[this_ref], reftypes[acceptable_ref]);
- if (this_ref == ref_as_ea) {
+ if (this_ref == REF_AS_EA) {
if (!(query( _("Okay to remove extended attributes "
"from %s inode %lld (0x%llx)? (y/n) "),
(inval ? _("invalidated") : ""),
@@ -278,8 +278,8 @@ static void resolve_dup_references(struct gfs2_sbd *sdp, struct duptree *dt,
dup_listent_delete(dt, id);
continue;
}
- } else if (acceptable_ref == ref_types &&
- this_ref == ref_as_data) {
+ } else if (acceptable_ref == REF_TYPES &&
+ this_ref == REF_AS_DATA) {
clone_data_block(sdp, dt, id);
dup_listent_delete(dt, id);
revise_dup_handler(dt->block, dh);
@@ -303,7 +303,7 @@ static void resolve_dup_references(struct gfs2_sbd *sdp, struct duptree *dt,
"deleted.\n"),
(unsigned long long)id->block_no,
(unsigned long long)id->block_no);
- else if (this_ref == ref_as_ea)
+ else if (this_ref == REF_AS_EA)
log_warn(_("Pass1b is removing extended attributes "
"from inode %lld (0x%llx).\n"),
(unsigned long long)id->block_no,
@@ -343,9 +343,9 @@ static void resolve_dup_references(struct gfs2_sbd *sdp, struct duptree *dt,
}
/* If the reference was as metadata or data, we've got
a corrupt dinode that will be deleted. */
- if ((this_ref != ref_as_ea) &&
- (inval || id->reftypecount[ref_as_data] ||
- id->reftypecount[ref_as_meta])) {
+ if ((this_ref != REF_AS_EA) &&
+ (inval || id->reftypecount[REF_AS_DATA] ||
+ id->reftypecount[REF_AS_META])) {
/* Fix the bitmap first, while the inodetree
and dirtree entries exist. That way, the
bitmap_set will do proper accounting for
@@ -385,7 +385,7 @@ static void resolve_dup_references(struct gfs2_sbd *sdp, struct duptree *dt,
(because they were eliminated earlier in pass1b). And so
the blocks will be mistakenly freed, when, in fact, they're
still being referenced by a valid dinode. */
- if (this_ref != ref_as_ea)
+ if (this_ref != REF_AS_EA)
delete_all_dups(ip);
fsck_inode_put(&ip); /* out, brelse, free */
}
@@ -584,12 +584,12 @@ static void resolve_last_reference(struct gfs2_sbd *sdp, struct duptree *dt,
"already marked free.\n"),
(unsigned long long)id->block_no,
(unsigned long long)id->block_no);
- } else if (id->reftypecount[ref_is_inode]) {
+ } else if (id->reftypecount[REF_IS_INODE]) {
set_ip_bitmap(ip);
- } else if (id->reftypecount[ref_as_data]) {
+ } else if (id->reftypecount[REF_AS_DATA]) {
fsck_bitmap_set(ip, dt->block, _("reference-repaired data"),
GFS2_BLKST_USED);
- } else if (id->reftypecount[ref_as_meta]) {
+ } else if (id->reftypecount[REF_AS_META]) {
if (is_dir(&ip->i_di, sdp->gfs1))
fsck_bitmap_set(ip, dt->block,
_("reference-repaired leaf"),
@@ -601,7 +601,7 @@ static void resolve_last_reference(struct gfs2_sbd *sdp, struct duptree *dt,
sdp->gfs1 ? GFS2_BLKST_DINODE :
GFS2_BLKST_USED);
} else {
- if (acceptable_ref == ref_as_ea)
+ if (acceptable_ref == REF_AS_EA)
fsck_bitmap_set(ip, dt->block,
_("reference-repaired extended "
"attribute"),
@@ -687,16 +687,16 @@ static int handle_dup_blk(struct gfs2_sbd *sdp, struct duptree *dt)
entries) are invalid and should be deleted. */
if (be32_to_cpu(cmagic) == GFS2_MAGIC &&
be32_to_cpu(ctype) == GFS2_METATYPE_DI)
- acceptable_ref = ref_is_inode;
+ acceptable_ref = REF_IS_INODE;
else if (be32_to_cpu(cmagic) == GFS2_MAGIC &&
(be32_to_cpu(ctype) == GFS2_METATYPE_EA ||
be32_to_cpu(ctype) == GFS2_METATYPE_ED))
- acceptable_ref = ref_as_ea;
+ acceptable_ref = REF_AS_EA;
else if (be32_to_cpu(cmagic) == GFS2_MAGIC &&
be32_to_cpu(ctype) <= GFS2_METATYPE_QC)
- acceptable_ref = ref_as_meta;
+ acceptable_ref = REF_AS_META;
else
- acceptable_ref = ref_as_data;
+ acceptable_ref = REF_AS_DATA;
/* A single reference to the block implies a possible situation where
a data pointer points to a metadata block. In other words, the
@@ -714,7 +714,7 @@ static int handle_dup_blk(struct gfs2_sbd *sdp, struct duptree *dt)
/* Step 1 - eliminate references from inodes that are not valid.
* This may be because they were deleted due to corruption.
- * All block types are unacceptable, so we use ref_types.
+ * All block types are unacceptable, so we use REF_TYPES.
*/
if (dh.ref_count > 1) {
log_debug( _("----------------------------------------------\n"
@@ -724,7 +724,7 @@ static int handle_dup_blk(struct gfs2_sbd *sdp, struct duptree *dt)
(unsigned long long)dt->block,
(unsigned long long)dt->block);
resolve_dup_references(sdp, dt, &dt->ref_invinode_list,
- &dh, 1, ref_types);
+ &dh, 1, REF_TYPES);
revise_dup_handler(dup_blk, &dh);
}
/* Step 2 - eliminate reference from inodes that reference it as the
@@ -744,7 +744,7 @@ static int handle_dup_blk(struct gfs2_sbd *sdp, struct duptree *dt)
}
/* Step 3 - We have multiple dinodes referencing it as the correct
* type. Just blast one of them.
- * All block types are fair game, so we use ref_types.
+ * All block types are fair game, so we use REF_TYPES.
*/
if (dh.ref_count > 1) {
log_debug( _("----------------------------------------------\n"
@@ -753,7 +753,7 @@ static int handle_dup_blk(struct gfs2_sbd *sdp, struct duptree *dt)
(unsigned long long)dt->block,
(unsigned long long)dt->block);
resolve_dup_references(sdp, dt, &dt->ref_inode_list, &dh, 0,
- ref_types);
+ REF_TYPES);
revise_dup_handler(dup_blk, &dh);
}
/* If there's still a last remaining reference, and it's a valid
@@ -786,7 +786,7 @@ static int handle_dup_blk(struct gfs2_sbd *sdp, struct duptree *dt)
static int check_leaf_refs(struct gfs2_inode *ip, uint64_t block,
void *private)
{
- return add_duplicate_ref(ip, block, ref_as_meta, 1, INODE_VALID);
+ return add_duplicate_ref(ip, block, REF_AS_META, 1, INODE_VALID);
}
static int check_metalist_refs(struct iptr iptr, struct gfs2_buffer_head **bh, int h,
@@ -797,14 +797,14 @@ static int check_metalist_refs(struct iptr iptr, struct gfs2_buffer_head **bh, i
*was_duplicate = 0;
*is_valid = 1;
- return add_duplicate_ref(ip, block, ref_as_meta, 1, INODE_VALID);
+ return add_duplicate_ref(ip, block, REF_AS_META, 1, INODE_VALID);
}
static int check_data_refs(struct gfs2_inode *ip, uint64_t metablock,
uint64_t block, void *private,
struct gfs2_buffer_head *bh, __be64 *ptr)
{
- return add_duplicate_ref(ip, block, ref_as_data, 1, INODE_VALID);
+ return add_duplicate_ref(ip, block, REF_AS_DATA, 1, INODE_VALID);
}
static int check_eattr_indir_refs(struct gfs2_inode *ip, uint64_t block,
@@ -814,7 +814,7 @@ static int check_eattr_indir_refs(struct gfs2_inode *ip, uint64_t block,
struct gfs2_sbd *sdp = ip->i_sbd;
int error;
- error = add_duplicate_ref(ip, block, ref_as_ea, 1, INODE_VALID);
+ error = add_duplicate_ref(ip, block, REF_AS_EA, 1, INODE_VALID);
if (!error)
*bh = bread(sdp, block);
@@ -828,7 +828,7 @@ static int check_eattr_leaf_refs(struct gfs2_inode *ip, uint64_t block,
struct gfs2_sbd *sdp = ip->i_sbd;
int error;
- error = add_duplicate_ref(ip, block, ref_as_ea, 1, INODE_VALID);
+ error = add_duplicate_ref(ip, block, REF_AS_EA, 1, INODE_VALID);
if (!error)
*bh = bread(sdp, block);
return error;
@@ -859,7 +859,7 @@ static int check_eattr_extentry_refs(struct gfs2_inode *ip, int i,
the blockmap. In this case, we should be okay because the only
error possible is a malloc that fails, in which case we don't
want to delete the eattr anyway. */
- return add_duplicate_ref(ip, block, ref_as_ea, 1, INODE_VALID);
+ return add_duplicate_ref(ip, block, REF_AS_EA, 1, INODE_VALID);
}
/* Finds all references to duplicate blocks in the metadata */
@@ -892,7 +892,7 @@ static int find_block_ref(struct gfs2_sbd *sdp, uint64_t inode)
goto out;
}
/* Check to see if this inode was referenced by another by mistake */
- add_duplicate_ref(ip, inode, ref_is_inode, 1, INODE_VALID);
+ add_duplicate_ref(ip, inode, REF_IS_INODE, 1, INODE_VALID);
/* Check this dinode's metadata for references to known duplicates */
error = check_metatree(ip, &find_refs);
diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c
index 9184bbc6..e595051d 100644
--- a/gfs2/fsck/pass2.c
+++ b/gfs2/fsck/pass2.c
@@ -977,9 +977,9 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
dentry_is_valid:
/* This directory inode links to this inode via this dentry */
error = incr_link_count(entry, ip, _("valid reference"));
- if (error == incr_link_check_orig) {
+ if (error == INCR_LINK_CHECK_ORIG) {
error = check_suspicious_dirref(sdp, &entry);
- } else if (error == incr_link_ino_mismatch) {
+ } else if (error == INCR_LINK_INO_MISMATCH) {
log_err("incr_link_count err=%d.\n", error);
if (bad_formal_ino(ip, dent, entry, tmp_name, q, de, bh) == 1)
goto nuke_dentry;
@@ -1882,7 +1882,7 @@ static int check_metalist_qc(struct iptr iptr, struct gfs2_buffer_head **bh, int
*was_duplicate = 0;
*is_valid = 1;
*bh = bread(ip->i_sbd, block);
- return meta_is_good;
+ return META_IS_GOOD;
}
static int check_data_qc(struct gfs2_inode *ip, uint64_t metablock,
diff --git a/gfs2/fsck/rgrepair.c b/gfs2/fsck/rgrepair.c
index cc7c9c9d..bf1641e8 100644
--- a/gfs2/fsck/rgrepair.c
+++ b/gfs2/fsck/rgrepair.c
@@ -488,7 +488,7 @@ static uint64_t hunt_and_peck(struct gfs2_sbd *sdp, uint64_t blk,
/*
* rindex_rebuild - rebuild a corrupt Resource Group (RG) index manually
- * where trust_lvl == distrust
+ * where trust_lvl == DISTRUST
*
* If this routine is called, it means we have RGs in odd/unexpected places,
* and there is a corrupt RG or RG index entry. It also means we can't trust
@@ -854,7 +854,7 @@ static int calc_rgrps(struct gfs2_sbd *sdp)
/*
* gfs2_rindex_calculate - calculate what the rindex should look like
- * in a perfect world (trust_lvl == open_minded)
+ * in a perfect world (trust_lvl == OPEN_MINDED)
*
* Calculate what the rindex should look like,
* so we can later check if all RG index entries are sane.
@@ -1002,11 +1002,11 @@ static int expect_rindex_sanity(struct gfs2_sbd *sdp, int *num_rgs)
/*
* rg_repair - try to repair a damaged rg index (rindex)
* trust_lvl - This is how much we trust the rindex file.
- * blind_faith means we take the rindex at face value.
- * open_minded means it might be okay, but we should verify it.
- * distrust means it's not to be trusted, so we should go to
+ * BLIND_FAITH means we take the rindex at face value.
+ * OPEN_MINDED means it might be okay, but we should verify it.
+ * DISTRUST means it's not to be trusted, so we should go to
* greater lengths to build it from scratch.
- * indignation means we have corruption, but the file system
+ * INDIGNATION means we have corruption, but the file system
* was converted from GFS via gfs2_convert, and its rgrps are
* not on nice boundaries thanks to previous gfs_grow ops. Lovely.
*/
@@ -1017,9 +1017,9 @@ int rg_repair(struct gfs2_sbd *sdp, int trust_lvl, int *ok)
int calc_rg_count = 0, rg;
struct gfs2_rindex buf;
- if (trust_lvl == blind_faith)
+ if (trust_lvl == BLIND_FAITH)
return 0;
- if (trust_lvl == ye_of_little_faith) { /* if rindex seems sane */
+ if (trust_lvl == YE_OF_LITTLE_FAITH) { /* if rindex seems sane */
/* Don't free previous incarnations in memory, if any.
* We need them to copy in the next function:
* gfs2_rgrp_free(&sdp->rglist); */
@@ -1033,7 +1033,7 @@ int rg_repair(struct gfs2_sbd *sdp, int trust_lvl, int *ok)
gfs2_rgrp_free(sdp, &sdp->rgcalc);
return error;
}
- } else if (trust_lvl == open_minded) { /* If we can't trust RG index */
+ } else if (trust_lvl == OPEN_MINDED) { /* If we can't trust RG index */
/* Free previous incarnations in memory, if any. */
gfs2_rgrp_free(sdp, &sdp->rgtree);
@@ -1043,7 +1043,7 @@ int rg_repair(struct gfs2_sbd *sdp, int trust_lvl, int *ok)
gfs2_rgrp_free(sdp, &sdp->rgcalc);
return -1;
}
- } else if (trust_lvl == distrust) { /* If we can't trust RG index */
+ } else if (trust_lvl == DISTRUST) { /* If we can't trust RG index */
/* Free previous incarnations in memory, if any. */
gfs2_rgrp_free(sdp, &sdp->rgtree);
@@ -1053,7 +1053,7 @@ int rg_repair(struct gfs2_sbd *sdp, int trust_lvl, int *ok)
gfs2_rgrp_free(sdp, &sdp->rgcalc);
return -1;
}
- } else if (trust_lvl == indignation) { /* If we can't trust anything */
+ } else if (trust_lvl == INDIGNATION) { /* If we can't trust anything */
/* Free previous incarnations in memory, if any. */
gfs2_rgrp_free(sdp, &sdp->rgtree);
@@ -1090,11 +1090,11 @@ int rg_repair(struct gfs2_sbd *sdp, int trust_lvl, int *ok)
"extended, (2) an odd\n"), trust_lvl + 1);
log_warn( _("L%d: rgrp size was used, or (3) we have a corrupt "
"rg index.\n"), trust_lvl + 1);
- /* If the trust level is open_minded, we would have calculated
+ /* If the trust level is OPEN_MINDED, we would have calculated
the rindex based on the device size. If it's not the same
number, don't trust it. Complain about the discrepancy,
- then try again with a little more distrust. */
- if ((trust_lvl < distrust) ||
+ then try again with a little more DISTRUST. */
+ if ((trust_lvl < DISTRUST) ||
!query( _("Attempt to use what rgrps we can? (y/n)"))) {
gfs2_rgrp_free(sdp, &sdp->rgcalc);
gfs2_rgrp_free(sdp, &sdp->rgtree);
diff --git a/gfs2/fsck/util.c b/gfs2/fsck/util.c
index abcf5f9c..26170fa5 100644
--- a/gfs2/fsck/util.c
+++ b/gfs2/fsck/util.c
@@ -17,7 +17,7 @@
#include "metawalk.h"
#include "util.h"
-const char *reftypes[ref_types + 1] = {"data", "metadata",
+const char *reftypes[REF_TYPES + 1] = {"data", "metadata",
"an extended attribute", "an inode",
"unimportant"};
@@ -304,12 +304,12 @@ int count_dup_meta_refs(struct duptree *dt)
osi_list_foreach(ref, &dt->ref_invinode_list) {
id = osi_list_entry(ref, struct inode_with_dups, list);
- if (id->reftypecount[ref_as_meta])
+ if (id->reftypecount[REF_AS_META])
metarefs++;
}
osi_list_foreach(ref, &dt->ref_inode_list) {
id = osi_list_entry(ref, struct inode_with_dups, list);
- if (id->reftypecount[ref_as_meta])
+ if (id->reftypecount[REF_AS_META])
metarefs++;
}
return metarefs;
@@ -336,19 +336,19 @@ int add_duplicate_ref(struct gfs2_inode *ip, uint64_t block,
struct duptree *dt;
if (!valid_block_ip(ip, block))
- return meta_is_good;
+ 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
to ignore references that aren't found. */
dt = gfs2_dup_set(block, !first);
if (!dt) /* If this isn't a duplicate */
- return meta_is_good;
+ return META_IS_GOOD;
/* If we found the duplicate reference but we've already discovered
the first reference (in pass1b) and the other references in pass1,
we don't need to count it, so just return. */
if (dt->dup_flags & DUPFLAG_REF1_FOUND)
- return meta_is_good;
+ return META_IS_GOOD;
/* Check for a previous reference to this duplicate */
id = find_dup_ref_inode(dt, ip);
@@ -391,7 +391,7 @@ int add_duplicate_ref(struct gfs2_inode *ip, uint64_t block,
id = calloc(1, sizeof(*id));
if (!id) {
log_crit( _("Unable to allocate inode_with_dups structure\n"));
- return meta_error;
+ return META_ERROR;
}
id->block_no = ip->i_di.di_num.no_addr;
q = bitmap_type(ip->i_sbd, ip->i_di.di_num.no_addr);
@@ -431,7 +431,7 @@ int add_duplicate_ref(struct gfs2_inode *ip, uint64_t block,
"%d from this inode.\n"),
dt->refs, id->dup_count);
}
- return meta_is_good;
+ return META_IS_GOOD;
}
struct dir_info *dirtree_insert(struct gfs2_inum inum)
@@ -491,10 +491,10 @@ enum dup_ref_type get_ref_type(struct inode_with_dups *id)
int found_type_with_ref;
int found_other_types;
- for (t = ref_as_data; t < ref_types; t++) {
+ for (t = REF_AS_DATA; t < REF_TYPES; t++) {
found_type_with_ref = 0;
found_other_types = 0;
- for (i = ref_as_data; i < ref_types; i++) {
+ for (i = REF_AS_DATA; i < REF_TYPES; i++) {
if (id->reftypecount[i]) {
if (t == i)
found_type_with_ref = 1;
@@ -503,9 +503,9 @@ enum dup_ref_type get_ref_type(struct inode_with_dups *id)
}
}
if (found_type_with_ref)
- return found_other_types ? ref_types : t;
+ return found_other_types ? REF_TYPES : t;
}
- return ref_types;
+ return REF_TYPES;
}
void dup_listent_delete(struct duptree *dt, struct inode_with_dups *id)
diff --git a/gfs2/fsck/util.h b/gfs2/fsck/util.h
index d93b65d3..d8767247 100644
--- a/gfs2/fsck/util.h
+++ b/gfs2/fsck/util.h
@@ -21,7 +21,7 @@ extern struct inode_with_dups *find_dup_ref_inode(struct duptree *dt,
struct gfs2_inode *ip);
extern void dup_listent_delete(struct duptree *dt, struct inode_with_dups *id);
extern int count_dup_meta_refs(struct duptree *dt);
-extern const char *reftypes[ref_types + 1];
+extern const char *reftypes[REF_TYPES + 1];
#define BLOCKMAP_SIZE1(size) ((size) >> 3)
#define BLOCKMAP_SIZE2(size) ((size) >> 2)
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
3 years
[gfs2-utils] 03/03: fsck.gfs2: Add partial extent-based inode support
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
agruenba pushed a commit to branch agruenba-extents
in repository gfs2-utils.
commit 322f821ce618200c68f7baf3f0798e0830ff223b
Author: Andreas Gruenbacher <agruenba(a)redhat.com>
AuthorDate: Wed Apr 21 20:52:31 2021 +0200
fsck.gfs2: Add partial extent-based inode support
Signed-off-by: Andreas Gruenbacher <agruenba(a)redhat.com>
---
gfs2/fsck/metawalk.c | 185 ++++++++++++++++++++++++++++++++++++++-------------
1 file changed, 140 insertions(+), 45 deletions(-)
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index ef029351..59aea1d6 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -1446,38 +1446,93 @@ static int metawalk_check_data(struct gfs2_inode *ip, struct metawalk_fxns *pass
struct gfs2_buffer_head *bh, unsigned int height,
uint64_t *blks_checked, struct error_block *error_blk)
{
- int error = 0, rc = 0;
+ int error = 0, rc;
uint64_t block;
- __be64 *ptr_start = (uint64_t *)(bh->b_data + hdr_size(bh, height));
- __be64 *ptr_end = (uint64_t *)(bh->b_data + ip->i_sbd->bsize);
- __be64 *ptr;
uint64_t metablock = bh->b_blocknr;
/* If there isn't much pointer corruption check the pointers */
log_debug("Processing data blocks for inode 0x%llx, metadata block 0x%llx.\n",
(unsigned long long)ip->i_di.di_num.no_addr,
(unsigned long long)metablock);
- for (ptr = ptr_start ; ptr < ptr_end && !fsck_abort; ptr++) {
- if (!*ptr)
- continue;
- if (skip_this_pass || fsck_abort)
- return error;
- block = be64_to_cpu(*ptr);
- /* It's important that we don't call valid_block() and
- bypass calling check_data on invalid blocks because that
- would defeat the rangecheck_block related functions in
- pass1. Therefore the individual check_data functions
- should do a range check. */
- rc = pass->check_data(ip, metablock, block, pass->private,
- bh, ptr);
- if (rc && (!error || (rc < error))) {
- report_data_error(metablock, (char *)ptr - bh->b_data, block, error_blk, rc, error);
- error = rc;
+ /* It's important that we don't call valid_block() and
+ bypass calling check_data on invalid blocks because that
+ would defeat the rangecheck_block related functions in
+ pass1. Therefore the individual check_data functions
+ should do a range check. */
+
+ if (ip->i_di.di_flags & GFS2_DIF_EXTENTS) {
+ unsigned int max_extents = (ip->i_sbd->bsize - hdr_size(bh, height)) /
+ sizeof(struct gfs2_extent);
+ struct gfs2_extent_header *eh = (struct gfs2_extent_header *)
+ (bh->b_data + hdr_size(bh, height));
+ struct gfs2_extent *first_ex = (struct gfs2_extent *)(eh + 1);
+ unsigned int extents = be16_to_cpu(eh->eh_entries);
+ struct gfs2_extent *ex;
+
+ if (extents > max_extents) {
+ log_err(_("Inode %"PRId64" (0x%"PRIx64") has a "
+ "number of extents greater than %u.\n"),
+ ip->i_di.di_num.no_addr,
+ ip->i_di.di_num.no_addr,
+ max_extents);
+ return meta_error;
+ }
+
+ for (ex = first_ex; ex != first_ex + extents && !fsck_abort; ex++) {
+ uint64_t first_block = be64_to_cpu(ex->ex_addr);
+ unsigned int len = be16_to_cpu(ex->ex_len);
+
+ /* if (!ex->ex_addr || !ex->ex_len || too_big(ex->ex_len)) */
+
+ for (block = first_block; block < first_block + len; block++) {
+ __be64 dummy = cpu_to_be64(-1);
+
+ /*
+ * FIXME: We cannot relocate or free blocks in
+ * the middle of an extent without rewriting
+ * the extent tree, which may require an
+ * allocation; handling this in clone_data()
+ * won't work.
+ */
+
+ if (skip_this_pass || fsck_abort)
+ return error;
+ rc = pass->check_data(ip, metablock, block, pass->private,
+ bh, &dummy);
+ if (rc && (!error || (rc < error))) {
+ report_data_error(metablock, (char *)ex - bh->b_data,
+ block, error_blk, rc, error);
+ error = rc;
+ }
+ if (rc < 0)
+ return rc;
+ (*blks_checked)++;
+ }
+ }
+ } else {
+ __be64 *ptr_start = (uint64_t *)(bh->b_data + hdr_size(bh, height));
+ __be64 *ptr_end = (uint64_t *)(bh->b_data + ip->i_sbd->bsize);
+ __be64 *ptr;
+
+ for (ptr = ptr_start ; ptr < ptr_end && !fsck_abort; ptr++) {
+ if (!*ptr)
+ continue;
+
+ if (skip_this_pass || fsck_abort)
+ return error;
+ block = be64_to_cpu(*ptr);
+ rc = pass->check_data(ip, metablock, block, pass->private,
+ bh, ptr);
+ if (rc && (!error || (rc < error))) {
+ report_data_error(metablock, (char *)ptr - bh->b_data,
+ block, error_blk, rc, error);
+ error = rc;
+ }
+ if (rc < 0)
+ return rc;
+ (*blks_checked)++;
}
- if (rc < 0)
- return rc;
- (*blks_checked)++;
}
return error;
}
@@ -1515,28 +1570,54 @@ static int undo_check_data(struct gfs2_inode *ip, struct metawalk_fxns *pass,
struct gfs2_buffer_head *bh, unsigned int height,
struct error_block *error_blk, int error)
{
- __be64 *ptr_start = (uint64_t *)(bh->b_data + hdr_size(bh, height));
- __be64 *ptr_end = (uint64_t *)(bh->b_data + ip->i_sbd->bsize);
- __be64 *ptr;
uint64_t metablock = bh->b_blocknr;
- int rc = 0;
+ int rc;
uint64_t block;
int found_error_blk = 0;
/* If there isn't much pointer corruption check the pointers */
- for (ptr = ptr_start ; ptr < ptr_end && !fsck_abort; ptr++) {
- if (!*ptr)
- continue;
- if (skip_this_pass || fsck_abort)
- return 1;
- block = be64_to_cpu(*ptr);
- if (report_undo_data_error(metablock, (char *)ptr - bh->b_data,
- block, error_blk, &found_error_blk, error))
- return 1;
- rc = pass->undo_check_data(ip, block, pass->private);
- if (rc < 0)
- return rc;
+ if (ip->i_di.di_flags & GFS2_DIF_EXTENTS) {
+ struct gfs2_extent_header *eh = (struct gfs2_extent_header *)
+ (bh->b_data + hdr_size(bh, height));
+ struct gfs2_extent *first_ex = (struct gfs2_extent *)(eh + 1);
+ unsigned int extents = be16_to_cpu(eh->eh_entries);
+ struct gfs2_extent *ex;
+
+ for (ex = first_ex; ex != first_ex + extents && !fsck_abort; ex++) {
+ uint64_t first_block = be64_to_cpu(ex->ex_addr);
+ unsigned int len = be16_to_cpu(ex->ex_len);
+
+ for (block = first_block; block < first_block + len; block++) {
+ if (skip_this_pass || fsck_abort)
+ return 1;
+ if (report_undo_data_error(metablock, (char *)ex - bh->b_data,
+ block, error_blk, &found_error_blk, error))
+ return 1;
+ rc = pass->undo_check_data(ip, block, pass->private);
+ if (rc < 0)
+ return rc;
+ }
+ }
+ } else {
+ __be64 *ptr_start = (uint64_t *)(bh->b_data + hdr_size(bh, height));
+ __be64 *ptr_end = (uint64_t *)(bh->b_data + ip->i_sbd->bsize);
+ __be64 *ptr;
+
+ for (ptr = ptr_start ; ptr < ptr_end && !fsck_abort; ptr++) {
+ if (!*ptr)
+ continue;
+
+ if (skip_this_pass || fsck_abort)
+ return 1;
+ block = be64_to_cpu(*ptr);
+ if (report_undo_data_error(metablock, (char *)ptr - bh->b_data,
+ block, error_blk, &found_error_blk, error))
+ return 1;
+ rc = pass->undo_check_data(ip, block, pass->private);
+ if (rc < 0)
+ return rc;
+ }
}
return found_error_blk;
}
@@ -1562,7 +1643,7 @@ int check_metatree(struct gfs2_inode *ip, struct metawalk_fxns *pass)
struct gfs2_buffer_head *bh;
unsigned int i;
uint64_t blks_checked = 0;
- int error, rc;
+ int error = 0, rc;
int metadata_clean = 0;
struct error_block error_blk = {0, 0, 0};
int hit_error_blk = 0;
@@ -1574,11 +1655,25 @@ int check_metatree(struct gfs2_inode *ip, struct metawalk_fxns *pass)
for (i = 0; i <= height; i++)
osi_list_init(&metalist[i]);
- /* create and check the metadata list for each height */
- error = build_and_check_metalist(ip, metalist, pass);
- if (error) {
- stack;
- goto undo_metalist;
+ if (ip->i_di.di_flags & GFS2_DIF_EXTENTS) {
+ if (height > 1) {
+ log_err(_("Inode %"PRId64" (0x%"PRIx64") has an "
+ "extent tree height greater than %u.\n"),
+ ip->i_di.di_num.no_addr,
+ ip->i_di.di_num.no_addr,
+ 1);
+ error = meta_error;
+ goto undo_metalist;
+ }
+ /* make sure we check the inode below */
+ osi_list_add(&ip->i_bh->b_altlist, metalist);
+ } else {
+ /* create and check the metadata list for each height */
+ error = build_and_check_metalist(ip, metalist, pass);
+ if (error) {
+ stack;
+ goto undo_metalist;
+ }
}
metadata_clean = 1;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
3 years
[gfs2-utils] 02/03: fsck.gfs2: Factor out error handling in
metawalk_check_data
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
agruenba pushed a commit to branch agruenba-extents
in repository gfs2-utils.
commit 311712319cc06095c9575dbd732721c7ff020e79
Author: Andreas Gruenbacher <agruenba(a)redhat.com>
AuthorDate: Thu Apr 22 00:11:03 2021 +0200
fsck.gfs2: Factor out error handling in metawalk_check_data
Move the error reporting in metawalk_check_data into a separate function
(report_data_error). Likewise, move the debug logging in undo_check_data into
a separate function (report_undo_data_error).
Fix the messages to report the actual offset instead of offset / 8.
Signed-off-by: Andreas Gruenbacher <agruenba(a)redhat.com>
---
gfs2/fsck/metawalk.c | 133 +++++++++++++++++++++++++++++----------------------
1 file changed, 75 insertions(+), 58 deletions(-)
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index acff5457..ef029351 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -1388,6 +1388,47 @@ struct error_block {
uint64_t errblk; /* error block */
};
+static void report_data_error(uint64_t metablock, int offset, uint64_t block,
+ struct error_block *error_blk,
+ int rc, int error)
+{
+ log_info("\n");
+ if (rc < 0) {
+ /* A fatal error trumps a non-fatal one. */
+ if ((error_blk->errblk == 0) ||
+ (rc < error)) {
+ log_debug(_("Fatal error on metadata "
+ "block 0x%"PRIx64", "
+ "offset 0x%x, referencing data "
+ "block 0x%"PRIx64" "
+ "preempts non-fatal error on "
+ "block 0x%"PRIx64"\n"),
+ metablock,
+ offset,
+ block,
+ error_blk->errblk);
+ error_blk->metablk = metablock;
+ error_blk->metaoff = offset;
+ error_blk->errblk = block;
+ }
+ log_info(_("Unrecoverable "));
+ } else { /* nonfatal error */
+ if (error_blk->errblk == 0) {
+ error_blk->metablk = metablock;
+ error_blk->metaoff = offset;
+ error_blk->errblk = block;
+ }
+ }
+ log_info(_("data block error %d on metadata "
+ "block %"PRId64" (0x%"PRIx64"), "
+ "offset %d (0x%x), referencing "
+ "data block %"PRId64" (0x%"PRIx64").\n"),
+ rc,
+ metablock, metablock,
+ offset, offset,
+ block, block);
+}
+
/**
* check_data - check all data pointers for a given buffer
* This does not include "data" blocks that are really
@@ -1415,7 +1456,7 @@ static int metawalk_check_data(struct gfs2_inode *ip, struct metawalk_fxns *pass
/* If there isn't much pointer corruption check the pointers */
log_debug("Processing data blocks for inode 0x%llx, metadata block 0x%llx.\n",
(unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)bh->b_blocknr);
+ (unsigned long long)metablock);
for (ptr = ptr_start ; ptr < ptr_end && !fsck_abort; ptr++) {
if (!*ptr)
continue;
@@ -1431,41 +1472,7 @@ static int metawalk_check_data(struct gfs2_inode *ip, struct metawalk_fxns *pass
rc = pass->check_data(ip, metablock, block, pass->private,
bh, ptr);
if (rc && (!error || (rc < error))) {
- log_info("\n");
- if (rc < 0) {
- /* A fatal error trumps a non-fatal one. */
- if ((error_blk->errblk == 0) ||
- (rc < error)) {
- log_debug(_("Fatal error on metadata "
- "block 0x%llx, offset "
- "0x%x, referencing block "
- "0x%llx preempts non-fatal"
- " error on block 0x%llx\n"),
- (unsigned long long)metablock,
- (int)(ptr - ptr_start),
- (unsigned long long)block,
- (unsigned long long)error_blk->errblk);
- error_blk->metablk = metablock;
- error_blk->metaoff = ptr - ptr_start;
- error_blk->errblk = block;
- }
- log_info(_("Unrecoverable "));
- } else { /* nonfatal error */
- if (error_blk->errblk == 0) {
- error_blk->metablk = metablock;
- error_blk->metaoff = ptr - ptr_start;
- error_blk->errblk = block;
- }
- }
- log_info(_("data block error %d on metadata block "
- "%lld (0x%llx), offset %d (0x%x), "
- "referencing data block %lld (0x%llx).\n"),
- rc, (unsigned long long)metablock,
- (unsigned long long)metablock,
- (int)(ptr - ptr_start),
- (int)(ptr - ptr_start),
- (unsigned long long)block,
- (unsigned long long)block);
+ report_data_error(metablock, (char *)ptr - bh->b_data, block, error_blk, rc, error);
error = rc;
}
if (rc < 0)
@@ -1475,6 +1482,35 @@ static int metawalk_check_data(struct gfs2_inode *ip, struct metawalk_fxns *pass
return error;
}
+static int report_undo_data_error(uint64_t metablock, int offset, uint64_t block,
+ struct error_block *error_blk,
+ int *found_error_blk, int error)
+{
+ if (metablock == error_blk->metablk &&
+ offset == error_blk->metaoff &&
+ block == error_blk->errblk) {
+ if (error < 0) { /* A fatal error that stopped it? */
+ log_debug(_("Stopping the undo process: "
+ "fatal error block 0x%"PRIx64" was "
+ "found at metadata block 0x%"PRIx64","
+ "offset 0x%x.\n"),
+ error_blk->errblk,
+ error_blk->metablk,
+ error_blk->metaoff);
+ return 1;
+ }
+ *found_error_blk = 1;
+ log_debug(_("The non-fatal error block 0x%"PRIx64" was "
+ "found at metadata block 0x%"PRIx64", offset "
+ "0x%d, but undo processing will continue "
+ "until the end of this metadata block.\n"),
+ error_blk->errblk,
+ error_blk->metablk,
+ error_blk->metaoff);
+ }
+ return 0;
+}
+
static int undo_check_data(struct gfs2_inode *ip, struct metawalk_fxns *pass,
struct gfs2_buffer_head *bh, unsigned int height,
struct error_block *error_blk, int error)
@@ -1495,28 +1531,9 @@ static int undo_check_data(struct gfs2_inode *ip, struct metawalk_fxns *pass,
if (skip_this_pass || fsck_abort)
return 1;
block = be64_to_cpu(*ptr);
- if (metablock == error_blk->metablk &&
- (ptr - ptr_start == error_blk->metaoff) &&
- block == error_blk->errblk) {
- if (error < 0) { /* A fatal error that stopped it? */
- log_debug(_("Stopping the undo process: "
- "fatal error block 0x%llx was "
- "found at metadata block 0x%llx,"
- "offset 0x%x.\n"),
- (unsigned long long)error_blk->errblk,
- (unsigned long long)error_blk->metablk,
- error_blk->metaoff);
- return 1;
- }
- found_error_blk = 1;
- log_debug(_("The non-fatal error block 0x%llx was "
- "found at metadata block 0x%llx, offset "
- "0x%d, but undo processing will continue "
- "until the end of this metadata block.\n"),
- (unsigned long long)error_blk->errblk,
- (unsigned long long)error_blk->metablk,
- error_blk->metaoff);
- }
+ if (report_undo_data_error(metablock, (char *)ptr - bh->b_data,
+ block, error_blk, &found_error_blk, error))
+ return 1;
rc = pass->undo_check_data(ip, block, pass->private);
if (rc < 0)
return rc;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
3 years
[gfs2-utils] 01/03: fsck.gfs2: Fix some endianness annotations
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
agruenba pushed a commit to branch agruenba-extents
in repository gfs2-utils.
commit 53133be87e7b003774c5d31cd803f7ee07d8b9e7
Author: Andreas Gruenbacher <agruenba(a)redhat.com>
AuthorDate: Thu Apr 22 15:38:11 2021 +0200
fsck.gfs2: Fix some endianness annotations
Signed-off-by: Andreas Gruenbacher <agruenba(a)redhat.com>
---
gfs2/fsck/afterpass1_common.c | 2 +-
gfs2/fsck/afterpass1_common.h | 2 +-
gfs2/fsck/fs_recovery.c | 2 +-
gfs2/fsck/metawalk.c | 14 ++++++++------
gfs2/fsck/metawalk.h | 2 +-
gfs2/fsck/pass1.c | 10 +++++-----
gfs2/fsck/pass1b.c | 6 +++---
gfs2/fsck/pass2.c | 2 +-
8 files changed, 21 insertions(+), 19 deletions(-)
diff --git a/gfs2/fsck/afterpass1_common.c b/gfs2/fsck/afterpass1_common.c
index 55a6c76b..646e4010 100644
--- a/gfs2/fsck/afterpass1_common.c
+++ b/gfs2/fsck/afterpass1_common.c
@@ -195,7 +195,7 @@ int delete_leaf(struct gfs2_inode *ip, uint64_t block, void *private)
int delete_data(struct gfs2_inode *ip, uint64_t metablock,
uint64_t block, void *private, struct gfs2_buffer_head *bh,
- uint64_t *ptr)
+ __be64 *ptr)
{
return delete_block_if_notdup(ip, block, NULL, _("data"), NULL,
private);
diff --git a/gfs2/fsck/afterpass1_common.h b/gfs2/fsck/afterpass1_common.h
index 74b913f3..e12ed96e 100644
--- a/gfs2/fsck/afterpass1_common.h
+++ b/gfs2/fsck/afterpass1_common.h
@@ -9,7 +9,7 @@ extern int delete_metadata(struct iptr iptr, struct gfs2_buffer_head **bh, int h
extern int delete_leaf(struct gfs2_inode *ip, uint64_t block, void *private);
extern int delete_data(struct gfs2_inode *ip, uint64_t metablock,
uint64_t block, void *private,
- struct gfs2_buffer_head *bh, uint64_t *ptr);
+ struct gfs2_buffer_head *bh, __be64 *ptr);
extern int delete_eattr_indir(struct gfs2_inode *ip, uint64_t block, uint64_t parent,
struct gfs2_buffer_head **bh, void *private);
extern int delete_eattr_leaf(struct gfs2_inode *ip, uint64_t block, uint64_t parent,
diff --git a/gfs2/fsck/fs_recovery.c b/gfs2/fsck/fs_recovery.c
index 820df1d0..7bfddbfd 100644
--- a/gfs2/fsck/fs_recovery.c
+++ b/gfs2/fsck/fs_recovery.c
@@ -666,7 +666,7 @@ static int rangecheck_jmeta(struct iptr iptr, struct gfs2_buffer_head **bh, int
static int rangecheck_jdata(struct gfs2_inode *ip, uint64_t metablock,
uint64_t block, void *private,
- struct gfs2_buffer_head *bh, uint64_t *ptr)
+ struct gfs2_buffer_head *bh, __be64 *ptr)
{
return rangecheck_jblock(ip, block);
}
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index 1b5272ff..acff5457 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -1406,9 +1406,10 @@ static int metawalk_check_data(struct gfs2_inode *ip, struct metawalk_fxns *pass
uint64_t *blks_checked, struct error_block *error_blk)
{
int error = 0, rc = 0;
- uint64_t block, *ptr;
- uint64_t *ptr_start = (uint64_t *)(bh->b_data + hdr_size(bh, height));
- uint64_t *ptr_end = (uint64_t *)(bh->b_data + ip->i_sbd->bsize);
+ uint64_t block;
+ __be64 *ptr_start = (uint64_t *)(bh->b_data + hdr_size(bh, height));
+ __be64 *ptr_end = (uint64_t *)(bh->b_data + ip->i_sbd->bsize);
+ __be64 *ptr;
uint64_t metablock = bh->b_blocknr;
/* If there isn't much pointer corruption check the pointers */
@@ -1478,11 +1479,12 @@ static int undo_check_data(struct gfs2_inode *ip, struct metawalk_fxns *pass,
struct gfs2_buffer_head *bh, unsigned int height,
struct error_block *error_blk, int error)
{
- uint64_t *ptr_start = (uint64_t *)(bh->b_data + hdr_size(bh, height));
- uint64_t *ptr_end = (uint64_t *)(bh->b_data + ip->i_sbd->bsize);
+ __be64 *ptr_start = (uint64_t *)(bh->b_data + hdr_size(bh, height));
+ __be64 *ptr_end = (uint64_t *)(bh->b_data + ip->i_sbd->bsize);
+ __be64 *ptr;
uint64_t metablock = bh->b_blocknr;
int rc = 0;
- uint64_t block, *ptr;
+ uint64_t block;
int found_error_blk = 0;
/* If there isn't much pointer corruption check the pointers */
diff --git a/gfs2/fsck/metawalk.h b/gfs2/fsck/metawalk.h
index 592479df..88c7d9c1 100644
--- a/gfs2/fsck/metawalk.h
+++ b/gfs2/fsck/metawalk.h
@@ -96,7 +96,7 @@ struct metawalk_fxns {
void *private);
int (*check_data) (struct gfs2_inode *ip, uint64_t metablock,
uint64_t block, void *private,
- struct gfs2_buffer_head *bh, uint64_t *ptr);
+ struct gfs2_buffer_head *bh, __be64 *ptr);
int (*check_eattr_indir) (struct gfs2_inode *ip, uint64_t block,
uint64_t parent,
struct gfs2_buffer_head **bh, void *private);
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index 70549a3a..27a7d6dc 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -45,7 +45,7 @@ static int undo_check_metalist(struct gfs2_inode *ip, uint64_t block,
int h, void *private);
static int pass1_check_data(struct gfs2_inode *ip, uint64_t metablock,
uint64_t block, void *private,
- struct gfs2_buffer_head *bh, uint64_t *ptr);
+ struct gfs2_buffer_head *bh, __be64 *ptr);
static int undo_check_data(struct gfs2_inode *ip, uint64_t block,
void *private);
static int check_eattr_indir(struct gfs2_inode *ip, uint64_t indirect,
@@ -549,7 +549,7 @@ out:
static int pass1_check_data(struct gfs2_inode *ip, uint64_t metablock,
uint64_t block, void *private,
- struct gfs2_buffer_head *bbh, uint64_t *ptr)
+ struct gfs2_buffer_head *bbh, __be64 *ptr)
{
int q;
struct block_count *bc = (struct block_count *) private;
@@ -1145,7 +1145,7 @@ static int invalidate_leaf(struct gfs2_inode *ip, uint64_t block,
static int invalidate_data(struct gfs2_inode *ip, uint64_t metablock,
uint64_t block, void *private,
- struct gfs2_buffer_head *bh, uint64_t *ptr)
+ struct gfs2_buffer_head *bh, __be64 *ptr)
{
return mark_block_invalid(ip, block, ref_as_data, _("data"),
NULL, NULL);
@@ -1247,7 +1247,7 @@ static int rangecheck_leaf(struct gfs2_inode *ip, uint64_t block,
static int rangecheck_data(struct gfs2_inode *ip, uint64_t metablock,
uint64_t block, void *private,
- struct gfs2_buffer_head *bh, uint64_t *ptr)
+ struct gfs2_buffer_head *bh, __be64 *ptr)
{
return rangecheck_block(ip, block, NULL, btype_data, private);
}
@@ -1360,7 +1360,7 @@ static int alloc_metalist(struct iptr iptr, struct gfs2_buffer_head **bh, int h,
static int alloc_data(struct gfs2_inode *ip, uint64_t metablock,
uint64_t block, void *private,
- struct gfs2_buffer_head *bh, uint64_t *ptr)
+ struct gfs2_buffer_head *bh, __be64 *ptr)
{
int q;
const char *desc = (const char *)private;
diff --git a/gfs2/fsck/pass1b.c b/gfs2/fsck/pass1b.c
index 91d7fa53..ae5a2c49 100644
--- a/gfs2/fsck/pass1b.c
+++ b/gfs2/fsck/pass1b.c
@@ -79,7 +79,7 @@ static int findref_meta(struct iptr iptr, struct gfs2_buffer_head **bh, int h,
static int findref_data(struct gfs2_inode *ip, uint64_t metablock,
uint64_t block, void *private,
- struct gfs2_buffer_head *bh, uint64_t *ptr)
+ struct gfs2_buffer_head *bh, __be64 *ptr)
{
struct meta_blk_ref *mbr = (struct meta_blk_ref *)private;
@@ -411,7 +411,7 @@ static int clone_check_meta(struct iptr iptr, struct gfs2_buffer_head **bh, int
*/
static int clone_data(struct gfs2_inode *ip, uint64_t metablock,
uint64_t block, void *private,
- struct gfs2_buffer_head *bh, uint64_t *ptr)
+ struct gfs2_buffer_head *bh, __be64 *ptr)
{
struct clone_target *clonet = (struct clone_target *)private;
struct gfs2_buffer_head *clone_bh;
@@ -802,7 +802,7 @@ static int check_metalist_refs(struct iptr iptr, struct gfs2_buffer_head **bh, i
static int check_data_refs(struct gfs2_inode *ip, uint64_t metablock,
uint64_t block, void *private,
- struct gfs2_buffer_head *bh, uint64_t *ptr)
+ struct gfs2_buffer_head *bh, __be64 *ptr)
{
return add_duplicate_ref(ip, block, ref_as_data, 1, INODE_VALID);
}
diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c
index b6a047c3..9184bbc6 100644
--- a/gfs2/fsck/pass2.c
+++ b/gfs2/fsck/pass2.c
@@ -1887,7 +1887,7 @@ static int check_metalist_qc(struct iptr iptr, struct gfs2_buffer_head **bh, int
static int check_data_qc(struct gfs2_inode *ip, uint64_t metablock,
uint64_t block, void *private,
- struct gfs2_buffer_head *bbh, uint64_t *ptr)
+ struct gfs2_buffer_head *bbh, __be64 *ptr)
{
struct gfs2_buffer_head *bh;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
3 years
[gfs2-utils] branch agruenba-extents updated (a6b9c363 -> 322f821c)
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
agruenba pushed a change to branch agruenba-extents
in repository gfs2-utils.
discard a6b9c363 fsck.gfs2: Add partial extent-based inode support
discard 6bea2bb0 fsck.gfs2: Factor out error handling in metawalk_check_data
new 53133be8 fsck.gfs2: Fix some endianness annotations
new 31171231 fsck.gfs2: Factor out error handling in metawalk_check_data
new 322f821c fsck.gfs2: Add partial extent-based inode support
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (a6b9c363)
\
N -- N -- N refs/heads/agruenba-extents (322f821c)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
gfs2/fsck/afterpass1_common.c | 2 +-
gfs2/fsck/afterpass1_common.h | 2 +-
gfs2/fsck/fs_recovery.c | 2 +-
gfs2/fsck/metawalk.c | 20 ++++++++++----------
gfs2/fsck/metawalk.h | 2 +-
gfs2/fsck/pass1.c | 10 +++++-----
gfs2/fsck/pass1b.c | 6 +++---
gfs2/fsck/pass2.c | 2 +-
8 files changed, 23 insertions(+), 23 deletions(-)
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
3 years
[gfs2-utils] 06/06: fsck.gfs2: Add partial extent-based inode support
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
agruenba pushed a commit to branch agruenba-extents
in repository gfs2-utils.
commit a6b9c36377de9e32b29c68eb31e67ad70c610d9e
Author: Andreas Gruenbacher <agruenba(a)redhat.com>
AuthorDate: Wed Apr 21 20:52:31 2021 +0200
fsck.gfs2: Add partial extent-based inode support
Signed-off-by: Andreas Gruenbacher <agruenba(a)redhat.com>
---
gfs2/fsck/metawalk.c | 185 +++++++++++++++++++++++++++++++++++++++------------
1 file changed, 141 insertions(+), 44 deletions(-)
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index 0e53b693..aab2bc00 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -1446,37 +1446,93 @@ static int metawalk_check_data(struct gfs2_inode *ip, struct metawalk_fxns *pass
struct gfs2_buffer_head *bh, unsigned int height,
uint64_t *blks_checked, struct error_block *error_blk)
{
- int error = 0, rc = 0;
- uint64_t block, *ptr;
- uint64_t *ptr_start = (uint64_t *)(bh->b_data + hdr_size(bh, height));
- uint64_t *ptr_end = (uint64_t *)(bh->b_data + ip->i_sbd->bsize);
+ int error = 0, rc;
uint64_t metablock = bh->b_blocknr;
+ uint64_t block;
/* If there isn't much pointer corruption check the pointers */
log_debug("Processing data blocks for inode 0x%llx, metadata block 0x%llx.\n",
(unsigned long long)ip->i_di.di_num.no_addr,
(unsigned long long)metablock);
- for (ptr = ptr_start ; ptr < ptr_end && !fsck_abort; ptr++) {
- if (!*ptr)
- continue;
- if (skip_this_pass || fsck_abort)
- return error;
- block = be64_to_cpu(*ptr);
- /* It's important that we don't call valid_block() and
- bypass calling check_data on invalid blocks because that
- would defeat the rangecheck_block related functions in
- pass1. Therefore the individual check_data functions
- should do a range check. */
- rc = pass->check_data(ip, metablock, block, pass->private,
- bh, ptr);
- if (rc && (!error || (rc < error))) {
- report_data_error(metablock, (char *)ptr - bh->b_data, block, error_blk, rc, error);
- error = rc;
+ /* It's important that we don't call valid_block() and
+ bypass calling check_data on invalid blocks because that
+ would defeat the rangecheck_block related functions in
+ pass1. Therefore the individual check_data functions
+ should do a range check. */
+
+ if (ip->i_di.di_flags & GFS2_DIF_EXTENTS) {
+ unsigned int max_extents = (ip->i_sbd->bsize - hdr_size(bh, height)) /
+ sizeof(struct gfs2_extent);
+ struct gfs2_extent_header *eh = (struct gfs2_extent_header *)
+ (bh->b_data + hdr_size(bh, height));
+ struct gfs2_extent *first_ex = (struct gfs2_extent *)(eh + 1);
+ unsigned int extents = be16_to_cpu(eh->eh_entries);
+ struct gfs2_extent *ex;
+
+ if (extents > max_extents) {
+ log_err(_("Inode %"PRId64" (0x%"PRIx64") has a "
+ "number of extents greater than %u.\n"),
+ ip->i_di.di_num.no_addr,
+ ip->i_di.di_num.no_addr,
+ max_extents);
+ return meta_error;
+ }
+
+ for (ex = first_ex; ex != first_ex + extents && !fsck_abort; ex++) {
+ uint64_t first_block = be64_to_cpu(ex->ex_addr);
+ unsigned int len = be16_to_cpu(ex->ex_len);
+
+ /* if (!ex->ex_addr || !ex->ex_len || too_big(ex->ex_len)) */
+
+ for (block = first_block; block < first_block + len; block++) {
+ uint64_t dummy = -1;
+
+ /*
+ * FIXME: We cannot relocate or free blocks in
+ * the middle of an extent without rewriting
+ * the extent tree, which may require an
+ * allocation; handling this in clone_data()
+ * won't work.
+ */
+
+ if (skip_this_pass || fsck_abort)
+ return error;
+ rc = pass->check_data(ip, bh->b_blocknr, block, pass->private,
+ bh, &dummy);
+ if (rc && (!error || (rc < error))) {
+ report_data_error(metablock, (char *)ex - bh->b_data,
+ block, error_blk, rc, error);
+ error = rc;
+ }
+ if (rc < 0)
+ return rc;
+ (*blks_checked)++;
+ }
+ }
+ } else {
+ uint64_t *ptr_start = (uint64_t *)(bh->b_data + hdr_size(bh, height));
+ uint64_t *ptr_end = (uint64_t *)(bh->b_data + ip->i_sbd->bsize);
+ uint64_t *ptr;
+
+ for (ptr = ptr_start ; ptr < ptr_end && !fsck_abort; ptr++) {
+ if (!*ptr)
+ continue;
+
+ if (skip_this_pass || fsck_abort)
+ return error;
+ block = be64_to_cpu(*ptr);
+ rc = pass->check_data(ip, metablock, block, pass->private,
+ bh, ptr);
+ if (rc && (!error || (rc < error))) {
+ report_data_error(metablock, (char *)ptr - bh->b_data,
+ block, error_blk, rc, error);
+ error = rc;
+ }
+ if (rc < 0)
+ return rc;
+ (*blks_checked)++;
}
- if (rc < 0)
- return rc;
- (*blks_checked)++;
}
return error;
}
@@ -1514,27 +1570,54 @@ static int undo_check_data(struct gfs2_inode *ip, struct metawalk_fxns *pass,
struct gfs2_buffer_head *bh, unsigned int height,
struct error_block *error_blk, int error)
{
- uint64_t *ptr_start = (uint64_t *)(bh->b_data + hdr_size(bh, height));
- uint64_t *ptr_end = (uint64_t *)(bh->b_data + ip->i_sbd->bsize);
uint64_t metablock = bh->b_blocknr;
- int rc = 0;
- uint64_t block, *ptr;
+ int rc;
+ uint64_t block;
int found_error_blk = 0;
/* If there isn't much pointer corruption check the pointers */
- for (ptr = ptr_start ; ptr < ptr_end && !fsck_abort; ptr++) {
- if (!*ptr)
- continue;
- if (skip_this_pass || fsck_abort)
- return 1;
- block = be64_to_cpu(*ptr);
- if (report_undo_data_error(metablock, (char *)ptr - bh->b_data,
- block, error_blk, &found_error_blk, error))
- return 1;
- rc = pass->undo_check_data(ip, block, pass->private);
- if (rc < 0)
- return rc;
+ if (ip->i_di.di_flags & GFS2_DIF_EXTENTS) {
+ struct gfs2_extent_header *eh = (struct gfs2_extent_header *)
+ (bh->b_data + hdr_size(bh, height));
+ struct gfs2_extent *first_ex = (struct gfs2_extent *)(eh + 1);
+ unsigned int extents = be16_to_cpu(eh->eh_entries);
+ struct gfs2_extent *ex;
+
+ for (ex = first_ex; ex != first_ex + extents && !fsck_abort; ex++) {
+ uint64_t first_block = be64_to_cpu(ex->ex_addr);
+ unsigned int len = be16_to_cpu(ex->ex_len);
+
+ for (block = first_block; block < first_block + len; block++) {
+ if (skip_this_pass || fsck_abort)
+ return 1;
+ if (report_undo_data_error(metablock, (char *)ex - bh->b_data,
+ block, error_blk, &found_error_blk, error))
+ return 1;
+ rc = pass->undo_check_data(ip, block, pass->private);
+ if (rc < 0)
+ return rc;
+ }
+ }
+ } else {
+ uint64_t *ptr_start = (uint64_t *)(bh->b_data + hdr_size(bh, height));
+ uint64_t *ptr_end = (uint64_t *)(bh->b_data + ip->i_sbd->bsize);
+ uint64_t *ptr;
+
+ for (ptr = ptr_start ; ptr < ptr_end && !fsck_abort; ptr++) {
+ if (!*ptr)
+ continue;
+
+ if (skip_this_pass || fsck_abort)
+ return 1;
+ block = be64_to_cpu(*ptr);
+ if (report_undo_data_error(metablock, (char *)ptr - bh->b_data,
+ block, error_blk, &found_error_blk, error))
+ return 1;
+ rc = pass->undo_check_data(ip, block, pass->private);
+ if (rc < 0)
+ return rc;
+ }
}
return found_error_blk;
}
@@ -1572,11 +1655,25 @@ int check_metatree(struct gfs2_inode *ip, struct metawalk_fxns *pass)
for (i = 0; i <= height; i++)
osi_list_init(&metalist[i]);
- /* create and check the metadata list for each height */
- error = build_and_check_metalist(ip, metalist, pass);
- if (error) {
- stack;
- goto undo_metalist;
+ if (ip->i_di.di_flags & GFS2_DIF_EXTENTS) {
+ if (height > 1) {
+ log_err(_("Inode %"PRId64" (0x%"PRIx64") has an "
+ "extent tree height greater than %u.\n"),
+ ip->i_di.di_num.no_addr,
+ ip->i_di.di_num.no_addr,
+ 1);
+ error = meta_error;
+ goto undo_metalist;
+ }
+ /* make sure we check the inode below */
+ osi_list_add(&ip->i_bh->b_altlist, metalist);
+ } else {
+ /* create and check the metadata list for each height */
+ error = build_and_check_metalist(ip, metalist, pass);
+ if (error) {
+ stack;
+ goto undo_metalist;
+ }
}
metadata_clean = 1;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
3 years
[gfs2-utils] 05/06: fsck.gfs2: Factor out error handling in
metawalk_check_data
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
agruenba pushed a commit to branch agruenba-extents
in repository gfs2-utils.
commit 6bea2bb0b483ce27328bbcf088ed8875502ac925
Author: Andreas Gruenbacher <agruenba(a)redhat.com>
AuthorDate: Thu Apr 22 00:11:03 2021 +0200
fsck.gfs2: Factor out error handling in metawalk_check_data
Move the error reporting in metawalk_check_data into a separate function
(report_data_error). Likewise, move the debug logging in undo_check_data into
a separate function (report_undo_data_error).
Fix the messages to report the actual offset instead of offset / 8.
Signed-off-by: Andreas Gruenbacher <agruenba(a)redhat.com>
---
gfs2/fsck/metawalk.c | 133 +++++++++++++++++++++++++++++----------------------
1 file changed, 75 insertions(+), 58 deletions(-)
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index 1b5272ff..0e53b693 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -1388,6 +1388,47 @@ struct error_block {
uint64_t errblk; /* error block */
};
+static void report_data_error(uint64_t metablock, int offset, uint64_t block,
+ struct error_block *error_blk,
+ int rc, int error)
+{
+ log_info("\n");
+ if (rc < 0) {
+ /* A fatal error trumps a non-fatal one. */
+ if ((error_blk->errblk == 0) ||
+ (rc < error)) {
+ log_debug(_("Fatal error on metadata "
+ "block 0x%"PRIx64", "
+ "offset 0x%x, referencing data "
+ "block 0x%"PRIx64" "
+ "preempts non-fatal error on "
+ "block 0x%"PRIx64"\n"),
+ metablock,
+ offset,
+ block,
+ error_blk->errblk);
+ error_blk->metablk = metablock;
+ error_blk->metaoff = offset;
+ error_blk->errblk = block;
+ }
+ log_info(_("Unrecoverable "));
+ } else { /* nonfatal error */
+ if (error_blk->errblk == 0) {
+ error_blk->metablk = metablock;
+ error_blk->metaoff = offset;
+ error_blk->errblk = block;
+ }
+ }
+ log_info(_("data block error %d on metadata "
+ "block %"PRId64" (0x%"PRIx64"), "
+ "offset %d (0x%x), referencing "
+ "data block %"PRId64" (0x%"PRIx64").\n"),
+ rc,
+ metablock, metablock,
+ offset, offset,
+ block, block);
+}
+
/**
* check_data - check all data pointers for a given buffer
* This does not include "data" blocks that are really
@@ -1414,7 +1455,7 @@ static int metawalk_check_data(struct gfs2_inode *ip, struct metawalk_fxns *pass
/* If there isn't much pointer corruption check the pointers */
log_debug("Processing data blocks for inode 0x%llx, metadata block 0x%llx.\n",
(unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)bh->b_blocknr);
+ (unsigned long long)metablock);
for (ptr = ptr_start ; ptr < ptr_end && !fsck_abort; ptr++) {
if (!*ptr)
continue;
@@ -1430,41 +1471,7 @@ static int metawalk_check_data(struct gfs2_inode *ip, struct metawalk_fxns *pass
rc = pass->check_data(ip, metablock, block, pass->private,
bh, ptr);
if (rc && (!error || (rc < error))) {
- log_info("\n");
- if (rc < 0) {
- /* A fatal error trumps a non-fatal one. */
- if ((error_blk->errblk == 0) ||
- (rc < error)) {
- log_debug(_("Fatal error on metadata "
- "block 0x%llx, offset "
- "0x%x, referencing block "
- "0x%llx preempts non-fatal"
- " error on block 0x%llx\n"),
- (unsigned long long)metablock,
- (int)(ptr - ptr_start),
- (unsigned long long)block,
- (unsigned long long)error_blk->errblk);
- error_blk->metablk = metablock;
- error_blk->metaoff = ptr - ptr_start;
- error_blk->errblk = block;
- }
- log_info(_("Unrecoverable "));
- } else { /* nonfatal error */
- if (error_blk->errblk == 0) {
- error_blk->metablk = metablock;
- error_blk->metaoff = ptr - ptr_start;
- error_blk->errblk = block;
- }
- }
- log_info(_("data block error %d on metadata block "
- "%lld (0x%llx), offset %d (0x%x), "
- "referencing data block %lld (0x%llx).\n"),
- rc, (unsigned long long)metablock,
- (unsigned long long)metablock,
- (int)(ptr - ptr_start),
- (int)(ptr - ptr_start),
- (unsigned long long)block,
- (unsigned long long)block);
+ report_data_error(metablock, (char *)ptr - bh->b_data, block, error_blk, rc, error);
error = rc;
}
if (rc < 0)
@@ -1474,6 +1481,35 @@ static int metawalk_check_data(struct gfs2_inode *ip, struct metawalk_fxns *pass
return error;
}
+static int report_undo_data_error(uint64_t metablock, int offset, uint64_t block,
+ struct error_block *error_blk,
+ int *found_error_blk, int error)
+{
+ if (metablock == error_blk->metablk &&
+ offset == error_blk->metaoff &&
+ block == error_blk->errblk) {
+ if (error < 0) { /* A fatal error that stopped it? */
+ log_debug(_("Stopping the undo process: "
+ "fatal error block 0x%"PRIx64" was "
+ "found at metadata block 0x%"PRIx64","
+ "offset 0x%x.\n"),
+ error_blk->errblk,
+ error_blk->metablk,
+ error_blk->metaoff);
+ return 1;
+ }
+ *found_error_blk = 1;
+ log_debug(_("The non-fatal error block 0x%"PRIx64" was "
+ "found at metadata block 0x%"PRIx64", offset "
+ "0x%d, but undo processing will continue "
+ "until the end of this metadata block.\n"),
+ error_blk->errblk,
+ error_blk->metablk,
+ error_blk->metaoff);
+ }
+ return 0;
+}
+
static int undo_check_data(struct gfs2_inode *ip, struct metawalk_fxns *pass,
struct gfs2_buffer_head *bh, unsigned int height,
struct error_block *error_blk, int error)
@@ -1493,28 +1529,9 @@ static int undo_check_data(struct gfs2_inode *ip, struct metawalk_fxns *pass,
if (skip_this_pass || fsck_abort)
return 1;
block = be64_to_cpu(*ptr);
- if (metablock == error_blk->metablk &&
- (ptr - ptr_start == error_blk->metaoff) &&
- block == error_blk->errblk) {
- if (error < 0) { /* A fatal error that stopped it? */
- log_debug(_("Stopping the undo process: "
- "fatal error block 0x%llx was "
- "found at metadata block 0x%llx,"
- "offset 0x%x.\n"),
- (unsigned long long)error_blk->errblk,
- (unsigned long long)error_blk->metablk,
- error_blk->metaoff);
- return 1;
- }
- found_error_blk = 1;
- log_debug(_("The non-fatal error block 0x%llx was "
- "found at metadata block 0x%llx, offset "
- "0x%d, but undo processing will continue "
- "until the end of this metadata block.\n"),
- (unsigned long long)error_blk->errblk,
- (unsigned long long)error_blk->metablk,
- error_blk->metaoff);
- }
+ if (report_undo_data_error(metablock, (char *)ptr - bh->b_data,
+ block, error_blk, &found_error_blk, error))
+ return 1;
rc = pass->undo_check_data(ip, block, pass->private);
if (rc < 0)
return rc;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
3 years
[gfs2-utils] 04/06: fsck.gfs2: Move struct error_block into
metawalk.c
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
agruenba pushed a commit to branch agruenba-extents
in repository gfs2-utils.
commit ee690a5df3562948bd0830e64b01ad32ea7ce31b
Author: Andreas Gruenbacher <agruenba(a)redhat.com>
AuthorDate: Thu Apr 22 00:45:42 2021 +0200
fsck.gfs2: Move struct error_block into metawalk.c
This structure isn't used anywhere else.
Signed-off-by: Andreas Gruenbacher <agruenba(a)redhat.com>
---
gfs2/fsck/fsck.h | 6 ------
gfs2/fsck/metawalk.c | 6 ++++++
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/gfs2/fsck/fsck.h b/gfs2/fsck/fsck.h
index d23326ec..aad9a360 100644
--- a/gfs2/fsck/fsck.h
+++ b/gfs2/fsck/fsck.h
@@ -108,12 +108,6 @@ enum rgindex_trust_level { /* how far can we trust our RG index? */
must have been converted from gfs2_convert. */
};
-struct error_block {
- uint64_t metablk; /* metadata block where error was found */
- int metaoff; /* offset in that metadata block where error found */
- uint64_t errblk; /* error block */
-};
-
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 rgrp_tree *rgd,
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index 43b3740b..1b5272ff 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -1382,6 +1382,12 @@ static unsigned int hdr_size(struct gfs2_buffer_head *bh, unsigned int height)
return sizeof(struct gfs2_dinode);
}
+struct error_block {
+ uint64_t metablk; /* metadata block where error was found */
+ int metaoff; /* offset in that metadata block where error found */
+ uint64_t errblk; /* error block */
+};
+
/**
* check_data - check all data pointers for a given buffer
* This does not include "data" blocks that are really
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
3 years
[gfs2-utils] 03/06: fsck.gfs2: More flexible metalist handling in
check_metatree
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
agruenba pushed a commit to branch agruenba-extents
in repository gfs2-utils.
commit d7fcd8d8d7e4789d037271602f5bc3c618ff80e4
Author: Andreas Gruenbacher <agruenba(a)redhat.com>
AuthorDate: Wed Apr 21 21:34:25 2021 +0200
fsck.gfs2: More flexible metalist handling in check_metatree
In check_metatree, allocate the metalist on the stack and only initialize it as
far as needed. Adjust free_metalist accordingly. This doesn't change much at
the moment, but it will help with the upcoming extent-based inode support
because the extent tree isn't limited to a height of GFS2_MAX_META_HEIGHT (and
is expected to be much smaller than that in practice).
Get rid of a duplicate but harmless free_metalist call in
build_and_check_metalist.
Get rid of some unnecessary &metalist[0] obfuscation. (There are several more
instances of &array[0] and similar that I didn't change.)
Signed-off-by: Andreas Gruenbacher <agruenba(a)redhat.com>
---
gfs2/fsck/metawalk.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index adaa4df7..43b3740b 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -1139,10 +1139,11 @@ int check_inode_eattr(struct gfs2_inode *ip, struct metawalk_fxns *pass)
*/
static void free_metalist(struct gfs2_inode *ip, osi_list_t *mlp)
{
+ unsigned int height = ip->i_di.di_height;
unsigned int i;
struct gfs2_buffer_head *nbh;
- for (i = 0; i < GFS2_MAX_META_HEIGHT; i++) {
+ for (i = 0; i <= height; i++) {
osi_list_t *list;
list = &mlp[i];
@@ -1333,10 +1334,8 @@ static int build_and_check_metalist(struct gfs2_inode *ip, osi_list_t *mlp,
for (; iptr.ipt_off < ip->i_sbd->bsize; iptr.ipt_off += sizeof(uint64_t)) {
struct gfs2_buffer_head *nbh = NULL;
- if (skip_this_pass || fsck_abort) {
- free_metalist(ip, mlp);
+ if (skip_this_pass || fsck_abort)
return meta_is_good;
- }
if (!iptr_block(iptr))
continue;
@@ -1533,7 +1532,7 @@ static unsigned int should_check(struct gfs2_buffer_head *bh, unsigned int heigh
int check_metatree(struct gfs2_inode *ip, struct metawalk_fxns *pass)
{
unsigned int height = ip->i_di.di_height;
- osi_list_t metalist[GFS2_MAX_META_HEIGHT];
+ osi_list_t *metalist = alloca((height + 1) * sizeof(*metalist));
osi_list_t *list, *tmp;
struct gfs2_buffer_head *bh;
unsigned int i;
@@ -1546,11 +1545,12 @@ int check_metatree(struct gfs2_inode *ip, struct metawalk_fxns *pass)
if (!height && !is_dir(&ip->i_di, ip->i_sbd->gfs1))
return 0;
- for (i = 0; i < GFS2_MAX_META_HEIGHT; i++)
+ /* metalist has one extra element for directories (see build_and_check_metalist). */
+ for (i = 0; i <= height; i++)
osi_list_init(&metalist[i]);
/* create and check the metadata list for each height */
- error = build_and_check_metalist(ip, &metalist[0], pass);
+ error = build_and_check_metalist(ip, metalist, pass);
if (error) {
stack;
goto undo_metalist;
@@ -1577,7 +1577,7 @@ int check_metatree(struct gfs2_inode *ip, struct metawalk_fxns *pass)
for (tmp = list->next; !error && tmp != list; tmp = tmp->next) {
if (fsck_abort) {
- free_metalist(ip, &metalist[0]);
+ free_metalist(ip, metalist);
return 0;
}
bh = osi_list_entry(tmp, struct gfs2_buffer_head, b_altlist);
@@ -1612,7 +1612,7 @@ undo_metalist:
(unsigned long long)error_blk.errblk,
(unsigned long long)error_blk.errblk);
if (!query( _("Remove the invalid inode? (y/n) "))) {
- free_metalist(ip, &metalist[0]);
+ free_metalist(ip, metalist);
log_err(_("Invalid inode not deleted.\n"));
return error;
}
@@ -1667,7 +1667,7 @@ undo_metalist:
GFS2_BLKST_FREE);
log_err(_("The corrupt inode was invalidated.\n"));
out:
- free_metalist(ip, &metalist[0]);
+ free_metalist(ip, metalist);
return error;
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
3 years
[gfs2-utils] 02/06: fsck.gfs2: Minor data type cleanups
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
agruenba pushed a commit to branch agruenba-extents
in repository gfs2-utils.
commit 0562776c5c49fba9fbbabd0fec0d0fe375e9ad33
Author: Andreas Gruenbacher <agruenba(a)redhat.com>
AuthorDate: Wed Apr 21 21:21:24 2021 +0200
fsck.gfs2: Minor data type cleanups
The on-disk height is an unsigned 16-bit value, so turn both height and i into
an unsigned int in check_metatree to avoid confusion. Similarly, turn i into
an unsigned int in free_metalist.
In metawalk_check_data and undo_check_data, turn ptr_end into a uint64_t
pointer.
Signed-off-by: Andreas Gruenbacher <agruenba(a)redhat.com>
---
gfs2/fsck/metawalk.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index 820ffcc1..adaa4df7 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -1139,7 +1139,7 @@ int check_inode_eattr(struct gfs2_inode *ip, struct metawalk_fxns *pass)
*/
static void free_metalist(struct gfs2_inode *ip, osi_list_t *mlp)
{
- int i;
+ unsigned int i;
struct gfs2_buffer_head *nbh;
for (i = 0; i < GFS2_MAX_META_HEIGHT; i++) {
@@ -1403,14 +1403,14 @@ static int metawalk_check_data(struct gfs2_inode *ip, struct metawalk_fxns *pass
int error = 0, rc = 0;
uint64_t block, *ptr;
uint64_t *ptr_start = (uint64_t *)(bh->b_data + hdr_size(bh, height));
- char *ptr_end = (bh->b_data + ip->i_sbd->bsize);
+ uint64_t *ptr_end = (uint64_t *)(bh->b_data + ip->i_sbd->bsize);
uint64_t metablock = bh->b_blocknr;
/* If there isn't much pointer corruption check the pointers */
log_debug("Processing data blocks for inode 0x%llx, metadata block 0x%llx.\n",
(unsigned long long)ip->i_di.di_num.no_addr,
(unsigned long long)bh->b_blocknr);
- for (ptr = ptr_start ; (char *)ptr < ptr_end && !fsck_abort; ptr++) {
+ for (ptr = ptr_start ; ptr < ptr_end && !fsck_abort; ptr++) {
if (!*ptr)
continue;
@@ -1474,14 +1474,14 @@ static int undo_check_data(struct gfs2_inode *ip, struct metawalk_fxns *pass,
struct error_block *error_blk, int error)
{
uint64_t *ptr_start = (uint64_t *)(bh->b_data + hdr_size(bh, height));
- char *ptr_end = bh->b_data + ip->i_sbd->bsize;
+ uint64_t *ptr_end = (uint64_t *)(bh->b_data + ip->i_sbd->bsize);
uint64_t metablock = bh->b_blocknr;
int rc = 0;
uint64_t block, *ptr;
int found_error_blk = 0;
/* If there isn't much pointer corruption check the pointers */
- for (ptr = ptr_start ; (char *)ptr < ptr_end && !fsck_abort; ptr++) {
+ for (ptr = ptr_start ; ptr < ptr_end && !fsck_abort; ptr++) {
if (!*ptr)
continue;
@@ -1532,12 +1532,11 @@ static unsigned int should_check(struct gfs2_buffer_head *bh, unsigned int heigh
*/
int check_metatree(struct gfs2_inode *ip, struct metawalk_fxns *pass)
{
-
+ unsigned int height = ip->i_di.di_height;
osi_list_t metalist[GFS2_MAX_META_HEIGHT];
osi_list_t *list, *tmp;
struct gfs2_buffer_head *bh;
- uint32_t height = ip->i_di.di_height;
- int i;
+ unsigned int i;
uint64_t blks_checked = 0;
int error, rc;
int metadata_clean = 0;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
3 years