This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch andyp-fsck_cx in repository gfs2-utils.
commit 4d4ee6c04e09e94eed763cbb3aaf7e66327d056b Author: Andrew Price anprice@redhat.com AuthorDate: Fri Jul 29 18:33:17 2022 +0100
fsck.gfs2: Move the global dup_blocks into fsck_cx
Signed-off-by: Andrew Price anprice@redhat.com --- gfs2/fsck/afterpass1_common.c | 26 +++++++++++------------ gfs2/fsck/fsck.h | 6 +++--- gfs2/fsck/initialize.c | 25 ++++++++++++---------- gfs2/fsck/main.c | 5 ++--- gfs2/fsck/metawalk.c | 6 +++--- gfs2/fsck/metawalk.h | 2 +- gfs2/fsck/pass1.c | 48 +++++++++++++++++++++---------------------- gfs2/fsck/pass1b.c | 38 +++++++++++++++++----------------- gfs2/fsck/util.c | 20 +++++++++--------- gfs2/fsck/util.h | 4 ++-- 10 files changed, 91 insertions(+), 89 deletions(-)
diff --git a/gfs2/fsck/afterpass1_common.c b/gfs2/fsck/afterpass1_common.c index 84e50f5b..e2ebae56 100644 --- a/gfs2/fsck/afterpass1_common.c +++ b/gfs2/fsck/afterpass1_common.c @@ -22,7 +22,7 @@ * * Returns: 1 if there are any remaining references to this block, else 0. */ -static int find_remove_dup(struct lgfs2_inode *ip, uint64_t block, +static int find_remove_dup(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t block, const char *btype, int *removed_last_meta) { struct duptree *dt; @@ -30,7 +30,7 @@ static int find_remove_dup(struct lgfs2_inode *ip, uint64_t block, int deleted_a_meta_ref = 0; int meta_refs_left = 0;
- dt = dupfind(block); + dt = dupfind(cx, block); if (!dt) return 0;
@@ -45,7 +45,7 @@ static int find_remove_dup(struct lgfs2_inode *ip, uint64_t block, if (dt->refs == 0) { log_info( _("This was the last reference: it's no longer a " "duplicate.\n")); - dup_delete(dt); /* not duplicate now */ + dup_delete(cx, dt); /* not duplicate now */ if (deleted_a_meta_ref) { log_debug("Removed the last reference as metadata.\n"); *removed_last_meta = 1; @@ -73,7 +73,7 @@ more_refs: * If it has been identified as duplicate, remove the duplicate reference. * If all duplicate references have been removed, delete the block. */ -static int delete_block_if_notdup(struct lgfs2_inode *ip, uint64_t block, +static int delete_block_if_notdup(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t block, struct lgfs2_buffer_head **bh, const char *btype, int *was_duplicate, void *private) @@ -91,7 +91,7 @@ static int delete_block_if_notdup(struct lgfs2_inode *ip, uint64_t block, btype, block, block, ip->i_num.in_addr, ip->i_num.in_addr); return META_IS_GOOD; } - if (find_remove_dup(ip, block, btype, &removed_lastmeta)) { /* a dup */ + if (find_remove_dup(cx, ip, block, btype, &removed_lastmeta)) { /* a dup */ if (was_duplicate) { if (removed_lastmeta) log_debug("Removed last reference as meta.\n"); @@ -174,13 +174,13 @@ int delete_metadata(struct fsck_cx *cx, struct iptr iptr, struct lgfs2_buffer_he
*is_valid = 1; *was_duplicate = 0; - return delete_block_if_notdup(ip, block, bh, _("metadata"), + return delete_block_if_notdup(cx, ip, block, bh, _("metadata"), was_duplicate, private); }
int delete_leaf(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t block, void *private) { - return delete_block_if_notdup(ip, block, NULL, _("leaf"), NULL, + return delete_block_if_notdup(cx, ip, block, NULL, _("leaf"), NULL, private); }
@@ -188,11 +188,11 @@ int delete_data(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t metablock, uint64_t block, void *private, struct lgfs2_buffer_head *bh, __be64 *ptr) { - return delete_block_if_notdup(ip, block, NULL, _("data"), NULL, + return delete_block_if_notdup(cx, ip, block, NULL, _("data"), NULL, private); }
-static int del_eattr_generic(struct lgfs2_inode *ip, uint64_t block, +static int del_eattr_generic(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t block, uint64_t parent, struct lgfs2_buffer_head **bh, void *private, const char *eatype) { @@ -204,7 +204,7 @@ static int del_eattr_generic(struct lgfs2_inode *ip, uint64_t block, q = bitmap_type(ip->i_sbd, block); if (q == GFS2_BLKST_FREE) was_free = 1; - ret = delete_block_if_notdup(ip, block, NULL, eatype, + ret = delete_block_if_notdup(cx, ip, block, NULL, eatype, NULL, private); if (!ret) { *bh = lgfs2_bread(ip->i_sbd, block); @@ -226,14 +226,14 @@ static int del_eattr_generic(struct lgfs2_inode *ip, uint64_t block, int delete_eattr_indir(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t block, uint64_t parent, struct lgfs2_buffer_head **bh, void *private) { - return del_eattr_generic(ip, block, parent, bh, private, + return del_eattr_generic(cx, ip, block, parent, bh, private, _("extended attribute")); }
int delete_eattr_leaf(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t block, uint64_t parent, struct lgfs2_buffer_head **bh, void *private) { - return del_eattr_generic(ip, block, parent, bh, private, + return del_eattr_generic(cx, ip, block, parent, bh, private, _("indirect extended attribute")); }
@@ -285,7 +285,7 @@ int delete_eattr_extentry(struct fsck_cx *cx, struct lgfs2_inode *ip, int i, __b uint64_t block = be64_to_cpu(*ea_data_ptr); int error;
- error = delete_block_if_notdup(ip, block, NULL, + error = delete_block_if_notdup(cx, ip, block, NULL, _("extended attribute"), NULL, private); if (error) { log_err(_("Bad extended attribute found at block %"PRIu64 " (0x%"PRIx64")"), diff --git a/gfs2/fsck/fsck.h b/gfs2/fsck/fsck.h index 1d7af191..2588e400 100644 --- a/gfs2/fsck/fsck.h +++ b/gfs2/fsck/fsck.h @@ -110,6 +110,7 @@ enum rgindex_trust_level { /* how far can we trust our RG index? */
struct fsck_cx { struct lgfs2_sbd *sdp; + struct osi_root dup_blocks; };
extern struct lgfs2_inode *fsck_load_inode(struct lgfs2_sbd *sdp, uint64_t block); @@ -119,7 +120,7 @@ extern struct lgfs2_inode *fsck_inode_get(struct lgfs2_sbd *sdp, extern void fsck_inode_put(struct lgfs2_inode **ip);
extern int initialize(struct fsck_cx *cx, int force_check, int preen, int *all_clean); -extern void destroy(struct lgfs2_sbd *sdp); +extern void destroy(struct fsck_cx *cx); extern int pass1(struct fsck_cx *cx); extern int pass1b(struct fsck_cx *cx); extern int pass1c(struct fsck_cx *cx); @@ -131,7 +132,7 @@ extern int rindex_repair(struct fsck_cx *cx, int trust_lvl, int *ok); extern int fsck_query(const char *format, ...) __attribute__((format(printf,1,2))); extern struct dir_info *dirtree_find(uint64_t block); -extern void dup_delete(struct duptree *dt); +extern void dup_delete(struct fsck_cx *cx, struct duptree *dt); extern void dirtree_delete(struct dir_info *b);
/* FIXME: Hack to get this going for pass2 - this should be pulled out @@ -154,7 +155,6 @@ extern int skip_this_pass, fsck_abort; extern int errors_found, errors_corrected; extern uint64_t last_data_block; extern uint64_t first_data_block; -extern struct osi_root dup_blocks; extern struct osi_root dirtree; extern struct osi_root inodetree; extern int dups_found; /* How many duplicate references have we found? */ diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c index b32cfa5a..f3b909df 100644 --- a/gfs2/fsck/initialize.c +++ b/gfs2/fsck/initialize.c @@ -67,14 +67,14 @@ static int block_mounters(struct lgfs2_sbd *sdp, int block_em) return 0; }
-static void dup_free(void) +static void dup_free(struct fsck_cx *cx) { struct osi_node *n; struct duptree *dt;
- while ((n = osi_first(&dup_blocks))) { + while ((n = osi_first(&cx->dup_blocks))) { dt = (struct duptree *)n; - dup_delete(dt); + dup_delete(cx, dt); } }
@@ -109,14 +109,14 @@ static void inodetree_free(void) * * Returns: Nothing */ -static void empty_super_block(struct lgfs2_sbd *sdp) +static void empty_super_block(struct fsck_cx *cx) { log_info( _("Freeing buffers.\n")); - lgfs2_rgrp_free(sdp, &sdp->rgtree); + lgfs2_rgrp_free(cx->sdp, &cx->sdp->rgtree);
inodetree_free(); dirtree_free(); - dup_free(); + dup_free(cx); }
@@ -774,8 +774,9 @@ static int fetch_rgrps(struct fsck_cx *cx) * * Returns: 0 on success, -1 on failure */ -static int init_system_inodes(struct lgfs2_sbd *sdp) +static int init_system_inodes(struct fsck_cx *cx) { + struct lgfs2_sbd *sdp = cx->sdp; __be64 inumbuf = 0; char *buf; int err; @@ -941,7 +942,7 @@ static int init_system_inodes(struct lgfs2_sbd *sdp)
return 0; fail: - empty_super_block(sdp); + empty_super_block(cx);
return -1; } @@ -1668,7 +1669,7 @@ int initialize(struct fsck_cx *cx, int force_check, int preen, return FSCK_OK; }
- if (init_system_inodes(sdp)) + if (init_system_inodes(cx)) return FSCK_ERROR;
return FSCK_OK; @@ -1680,8 +1681,10 @@ mount_fail: return FSCK_USAGE; }
-void destroy(struct lgfs2_sbd *sdp) +void destroy(struct fsck_cx *cx) { + struct lgfs2_sbd *sdp = cx->sdp; + if (!opts.no) { if (block_mounters(sdp, 0)) { log_warn( _("Unable to unblock other mounters - manual intervention required\n")); @@ -1690,7 +1693,7 @@ void destroy(struct lgfs2_sbd *sdp) log_info( _("Syncing the device.\n")); fsync(sdp->device_fd); } - empty_super_block(sdp); + empty_super_block(cx); close(sdp->device_fd); if (was_mounted_ro && errors_corrected) { sdp->device_fd = open("/proc/sys/vm/drop_caches", O_WRONLY); diff --git a/gfs2/fsck/main.c b/gfs2/fsck/main.c index bd6563a0..2bb2233f 100644 --- a/gfs2/fsck/main.c +++ b/gfs2/fsck/main.c @@ -34,7 +34,6 @@ int skip_this_pass = 0, fsck_abort = 0; int errors_found = 0, errors_corrected = 0; uint64_t last_data_block; uint64_t first_data_block; -struct osi_root dup_blocks; struct osi_root dirtree; struct osi_root inodetree; int dups_found = 0, dups_found_first = 0; @@ -335,7 +334,7 @@ int main(int argc, char **argv)
if (!force_check && all_clean && preen) { log_err( _("%s: clean.\n"), opts.device); - destroy(&sb); + destroy(&cx); exit(FSCK_OK); }
@@ -368,7 +367,7 @@ int main(int argc, char **argv) fsync(sb.device_fd); link1_destroy(&nlink1map); link1_destroy(&clink1map); - destroy(&sb); + destroy(&cx); if (sb_fixed) log_warn(_("Superblock was reset. Use tunegfs2 to manually " "set lock table before mounting.\n")); diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c index abdbb95f..2da746c0 100644 --- a/gfs2/fsck/metawalk.c +++ b/gfs2/fsck/metawalk.c @@ -207,9 +207,9 @@ int _fsck_bitmap_set(struct lgfs2_inode *ip, uint64_t bblock, return error; }
-struct duptree *dupfind(uint64_t block) +struct duptree *dupfind(struct fsck_cx *cx, uint64_t block) { - struct osi_node *node = dup_blocks.osi_node; + struct osi_node *node = cx->dup_blocks.osi_node;
while (node) { struct duptree *dt = (struct duptree *)node; @@ -1614,7 +1614,7 @@ undo_metalist: For example, if a metadata block was found to be a duplicate, we may not have added it to the metalist, which means it's not there to undo. */ - delete_all_dups(ip); + delete_all_dups(cx, ip); /* Set the dinode as "bad" so it gets deleted */ fsck_bitmap_set(ip, ip->i_num.in_addr, "corrupt", GFS2_BLKST_FREE); log_err(_("The corrupt inode was invalidated.\n")); diff --git a/gfs2/fsck/metawalk.h b/gfs2/fsck/metawalk.h index 0934c71c..90e1b988 100644 --- a/gfs2/fsck/metawalk.h +++ b/gfs2/fsck/metawalk.h @@ -25,7 +25,7 @@ extern int _fsck_bitmap_set(struct lgfs2_inode *ip, uint64_t bblock, extern int check_n_fix_bitmap(struct lgfs2_sbd *sdp, struct lgfs2_rgrp_tree *rgd, uint64_t blk, int error_on_dinode, int new_state); -extern struct duptree *dupfind(uint64_t block); +extern struct duptree *dupfind(struct fsck_cx *cx, uint64_t block); extern struct lgfs2_inode *fsck_system_inode(struct lgfs2_sbd *sdp, uint64_t block);
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c index fd7a279e..5b900b92 100644 --- a/gfs2/fsck/pass1.c +++ b/gfs2/fsck/pass1.c @@ -237,7 +237,7 @@ static int p1_check_leaf(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t bl "%"PRIu64" (0x%"PRIx64") - was marked %d (%s)\n"), block, block, ip->i_num.in_addr, ip->i_num.in_addr, q, block_type_string(q)); - add_duplicate_ref(ip, block, REF_AS_META, 0, INODE_VALID); + add_duplicate_ref(cx, 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, @@ -316,7 +316,7 @@ static int p1_check_metalist(struct fsck_cx *cx, struct iptr iptr, struct lgfs2_
bc->indir_count++; if (*was_duplicate) { - add_duplicate_ref(ip, block, REF_AS_META, 0, + add_duplicate_ref(cx, ip, block, REF_AS_META, 0, *is_valid ? INODE_VALID : INODE_INVALID); lgfs2_brelse(nbh); } else { @@ -339,7 +339,7 @@ static int p1_check_metalist(struct fsck_cx *cx, struct iptr iptr, struct lgfs2_ * 1 - We can't process the block as metadata. */
-static int undo_reference(struct lgfs2_inode *ip, uint64_t block, int meta, +static int undo_reference(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t block, int meta, void *private) { struct block_count *bc = (struct block_count *)private; @@ -355,7 +355,7 @@ static int undo_reference(struct lgfs2_inode *ip, uint64_t block, int meta,
if (meta) bc->indir_count--; - dt = dupfind(block); + dt = dupfind(cx, block); if (dt) { /* remove all duplicate reference structures from this inode */ do { @@ -373,7 +373,7 @@ static int undo_reference(struct lgfs2_inode *ip, uint64_t block, int meta, if (dt->refs == 1) { log_err(_("This was the only duplicate " "reference so far; removing it.\n")); - dup_delete(dt); + dup_delete(cx, dt); } return 1; } @@ -393,13 +393,13 @@ static int undo_reference(struct lgfs2_inode *ip, uint64_t block, int meta, static int p1_undo_check_metalist(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t block, int h, void *private) { - return undo_reference(ip, block, 1, private); + return undo_reference(cx, ip, block, 1, private); }
static int p1_undo_check_data(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t block, void *private) { - return undo_reference(ip, block, 0, private); + return undo_reference(cx, ip, block, 0, private); }
/* blockmap_set_as_data - set block as 'data' in the blockmap, if not dinode @@ -491,7 +491,7 @@ static int p1_check_data(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t me 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(cx, ip, block, REF_AS_DATA, 0, INODE_VALID); return 1; case GFS2_BLKST_USED: /* tough decision: May be data or meta */ @@ -512,13 +512,13 @@ static int p1_check_data(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t me 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(cx, 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(cx, 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. */ @@ -526,7 +526,7 @@ static int p1_check_data(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t me 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(cx, ip, block, REF_AS_DATA, 0, INODE_VALID); return 0; } } @@ -547,7 +547,7 @@ static int p1_check_data(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t me return 0; }
-static int ask_remove_inode_eattr(struct lgfs2_inode *ip, +static int ask_remove_inode_eattr(struct fsck_cx *cx, struct lgfs2_inode *ip, struct block_count *bc) { if (ip->i_eattr == 0) @@ -555,7 +555,7 @@ static int ask_remove_inode_eattr(struct lgfs2_inode *ip, log_err(_("Inode %"PRIu64" (0x%"PRIx64") has unrecoverable Extended Attribute errors.\n"), ip->i_num.in_addr, ip->i_num.in_addr); if (query( _("Clear all Extended Attributes from the inode? (y/n) "))){ - undo_reference(ip, ip->i_eattr, 0, bc); + undo_reference(cx, ip, ip->i_eattr, 0, bc); ip->i_eattr = 0; bc->ea_count = 0; ip->i_blocks = 1 + bc->indir_count + bc->data_count; @@ -585,7 +585,7 @@ static int undo_eattr_indir_or_leaf(struct fsck_cx *cx, struct lgfs2_inode *ip, set it to free, which would cause the test below to fail. */ q = block_type(bl, block);
- error = undo_reference(ip, block, 0, private); + error = undo_reference(cx, ip, block, 0, private); if (error) return error;
@@ -639,7 +639,7 @@ static int p1_check_eattr_indir(struct fsck_cx *cx, struct lgfs2_inode *ip, uint if (lgfs2_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(cx, ip, indirect, REF_AS_EA, 0, INODE_VALID); complain_eas(ip, indirect, _("Bad indirect Extended Attribute " @@ -656,7 +656,7 @@ static int p1_check_eattr_indir(struct fsck_cx *cx, struct lgfs2_inode *ip, uint return 1; } if (q != GFS2_BLKST_FREE) { /* Duplicate? */ - add_duplicate_ref(ip, indirect, REF_AS_EA, 0, INODE_VALID); + add_duplicate_ref(cx, ip, indirect, REF_AS_EA, 0, INODE_VALID); complain_eas(ip, indirect, _("Duplicate Extended Attribute indirect block")); bc->ea_count++; @@ -676,7 +676,7 @@ static int p1_finish_eattr_indir(struct fsck_cx *cx, struct lgfs2_inode *ip, int struct block_count *bc = (struct block_count *) private;
if (leaf_pointer_errors == leaf_pointers) /* All eas were bad */ - return ask_remove_inode_eattr(ip, bc); + return ask_remove_inode_eattr(cx, ip, bc); log_debug(_("Marking inode #%"PRIu64" (0x%"PRIx64") with extended attribute block\n"), ip->i_num.in_addr, ip->i_num.in_addr); if (!leaf_pointer_errors) @@ -697,7 +697,7 @@ static int p1_finish_eattr_indir(struct fsck_cx *cx, struct lgfs2_inode *ip, int /* check_ealeaf_block * checks an extended attribute (not directory) leaf block */ -static int check_ealeaf_block(struct lgfs2_inode *ip, uint64_t block, int btype, +static int check_ealeaf_block(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t block, int btype, struct lgfs2_buffer_head **bh, void *private) { struct lgfs2_buffer_head *leaf_bh = NULL; @@ -713,7 +713,7 @@ static int check_ealeaf_block(struct lgfs2_inode *ip, uint64_t block, int btype, if (lgfs2_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(cx, ip, block, REF_AS_EA, 0, INODE_VALID); complain_eas(ip, block, _("Extended attribute leaf " "duplicate found")); @@ -731,7 +731,7 @@ static int check_ealeaf_block(struct lgfs2_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(cx, ip, block, REF_AS_DATA, 0, INODE_VALID); bc->ea_count++; lgfs2_brelse(leaf_bh); /* Return 0 here because if all that's wrong is a duplicate @@ -783,7 +783,7 @@ static int p1_check_extended_leaf_eattr(struct fsck_cx *cx, struct lgfs2_inode * GFS2_BLKST_UNLINKED); error = 1; } else { - error = check_ealeaf_block(ip, el_blk, GFS2_METATYPE_ED, &bh, + error = check_ealeaf_block(cx, ip, el_blk, GFS2_METATYPE_ED, &bh, private); } if (bh) @@ -825,7 +825,7 @@ static int p1_check_eattr_leaf(struct fsck_cx *cx, struct lgfs2_inode *ip, uint6 GFS2_BLKST_UNLINKED); return 1; } - return check_ealeaf_block(ip, block, GFS2_METATYPE_EA, bh, private); + return check_ealeaf_block(cx, ip, block, GFS2_METATYPE_EA, bh, private); }
static int ask_remove_eattr_entry(struct lgfs2_sbd *sdp, @@ -1292,7 +1292,7 @@ static int handle_ip(struct fsck_cx *cx, struct lgfs2_inode *ip) ip->i_num.in_addr, ip->i_num.in_addr); eattr_undo_fxns.private = &bc; check_inode_eattr(cx, ip, &eattr_undo_fxns); - ask_remove_inode_eattr(ip, &bc); + ask_remove_inode_eattr(cx, ip, &bc); return 1; } } @@ -1770,7 +1770,7 @@ static int pass1_process_bitmap(struct fsck_cx *cx, struct lgfs2_rgrp_tree *rgd, block, block, block_type_string(q)); ip = fsck_inode_get(sdp, rgd, bh); if (is_inode && ip->i_num.in_addr == block) - add_duplicate_ref(ip, block, REF_IS_INODE, 0, + add_duplicate_ref(cx, 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 9e78bd14..034bfe82 100644 --- a/gfs2/fsck/pass1b.c +++ b/gfs2/fsck/pass1b.c @@ -134,7 +134,7 @@ static void clone_data_block(struct fsck_cx *cx, struct duptree *dt, * constantly being changed. This function revises the duplicate handler so * that it accurately matches what's in the duplicate tree regarding this block */ -static void revise_dup_handler(uint64_t dup_blk, struct dup_handler *dh) +static void revise_dup_handler(struct fsck_cx *cx, uint64_t dup_blk, struct dup_handler *dh) { osi_list_t *tmp; struct duptree *dt; @@ -144,7 +144,7 @@ static void revise_dup_handler(uint64_t dup_blk, struct dup_handler *dh) dh->ref_count = 0; dh->dt = NULL;
- dt = dupfind(dup_blk); + dt = dupfind(cx, dup_blk); if (!dt) return;
@@ -267,7 +267,7 @@ static void resolve_dup_references(struct fsck_cx *cx, struct duptree *dt, this_ref == REF_AS_DATA) { clone_data_block(cx, dt, id); dup_listent_delete(dt, id); - revise_dup_handler(dt->block, dh); + revise_dup_handler(cx, dt->block, dh); continue; } else if (!(query(_("Okay to delete %s inode %"PRIu64" (0x%"PRIx64")? (y/n) "), (inval ? _("invalidated") : ""), @@ -364,7 +364,7 @@ static void resolve_dup_references(struct fsck_cx *cx, struct duptree *dt, the blocks will be mistakenly freed, when, in fact, they're still being referenced by a valid dinode. */ if (this_ref != REF_AS_EA) - delete_all_dups(ip); + delete_all_dups(cx, ip); fsck_inode_put(&ip); /* out, lgfs2_brelse, free */ } return; @@ -594,7 +594,7 @@ static void resolve_last_reference(struct fsck_cx *cx, struct duptree *dt, } fsck_inode_put(&ip); /* out, lgfs2_brelse, free */ log_debug(_("Done with duplicate reference to block 0x%"PRIx64"\n"), dt->block); - dup_delete(dt); + dup_delete(cx, dt); }
/* handle_dup_blk - handle a duplicate block reference. @@ -612,7 +612,7 @@ static int handle_dup_blk(struct fsck_cx *cx, struct duptree *dt) uint64_t dup_blk;
dup_blk = dt->block; - revise_dup_handler(dup_blk, &dh); + revise_dup_handler(cx, dup_blk, &dh);
/* Log the duplicate references */ log_notice(_("Block %"PRIu64" (0x%"PRIx64") has %d inodes referencing it" @@ -677,7 +677,7 @@ static int handle_dup_blk(struct fsck_cx *cx, struct duptree *dt) dt->block, dt->block); resolve_dup_references(cx, dt, &dt->ref_invinode_list, &dh, 1, REF_TYPES); - revise_dup_handler(dup_blk, &dh); + revise_dup_handler(cx, dup_blk, &dh); } /* Step 2 - eliminate reference from inodes that reference it as the * wrong type. For example, a data file referencing it as @@ -691,7 +691,7 @@ static int handle_dup_blk(struct fsck_cx *cx, struct duptree *dt) dt->block, dt->block); resolve_dup_references(cx, dt, &dt->ref_inode_list, &dh, 0, acceptable_ref); - revise_dup_handler(dup_blk, &dh); + revise_dup_handler(cx, dup_blk, &dh); } /* Step 3 - We have multiple dinodes referencing it as the correct * type. Just blast one of them. @@ -704,7 +704,7 @@ static int handle_dup_blk(struct fsck_cx *cx, struct duptree *dt) dt->block, dt->block); resolve_dup_references(cx, dt, &dt->ref_inode_list, &dh, 0, REF_TYPES); - revise_dup_handler(dup_blk, &dh); + revise_dup_handler(cx, dup_blk, &dh); } /* If there's still a last remaining reference, and it's a valid reference, use it to determine the correct block type for our @@ -723,7 +723,7 @@ static int handle_dup_blk(struct fsck_cx *cx, struct duptree *dt) "references; Marking as 'free'.\n"), dup_blk, dup_blk); if (dh.dt) - dup_delete(dh.dt); + dup_delete(cx, dh.dt); check_n_fix_bitmap(cx->sdp, NULL, dup_blk, 0, GFS2_BLKST_FREE); } @@ -734,7 +734,7 @@ static int handle_dup_blk(struct fsck_cx *cx, struct duptree *dt) static int check_leaf_refs(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t block, void *private) { - return add_duplicate_ref(ip, block, REF_AS_META, 1, INODE_VALID); + return add_duplicate_ref(cx, ip, block, REF_AS_META, 1, INODE_VALID); }
static int check_metalist_refs(struct fsck_cx *cx, struct iptr iptr, struct lgfs2_buffer_head **bh, int h, @@ -745,14 +745,14 @@ static int check_metalist_refs(struct fsck_cx *cx, struct iptr iptr, struct lgfs
*was_duplicate = 0; *is_valid = 1; - return add_duplicate_ref(ip, block, REF_AS_META, 1, INODE_VALID); + return add_duplicate_ref(cx, ip, block, REF_AS_META, 1, INODE_VALID); }
static int check_data_refs(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t metablock, uint64_t block, void *private, struct lgfs2_buffer_head *bh, __be64 *ptr) { - return add_duplicate_ref(ip, block, REF_AS_DATA, 1, INODE_VALID); + return add_duplicate_ref(cx, ip, block, REF_AS_DATA, 1, INODE_VALID); }
static int check_eattr_indir_refs(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t block, @@ -762,7 +762,7 @@ static int check_eattr_indir_refs(struct fsck_cx *cx, struct lgfs2_inode *ip, ui struct lgfs2_sbd *sdp = ip->i_sbd; int error;
- error = add_duplicate_ref(ip, block, REF_AS_EA, 1, INODE_VALID); + error = add_duplicate_ref(cx, ip, block, REF_AS_EA, 1, INODE_VALID); if (!error) *bh = lgfs2_bread(sdp, block);
@@ -776,7 +776,7 @@ static int check_eattr_leaf_refs(struct fsck_cx *cx, struct lgfs2_inode *ip, uin struct lgfs2_sbd *sdp = ip->i_sbd; int error;
- error = add_duplicate_ref(ip, block, REF_AS_EA, 1, INODE_VALID); + error = add_duplicate_ref(cx, ip, block, REF_AS_EA, 1, INODE_VALID); if (!error) *bh = lgfs2_bread(sdp, block); return error; @@ -807,7 +807,7 @@ static int check_eattr_extentry_refs(struct fsck_cx *cx, struct lgfs2_inode *ip, 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(cx, ip, block, REF_AS_EA, 1, INODE_VALID); }
/* Finds all references to duplicate blocks in the metadata */ @@ -839,7 +839,7 @@ static int find_block_ref(struct fsck_cx *cx, 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(cx, ip, inode, REF_IS_INODE, 1, INODE_VALID);
/* Check this dinode's metadata for references to known duplicates */ error = check_metatree(cx, ip, &find_refs); @@ -870,7 +870,7 @@ int pass1b(struct fsck_cx *cx) log_info( _("Looking for duplicate blocks...\n"));
/* If there were no dups in the bitmap, we don't need to do anymore */ - if (dup_blocks.osi_node == NULL) { + if (cx->dup_blocks.osi_node == NULL) { log_info( _("No duplicate blocks found\n")); return FSCK_OK; } @@ -913,7 +913,7 @@ int pass1b(struct fsck_cx *cx) log_info( _("Handling duplicate blocks\n")); out: /* Resolve all duplicates by clearing out the dup tree */ - while ((n = osi_first(&dup_blocks))) { + while ((n = osi_first(&cx->dup_blocks))) { dt = (struct duptree *)n; if (!skip_this_pass && !rc) /* no error & not asked to skip the rest */ handle_dup_blk(cx, dt); diff --git a/gfs2/fsck/util.c b/gfs2/fsck/util.c index 3c1b7116..df791409 100644 --- a/gfs2/fsck/util.c +++ b/gfs2/fsck/util.c @@ -224,9 +224,9 @@ int fsck_query(const char *format, ...) * This will return the number of references to the block. * * create - will be set if the call is supposed to create the reference. */ -static struct duptree *dup_set(uint64_t dblock, int create) +static struct duptree *dup_set(struct fsck_cx *cx, uint64_t dblock, int create) { - struct osi_node **newn = &dup_blocks.osi_node, *parent = NULL; + struct osi_node **newn = &cx->dup_blocks.osi_node, *parent = NULL; struct duptree *dt;
/* Figure out where to put new node */ @@ -258,7 +258,7 @@ static struct duptree *dup_set(uint64_t dblock, int create) osi_list_init(&dt->ref_inode_list); osi_list_init(&dt->ref_invinode_list); osi_link_node(&dt->node, parent, newn); - osi_insert_color(&dt->node, &dup_blocks); + osi_insert_color(&dt->node, &cx->dup_blocks);
return dt; } @@ -323,7 +323,7 @@ int count_dup_meta_refs(struct duptree *dt) * called from pass1, which is the second reference, which determined * it was a duplicate.. */ -int add_duplicate_ref(struct lgfs2_inode *ip, uint64_t block, +int add_duplicate_ref(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t block, enum dup_ref_type reftype, int first, int inode_valid) { struct inode_with_dups *id; @@ -334,7 +334,7 @@ int add_duplicate_ref(struct lgfs2_inode *ip, uint64_t block, /* 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 = dup_set(block, !first); + dt = dup_set(cx, block, !first); if (!dt) /* If this isn't a duplicate */ return META_IS_GOOD;
@@ -510,7 +510,7 @@ void dup_listent_delete(struct duptree *dt, struct inode_with_dups *id) free(id); }
-void dup_delete(struct duptree *dt) +void dup_delete(struct fsck_cx *cx, struct duptree *dt) { struct inode_with_dups *id; osi_list_t *tmp; @@ -525,7 +525,7 @@ void dup_delete(struct duptree *dt) id = osi_list_entry(tmp, struct inode_with_dups, list); dup_listent_delete(dt, id); } - osi_erase(&dt->node, &dup_blocks); + osi_erase(&dt->node, &cx->dup_blocks); free(dt); }
@@ -587,7 +587,7 @@ __be64 *get_dir_hash(struct lgfs2_inode *ip) return tbl; }
-void delete_all_dups(struct lgfs2_inode *ip) +void delete_all_dups(struct fsck_cx *cx, struct lgfs2_inode *ip) { struct osi_node *n, *next; struct duptree *dt; @@ -595,7 +595,7 @@ void delete_all_dups(struct lgfs2_inode *ip) struct inode_with_dups *id; int found;
- for (n = osi_first(&dup_blocks); n; n = next) { + for (n = osi_first(&cx->dup_blocks); n; n = next) { next = osi_next(n); dt = (struct duptree *)n;
@@ -623,7 +623,7 @@ void delete_all_dups(struct lgfs2_inode *ip) log_debug(_("This was the last reference: 0x%"PRIx64" is " "no longer a duplicate.\n"), dt->block); - dup_delete(dt); + dup_delete(cx, dt); } else { log_debug(_("%d references remain to 0x%"PRIx64"\n"), dt->refs, dt->block); diff --git a/gfs2/fsck/util.h b/gfs2/fsck/util.h index 0eb050e5..a4bac187 100644 --- a/gfs2/fsck/util.h +++ b/gfs2/fsck/util.h @@ -12,7 +12,7 @@ struct di_info *search_list(osi_list_t *list, uint64_t addr); void big_file_comfort(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t blks_checked); void display_progress(uint64_t block); -int add_duplicate_ref(struct lgfs2_inode *ip, uint64_t block, +int add_duplicate_ref(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t block, enum dup_ref_type reftype, int first, int inode_valid); extern struct inode_with_dups *find_dup_ref_inode(struct duptree *dt, struct lgfs2_inode *ip); @@ -126,7 +126,7 @@ extern char generic_interrupt(const char *caller, const char *where, extern char fsck_getch(void); extern uint64_t find_free_blk(struct lgfs2_sbd *sdp); extern __be64 *get_dir_hash(struct lgfs2_inode *ip); -extern void delete_all_dups(struct lgfs2_inode *ip); +extern void delete_all_dups(struct fsck_cx *cx, struct lgfs2_inode *ip); extern void print_pass_duration(const char *name, struct timeval *start);
#define stack log_debug("<backtrace> - %s()\n", __func__)