This is an automated email from the git hooks/post-receive script.
andyp pushed a change to branch andyp-fsck_cx in repository gfs2-utils.
at 6983fa98 fsck.gfs2: Remove the global opts variable
This branch includes the following new commits:
new fedc173c fsck.gfs2: Introduce struct fsck_cx new 5f70beb3 fsck.gfs2: Pass the fsck_cx into the metawalk_fxns new f5f93c66 fsck.gfs2: Don't define names in the gfs2_ namespace new 4d4ee6c0 fsck.gfs2: Move the global dup_blocks into fsck_cx new c8bb893f fsck.gfs2: Move the global dirtree into fsck_cx new 24a3ebaf fsck.gfs2: Move the global inodetree into fsck_cx new 5a517177 fsck.gfs2: Move the global preen into fsck_options new 21a0c1a6 fsck.gfs2: Move the global force_check into fsck_options new 3ea1464f fsck.gfs2: Pass fsck_options into initialize() new 76dade28 fsck.gfs2: Pass fsck_options into replay_journals() new 57d193df fsck.gfs2: Pass fsck_options into recover_journal() new bfaaee54 fsck.gfs2: Pass fsck_options into preen_is_safe() new c354c64a fsck.gfs2: Pass fsck_options into destroy() new e83238c7 fsck.gfs2: Remove unused query field from fsck_options new 005df252 fsck.gfs2: Add an options pointer to fsck_cx new c436ecc8 fsck.gfs2: Pass fsck_cx into check_rgrp(s)_integrity() new fb6cb271 fsck.gfs2: Pass fsck_cx into rebuild_master() new 28a1a014 fsck.gfs2: Pass fsck_cx into lookup_per_node() new ff58c0f8 fsck.gfs2: Pass fsck_cx into fill_super_block() new f75e1578 fsck.gfs2: Pass fsck_cx into sb_repair() new 3c836469 fsck.gfs2: Pass fsck_cx into peruse_metadata() new 5e70af16 fsck.gfs2: Pass fsck_cx into peruse_{system,user}_dinode() new f33d1bb5 fsck.gfs2: Pass fsck_cx into reconstruct_journals() new fdee4537 fsck.gfs2: Pass fsck_cx into correct_journal_seg_size() new 15ff4093 fsck.gfs2: Pass fsck_cx into reset_journal_seg_size() new b35124cd fsck.gfs2: Pass fsck_cx into init_rindex() new 1e112d8e fsck.gfs2: Pass fsck_cx into ask_remove_eattr_entry() new b4b5fc4c fsck.gfs2: Pass fsck_cx into check_i_goal() new 05b2c7d3 fsck.gfs2: Pass fsck_cx into handle_inconsist() new 96a87624 fsck.gfs2: Pass fsck_cx into update_rgrp() new 69428814 fsck.gfs2: Pass fsck_cx into check_block_status() new 22757d1b fsck.gfs2: Pass fsck_cx into rewrite_rg_block() new 2dd2e939 fsck.gfs2: Pass fsck_cx into fsck_query() new 6983fa98 fsck.gfs2: Remove the global opts variable
The 34 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.
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 fedc173c33315aefa1a04c8f246af9231c1d6992 Author: Andrew Price anprice@redhat.com AuthorDate: Fri Jul 29 12:28:14 2022 +0100
fsck.gfs2: Introduce struct fsck_cx
Add a fsck-specific context structure so that we can pass around more context than the general lgfs2_sbd structure, without overloading the libgfs2 structure with fsck-specific fields. Use it in the pass functions to begin with.
Signed-off-by: Andrew Price anprice@redhat.com --- gfs2/fsck/fsck.h | 18 +++++++++++------- gfs2/fsck/main.c | 53 ++++++++++++++++++++++++++++------------------------- gfs2/fsck/pass1.c | 5 +++-- gfs2/fsck/pass1b.c | 3 ++- gfs2/fsck/pass2.c | 3 ++- gfs2/fsck/pass3.c | 3 ++- gfs2/fsck/pass4.c | 4 +++- gfs2/fsck/pass5.c | 3 ++- gfs2/fsck/util.h | 2 +- 9 files changed, 54 insertions(+), 40 deletions(-)
diff --git a/gfs2/fsck/fsck.h b/gfs2/fsck/fsck.h index 94b8620c..d4be11e4 100644 --- a/gfs2/fsck/fsck.h +++ b/gfs2/fsck/fsck.h @@ -108,6 +108,10 @@ enum rgindex_trust_level { /* how far can we trust our RG index? */ must have been converted from gfs2_convert. */ };
+struct fsck_cx { + struct lgfs2_sbd *sdp; +}; + extern struct lgfs2_inode *fsck_load_inode(struct lgfs2_sbd *sdp, uint64_t block); extern struct lgfs2_inode *fsck_inode_get(struct lgfs2_sbd *sdp, struct lgfs2_rgrp_tree *rgd, @@ -117,13 +121,13 @@ extern void fsck_inode_put(struct lgfs2_inode **ip); extern int initialize(struct lgfs2_sbd *sdp, int force_check, int preen, int *all_clean); extern void destroy(struct lgfs2_sbd *sdp); -extern int pass1(struct lgfs2_sbd *sdp); -extern int pass1b(struct lgfs2_sbd *sdp); -extern int pass1c(struct lgfs2_sbd *sdp); -extern int pass2(struct lgfs2_sbd *sdp); -extern int pass3(struct lgfs2_sbd *sdp); -extern int pass4(struct lgfs2_sbd *sdp); -extern int pass5(struct lgfs2_sbd *sdp, struct gfs2_bmap *bl); +extern int pass1(struct fsck_cx *cx); +extern int pass1b(struct fsck_cx *cx); +extern int pass1c(struct fsck_cx *cx); +extern int pass2(struct fsck_cx *cx); +extern int pass3(struct fsck_cx *cx); +extern int pass4(struct fsck_cx *cx); +extern int pass5(struct fsck_cx *cx, struct gfs2_bmap *bl); extern int rindex_repair(struct lgfs2_sbd *sdp, int trust_lvl, int *ok); extern int fsck_query(const char *format, ...) __attribute__((format(printf,1,2))); diff --git a/gfs2/fsck/main.c b/gfs2/fsck/main.c index ed6b068f..7eb45c63 100644 --- a/gfs2/fsck/main.c +++ b/gfs2/fsck/main.c @@ -152,11 +152,12 @@ static void interrupt(int sig) } }
-static int check_statfs(struct lgfs2_sbd *sdp) +static int check_statfs(struct fsck_cx *cx) { struct osi_node *n, *next = NULL; struct lgfs2_rgrp_tree *rgd; struct gfs2_statfs_change sc; + struct lgfs2_sbd *sdp = cx->sdp; uint64_t sc_total; uint64_t sc_free; uint64_t sc_dinodes; @@ -233,7 +234,7 @@ static const struct fsck_pass passes[] = { { .name = NULL, } };
-static int fsck_pass(const struct fsck_pass *p, struct lgfs2_sbd *sdp) +static int fsck_pass(const struct fsck_pass *p, struct fsck_cx *cx) { int ret; struct timeval timer; @@ -245,7 +246,7 @@ static int fsck_pass(const struct fsck_pass *p, struct lgfs2_sbd *sdp) log_notice( _("Starting %s\n"), p->name); gettimeofday(&timer, NULL);
- ret = p->f(sdp); + ret = p->f(cx); if (ret) exit(ret); if (skip_this_pass || fsck_abort) { @@ -303,7 +304,9 @@ static void startlog(int argc, char **argv) int main(int argc, char **argv) { struct lgfs2_sbd sb; - struct lgfs2_sbd *sdp = &sb; + struct fsck_cx cx = { + .sdp = &sb + }; int j; int i; int error = 0; @@ -321,51 +324,51 @@ int main(int argc, char **argv) atexit(exitlog); #endif
- memset(sdp, 0, sizeof(*sdp)); + memset(&sb, 0, sizeof(sb));
if ((error = read_cmdline(argc, argv, &opts))) exit(error); setbuf(stdout, NULL); log_notice( _("Initializing fsck\n")); - if ((error = initialize(sdp, force_check, preen, &all_clean))) + if ((error = initialize(&sb, force_check, preen, &all_clean))) exit(error);
if (!force_check && all_clean && preen) { log_err( _("%s: clean.\n"), opts.device); - destroy(sdp); + destroy(&sb); exit(FSCK_OK); }
sigaction(SIGINT, &act, NULL);
for (i = 0; passes[i].name; i++) - error = fsck_pass(passes + i, sdp); + error = fsck_pass(passes + i, &cx);
/* Free up our system inodes */ - if (!sdp->gfs1) - lgfs2_inode_put(&sdp->md.inum); - lgfs2_inode_put(&sdp->md.statfs); - for (j = 0; j < sdp->md.journals; j++) - lgfs2_inode_put(&sdp->md.journal[j]); - free(sdp->md.journal); - sdp->md.journal = NULL; - lgfs2_inode_put(&sdp->md.jiinode); - lgfs2_inode_put(&sdp->md.riinode); - lgfs2_inode_put(&sdp->md.qinode); - if (!sdp->gfs1) - lgfs2_inode_put(&sdp->md.pinode); - lgfs2_inode_put(&sdp->md.rooti); - if (!sdp->gfs1) - lgfs2_inode_put(&sdp->master_dir); + if (!sb.gfs1) + lgfs2_inode_put(&sb.md.inum); + lgfs2_inode_put(&sb.md.statfs); + for (j = 0; j < sb.md.journals; j++) + lgfs2_inode_put(&sb.md.journal[j]); + free(sb.md.journal); + sb.md.journal = NULL; + lgfs2_inode_put(&sb.md.jiinode); + lgfs2_inode_put(&sb.md.riinode); + lgfs2_inode_put(&sb.md.qinode); + if (!sb.gfs1) + lgfs2_inode_put(&sb.md.pinode); + lgfs2_inode_put(&sb.md.rooti); + if (!sb.gfs1) + lgfs2_inode_put(&sb.master_dir); if (lf_dip) lgfs2_inode_put(&lf_dip);
if (!opts.no && errors_corrected) log_notice( _("Writing changes to disk\n")); - fsync(sdp->device_fd); + fsync(sb.device_fd); link1_destroy(&nlink1map); link1_destroy(&clink1map); - destroy(sdp); + destroy(&sb); if (sb_fixed) log_warn(_("Superblock was reset. Use tunegfs2 to manually " "set lock table before mounting.\n")); diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c index 1ee10795..a7dc442e 100644 --- a/gfs2/fsck/pass1.c +++ b/gfs2/fsck/pass1.c @@ -1948,8 +1948,9 @@ static void enomem(uint64_t addl_mem_needed) * inodes size * dir info */ -int pass1(struct lgfs2_sbd *sdp) +int pass1(struct fsck_cx *cx) { + struct lgfs2_sbd *sdp = cx->sdp; struct osi_node *n, *next = NULL; struct lgfs2_rgrp_tree *rgd; uint64_t i; @@ -2025,7 +2026,7 @@ int pass1(struct lgfs2_sbd *sdp) } log_notice(_("Reconciling bitmaps.\n")); gettimeofday(&timer, NULL); - pass5(sdp, bl); + pass5(cx, bl); print_pass_duration("reconcile_bitmaps", &timer); out: gfs2_special_free(&gfs1_rindex_blks); diff --git a/gfs2/fsck/pass1b.c b/gfs2/fsck/pass1b.c index d1e1050a..76c01fb3 100644 --- a/gfs2/fsck/pass1b.c +++ b/gfs2/fsck/pass1b.c @@ -857,8 +857,9 @@ out: /* Pass 1b handles finding the previous inode for a duplicate block * When found, store the inodes pointing to the duplicate block for * use in pass2 */ -int pass1b(struct lgfs2_sbd *sdp) +int pass1b(struct fsck_cx *cx) { + struct lgfs2_sbd *sdp = cx->sdp; struct duptree *dt; uint64_t i; int q; diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c index 25da1091..62f84516 100644 --- a/gfs2/fsck/pass2.c +++ b/gfs2/fsck/pass2.c @@ -2106,8 +2106,9 @@ static int pass2_check_dir(struct lgfs2_sbd *sdp, struct lgfs2_inode *ip) * directory name length * entries in range */ -int pass2(struct lgfs2_sbd *sdp) +int pass2(struct fsck_cx *cx) { + struct lgfs2_sbd *sdp = cx->sdp; struct osi_node *tmp, *next = NULL; struct lgfs2_inode *ip; struct dir_info *dt; diff --git a/gfs2/fsck/pass3.c b/gfs2/fsck/pass3.c index 4fa826e7..94d91d19 100644 --- a/gfs2/fsck/pass3.c +++ b/gfs2/fsck/pass3.c @@ -156,8 +156,9 @@ out: * handle disconnected directories * handle lost+found directory errors (missing, not a directory, no space) */ -int pass3(struct lgfs2_sbd *sdp) +int pass3(struct fsck_cx *cx) { + struct lgfs2_sbd *sdp = cx->sdp; struct osi_node *tmp, *next = NULL; struct dir_info *di, *tdi; struct lgfs2_inode *ip; diff --git a/gfs2/fsck/pass4.c b/gfs2/fsck/pass4.c index 651c7752..5862ca0f 100644 --- a/gfs2/fsck/pass4.c +++ b/gfs2/fsck/pass4.c @@ -262,8 +262,10 @@ static int scan_nlink1_list(struct lgfs2_sbd *sdp) * handle unreferenced inodes of other types * handle bad blocks */ -int pass4(struct lgfs2_sbd *sdp) +int pass4(struct fsck_cx *cx) { + struct lgfs2_sbd *sdp = cx->sdp; + if (lf_dip) log_debug( _("At beginning of pass4, lost+found entries is %u\n"), lf_dip->i_entries); diff --git a/gfs2/fsck/pass5.c b/gfs2/fsck/pass5.c index e412a4d0..e464fdff 100644 --- a/gfs2/fsck/pass5.c +++ b/gfs2/fsck/pass5.c @@ -194,8 +194,9 @@ static void update_rgrp(struct lgfs2_sbd *sdp, struct lgfs2_rgrp_tree *rgp, * fix free block maps * fix used inode maps */ -int pass5(struct lgfs2_sbd *sdp, struct gfs2_bmap *bl) +int pass5(struct fsck_cx *cx, struct gfs2_bmap *bl) { + struct lgfs2_sbd *sdp = cx->sdp; struct osi_node *n, *next = NULL; struct lgfs2_rgrp_tree *rgp = NULL; uint32_t count[5]; /* we need 5 because of GFS1 usedmeta */ diff --git a/gfs2/fsck/util.h b/gfs2/fsck/util.h index daef0b86..f63a8af1 100644 --- a/gfs2/fsck/util.h +++ b/gfs2/fsck/util.h @@ -29,7 +29,7 @@ extern const char *reftypes[REF_TYPES + 1];
struct fsck_pass { const char *name; - int (*f)(struct lgfs2_sbd *sdp); + int (*f)(struct fsck_cx *cx); };
static inline int block_type(struct gfs2_bmap *bl, uint64_t bblock)
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 5f70beb3ef86f68a0fdc22d9e1adcec3612c0358 Author: Andrew Price anprice@redhat.com AuthorDate: Fri Jul 29 17:12:45 2022 +0100
fsck.gfs2: Pass the fsck_cx into the metawalk_fxns
This will allow data such as currently global variables and a separate set of resource groups to be passed in later.
Signed-off-by: Andrew Price anprice@redhat.com --- gfs2/fsck/afterpass1_common.c | 22 +++---- gfs2/fsck/afterpass1_common.h | 19 +++--- gfs2/fsck/fs_recovery.c | 29 +++++---- gfs2/fsck/fs_recovery.h | 4 +- gfs2/fsck/fsck.h | 5 +- gfs2/fsck/initialize.c | 23 +++---- gfs2/fsck/main.c | 2 +- gfs2/fsck/metawalk.c | 92 ++++++++++++++-------------- gfs2/fsck/metawalk.h | 44 +++++++------- gfs2/fsck/pass1.c | 137 +++++++++++++++++++++--------------------- gfs2/fsck/pass1b.c | 85 +++++++++++++------------- gfs2/fsck/pass2.c | 111 +++++++++++++++++----------------- gfs2/fsck/pass3.c | 8 +-- gfs2/fsck/pass4.c | 34 +++++------ gfs2/fsck/rgrepair.c | 12 ++-- gfs2/fsck/util.c | 2 +- gfs2/fsck/util.h | 2 +- 17 files changed, 315 insertions(+), 316 deletions(-)
diff --git a/gfs2/fsck/afterpass1_common.c b/gfs2/fsck/afterpass1_common.c index b41f216e..84e50f5b 100644 --- a/gfs2/fsck/afterpass1_common.c +++ b/gfs2/fsck/afterpass1_common.c @@ -109,7 +109,7 @@ static int delete_block_if_notdup(struct lgfs2_inode *ip, uint64_t block, return META_IS_GOOD; }
-static int remove_dentry(struct lgfs2_inode *ip, struct gfs2_dirent *dent, +static int remove_dentry(struct fsck_cx *cx, struct lgfs2_inode *ip, struct gfs2_dirent *dent, struct gfs2_dirent *prev_de, struct lgfs2_buffer_head *bh, char *filename, uint32_t *count, int *lindex, @@ -131,10 +131,10 @@ static int remove_dentry(struct lgfs2_inode *ip, struct gfs2_dirent *dent,
}
-int remove_dentry_from_dir(struct lgfs2_sbd *sdp, uint64_t dir, - uint64_t dentryblock) +int remove_dentry_from_dir(struct fsck_cx *cx, uint64_t dir, uint64_t dentryblock) { struct metawalk_fxns remove_dentry_fxns = {0}; + struct lgfs2_sbd *sdp = cx->sdp; struct lgfs2_inode *ip; int q; int error; @@ -161,12 +161,12 @@ int remove_dentry_from_dir(struct lgfs2_sbd *sdp, uint64_t dir, } /* Need to run check_dir with a private var of dentryblock, * and fxns that remove that dentry if found */ - error = check_dir(sdp, ip, &remove_dentry_fxns); + error = check_dir(cx, ip, &remove_dentry_fxns); fsck_inode_put(&ip); return error; }
-int delete_metadata(struct iptr iptr, struct lgfs2_buffer_head **bh, int h, int *is_valid, +int delete_metadata(struct fsck_cx *cx, struct iptr iptr, struct lgfs2_buffer_head **bh, int h, int *is_valid, int *was_duplicate, void *private) { struct lgfs2_inode *ip = iptr.ipt_ip; @@ -178,13 +178,13 @@ int delete_metadata(struct iptr iptr, struct lgfs2_buffer_head **bh, int h, int was_duplicate, private); }
-int delete_leaf(struct lgfs2_inode *ip, uint64_t block, void *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, private); }
-int delete_data(struct lgfs2_inode *ip, uint64_t metablock, +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) { @@ -223,21 +223,21 @@ static int del_eattr_generic(struct lgfs2_inode *ip, uint64_t block, return ret; }
-int delete_eattr_indir(struct lgfs2_inode *ip, uint64_t block, uint64_t parent, +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, _("extended attribute")); }
-int delete_eattr_leaf(struct lgfs2_inode *ip, uint64_t block, uint64_t parent, +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, _("indirect extended attribute")); }
-int delete_eattr_entry(struct lgfs2_inode *ip, struct lgfs2_buffer_head *leaf_bh, +int delete_eattr_entry(struct fsck_cx *cx, struct lgfs2_inode *ip, struct lgfs2_buffer_head *leaf_bh, struct gfs2_ea_header *ea_hdr, struct gfs2_ea_header *ea_hdr_prev, void *private) { @@ -277,7 +277,7 @@ int delete_eattr_entry(struct lgfs2_inode *ip, struct lgfs2_buffer_head *leaf_bh return 0; }
-int delete_eattr_extentry(struct lgfs2_inode *ip, int i, __be64 *ea_data_ptr, +int delete_eattr_extentry(struct fsck_cx *cx, struct lgfs2_inode *ip, int i, __be64 *ea_data_ptr, struct lgfs2_buffer_head *leaf_bh, uint32_t tot_ealen, struct gfs2_ea_header *ea_hdr, struct gfs2_ea_header *ea_hdr_prev, void *private) diff --git a/gfs2/fsck/afterpass1_common.h b/gfs2/fsck/afterpass1_common.h index 055816b4..4b0ab96e 100644 --- a/gfs2/fsck/afterpass1_common.h +++ b/gfs2/fsck/afterpass1_common.h @@ -4,28 +4,27 @@ #include "util.h" #include "metawalk.h"
-extern int delete_metadata(struct iptr iptr, struct lgfs2_buffer_head **bh, int h, int *is_valid, - int *was_duplicate, void *private); -extern int delete_leaf(struct lgfs2_inode *ip, uint64_t block, void *private); -extern int delete_data(struct lgfs2_inode *ip, uint64_t metablock, +extern int delete_metadata(struct fsck_cx *cx, struct iptr iptr, struct lgfs2_buffer_head **bh, + int h, int *is_valid, int *was_duplicate, void *private); +extern int delete_leaf(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t block, void *private); +extern 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); -extern int delete_eattr_indir(struct lgfs2_inode *ip, uint64_t block, uint64_t parent, +extern 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); -extern int delete_eattr_leaf(struct lgfs2_inode *ip, uint64_t block, uint64_t parent, +extern 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); -extern int delete_eattr_entry(struct lgfs2_inode *ip, +extern int delete_eattr_entry(struct fsck_cx *cx, struct lgfs2_inode *ip, struct lgfs2_buffer_head *leaf_bh, struct gfs2_ea_header *ea_hdr, struct gfs2_ea_header *ea_hdr_prev, void *private); -extern int delete_eattr_extentry(struct lgfs2_inode *ip, int i, +extern int delete_eattr_extentry(struct fsck_cx *cx, struct lgfs2_inode *ip, int i, __be64 *ea_data_ptr, struct lgfs2_buffer_head *leaf_bh, uint32_t tot_ealen, struct gfs2_ea_header *ea_hdr, struct gfs2_ea_header *ea_hdr_prev, void *private); -extern int remove_dentry_from_dir(struct lgfs2_sbd *sdp, uint64_t dir, - uint64_t dentryblock); +extern int remove_dentry_from_dir(struct fsck_cx *cx, uint64_t dir, uint64_t dentryblock); #endif diff --git a/gfs2/fsck/fs_recovery.c b/gfs2/fsck/fs_recovery.c index 97c42e4d..607ef9c2 100644 --- a/gfs2/fsck/fs_recovery.c +++ b/gfs2/fsck/fs_recovery.c @@ -620,7 +620,7 @@ static int rangecheck_jblock(struct lgfs2_inode *ip, uint64_t block) return META_IS_GOOD; }
-static int rangecheck_jmeta(struct iptr iptr, struct lgfs2_buffer_head **bh, int h, +static int rangecheck_jmeta(struct fsck_cx *cx, struct iptr iptr, struct lgfs2_buffer_head **bh, int h, int *is_valid, int *was_duplicate, void *private) { struct lgfs2_inode *ip = iptr.ipt_ip; @@ -648,7 +648,7 @@ static int rangecheck_jmeta(struct iptr iptr, struct lgfs2_buffer_head **bh, int return rc; }
-static int rangecheck_jdata(struct lgfs2_inode *ip, uint64_t metablock, +static int rangecheck_jdata(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t metablock, uint64_t block, void *private, struct lgfs2_buffer_head *bh, __be64 *ptr) { @@ -675,11 +675,15 @@ static struct metawalk_fxns rangecheck_journal = { * * Returns: 0 on success, -1 on failure */ -int replay_journals(struct lgfs2_sbd *sdp, int preen, int force_check, +int replay_journals(struct fsck_cx *cx, int preen, int force_check, int *clean_journals) { + struct lgfs2_sbd *sdp = cx->sdp; + int dirty_journals = 0; + int gave_msg = 0; + int error = 0; + int clean = 0; int i; - int clean = 0, dirty_journals = 0, error = 0, gave_msg = 0;
*clean_journals = 0;
@@ -687,7 +691,7 @@ int replay_journals(struct lgfs2_sbd *sdp, int preen, int force_check,
for(i = 0; i < sdp->md.journals; i++) { if (sdp->md.journal[i]) { - error = check_metatree(sdp->md.journal[i], + error = check_metatree(cx, sdp->md.journal[i], &rangecheck_journal); if (error) /* Don't use fsck_inode_put here because it's a @@ -808,7 +812,7 @@ static void bad_journalname(const char *filename, int len) * This function makes sure the directory entries of the jindex are valid. * If they're not '.' or '..' they better have the form journalXXX. */ -static int check_jindex_dent(struct lgfs2_inode *ip, struct gfs2_dirent *dent, +static int check_jindex_dent(struct fsck_cx *cx, struct lgfs2_inode *ip, struct gfs2_dirent *dent, struct gfs2_dirent *prev_de, struct lgfs2_buffer_head *bh, char *filename, uint32_t *count, int *lindex, void *priv) @@ -869,14 +873,9 @@ int build_jindex(struct lgfs2_sbd *sdp) return 0; }
-/** - * init_jindex - read in the rindex file - */ -int init_jindex(struct lgfs2_sbd *sdp, int allow_ji_rebuild) +int init_jindex(struct fsck_cx *cx, int allow_ji_rebuild) { - /******************************************************************* - ****************** Fill in journal information ****************** - *******************************************************************/ + struct lgfs2_sbd *sdp = cx->sdp;
log_debug(_("Validating the journal index.\n")); /* rgrepair requires the journals be read in in order to distinguish @@ -916,10 +915,10 @@ int init_jindex(struct lgfs2_sbd *sdp, int allow_ji_rebuild)
log_debug(_("Checking the integrity of the journal index.\n")); if (sdp->md.jiinode->i_flags & GFS2_DIF_EXHASH) - error = check_leaf_blks(sdp->md.jiinode, + error = check_leaf_blks(cx, sdp->md.jiinode, &jindex_check_fxns); else - error = check_linear_dir(sdp->md.jiinode, + error = check_linear_dir(cx, sdp->md.jiinode, sdp->md.jiinode->i_bh, &jindex_check_fxns); if (error) { diff --git a/gfs2/fsck/fs_recovery.h b/gfs2/fsck/fs_recovery.h index 0d5a785d..51d632ee 100644 --- a/gfs2/fsck/fs_recovery.h +++ b/gfs2/fsck/fs_recovery.h @@ -3,12 +3,12 @@
#include "libgfs2.h"
-extern int replay_journals(struct lgfs2_sbd *sdp, int preen, int force_check, +extern int replay_journals(struct fsck_cx *cx, int preen, int force_check, int *clean_journals); extern int preen_is_safe(struct lgfs2_sbd *sdp, int preen, int force_check);
extern int ji_update(struct lgfs2_sbd *sdp); extern int build_jindex(struct lgfs2_sbd *sdp); -extern int init_jindex(struct lgfs2_sbd *sdp, int allow_ji_rebuild); +extern int init_jindex(struct fsck_cx *cx, int allow_ji_rebuild); #endif /* __FS_RECOVERY_H__ */
diff --git a/gfs2/fsck/fsck.h b/gfs2/fsck/fsck.h index d4be11e4..382abfab 100644 --- a/gfs2/fsck/fsck.h +++ b/gfs2/fsck/fsck.h @@ -118,8 +118,7 @@ extern struct lgfs2_inode *fsck_inode_get(struct lgfs2_sbd *sdp, struct lgfs2_buffer_head *bh); extern void fsck_inode_put(struct lgfs2_inode **ip);
-extern int initialize(struct lgfs2_sbd *sdp, int force_check, int preen, - int *all_clean); +extern int initialize(struct fsck_cx *cx, int force_check, int preen, int *all_clean); extern void destroy(struct lgfs2_sbd *sdp); extern int pass1(struct fsck_cx *cx); extern int pass1b(struct fsck_cx *cx); @@ -128,7 +127,7 @@ extern int pass2(struct fsck_cx *cx); extern int pass3(struct fsck_cx *cx); extern int pass4(struct fsck_cx *cx); extern int pass5(struct fsck_cx *cx, struct gfs2_bmap *bl); -extern int rindex_repair(struct lgfs2_sbd *sdp, int trust_lvl, int *ok); +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); diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c index eade7f3c..9d771a70 100644 --- a/gfs2/fsck/initialize.c +++ b/gfs2/fsck/initialize.c @@ -697,7 +697,7 @@ static int read_rgrps(struct lgfs2_sbd *sdp, uint64_t expected) return -1; }
-static int fetch_rgrps_level(struct lgfs2_sbd *sdp, enum rgindex_trust_level lvl, uint64_t *count, int *ok) +static int fetch_rgrps_level(struct fsck_cx *cx, enum rgindex_trust_level lvl, uint64_t *count, int *ok) { int ret = 1;
@@ -718,13 +718,13 @@ static int fetch_rgrps_level(struct lgfs2_sbd *sdp, enum rgindex_trust_level lvl
log_notice(_("Level %d resource group check: %s.\n"), lvl + 1, level_desc[lvl]);
- if (rindex_repair(sdp, lvl, ok) != 0) + if (rindex_repair(cx, lvl, ok) != 0) goto fail;
- if (lgfs2_rindex_read(sdp, count, ok) != 0 || !*ok) + if (lgfs2_rindex_read(cx->sdp, count, ok) != 0 || !*ok) goto fail;
- ret = read_rgrps(sdp, *count); + ret = read_rgrps(cx->sdp, *count); if (ret != 0) goto fail;
@@ -742,7 +742,7 @@ fail: /** * fetch_rgrps - fetch the resource groups from disk, and check their integrity */ -static int fetch_rgrps(struct lgfs2_sbd *sdp) +static int fetch_rgrps(struct fsck_cx *cx) { enum rgindex_trust_level trust_lvl; uint64_t rgcount; @@ -752,7 +752,7 @@ static int fetch_rgrps(struct lgfs2_sbd *sdp) for (trust_lvl = BLIND_FAITH; trust_lvl <= INDIGNATION; trust_lvl++) { int ret = 0;
- ret = fetch_rgrps_level(sdp, trust_lvl, &rgcount, &ok); + ret = fetch_rgrps_level(cx, trust_lvl, &rgcount, &ok); if (ret == 0) break; if (fsck_abort) @@ -765,7 +765,7 @@ static int fetch_rgrps(struct lgfs2_sbd *sdp) } log_info( _("%"PRIu64" resource groups found.\n"), rgcount);
- check_rgrps_integrity(sdp); + check_rgrps_integrity(cx->sdp); return 0; }
@@ -1544,9 +1544,10 @@ static int init_rindex(struct lgfs2_sbd *sdp) * initialize - initialize superblock pointer * */ -int initialize(struct lgfs2_sbd *sdp, int force_check, int preen, +int initialize(struct fsck_cx *cx, int force_check, int preen, int *all_clean) { + struct lgfs2_sbd *sdp = cx->sdp; int clean_journals = 0, open_flag; int err;
@@ -1638,20 +1639,20 @@ int initialize(struct lgfs2_sbd *sdp, int force_check, int preen, if (init_rindex(sdp)) return FSCK_ERROR;
- if (fetch_rgrps(sdp)) + if (fetch_rgrps(cx)) return FSCK_ERROR;
/* We need to read in jindex in order to replay the journals. If there's an error, we may proceed and let init_system_inodes try to rebuild it. */ - if (init_jindex(sdp, 1) == 0) { + if (init_jindex(cx, 1) == 0) { /* If GFS, rebuild the journals. If GFS2, replay them. We don't have the smarts to replay GFS1 journals (neither did gfs_fsck). */ if (sdp->gfs1) { if (reconstruct_journals(sdp)) return FSCK_ERROR; - } else if (replay_journals(sdp, preen, force_check, + } else if (replay_journals(cx, preen, force_check, &clean_journals)) { if (!opts.no && preen_is_safe(sdp, preen, force_check)) block_mounters(sdp, 0); diff --git a/gfs2/fsck/main.c b/gfs2/fsck/main.c index 7eb45c63..fff0d32d 100644 --- a/gfs2/fsck/main.c +++ b/gfs2/fsck/main.c @@ -330,7 +330,7 @@ int main(int argc, char **argv) exit(error); setbuf(stdout, NULL); log_notice( _("Initializing fsck\n")); - if ((error = initialize(&sb, force_check, preen, &all_clean))) + if ((error = initialize(&cx, force_check, preen, &all_clean))) exit(error);
if (!force_check && all_clean && preen) { diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c index 9c8d857b..36f4abcb 100644 --- a/gfs2/fsck/metawalk.c +++ b/gfs2/fsck/metawalk.c @@ -381,7 +381,7 @@ static void dirblk_truncate(struct lgfs2_inode *ip, struct gfs2_dirent *fixb, * returns: 0 - good block or it was repaired to be good * -1 - error occurred */ -static int check_entries(struct lgfs2_inode *ip, struct lgfs2_buffer_head *bh, +static int check_entries(struct fsck_cx *cx, struct lgfs2_inode *ip, struct lgfs2_buffer_head *bh, int type, uint32_t *count, int lindex, struct metawalk_fxns *pass) { @@ -477,7 +477,7 @@ static int check_entries(struct lgfs2_inode *ip, struct lgfs2_buffer_head *bh, /* Mark dirent buffer as modified */ first = 0; } else { - error = pass->check_dentry(ip, dent, prev, bh, + error = pass->check_dentry(cx, ip, dent, prev, bh, filename, count, &lindex, pass->private); @@ -511,7 +511,7 @@ static int check_entries(struct lgfs2_inode *ip, struct lgfs2_buffer_head *bh, * Reads in the leaf block * Leaves the buffer around for further analysis (caller must lgfs2_brelse) */ -int check_leaf(struct lgfs2_inode *ip, int lindex, struct metawalk_fxns *pass, +int check_leaf(struct fsck_cx *cx, struct lgfs2_inode *ip, int lindex, struct metawalk_fxns *pass, uint64_t *leaf_no, struct lgfs2_leaf *leaf, int *ref_count) { int error = 0, fix; @@ -540,10 +540,10 @@ int check_leaf(struct lgfs2_inode *ip, int lindex, struct metawalk_fxns *pass, goto bad_leaf; } if (pass->check_leaf_depth) - error = pass->check_leaf_depth(ip, *leaf_no, *ref_count, lbh); + error = pass->check_leaf_depth(cx, ip, *leaf_no, *ref_count, lbh);
if (error >= 0 && pass->check_leaf) { - error = pass->check_leaf(ip, *leaf_no, pass->private); + error = pass->check_leaf(cx, ip, *leaf_no, pass->private); if (error == -EEXIST) { log_info(_("Previous reference to leaf %"PRIu64" (0x%"PRIx64") " "has already checked it; skipping.\n"), @@ -578,7 +578,7 @@ int check_leaf(struct lgfs2_inode *ip, int lindex, struct metawalk_fxns *pass, }
if (pass->check_dentry && is_dir(ip, sdp->gfs1)) { - error = check_entries(ip, lbh, DIR_EXHASH, &count, lindex, + error = check_entries(cx, ip, lbh, DIR_EXHASH, &count, lindex, pass);
if (skip_this_pass || fsck_abort) @@ -631,7 +631,7 @@ bad_leaf: lgfs2_brelse(lbh); if (pass->repair_leaf) { /* The leaf we read in is bad so we need to repair it. */ - fix = pass->repair_leaf(ip, leaf_no, lindex, *ref_count, msg); + fix = pass->repair_leaf(cx, ip, leaf_no, lindex, *ref_count, msg); if (fix < 0) return fix;
@@ -678,7 +678,7 @@ static void dir_leaf_reada(struct lgfs2_inode *ip, __be64 *tbl, unsigned hsize) }
/* Checks exhash directory entries */ -int check_leaf_blks(struct lgfs2_inode *ip, struct metawalk_fxns *pass) +int check_leaf_blks(struct fsck_cx *cx, struct lgfs2_inode *ip, struct metawalk_fxns *pass) { int error = 0; unsigned hsize = (1 << ip->i_depth); @@ -708,7 +708,7 @@ int check_leaf_blks(struct lgfs2_inode *ip, struct metawalk_fxns *pass) dir_leaf_reada(ip, tbl, hsize);
if (pass->check_hash_tbl) { - error = pass->check_hash_tbl(ip, tbl, hsize, pass->private); + error = pass->check_hash_tbl(cx, ip, tbl, hsize, pass->private); if (error < 0) { free(tbl); (void)posix_fadvise(sdp->device_fd, 0, 0, POSIX_FADV_NORMAL); @@ -793,7 +793,7 @@ int check_leaf_blks(struct lgfs2_inode *ip, struct metawalk_fxns *pass) (void)posix_fadvise(sdp->device_fd, 0, 0, POSIX_FADV_NORMAL); return 0; } - error = check_leaf(ip, lindex, pass, &leaf_no, &leaf, + error = check_leaf(cx, ip, lindex, pass, &leaf_no, &leaf, &ref_count); if (ref_count != orig_ref_count) { log_debug(_("Ref count of leaf 0x%"PRIx64 @@ -836,7 +836,7 @@ int check_leaf_blks(struct lgfs2_inode *ip, struct metawalk_fxns *pass) return 0; }
-static int check_eattr_entries(struct lgfs2_inode *ip, +static int check_eattr_entries(struct fsck_cx *cx, struct lgfs2_inode *ip, struct lgfs2_buffer_head *bh, struct metawalk_fxns *pass) { @@ -856,7 +856,7 @@ static int check_eattr_entries(struct lgfs2_inode *ip, if (ea_hdr->ea_type == GFS2_EATYPE_UNUSED) error = 0; else - error = pass->check_eattr_entry(ip, bh, ea_hdr, + error = pass->check_eattr_entry(cx, ip, bh, ea_hdr, ea_hdr_prev, pass->private); if (error < 0) { @@ -880,7 +880,7 @@ static int check_eattr_entries(struct lgfs2_inode *ip, ** reuse........... */
for(i = 0; i < ea_hdr->ea_num_ptrs; i++){ - err = pass->check_eattr_extentry(ip, i, + err = pass->check_eattr_extentry(cx, ip, i, ea_data_ptr, bh, tot_ealen, ea_hdr, ea_hdr_prev, pass->private); @@ -912,7 +912,7 @@ static int check_eattr_entries(struct lgfs2_inode *ip, * * Returns: 0 on success, 1 if removal is needed, -1 on error */ -static int check_leaf_eattr(struct lgfs2_inode *ip, uint64_t block, +static int check_leaf_eattr(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t block, uint64_t parent, struct metawalk_fxns *pass) { struct lgfs2_buffer_head *bh = NULL; @@ -924,7 +924,7 @@ static int check_leaf_eattr(struct lgfs2_inode *ip, uint64_t block, "inode #%"PRIu64" (0x%"PRIx64").\n"), block, block, ip->i_num.in_addr, ip->i_num.in_addr);
- error = pass->check_eattr_leaf(ip, block, parent, &bh, + error = pass->check_eattr_leaf(cx, ip, block, parent, &bh, pass->private); if (error < 0) { stack; @@ -936,7 +936,7 @@ static int check_leaf_eattr(struct lgfs2_inode *ip, uint64_t block, return 1; } if (bh) { - error = check_eattr_entries(ip, bh, pass); + error = check_eattr_entries(cx, ip, bh, pass); lgfs2_brelse(bh); } return error; @@ -952,7 +952,7 @@ static int check_leaf_eattr(struct lgfs2_inode *ip, uint64_t block, * * Returns: 0 on success -1 on error */ -static int check_indirect_eattr(struct lgfs2_inode *ip, uint64_t indirect, +static int check_indirect_eattr(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t indirect, struct lgfs2_buffer_head *indirect_buf, struct metawalk_fxns *pass) { @@ -971,7 +971,7 @@ static int check_indirect_eattr(struct lgfs2_inode *ip, uint64_t indirect, while (*ea_leaf_ptr && (ea_leaf_ptr < end)){ block = be64_to_cpu(*ea_leaf_ptr); leaf_pointers++; - err = check_leaf_eattr(ip, block, indirect, pass); + err = check_leaf_eattr(cx, ip, block, indirect, pass); if (err) { error = err; log_err(_("Error detected in leaf block %"PRIu64" (0x%"PRIx64") " @@ -996,7 +996,7 @@ static int check_indirect_eattr(struct lgfs2_inode *ip, uint64_t indirect, if (leaf_pointers == 1 && leaf_pointer_errors == 1) { first_ea_is_bad = 1; if (pass->finish_eattr_indir) - pass->finish_eattr_indir(ip, leaf_pointers, + pass->finish_eattr_indir(cx, ip, leaf_pointers, leaf_pointer_errors, pass->private); } else if (leaf_pointer_errors) { @@ -1017,13 +1017,13 @@ static int check_indirect_eattr(struct lgfs2_inode *ip, uint64_t indirect, ip->i_eattr = di_eattr_save; if (pass->finish_eattr_indir) { if (!first_ea_is_bad) { - pass->finish_eattr_indir(ip, leaf_pointers, + pass->finish_eattr_indir(cx, ip, leaf_pointers, leaf_pointer_errors, pass->private); } if (pass->delete_block && leaf_pointer_errors && leaf_pointer_errors == leaf_pointers) { - pass->delete_block(ip, indirect, NULL, "leaf", NULL); + pass->delete_block(cx, ip, indirect, NULL, "leaf", NULL); error = 1; } } @@ -1037,7 +1037,7 @@ static int check_indirect_eattr(struct lgfs2_inode *ip, uint64_t indirect, * * Returns: 0 on success, -1 on error */ -int check_inode_eattr(struct lgfs2_inode *ip, struct metawalk_fxns *pass) +int check_inode_eattr(struct fsck_cx *cx, struct lgfs2_inode *ip, struct metawalk_fxns *pass) { int error = 0; struct lgfs2_buffer_head *indirect_buf = NULL; @@ -1052,10 +1052,10 @@ int check_inode_eattr(struct lgfs2_inode *ip, struct metawalk_fxns *pass) log_debug(_("Checking EA indirect block #%"PRIu64" (0x%"PRIx64") for " "inode #%"PRIu64" (0x%"PRIx64")..\n"), ip->i_eattr, ip->i_eattr, ip->i_num.in_addr, ip->i_num.in_addr); - error = pass->check_eattr_indir(ip, ip->i_eattr, ip->i_num.in_addr, + error = pass->check_eattr_indir(cx, ip, ip->i_eattr, ip->i_num.in_addr, &indirect_buf, pass->private); if (!error) { - error = check_indirect_eattr(ip, ip->i_eattr, + error = check_indirect_eattr(cx, ip, ip->i_eattr, indirect_buf, pass); if (error) stack; @@ -1064,7 +1064,7 @@ int check_inode_eattr(struct lgfs2_inode *ip, struct metawalk_fxns *pass) lgfs2_brelse(indirect_buf); return error; } - error = check_leaf_eattr(ip, ip->i_eattr, ip->i_num.in_addr, pass); + error = check_leaf_eattr(cx, ip, ip->i_eattr, ip->i_num.in_addr, pass); if (error) stack;
@@ -1149,7 +1149,7 @@ static void file_ra(struct lgfs2_inode *ip, struct lgfs2_buffer_head *bh, extlen * sdp->sd_bsize, POSIX_FADV_WILLNEED); }
-static int do_check_metalist(struct iptr iptr, int height, struct lgfs2_buffer_head **bhp, +static int do_check_metalist(struct fsck_cx *cx, struct iptr iptr, int height, struct lgfs2_buffer_head **bhp, struct metawalk_fxns *pass) { struct lgfs2_inode *ip = iptr.ipt_ip; @@ -1161,7 +1161,7 @@ static int do_check_metalist(struct iptr iptr, int height, struct lgfs2_buffer_h if (pass->check_metalist == NULL) return 0;
- error = pass->check_metalist(iptr, bhp, height, &is_valid, + error = pass->check_metalist(cx, iptr, bhp, height, &is_valid, &was_duplicate, pass->private); if (error == META_ERROR) { stack; @@ -1207,7 +1207,7 @@ static int do_check_metalist(struct iptr iptr, int height, struct lgfs2_buffer_h * @ip: * @mlp: */ -static int build_and_check_metalist(struct lgfs2_inode *ip, osi_list_t *mlp, +static int build_and_check_metalist(struct fsck_cx *cx, struct lgfs2_inode *ip, osi_list_t *mlp, struct metawalk_fxns *pass) { uint32_t height = ip->i_height; @@ -1277,7 +1277,7 @@ static int build_and_check_metalist(struct lgfs2_inode *ip, osi_list_t *mlp, if (!iptr_block(iptr)) continue;
- error = do_check_metalist(iptr, h, &nbh, pass); + error = do_check_metalist(cx, iptr, h, &nbh, pass); if (error == META_ERROR || error == META_SKIP_FURTHER) goto error_undo; if (error == META_SKIP_ONE) @@ -1304,7 +1304,7 @@ error_undo: /* undo what we've done so far for this block */ if (block == 0) continue;
- pass->undo_check_meta(ip, block, h, pass->private); + pass->undo_check_meta(cx, ip, block, h, pass->private); } return error; } @@ -1380,7 +1380,7 @@ static void report_data_error(uint64_t metablock, int offset, uint64_t block, * 1 if errors were found and corrected * 2 (ENOENT) is there were too many bad pointers */ -static int metawalk_check_data(struct lgfs2_inode *ip, struct metawalk_fxns *pass, +static int metawalk_check_data(struct fsck_cx *cx, struct lgfs2_inode *ip, struct metawalk_fxns *pass, struct lgfs2_buffer_head *bh, unsigned int height, uint64_t *blks_checked, struct error_block *error_blk) { @@ -1406,7 +1406,7 @@ static int metawalk_check_data(struct lgfs2_inode *ip, struct metawalk_fxns *pas 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, + rc = pass->check_data(cx, 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); @@ -1448,7 +1448,7 @@ static int report_undo_data_error(uint64_t metablock, int offset, uint64_t block return 0; }
-static int undo_check_data(struct lgfs2_inode *ip, struct metawalk_fxns *pass, +static int undo_check_data(struct fsck_cx *cx, struct lgfs2_inode *ip, struct metawalk_fxns *pass, struct lgfs2_buffer_head *bh, unsigned int height, struct error_block *error_blk, int error) { @@ -1471,7 +1471,7 @@ static int undo_check_data(struct lgfs2_inode *ip, struct metawalk_fxns *pass, 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); + rc = pass->undo_check_data(cx, ip, block, pass->private); if (rc < 0) return rc; } @@ -1491,7 +1491,7 @@ static unsigned int should_check(struct lgfs2_buffer_head *bh, unsigned int heig * @pass: structure passed in from caller to determine the sub-functions * */ -int check_metatree(struct lgfs2_inode *ip, struct metawalk_fxns *pass) +int check_metatree(struct fsck_cx *cx, struct lgfs2_inode *ip, struct metawalk_fxns *pass) { unsigned int height = ip->i_height; osi_list_t *metalist = alloca((height + 1) * sizeof(*metalist)); @@ -1512,7 +1512,7 @@ int check_metatree(struct lgfs2_inode *ip, struct metawalk_fxns *pass) osi_list_init(&metalist[i]);
/* create and check the metadata list for each height */ - error = build_and_check_metalist(ip, metalist, pass); + error = build_and_check_metalist(cx, ip, metalist, pass); if (error) { stack; goto undo_metalist; @@ -1526,7 +1526,7 @@ int check_metatree(struct lgfs2_inode *ip, struct metawalk_fxns *pass) if (!(ip->i_flags & GFS2_DIF_EXHASH)) goto out; /* check validity of leaf blocks and leaf chains */ - error = check_leaf_blks(ip, pass); + error = check_leaf_blks(cx, ip, pass); if (error) goto undo_metalist; goto out; @@ -1547,10 +1547,10 @@ int check_metatree(struct lgfs2_inode *ip, struct metawalk_fxns *pass) continue;
if (pass->check_data) - error = metawalk_check_data(ip, pass, bh, height, + error = metawalk_check_data(cx, ip, pass, bh, height, &blks_checked, &error_blk); if (pass->big_file_msg && ip->i_blocks > COMFORTABLE_BLKS) - pass->big_file_msg(ip, blks_checked); + pass->big_file_msg(cx, ip, blks_checked); } if (pass->big_file_msg && ip->i_blocks > COMFORTABLE_BLKS) { log_notice( _("\rLarge file at %"PRIu64" (0x%"PRIx64") - 100 percent " @@ -1581,14 +1581,14 @@ undo_metalist: log_err(_("Undoing metadata work for block %"PRIu64" (0x%"PRIx64")\n"), bh->b_blocknr, bh->b_blocknr); if (i) - rc = pass->undo_check_meta(ip, bh->b_blocknr, + rc = pass->undo_check_meta(cx, ip, bh->b_blocknr, i, pass->private); else rc = 0; if (metadata_clean && rc == 0 && i == height - 1 && !hit_error_blk) { if (should_check(bh, height)) { - rc = undo_check_data(ip, pass, + rc = undo_check_data(cx, ip, pass, bh, height, &error_blk, @@ -1624,13 +1624,13 @@ out: }
/* Checks stuffed inode directories */ -int check_linear_dir(struct lgfs2_inode *ip, struct lgfs2_buffer_head *bh, +int check_linear_dir(struct fsck_cx *cx, struct lgfs2_inode *ip, struct lgfs2_buffer_head *bh, struct metawalk_fxns *pass) { int error = 0; uint32_t count = 0;
- error = check_entries(ip, bh, DIR_LINEAR, &count, 0, pass); + error = check_entries(cx, ip, bh, DIR_LINEAR, &count, 0, pass); if (error < 0) { stack; return -1; @@ -1639,14 +1639,14 @@ int check_linear_dir(struct lgfs2_inode *ip, struct lgfs2_buffer_head *bh, return error; }
-int check_dir(struct lgfs2_sbd *sdp, struct lgfs2_inode *ip, struct metawalk_fxns *pass) +int check_dir(struct fsck_cx *cx, struct lgfs2_inode *ip, struct metawalk_fxns *pass) { int error = 0;
if (ip->i_flags & GFS2_DIF_EXHASH) - error = check_leaf_blks(ip, pass); + error = check_leaf_blks(cx, ip, pass); else - error = check_linear_dir(ip, ip->i_bh, pass); + error = check_linear_dir(cx, ip, ip->i_bh, pass);
if (error < 0) stack; diff --git a/gfs2/fsck/metawalk.h b/gfs2/fsck/metawalk.h index eeff431d..0934c71c 100644 --- a/gfs2/fsck/metawalk.h +++ b/gfs2/fsck/metawalk.h @@ -8,15 +8,15 @@
struct metawalk_fxns;
-extern int check_inode_eattr(struct lgfs2_inode *ip, +extern int check_inode_eattr(struct fsck_cx *cx, struct lgfs2_inode *ip, struct metawalk_fxns *pass); -extern int check_metatree(struct lgfs2_inode *ip, struct metawalk_fxns *pass); -extern int check_leaf_blks(struct lgfs2_inode *ip, struct metawalk_fxns *pass); -extern int check_dir(struct lgfs2_sbd *sdp, struct lgfs2_inode *ip, +extern int check_metatree(struct fsck_cx *cx, struct lgfs2_inode *ip, struct metawalk_fxns *pass); +extern int check_leaf_blks(struct fsck_cx *cx, struct lgfs2_inode *ip, struct metawalk_fxns *pass); +extern int check_dir(struct fsck_cx *cx, struct lgfs2_inode *ip, struct metawalk_fxns *pass); -extern int check_linear_dir(struct lgfs2_inode *ip, struct lgfs2_buffer_head *bh, +extern int check_linear_dir(struct fsck_cx *cx, struct lgfs2_inode *ip, struct lgfs2_buffer_head *bh, struct metawalk_fxns *pass); -extern int check_leaf(struct lgfs2_inode *ip, int lindex, +extern int check_leaf(struct fsck_cx *cx, struct lgfs2_inode *ip, int lindex, struct metawalk_fxns *pass, uint64_t *leaf_no, struct lgfs2_leaf *leaf, int *ref_count); extern int _fsck_bitmap_set(struct lgfs2_inode *ip, uint64_t bblock, @@ -72,9 +72,9 @@ struct metawalk_fxns { void *private; int invalid_meta_is_fatal; int readahead; - int (*check_leaf_depth) (struct lgfs2_inode *ip, uint64_t leaf_no, + int (*check_leaf_depth) (struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t leaf_no, int ref_count, struct lgfs2_buffer_head *lbh); - int (*check_leaf) (struct lgfs2_inode *ip, uint64_t block, + int (*check_leaf) (struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t block, void *private); /* parameters to the check_metalist sub-functions: iptr: reference to the inode and its indirect pointer that we're analyzing @@ -90,48 +90,48 @@ struct metawalk_fxns { returns: 0 - everything is good, but there may be duplicates 1 - skip further processing */ - int (*check_metalist) (struct iptr iptr, + int (*check_metalist) (struct fsck_cx *cx, struct iptr iptr, struct lgfs2_buffer_head **bh, int h, int *is_valid, int *was_duplicate, void *private); - int (*check_data) (struct lgfs2_inode *ip, uint64_t metablock, + int (*check_data) (struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t metablock, uint64_t block, void *private, struct lgfs2_buffer_head *bh, __be64 *ptr); - int (*check_eattr_indir) (struct lgfs2_inode *ip, uint64_t block, + int (*check_eattr_indir) (struct fsck_cx *, struct lgfs2_inode *ip, uint64_t block, uint64_t parent, struct lgfs2_buffer_head **bh, void *private); - int (*check_eattr_leaf) (struct lgfs2_inode *ip, uint64_t block, + int (*check_eattr_leaf) (struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t block, uint64_t parent, struct lgfs2_buffer_head **bh, void *private); - int (*check_dentry) (struct lgfs2_inode *ip, struct gfs2_dirent *de, + int (*check_dentry) (struct fsck_cx *cx, struct lgfs2_inode *ip, struct gfs2_dirent *de, struct gfs2_dirent *prev, struct lgfs2_buffer_head *bh, char *filename, uint32_t *count, int *lindex, void *private); - int (*check_eattr_entry) (struct lgfs2_inode *ip, + int (*check_eattr_entry) (struct fsck_cx *cx, struct lgfs2_inode *ip, struct lgfs2_buffer_head *leaf_bh, struct gfs2_ea_header *ea_hdr, struct gfs2_ea_header *ea_hdr_prev, void *private); - int (*check_eattr_extentry) (struct lgfs2_inode *ip, int i, + int (*check_eattr_extentry) (struct fsck_cx *cx, struct lgfs2_inode *ip, int i, __be64 *ea_data_ptr, struct lgfs2_buffer_head *leaf_bh, uint32_t tot_ealen, struct gfs2_ea_header *ea_hdr, struct gfs2_ea_header *ea_hdr_prev, void *private); - int (*finish_eattr_indir) (struct lgfs2_inode *ip, int leaf_pointers, + int (*finish_eattr_indir) (struct fsck_cx *cx, struct lgfs2_inode *ip, int leaf_pointers, int leaf_pointer_errors, void *private); - void (*big_file_msg) (struct lgfs2_inode *ip, uint64_t blks_checked); - int (*check_hash_tbl) (struct lgfs2_inode *ip, __be64 *tbl, + void (*big_file_msg) (struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t blks_checked); + int (*check_hash_tbl) (struct fsck_cx *cx, struct lgfs2_inode *ip, __be64 *tbl, unsigned hsize, void *private); - int (*repair_leaf) (struct lgfs2_inode *ip, uint64_t *leaf_no, + int (*repair_leaf) (struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t *leaf_no, int lindex, int ref_count, const char *msg); - int (*undo_check_meta) (struct lgfs2_inode *ip, uint64_t block, + int (*undo_check_meta) (struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t block, int h, void *private); - int (*undo_check_data) (struct lgfs2_inode *ip, uint64_t block, + int (*undo_check_data) (struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t block, void *private); - int (*delete_block) (struct lgfs2_inode *ip, uint64_t block, + int (*delete_block) (struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t block, struct lgfs2_buffer_head **bh, const char *btype, void *private); }; diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c index a7dc442e..44199ac6 100644 --- a/gfs2/fsck/pass1.c +++ b/gfs2/fsck/pass1.c @@ -80,7 +80,7 @@ static int _fsck_blockmap_set(struct lgfs2_inode *ip, uint64_t bblock, /** * p1_delete_block - delete a block associated with an inode */ -static int p1_delete_block(struct lgfs2_inode *ip, uint64_t block, +static int p1_delete_block(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t block, struct lgfs2_buffer_head **bh, const char *btype, void *private) { @@ -93,7 +93,7 @@ static int p1_delete_block(struct lgfs2_inode *ip, uint64_t block,
/* This is a pass1-specific leaf repair. Since we are not allowed to do * block allocations, we do what we can. */ -static int p1_repair_leaf(struct lgfs2_inode *ip, uint64_t *leaf_no, +static int p1_repair_leaf(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t *leaf_no, int lindex, int ref_count, const char *msg) { uint64_t *cpyptr; @@ -138,7 +138,7 @@ out: * marked "in use" by the bitmap. You don't want root's indirect blocks * deleted, do you? Or worse, reused for lost+found. */ -static int resuscitate_metalist(struct iptr iptr, struct lgfs2_buffer_head **bh, int h, +static int resuscitate_metalist(struct fsck_cx *cx, struct iptr iptr, struct lgfs2_buffer_head **bh, int h, int *is_valid, int *was_duplicate, void *private) { struct block_count *bc = (struct block_count *)private; @@ -174,7 +174,7 @@ static int resuscitate_metalist(struct iptr iptr, struct lgfs2_buffer_head **bh, * This function makes sure directory entries in system directories are * kept alive. You don't want journal0 deleted from jindex, do you? */ -static int resuscitate_dentry(struct lgfs2_inode *ip, struct gfs2_dirent *dent, +static int resuscitate_dentry(struct fsck_cx *cx, struct lgfs2_inode *ip, struct gfs2_dirent *dent, struct gfs2_dirent *prev_de, struct lgfs2_buffer_head *bh, char *filename, uint32_t *count, int *lindex, void *priv) @@ -221,7 +221,7 @@ static struct metawalk_fxns sysdir_fxns = { .delete_block = p1_delete_block, };
-static int p1_check_leaf(struct lgfs2_inode *ip, uint64_t block, void *private) +static int p1_check_leaf(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t block, void *private) { struct block_count *bc = (struct block_count *) private; int q; @@ -250,7 +250,7 @@ static int p1_check_leaf(struct lgfs2_inode *ip, uint64_t block, void *private) return 0; }
-static int p1_check_metalist(struct iptr iptr, struct lgfs2_buffer_head **bh, int h, +static int p1_check_metalist(struct fsck_cx *cx, struct iptr iptr, struct lgfs2_buffer_head **bh, int h, int *is_valid, int *was_duplicate, void *private) { struct block_count *bc = (struct block_count *)private; @@ -390,13 +390,13 @@ static int undo_reference(struct lgfs2_inode *ip, uint64_t block, int meta, return 0; }
-static int p1_undo_check_metalist(struct lgfs2_inode *ip, uint64_t block, +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); }
-static int p1_undo_check_data(struct lgfs2_inode *ip, uint64_t block, +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); @@ -444,7 +444,7 @@ out: return error; }
-static int p1_check_data(struct lgfs2_inode *ip, uint64_t metablock, +static int p1_check_data(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t metablock, uint64_t block, void *private, struct lgfs2_buffer_head *bbh, __be64 *ptr) { @@ -568,7 +568,7 @@ static int ask_remove_inode_eattr(struct lgfs2_inode *ip, return 0; }
-static int undo_eattr_indir_or_leaf(struct lgfs2_inode *ip, uint64_t block, +static int undo_eattr_indir_or_leaf(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t block, uint64_t parent, struct lgfs2_buffer_head **bh, void *private) @@ -613,7 +613,7 @@ static void complain_eas(struct lgfs2_inode *ip, uint64_t block, log_err(_(" at block #%"PRIu64" (0x%"PRIx64").\n"), block, block); }
-static int p1_check_eattr_indir(struct lgfs2_inode *ip, uint64_t indirect, +static int p1_check_eattr_indir(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t indirect, uint64_t parent, struct lgfs2_buffer_head **bh, void *private) { @@ -670,7 +670,7 @@ static int p1_check_eattr_indir(struct lgfs2_inode *ip, uint64_t indirect, return ret; }
-static int p1_finish_eattr_indir(struct lgfs2_inode *ip, int leaf_pointers, +static int p1_finish_eattr_indir(struct fsck_cx *cx, struct lgfs2_inode *ip, int leaf_pointers, int leaf_pointer_errors, void *private) { struct block_count *bc = (struct block_count *) private; @@ -761,7 +761,7 @@ static int check_ealeaf_block(struct lgfs2_inode *ip, uint64_t block, int btype, * * Returns: 0 if correct[able], -1 if removal is needed */ -static int p1_check_extended_leaf_eattr(struct lgfs2_inode *ip, int i, +static int p1_check_extended_leaf_eattr(struct fsck_cx *cx, struct lgfs2_inode *ip, int i, __be64 *data_ptr, struct lgfs2_buffer_head *leaf_bh, uint32_t tot_ealen, @@ -812,7 +812,7 @@ static int p1_check_extended_leaf_eattr(struct lgfs2_inode *ip, int i, return error; }
-static int p1_check_eattr_leaf(struct lgfs2_inode *ip, uint64_t block, +static int p1_check_eattr_leaf(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t block, uint64_t parent, struct lgfs2_buffer_head **bh, void *private) { @@ -869,7 +869,7 @@ static int eatype_max(unsigned fs_format) return max; }
-static int p1_check_eattr_entries(struct lgfs2_inode *ip, +static int p1_check_eattr_entries(struct fsck_cx *cx, struct lgfs2_inode *ip, struct lgfs2_buffer_head *leaf_bh, struct gfs2_ea_header *ea_hdr, struct gfs2_ea_header *ea_hdr_prev, @@ -991,7 +991,7 @@ static int rangecheck_block(struct lgfs2_inode *ip, uint64_t block, return META_IS_GOOD; }
-static int rangecheck_metadata(struct iptr iptr, struct lgfs2_buffer_head **bh, int h, +static int rangecheck_metadata(struct fsck_cx *cx, struct iptr iptr, struct lgfs2_buffer_head **bh, int h, int *is_valid, int *was_duplicate, void *private) { struct lgfs2_inode *ip = iptr.ipt_ip; @@ -1002,27 +1002,27 @@ static int rangecheck_metadata(struct iptr iptr, struct lgfs2_buffer_head **bh, return rangecheck_block(ip, block, bh, BTYPE_META, private); }
-static int rangecheck_leaf(struct lgfs2_inode *ip, uint64_t block, +static int rangecheck_leaf(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t block, void *private) { return rangecheck_block(ip, block, NULL, BTYPE_LEAF, private); }
-static int rangecheck_data(struct lgfs2_inode *ip, uint64_t metablock, +static int rangecheck_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 rangecheck_block(ip, block, NULL, BTYPE_DATA, private); }
-static int rangecheck_eattr_indir(struct lgfs2_inode *ip, uint64_t block, +static int rangecheck_eattr_indir(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t block, uint64_t parent, struct lgfs2_buffer_head **bh, void *private) { return rangecheck_block(ip, block, NULL, BTYPE_IEATTR, private); }
-static int rangecheck_eattr_leaf(struct lgfs2_inode *ip, uint64_t block, +static int rangecheck_eattr_leaf(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t block, uint64_t parent, struct lgfs2_buffer_head **bh, void *private) { @@ -1097,7 +1097,7 @@ static int set_ip_blockmap(struct lgfs2_inode *ip) return 0; }
-static int alloc_metalist(struct iptr iptr, struct lgfs2_buffer_head **bh, int h, +static int alloc_metalist(struct fsck_cx *cx, struct iptr iptr, struct lgfs2_buffer_head **bh, int h, int *is_valid, int *was_duplicate, void *private) { const char *desc = (const char *)private; @@ -1121,7 +1121,7 @@ static int alloc_metalist(struct iptr iptr, struct lgfs2_buffer_head **bh, int h return META_IS_GOOD; }
-static int alloc_data(struct lgfs2_inode *ip, uint64_t metablock, +static int alloc_data(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t metablock, uint64_t block, void *private, struct lgfs2_buffer_head *bh, __be64 *ptr) { @@ -1140,7 +1140,7 @@ static int alloc_data(struct lgfs2_inode *ip, uint64_t metablock, return 0; }
-static int alloc_leaf(struct lgfs2_inode *ip, uint64_t block, void *private) +static int alloc_leaf(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t block, void *private) { int q;
@@ -1177,12 +1177,12 @@ static struct metawalk_fxns alloc_fxns = { * have been freed in the bitmap. We need to set the inode address as free * as well. */ -static int pass1_check_metatree(struct lgfs2_inode *ip, +static int pass1_check_metatree(struct fsck_cx *cx, struct lgfs2_inode *ip, struct metawalk_fxns *pass) { int error;
- error = check_metatree(ip, pass); + error = check_metatree(cx, ip, pass); if (error) gfs2_blockmap_set(bl, ip->i_num.in_addr, GFS2_BLKST_FREE); return error; @@ -1205,7 +1205,7 @@ static int pass1_check_metatree(struct lgfs2_inode *ip, * So it's only our blockmap that now disagrees with the rgrp bitmap, so we * need to fix only that. */ -static void reprocess_inode(struct lgfs2_inode *ip, const char *desc) +static void reprocess_inode(struct fsck_cx *cx, struct lgfs2_inode *ip, const char *desc) { int error;
@@ -1213,7 +1213,7 @@ static void reprocess_inode(struct lgfs2_inode *ip, const char *desc) log_info(_("%s inode %"PRIu64" (0x%"PRIx64") had blocks added; reprocessing " "its metadata tree at height=%d.\n"), desc, ip->i_num.in_addr, ip->i_num.in_addr, ip->i_height); - error = pass1_check_metatree(ip, &alloc_fxns); + error = pass1_check_metatree(cx, ip, &alloc_fxns); if (error) log_err( _("Error %d reprocessing the %s metadata tree.\n"), error, desc); @@ -1222,7 +1222,7 @@ static void reprocess_inode(struct lgfs2_inode *ip, const char *desc) /* * handle_ip - process an incore structure representing a dinode. */ -static int handle_ip(struct lgfs2_sbd *sdp, struct lgfs2_inode *ip) +static int handle_ip(struct fsck_cx *cx, struct lgfs2_inode *ip) { int error; struct block_count bc = {0}; @@ -1236,7 +1236,7 @@ static int handle_ip(struct lgfs2_sbd *sdp, struct lgfs2_inode *ip) so it's better to check it up front and delete the inode if there is corruption. */ rangecheck_fxns.private = &bad_pointers; - error = pass1_check_metatree(ip, &rangecheck_fxns); + error = pass1_check_metatree(cx, ip, &rangecheck_fxns); if (bad_pointers > BAD_POINTER_TOLERANCE) { log_err(_("Error: inode %"PRIu64" (0x%"PRIx64") has more than %d bad pointers.\n"), ip->i_num.in_addr, ip->i_num.in_addr, BAD_POINTER_TOLERANCE); @@ -1264,13 +1264,13 @@ static int handle_ip(struct lgfs2_sbd *sdp, struct lgfs2_inode *ip) lf_blks = lf_dip->i_blocks;
pass1_fxns.private = &bc; - error = pass1_check_metatree(ip, &pass1_fxns); + error = pass1_check_metatree(cx, ip, &pass1_fxns);
/* Pass1 may have added some blocks to lost+found by virtue of leafs that were misplaced. If it did, we need to reprocess lost+found to correctly account for its blocks. */ if (lf_dip && lf_dip->i_blocks != lf_blks) - reprocess_inode(lf_dip, "lost+found"); + reprocess_inode(cx, lf_dip, "lost+found");
/* We there was an error, we return 0 because we want fsck to continue and analyze the other dinodes as well. */ @@ -1278,7 +1278,7 @@ static int handle_ip(struct lgfs2_sbd *sdp, struct lgfs2_inode *ip) return 0;
if (!error) { - error = check_inode_eattr(ip, &pass1_fxns); + error = check_inode_eattr(cx, ip, &pass1_fxns);
if (error) { if (!query(_("Clear the bad Extended Attributes? " @@ -1291,7 +1291,7 @@ static int handle_ip(struct lgfs2_sbd *sdp, struct lgfs2_inode *ip) "inode %"PRIu64" (0x%"PRIx64").\n"), ip->i_num.in_addr, ip->i_num.in_addr); eattr_undo_fxns.private = &bc; - check_inode_eattr(ip, &eattr_undo_fxns); + check_inode_eattr(cx, ip, &eattr_undo_fxns); ask_remove_inode_eattr(ip, &bc); return 1; } @@ -1346,14 +1346,14 @@ static void check_i_goal(struct lgfs2_sbd *sdp, struct lgfs2_inode *ip) * handle_di - This is now a wrapper function that takes a lgfs2_buffer_head * and calls handle_ip, which takes an in-code dinode structure. */ -static int handle_di(struct lgfs2_sbd *sdp, struct lgfs2_rgrp_tree *rgd, +static int handle_di(struct fsck_cx *cx, struct lgfs2_rgrp_tree *rgd, struct lgfs2_buffer_head *bh) { int error = 0; uint64_t block = bh->b_blocknr; struct lgfs2_inode *ip;
- ip = fsck_inode_get(sdp, rgd, bh); + ip = fsck_inode_get(cx->sdp, rgd, bh);
if (ip->i_num.in_addr != block) { log_err(_("Inode #%"PRIu64" (0x%"PRIx64"): Bad inode address found: %"PRIu64 @@ -1367,7 +1367,7 @@ static int handle_di(struct lgfs2_sbd *sdp, struct lgfs2_rgrp_tree *rgd, log_err(_("Address in inode at block #%"PRIu64" (0x%"PRIx64" not fixed\n"), block, block); } - if (sdp->gfs1 && ip->i_num.in_formal_ino != block) { + if (cx->sdp->gfs1 && ip->i_num.in_formal_ino != block) { log_err(_("Inode #%"PRIu64" (0x%"PRIx64"): GFS1 formal inode number " "mismatch: was %"PRIu64" (0x%"PRIx64")\n"), block, block, ip->i_num.in_formal_ino, ip->i_num.in_formal_ino); @@ -1379,8 +1379,8 @@ static int handle_di(struct lgfs2_sbd *sdp, struct lgfs2_rgrp_tree *rgd, log_err(_("Inode number in inode at block %"PRIu64" (0x%"PRIx64") not fixed\n"), block, block); } - check_i_goal(sdp, ip); - error = handle_ip(sdp, ip); + check_i_goal(cx->sdp, ip); + error = handle_ip(cx, ip); fsck_inode_put(&ip); return error; } @@ -1389,7 +1389,7 @@ static int handle_di(struct lgfs2_sbd *sdp, struct lgfs2_rgrp_tree *rgd, /* Should work for all system inodes: root, master, jindex, per_node, etc. */ /* We have to pass the sysinode as ** because the pointer may change out from under the reference by way of the builder() function. */ -static int check_system_inode(struct lgfs2_sbd *sdp, +static int check_system_inode(struct fsck_cx *cx, struct lgfs2_inode **sysinode, const char *filename, int builder(struct lgfs2_sbd *sdp), int isdir, @@ -1410,7 +1410,7 @@ static int check_system_inode(struct lgfs2_sbd *sdp, log_err(_("Found invalid system dinode at block %"PRIu64" (0x%"PRIx64")\n"), iblock, iblock); gfs2_blockmap_set(bl, iblock, GFS2_BLKST_FREE); - check_n_fix_bitmap(sdp, (*sysinode)->i_rgd, iblock, 0, + check_n_fix_bitmap(cx->sdp, (*sysinode)->i_rgd, iblock, 0, GFS2_BLKST_FREE); lgfs2_inode_put(sysinode); } @@ -1465,15 +1465,15 @@ static int check_system_inode(struct lgfs2_sbd *sdp, if (query(_("Create new %s system inode? (y/n) "), filename)) { log_err( _("Rebuilding system file "%s"\n"), filename); - error = builder(sdp); + error = builder(cx->sdp); if (error) { log_err( _("Error rebuilding system " "inode %s: Cannot continue\n"), filename); return error; } - if (*sysinode == sdp->md.jiinode) - ji_update(sdp); + if (*sysinode == cx->sdp->md.jiinode) + ji_update(cx->sdp); fsck_blockmap_set(*sysinode, (*sysinode)->i_num.in_addr, filename, GFS2_BLKST_DINODE); ds.q = GFS2_BLKST_DINODE; @@ -1487,14 +1487,14 @@ static int check_system_inode(struct lgfs2_sbd *sdp, return -1; } } - if (is_dir(*sysinode, sdp->gfs1)) { + if (is_dir(*sysinode, cx->sdp->gfs1)) { struct block_count bc = {0};
sysdir_fxns.private = &bc; if ((*sysinode)->i_flags & GFS2_DIF_EXHASH) - pass1_check_metatree(*sysinode, &sysdir_fxns); + pass1_check_metatree(cx, *sysinode, &sysdir_fxns); else { - err = check_linear_dir(*sysinode, (*sysinode)->i_bh, + err = check_linear_dir(cx, *sysinode, (*sysinode)->i_bh, &sysdir_fxns); /* If we encountered an error in our directory check we should still call handle_ip, but return the @@ -1504,8 +1504,8 @@ static int check_system_inode(struct lgfs2_sbd *sdp, "directory entries.\n"), filename); } } - check_i_goal(sdp, *sysinode); - error = handle_ip(sdp, *sysinode); + check_i_goal(cx->sdp, *sysinode); + error = handle_ip(cx, *sysinode); return error ? error : err; }
@@ -1604,20 +1604,18 @@ static int build_quota(struct lgfs2_sbd *sdp) return 0; }
-static int check_system_inodes(struct lgfs2_sbd *sdp) +static int check_system_inodes(struct fsck_cx *cx) { + struct lgfs2_sbd *sdp = cx->sdp; int journal_count;
- /******************************************************************* - ******* Check the system inode integrity ************* - *******************************************************************/ /* Mark the master system dinode as a "dinode" in the block map. All other system dinodes in master will be taken care of by function resuscitate_metalist. But master won't since it has no parent.*/ if (!sdp->gfs1) { fsck_blockmap_set(sdp->master_dir, sdp->master_dir->i_num.in_addr, "master", GFS2_BLKST_DINODE); - if (check_system_inode(sdp, &sdp->master_dir, "master", + if (check_system_inode(cx, &sdp->master_dir, "master", lgfs2_build_master, 1, NULL, 1)) { stack; return -1; @@ -1627,40 +1625,40 @@ static int check_system_inodes(struct lgfs2_sbd *sdp) for master, since it has no parent. */ fsck_blockmap_set(sdp->md.rooti, sdp->md.rooti->i_num.in_addr, "root", GFS2_BLKST_DINODE); - if (check_system_inode(sdp, &sdp->md.rooti, "root", lgfs2_build_root, 1, + if (check_system_inode(cx, &sdp->md.rooti, "root", lgfs2_build_root, 1, NULL, 0)) { stack; return -1; } if (!sdp->gfs1 && - check_system_inode(sdp, &sdp->md.inum, "inum", build_inum, 0, + check_system_inode(cx, &sdp->md.inum, "inum", build_inum, 0, sdp->master_dir, 1)) { stack; return -1; } - if (check_system_inode(sdp, &sdp->md.statfs, "statfs", build_statfs, 0, + if (check_system_inode(cx, &sdp->md.statfs, "statfs", build_statfs, 0, sdp->master_dir, !sdp->gfs1)) { stack; return -1; } - if (check_system_inode(sdp, &sdp->md.jiinode, "jindex", build_jindex, + if (check_system_inode(cx, &sdp->md.jiinode, "jindex", build_jindex, (sdp->gfs1 ? 0 : 1), sdp->master_dir, !sdp->gfs1)) { stack; return -1; } - if (check_system_inode(sdp, &sdp->md.riinode, "rindex", build_rindex, + if (check_system_inode(cx, &sdp->md.riinode, "rindex", build_rindex, 0, sdp->master_dir, !sdp->gfs1)) { stack; return -1; } - if (check_system_inode(sdp, &sdp->md.qinode, "quota", build_quota, + if (check_system_inode(cx, &sdp->md.qinode, "quota", build_quota, 0, sdp->master_dir, !sdp->gfs1)) { stack; return -1; } if (!sdp->gfs1 && - check_system_inode(sdp, &sdp->md.pinode, "per_node", + check_system_inode(cx, &sdp->md.pinode, "per_node", build_per_node, 1, sdp->master_dir, 1)) { stack; return -1; @@ -1689,7 +1687,7 @@ static int check_system_inodes(struct lgfs2_sbd *sdp) char jname[16];
sprintf(jname, "journal%d", sdp->md.journals); - if (check_system_inode(sdp, &sdp->md.journal[sdp->md.journals], + if (check_system_inode(cx, &sdp->md.journal[sdp->md.journals], jname, build_a_journal, 0, sdp->md.jiinode, 1)) { stack; @@ -1700,9 +1698,10 @@ static int check_system_inodes(struct lgfs2_sbd *sdp) return 0; }
-static int pass1_process_bitmap(struct lgfs2_sbd *sdp, struct lgfs2_rgrp_tree *rgd, uint64_t *ibuf, unsigned n) +static int pass1_process_bitmap(struct fsck_cx *cx, struct lgfs2_rgrp_tree *rgd, uint64_t *ibuf, unsigned n) { struct lgfs2_buffer_head *bh; + struct lgfs2_sbd *sdp = cx->sdp; unsigned i; uint64_t block; struct lgfs2_inode *ip; @@ -1804,7 +1803,7 @@ static int pass1_process_bitmap(struct lgfs2_sbd *sdp, struct lgfs2_rgrp_tree *r log_err(_("Found invalid inode at block %"PRIu64" (0x%"PRIx64")\n"), block, block); check_n_fix_bitmap(sdp, rgd, block, 0, GFS2_BLKST_FREE); - } else if (handle_di(sdp, rgd, bh) < 0) { + } else if (handle_di(cx, rgd, bh) < 0) { stack; lgfs2_brelse(bh); gfs2_special_free(&gfs1_rindex_blks); @@ -1823,10 +1822,10 @@ static int pass1_process_bitmap(struct lgfs2_sbd *sdp, struct lgfs2_rgrp_tree *r return 0; }
-static int pass1_process_rgrp(struct lgfs2_sbd *sdp, struct lgfs2_rgrp_tree *rgd) +static int pass1_process_rgrp(struct fsck_cx *cx, struct lgfs2_rgrp_tree *rgd) { unsigned k, n, i; - uint64_t *ibuf = malloc(sdp->sd_bsize * GFS2_NBBY * sizeof(uint64_t)); + uint64_t *ibuf = malloc(cx->sdp->sd_bsize * GFS2_NBBY * sizeof(uint64_t)); int ret = 0;
if (ibuf == NULL) @@ -1836,7 +1835,7 @@ static int pass1_process_rgrp(struct lgfs2_sbd *sdp, struct lgfs2_rgrp_tree *rgd n = lgfs2_bm_scan(rgd, k, ibuf, GFS2_BLKST_DINODE);
if (n) { - ret = pass1_process_bitmap(sdp, rgd, ibuf, n); + ret = pass1_process_bitmap(cx, rgd, ibuf, n); if (ret) goto out; } @@ -1848,7 +1847,7 @@ static int pass1_process_rgrp(struct lgfs2_sbd *sdp, struct lgfs2_rgrp_tree *rgd resource group and mark them specially so we can count them properly in pass5. */ - if (!sdp->gfs1) + if (!cx->sdp->gfs1) continue;
n = lgfs2_bm_scan(rgd, k, ibuf, GFS2_BLKST_UNLINKED); @@ -1986,7 +1985,7 @@ int pass1(struct fsck_cx *cx) * the sweeps start that we won't find otherwise? */
/* Make sure the system inodes are okay & represented in the bitmap. */ - check_system_inodes(sdp); + check_system_inodes(cx);
/* So, do we do a depth first search starting at the root * inode, or use the rg bitmaps, or just read every fs block @@ -2020,7 +2019,7 @@ int pass1(struct fsck_cx *cx) gfs2_meta_rgrp);*/ }
- ret = pass1_process_rgrp(sdp, rgd); + ret = pass1_process_rgrp(cx, rgd); if (ret) goto out; } diff --git a/gfs2/fsck/pass1b.c b/gfs2/fsck/pass1b.c index 76c01fb3..9e78bd14 100644 --- a/gfs2/fsck/pass1b.c +++ b/gfs2/fsck/pass1b.c @@ -41,7 +41,7 @@ struct meta_blk_ref { int off; /* offset to the reference within the buffer */ };
-static int clone_data(struct lgfs2_inode *ip, uint64_t metablock, +static int clone_data(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t metablock, uint64_t block, void *private, struct lgfs2_buffer_head *bh, __be64 *ptr);
@@ -66,7 +66,7 @@ static void log_inode_reference(struct duptree *dt, osi_list_t *tmp, int inval) reftypestring); }
-static int findref_meta(struct iptr iptr, struct lgfs2_buffer_head **bh, int h, +static int findref_meta(struct fsck_cx *cx, struct iptr iptr, struct lgfs2_buffer_head **bh, int h, int *is_valid, int *was_duplicate, void *private) { *is_valid = 1; @@ -74,7 +74,7 @@ static int findref_meta(struct iptr iptr, struct lgfs2_buffer_head **bh, int h, return META_IS_GOOD; }
-static int findref_data(struct lgfs2_inode *ip, uint64_t metablock, +static int findref_data(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t metablock, uint64_t block, void *private, struct lgfs2_buffer_head *bh, __be64 *ptr) { @@ -89,7 +89,7 @@ static int findref_data(struct lgfs2_inode *ip, uint64_t metablock, return META_IS_GOOD; }
-static void clone_data_block(struct lgfs2_sbd *sdp, struct duptree *dt, +static void clone_data_block(struct fsck_cx *cx, struct duptree *dt, struct inode_with_dups *id) { struct meta_blk_ref metaref = { .block = dt->block, }; @@ -108,17 +108,17 @@ static void clone_data_block(struct lgfs2_sbd *sdp, struct duptree *dt, log_warn(_("The duplicate reference was not cloned.\n")); return; } - ip = fsck_load_inode(sdp, id->block_no); - check_metatree(ip, &find1ref_fxns); + ip = fsck_load_inode(cx->sdp, id->block_no); + check_metatree(cx, ip, &find1ref_fxns); if (metaref.metablock == 0) { log_err(_("Unable to clone data block.\n")); } else { if (metaref.metablock != id->block_no) - bh = lgfs2_bread(sdp, metaref.metablock); + bh = lgfs2_bread(cx->sdp, metaref.metablock); else bh = ip->i_bh; ptr = (__be64 *)bh->b_data + metaref.off; - clone_data(ip, 0, dt->block, &clone, bh, ptr); + clone_data(cx, ip, 0, dt->block, &clone, bh, ptr); if (metaref.metablock != id->block_no) lgfs2_brelse(bh); else @@ -175,7 +175,7 @@ static void revise_dup_handler(uint64_t dup_blk, struct dup_handler *dh) * acceptable_ref - Delete dinodes that reference the given block as anything * _but_ this type. Try to save references as this type. */ -static void resolve_dup_references(struct lgfs2_sbd *sdp, struct duptree *dt, +static void resolve_dup_references(struct fsck_cx *cx, struct duptree *dt, osi_list_t *ref_list, struct dup_handler *dh, int inval, int acceptable_ref) @@ -210,7 +210,7 @@ static void resolve_dup_references(struct lgfs2_sbd *sdp, struct duptree *dt, return;
this_ref = get_ref_type(id); - q = bitmap_type(sdp, id->block_no); + q = bitmap_type(cx->sdp, id->block_no); if (inval) log_warn( _("Invalid ")); /* FIXME: If we already found an acceptable reference to this @@ -238,7 +238,7 @@ static void resolve_dup_references(struct lgfs2_sbd *sdp, struct duptree *dt, it's data or metadata inside a journal, the reference should take priority over user dinodes that reference the block. */ - if (!found_good_ref && fsck_system_inode(sdp, id->block_no)) { + if (!found_good_ref && fsck_system_inode(cx->sdp, id->block_no)) { found_good_ref = 1; continue; /* don't delete the dinode */ } @@ -265,7 +265,7 @@ static void resolve_dup_references(struct lgfs2_sbd *sdp, struct duptree *dt, } } else if (acceptable_ref == REF_TYPES && this_ref == REF_AS_DATA) { - clone_data_block(sdp, dt, id); + clone_data_block(cx, dt, id); dup_listent_delete(dt, id); revise_dup_handler(dt->block, dh); continue; @@ -291,7 +291,7 @@ static void resolve_dup_references(struct lgfs2_sbd *sdp, struct duptree *dt, log_warn(_("Pass1b is deleting inode %"PRIu64" (0x%"PRIx64").\n"), id->block_no, id->block_no);
- ip = fsck_load_inode(sdp, id->block_no); + ip = fsck_load_inode(cx->sdp, id->block_no); /* If we've already deleted this dinode, don't try to delete it again. That could free blocks that used to be duplicate references that are now resolved (and gone). */ @@ -316,7 +316,7 @@ static void resolve_dup_references(struct lgfs2_sbd *sdp, struct duptree *dt, (dh->ref_inode_count)--; } else { /* Clear the EAs for the inode first */ - check_inode_eattr(ip, &pass1b_fxns_delete); + check_inode_eattr(cx, ip, &pass1b_fxns_delete); (dh->ref_inode_count)--; } /* If the reference was as metadata or data, we've got @@ -352,7 +352,7 @@ static void resolve_dup_references(struct lgfs2_sbd *sdp, struct duptree *dt, /* FIXME: other option should be to duplicate the block for each duplicate and point the metadata at the cloned blocks */ - check_metatree(ip, &pass1b_fxns_delete); + check_metatree(cx, ip, &pass1b_fxns_delete); } } /* Now we've got to go through and delete any other duplicate @@ -370,7 +370,7 @@ static void resolve_dup_references(struct lgfs2_sbd *sdp, struct duptree *dt, return; }
-static int clone_check_meta(struct iptr iptr, struct lgfs2_buffer_head **bh, int h, +static int clone_check_meta(struct fsck_cx *cx, struct iptr iptr, struct lgfs2_buffer_head **bh, int h, int *is_valid, int *was_duplicate, void *private) { struct lgfs2_inode *ip = iptr.ipt_ip; @@ -387,7 +387,7 @@ static int clone_check_meta(struct iptr iptr, struct lgfs2_buffer_head **bh, int * This function remembers the first reference to the specified block, and * clones all subsequent references to it (with permission). */ -static int clone_data(struct lgfs2_inode *ip, uint64_t metablock, +static int clone_data(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t metablock, uint64_t block, void *private, struct lgfs2_buffer_head *bh, __be64 *ptr) { @@ -452,7 +452,7 @@ static int clone_data(struct lgfs2_inode *ip, uint64_t metablock, * This function traverses the metadata tree of an inode, cloning all * but the first reference to a duplicate block reference. */ -static void clone_dup_ref_in_inode(struct lgfs2_inode *ip, struct duptree *dt) +static void clone_dup_ref_in_inode(struct fsck_cx *cx, struct lgfs2_inode *ip, struct duptree *dt) { int error; struct clone_target clonet = {.dup_block = dt->block, .first = 1}; @@ -465,7 +465,7 @@ static void clone_dup_ref_in_inode(struct lgfs2_inode *ip, struct duptree *dt) log_err(_("There are multiple references to block %"PRIu64" (0x%"PRIx64") in " "inode %"PRIu64" (0x%"PRIx64")\n"), ip->i_num.in_addr, ip->i_num.in_addr, dt->block, dt->block); - error = check_metatree(ip, &pass1b_fxns_clone); + error = check_metatree(cx, ip, &pass1b_fxns_clone); if (error) { log_err(_("Error cloning duplicate reference(s) to block %"PRIu64 " (0x%"PRIx64").\n"), dt->block, dt->block); @@ -512,9 +512,10 @@ static int set_ip_bitmap(struct lgfs2_inode *ip) return 0; }
-static void resolve_last_reference(struct lgfs2_sbd *sdp, struct duptree *dt, +static void resolve_last_reference(struct fsck_cx *cx, struct duptree *dt, enum dup_ref_type acceptable_ref) { + struct lgfs2_sbd *sdp = cx->sdp; struct lgfs2_inode *ip; struct inode_with_dups *id; osi_list_t *tmp; @@ -536,7 +537,7 @@ static void resolve_last_reference(struct lgfs2_sbd *sdp, struct duptree *dt, ip = fsck_load_inode(sdp, id->block_no);
if (dt->dup_flags & DUPFLAG_REF1_IS_DUPL) - clone_dup_ref_in_inode(ip, dt); + clone_dup_ref_in_inode(cx, ip, dt);
q = bitmap_type(sdp, id->block_no); if (q == GFS2_BLKST_FREE) { @@ -601,7 +602,7 @@ static void resolve_last_reference(struct lgfs2_sbd *sdp, struct duptree *dt, * This function should resolve and delete the duplicate block reference given, * iow dt. */ -static int handle_dup_blk(struct lgfs2_sbd *sdp, struct duptree *dt) +static int handle_dup_blk(struct fsck_cx *cx, struct duptree *dt) { osi_list_t *tmp; struct dup_handler dh = {0}; @@ -630,7 +631,7 @@ static int handle_dup_blk(struct lgfs2_sbd *sdp, struct duptree *dt) references to it as metadata. Dinodes with such references are clearly corrupt and need to be deleted. And if we're left with a single reference, problem solved. */ - bh = lgfs2_bread(sdp, dt->block); + bh = lgfs2_bread(cx->sdp, dt->block); cmagic = ((struct gfs2_meta_header *)(bh->b_data))->mh_magic; ctype = ((struct gfs2_meta_header *)(bh->b_data))->mh_type; lgfs2_brelse(bh); @@ -674,7 +675,7 @@ static int handle_dup_blk(struct lgfs2_sbd *sdp, struct duptree *dt) "(0x%"PRIx64") that were previously marked " "invalid.\n"), dt->block, dt->block); - resolve_dup_references(sdp, dt, &dt->ref_invinode_list, + resolve_dup_references(cx, dt, &dt->ref_invinode_list, &dh, 1, REF_TYPES); revise_dup_handler(dup_blk, &dh); } @@ -688,7 +689,7 @@ static int handle_dup_blk(struct lgfs2_sbd *sdp, struct duptree *dt) "Step 2: Eliminate references to block %"PRIu64" " "(0x%"PRIx64") that need the wrong block type.\n"), dt->block, dt->block); - resolve_dup_references(sdp, dt, &dt->ref_inode_list, &dh, 0, + resolve_dup_references(cx, dt, &dt->ref_inode_list, &dh, 0, acceptable_ref); revise_dup_handler(dup_blk, &dh); } @@ -701,7 +702,7 @@ static int handle_dup_blk(struct lgfs2_sbd *sdp, struct duptree *dt) "Step 3: Choose one reference to block %"PRIu64" " "(0x%"PRIx64") to keep.\n"), dt->block, dt->block); - resolve_dup_references(sdp, dt, &dt->ref_inode_list, &dh, 0, + resolve_dup_references(cx, dt, &dt->ref_inode_list, &dh, 0, REF_TYPES); revise_dup_handler(dup_blk, &dh); } @@ -709,7 +710,7 @@ static int handle_dup_blk(struct lgfs2_sbd *sdp, struct duptree *dt) reference, use it to determine the correct block type for our blockmap and bitmap. */ if (dh.ref_inode_count == 1 && !osi_list_empty(&dt->ref_inode_list)) { - resolve_last_reference(sdp, dt, acceptable_ref); + resolve_last_reference(cx, dt, acceptable_ref); } else { /* They may have answered no and not fixed all references. */ log_debug( _("All duplicate references to block 0x%"PRIx64" were processed.\n"), dup_blk); @@ -723,20 +724,20 @@ static int handle_dup_blk(struct lgfs2_sbd *sdp, struct duptree *dt) dup_blk, dup_blk); if (dh.dt) dup_delete(dh.dt); - check_n_fix_bitmap(sdp, NULL, dup_blk, 0, + check_n_fix_bitmap(cx->sdp, NULL, dup_blk, 0, GFS2_BLKST_FREE); } } return 0; }
-static int check_leaf_refs(struct lgfs2_inode *ip, uint64_t block, +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); }
-static int check_metalist_refs(struct iptr iptr, struct lgfs2_buffer_head **bh, int h, +static int check_metalist_refs(struct fsck_cx *cx, struct iptr iptr, struct lgfs2_buffer_head **bh, int h, int *is_valid, int *was_duplicate, void *private) { struct lgfs2_inode *ip = iptr.ipt_ip; @@ -747,14 +748,14 @@ static int check_metalist_refs(struct iptr iptr, struct lgfs2_buffer_head **bh, return add_duplicate_ref(ip, block, REF_AS_META, 1, INODE_VALID); }
-static int check_data_refs(struct lgfs2_inode *ip, uint64_t metablock, +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); }
-static int check_eattr_indir_refs(struct lgfs2_inode *ip, uint64_t block, +static int check_eattr_indir_refs(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t block, uint64_t parent, struct lgfs2_buffer_head **bh, void *private) { @@ -768,7 +769,7 @@ static int check_eattr_indir_refs(struct lgfs2_inode *ip, uint64_t block, return error; }
-static int check_eattr_leaf_refs(struct lgfs2_inode *ip, uint64_t block, +static int check_eattr_leaf_refs(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t block, uint64_t parent, struct lgfs2_buffer_head **bh, void *private) { @@ -781,7 +782,7 @@ static int check_eattr_leaf_refs(struct lgfs2_inode *ip, uint64_t block, return error; }
-static int check_eattr_entry_refs(struct lgfs2_inode *ip, +static int check_eattr_entry_refs(struct fsck_cx *cx, struct lgfs2_inode *ip, struct lgfs2_buffer_head *leaf_bh, struct gfs2_ea_header *ea_hdr, struct gfs2_ea_header *ea_hdr_prev, @@ -790,7 +791,7 @@ static int check_eattr_entry_refs(struct lgfs2_inode *ip, return 0; }
-static int check_eattr_extentry_refs(struct lgfs2_inode *ip, int i, +static int check_eattr_extentry_refs(struct fsck_cx *cx, struct lgfs2_inode *ip, int i, __be64 *ea_data_ptr, struct lgfs2_buffer_head *leaf_bh, uint32_t tot_ealen, @@ -811,7 +812,7 @@ static int check_eattr_extentry_refs(struct lgfs2_inode *ip, int i,
/* Finds all references to duplicate blocks in the metadata */ /* Finds all references to duplicate blocks in the metadata */ -static int find_block_ref(struct lgfs2_sbd *sdp, uint64_t inode) +static int find_block_ref(struct fsck_cx *cx, uint64_t inode) { struct lgfs2_inode *ip; int error = 0; @@ -826,12 +827,12 @@ static int find_block_ref(struct lgfs2_sbd *sdp, uint64_t inode) .check_eattr_extentry = check_eattr_extentry_refs, };
- ip = fsck_load_inode(sdp, inode); /* lgfs2_bread, inode_get */ + ip = fsck_load_inode(cx->sdp, inode); /* lgfs2_bread, inode_get */
/* double-check the meta header just to be sure it's metadata */ if (ip->i_magic != GFS2_MAGIC || ip->i_mh_type != GFS2_METATYPE_DI) { - if (!sdp->gfs1) + if (!cx->sdp->gfs1) log_debug(_("Block %"PRIu64" (0x%"PRIx64") is not a dinode.\n"), inode, inode); error = 1; @@ -841,13 +842,13 @@ static int find_block_ref(struct lgfs2_sbd *sdp, uint64_t inode) 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); + error = check_metatree(cx, ip, &find_refs); if (error < 0) stack;
/* Check for ea references in the inode */ if (!error) - error = check_inode_eattr(ip, &find_refs); + error = check_inode_eattr(cx, ip, &find_refs);
out: fsck_inode_put(&ip); /* out, lgfs2_brelse, free */ @@ -900,7 +901,7 @@ int pass1b(struct fsck_cx *cx) }
display_progress(i); - if (find_block_ref(sdp, i) < 0) { + if (find_block_ref(cx, i) < 0) { stack; rc = FSCK_ERROR; goto out; @@ -915,7 +916,7 @@ out: while ((n = osi_first(&dup_blocks))) { dt = (struct duptree *)n; if (!skip_this_pass && !rc) /* no error & not asked to skip the rest */ - handle_dup_blk(sdp, dt); + handle_dup_blk(cx, dt); } return rc; } diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c index 62f84516..e5734fd6 100644 --- a/gfs2/fsck/pass2.c +++ b/gfs2/fsck/pass2.c @@ -95,14 +95,14 @@ static int set_dotdot_dir(struct lgfs2_sbd *sdp, uint64_t childblock, struct lgf return 0; }
-static int check_eattr_indir(struct lgfs2_inode *ip, uint64_t block, +static int check_eattr_indir(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t block, uint64_t parent, struct lgfs2_buffer_head **bh, void *private) { *bh = lgfs2_bread(ip->i_sbd, block); return 0; } -static int check_eattr_leaf(struct lgfs2_inode *ip, uint64_t block, +static int check_eattr_leaf(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t block, uint64_t parent, struct lgfs2_buffer_head **bh, void *private) { @@ -245,7 +245,7 @@ static int hash_table_max(int lindex, struct lgfs2_inode *ip, lindex - 1; }
-static int check_leaf_depth(struct lgfs2_inode *ip, uint64_t leaf_no, +static int check_leaf_depth(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t leaf_no, int ref_count, struct lgfs2_buffer_head *lbh) { struct gfs2_leaf *leaf = (struct gfs2_leaf *)lbh->b_data; @@ -290,7 +290,7 @@ static int check_leaf_depth(struct lgfs2_inode *ip, uint64_t leaf_no, * Returns: 1 if the dirent is to be removed, 0 if it needs to be kept, * or -1 on error */ -static int wrong_leaf(struct lgfs2_inode *ip, struct lgfs2_inum *entry, +static int wrong_leaf(struct fsck_cx *cx, struct lgfs2_inode *ip, struct lgfs2_inum *entry, const char *tmp_name, int *lindex, int lindex_max, int hash_index, struct lgfs2_buffer_head *bh, struct dir_status *ds, struct gfs2_dirent *dent, @@ -332,7 +332,7 @@ static int wrong_leaf(struct lgfs2_inode *ip, struct lgfs2_inum *entry, break; } dest_lbh = lgfs2_bread(sdp, planned_leaf); - check_leaf_depth(ip, planned_leaf, dest_ref, dest_lbh); + check_leaf_depth(cx, ip, planned_leaf, dest_ref, dest_lbh); lgfs2_brelse(dest_lbh); free(tbl);
@@ -420,7 +420,7 @@ static int wrong_leaf(struct lgfs2_inode *ip, struct lgfs2_inum *entry, * * Returns: 1 means corruption, nuke the dentry, 0 means checks pass */ -static int basic_dentry_checks(struct lgfs2_inode *ip, struct gfs2_dirent *dent, +static int basic_dentry_checks(struct fsck_cx *cx, struct lgfs2_inode *ip, struct gfs2_dirent *dent, struct lgfs2_inum *entry, const char *tmp_name, uint32_t *count, struct lgfs2_dirent *d, struct dir_status *ds, int *q, @@ -562,7 +562,7 @@ static int basic_dentry_checks(struct lgfs2_inode *ip, struct gfs2_dirent *dent, entry_ip = ip; else entry_ip = fsck_load_inode(sdp, entry->in_addr); - check_inode_eattr(entry_ip, &delete_eattrs); + check_inode_eattr(cx, entry_ip, &delete_eattrs); if (entry_ip != ip) fsck_inode_put(&entry_ip); return 1; @@ -614,7 +614,7 @@ static int basic_dentry_checks(struct lgfs2_inode *ip, struct gfs2_dirent *dent, return 0; }
-static int dirref_find(struct lgfs2_inode *ip, struct gfs2_dirent *dent, +static int dirref_find(struct fsck_cx *cx, struct lgfs2_inode *ip, struct gfs2_dirent *dent, struct gfs2_dirent *prev, struct lgfs2_buffer_head *bh, char *filename, uint32_t *count, int *lindex, void *private) @@ -678,8 +678,7 @@ out: * the same, that's an error, and we need to delete the damaged original * dentry, since we failed to detect the problem earlier. */ -static int check_suspicious_dirref(struct lgfs2_sbd *sdp, - struct lgfs2_inum *entry) +static int check_suspicious_dirref(struct fsck_cx *cx, struct lgfs2_inum *entry) { struct osi_node *tmp, *next = NULL; struct dir_info *dt; @@ -700,12 +699,12 @@ static int check_suspicious_dirref(struct lgfs2_sbd *sdp, dirblk = dt->dinode.in_addr; if (skip_this_pass || fsck_abort) /* asked to skip the rest */ break; - ip = fsck_load_inode(sdp, dirblk); + ip = fsck_load_inode(cx->sdp, dirblk); if (ip == NULL) { stack; return FSCK_ERROR; } - error = check_dir(sdp, ip, &dirref_hunt); + error = check_dir(cx, ip, &dirref_hunt); fsck_inode_put(&ip); /* Error just means we found the dentry and dealt with it. */ if (error) @@ -718,7 +717,7 @@ static int check_suspicious_dirref(struct lgfs2_sbd *sdp,
/* FIXME: should maybe refactor this a bit - but need to deal with * FIXMEs internally first */ -static int check_dentry(struct lgfs2_inode *ip, struct gfs2_dirent *dent, +static int check_dentry(struct fsck_cx *cx, struct lgfs2_inode *ip, struct gfs2_dirent *dent, struct gfs2_dirent *prev_de, struct lgfs2_buffer_head *bh, char *filename, uint32_t *count, int *lindex, void *priv) @@ -747,7 +746,7 @@ static int check_dentry(struct lgfs2_inode *ip, struct gfs2_dirent *dent, else strncpy(tmp_name, filename, MAX_FILENAME - 1);
- error = basic_dentry_checks(ip, dent, &entry, tmp_name, count, &d, + error = basic_dentry_checks(cx, ip, dent, &entry, tmp_name, count, &d, ds, &q, bh, &isdir); if (error) goto nuke_dentry; @@ -769,7 +768,7 @@ static int check_dentry(struct lgfs2_inode *ip, struct gfs2_dirent *dent, entry_ip = ip; else entry_ip = fsck_load_inode(sdp, entry.in_addr); - check_inode_eattr(entry_ip, &delete_eattrs); + check_inode_eattr(cx, entry_ip, &delete_eattrs); if (entry_ip != ip) fsck_inode_put(&entry_ip); goto nuke_dentry; @@ -795,7 +794,7 @@ static int check_dentry(struct lgfs2_inode *ip, struct gfs2_dirent *dent, entry_ip = ip; else entry_ip = fsck_load_inode(sdp, entry.in_addr); - check_inode_eattr(entry_ip, &delete_eattrs); + check_inode_eattr(cx, entry_ip, &delete_eattrs); if (entry_ip != ip) fsck_inode_put(&entry_ip); goto nuke_dentry; @@ -822,7 +821,7 @@ static int check_dentry(struct lgfs2_inode *ip, struct gfs2_dirent *dent, entry_ip = ip; else entry_ip = fsck_load_inode(sdp, entry.in_addr); - check_inode_eattr(entry_ip, &delete_eattrs); + check_inode_eattr(cx, entry_ip, &delete_eattrs); if (entry_ip != ip) fsck_inode_put(&entry_ip);
@@ -840,7 +839,7 @@ static int check_dentry(struct lgfs2_inode *ip, struct gfs2_dirent *dent, entry_ip = ip; else entry_ip = fsck_load_inode(sdp, entry.in_addr); - check_inode_eattr(entry_ip, &delete_eattrs); + check_inode_eattr(cx, entry_ip, &delete_eattrs); if (entry_ip != ip) fsck_inode_put(&entry_ip);
@@ -867,7 +866,7 @@ static int check_dentry(struct lgfs2_inode *ip, struct gfs2_dirent *dent, if (hash_index < *lindex || hash_index > lindex_max) { int nuke_dent;
- nuke_dent = wrong_leaf(ip, &entry, tmp_name, lindex, + nuke_dent = wrong_leaf(cx, ip, &entry, tmp_name, lindex, lindex_max, hash_index, bh, ds, dent, &d, prev_de, count, q); if (nuke_dent) @@ -902,7 +901,7 @@ 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) { - error = check_suspicious_dirref(sdp, &entry); + error = check_suspicious_dirref(cx, &entry); } 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, &d, bh) == 1) @@ -1070,7 +1069,7 @@ static void pad_with_leafblks(struct lgfs2_inode *ip, __be64 *tbl, * directory entries to lost+found so we don't overwrite the good leaf. Then * we need to pad the gap we leave. */ -static int lost_leaf(struct lgfs2_inode *ip, __be64 *tbl, uint64_t leafno, +static int lost_leaf(struct fsck_cx *cx, struct lgfs2_inode *ip, __be64 *tbl, uint64_t leafno, int ref_count, int lindex, struct lgfs2_buffer_head *bh) { char *filename; @@ -1115,7 +1114,7 @@ static int lost_leaf(struct lgfs2_inode *ip, __be64 *tbl, uint64_t leafno, struct dir_status ds = {0}; int q = 0;
- error = basic_dentry_checks(ip, dent, &de.dr_inum, + error = basic_dentry_checks(cx, ip, dent, &de.dr_inum, tmp_name, &count, &de, &ds, &q, bh, &isdir); if (error) { @@ -1164,7 +1163,7 @@ static int lost_leaf(struct lgfs2_inode *ip, __be64 *tbl, uint64_t leafno, return 1; }
-static int basic_check_dentry(struct lgfs2_inode *ip, struct gfs2_dirent *dent, +static int basic_check_dentry(struct fsck_cx *cx, struct lgfs2_inode *ip, struct gfs2_dirent *dent, struct gfs2_dirent *prev_de, struct lgfs2_buffer_head *bh, char *filename, uint32_t *count, int *lindex, void *priv) @@ -1191,7 +1190,7 @@ static int basic_check_dentry(struct lgfs2_inode *ip, struct gfs2_dirent *dent, else strncpy(tmp_name, filename, MAX_FILENAME - 1);
- error = basic_dentry_checks(ip, dent, &entry, tmp_name, count, de, + error = basic_dentry_checks(cx, ip, dent, &entry, tmp_name, count, de, ds, &q, bh, &isdir); if (error) { lgfs2_dirent2_del(ip, bh, prev_de, dent); @@ -1209,7 +1208,7 @@ static int basic_check_dentry(struct lgfs2_inode *ip, struct gfs2_dirent *dent, * so that they replace the bad ones. We have to hack up the old * leaf a bit, but it's better than deleting the whole directory, * which is what used to happen before. */ -static int pass2_repair_leaf(struct lgfs2_inode *ip, uint64_t *leaf_no, +static int pass2_repair_leaf(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t *leaf_no, int lindex, int ref_count, const char *msg) { int new_leaf_blks = 0, error, refs; @@ -1287,7 +1286,7 @@ static struct metawalk_fxns leafck_fxns = { * * Returns: 0 - no changes made, or X if changes were made */ -static int fix_hashtable(struct lgfs2_inode *ip, __be64 *tbl, unsigned hsize, +static int fix_hashtable(struct fsck_cx *cx, struct lgfs2_inode *ip, __be64 *tbl, unsigned hsize, uint64_t leafblk, int lindex, uint32_t proper_start, int len, int *proper_len, int factor) { @@ -1311,7 +1310,7 @@ static int fix_hashtable(struct lgfs2_inode *ip, __be64 *tbl, unsigned hsize,
memset(&leaf, 0, sizeof(leaf)); leaf_no = leafblk; - error = check_leaf(ip, lindex, &leafck_fxns, &leaf_no, &leaf, &len); + error = check_leaf(cx, ip, lindex, &leafck_fxns, &leaf_no, &leaf, &len); if (error) { log_debug("Leaf repaired while fixing the hash table.\n"); error = 0; @@ -1323,7 +1322,7 @@ static int fix_hashtable(struct lgfs2_inode *ip, __be64 *tbl, unsigned hsize, log_err(_("This leaf block's depth (%d) is too big for this " "dinode's depth (%d)\n"), leaf.lf_depth, ip->i_depth); - error = lost_leaf(ip, tbl, leafblk, len, lindex, lbh); + error = lost_leaf(cx, ip, tbl, leafblk, len, lindex, lbh); lgfs2_brelse(lbh); return error; } @@ -1358,7 +1357,7 @@ static int fix_hashtable(struct lgfs2_inode *ip, __be64 *tbl, unsigned hsize, "bounds for where it appears in the hash table " "(%d - %d)\n"), hash_index, lindex, lindex + *proper_len); - error = lost_leaf(ip, tbl, leafblk, len, lindex, lbh); + error = lost_leaf(cx, ip, tbl, leafblk, len, lindex, lbh); lgfs2_brelse(lbh); return error; } @@ -1385,7 +1384,7 @@ static int fix_hashtable(struct lgfs2_inode *ip, __be64 *tbl, unsigned hsize, log_err(_("Leaf block should start at 0x%x, but it appears at " "0x%x in the hash table.\n"), leaf_proper_start, proper_start); - error = lost_leaf(ip, tbl, leafblk, len, lindex, lbh); + error = lost_leaf(cx, ip, tbl, leafblk, len, lindex, lbh); lgfs2_brelse(lbh); return error; } @@ -1579,7 +1578,7 @@ static int check_hash_tbl_dups(struct lgfs2_inode *ip, __be64 *tbl, * we may need to reference leaf blocks to fix it, which means we need * to check and/or fix a leaf block along the way. */ -static int check_hash_tbl(struct lgfs2_inode *ip, __be64 *tbl, +static int check_hash_tbl(struct fsck_cx *cx, struct lgfs2_inode *ip, __be64 *tbl, unsigned hsize, void *private) { int error = 0; @@ -1660,7 +1659,7 @@ static int check_hash_tbl(struct lgfs2_inode *ip, __be64 *tbl, log_debug(_("lindex 0x%x is not a proper starting " "point for leaf %"PRIu64" (0x%"PRIx64"): 0x%"PRIx32"\n"), lindex, leafblk, leafblk, proper_start); - changes = fix_hashtable(ip, tbl, hsize, leafblk, + changes = fix_hashtable(cx, ip, tbl, hsize, leafblk, lindex, proper_start, len, &proper_len, factor); /* Check if we need to split more leaf blocks */ @@ -1690,7 +1689,7 @@ static int check_hash_tbl(struct lgfs2_inode *ip, __be64 *tbl, leaf.lf_depth > ip->i_depth) leaf.lf_depth = factor; lgfs2_brelse(lbh); - changes = fix_hashtable(ip, tbl, hsize, leafblk, + changes = fix_hashtable(cx, ip, tbl, hsize, leafblk, lindex, lindex, len, &proper_len, leaf.lf_depth); /* If fixing the hash table made changes, we can no @@ -1734,7 +1733,7 @@ static int check_hash_tbl(struct lgfs2_inode *ip, __be64 *tbl, "leaf %"PRIu64" (0x%"PRIx64"): 0x%x\n"), len, leafblk, leafblk, proper_len); - changes = fix_hashtable(ip, tbl, hsize, + changes = fix_hashtable(cx, ip, tbl, hsize, leafblk, lindex, lindex, len, &proper_len, @@ -1763,7 +1762,7 @@ static struct metawalk_fxns pass2_fxns = { .repair_leaf = pass2_repair_leaf, };
-static int check_metalist_qc(struct iptr iptr, struct lgfs2_buffer_head **bh, int h, +static int check_metalist_qc(struct fsck_cx *cx, struct iptr iptr, struct lgfs2_buffer_head **bh, int h, int *is_valid, int *was_duplicate, void *private) { struct lgfs2_inode *ip = iptr.ipt_ip; @@ -1775,7 +1774,7 @@ static int check_metalist_qc(struct iptr iptr, struct lgfs2_buffer_head **bh, in return META_IS_GOOD; }
-static int check_data_qc(struct lgfs2_inode *ip, uint64_t metablock, +static int check_data_qc(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t metablock, uint64_t block, void *private, struct lgfs2_buffer_head *bbh, __be64 *ptr) { @@ -1813,7 +1812,7 @@ static struct metawalk_fxns quota_change_fxns = { * @builder - a rebuild function for the file * * Returns: 0 if all went well, else error. */ -static int check_pernode_for(int x, struct lgfs2_inode *pernode, const char *fn, +static int check_pernode_for(struct fsck_cx *cx, int x, struct lgfs2_inode *pernode, const char *fn, size_t filelen, int multiple, struct metawalk_fxns *pass, int builder(struct lgfs2_inode *per_node, @@ -1845,13 +1844,13 @@ static int check_pernode_for(int x, struct lgfs2_inode *pernode, const char *fn, goto build_it; } if (pass) { - error = check_metatree(ip, pass); + error = check_metatree(cx, ip, pass); if (!error) goto out_good; log_err(_("System file %s has bad contents.\n"), fn); if (!query( _("Delete and rebuild the system file? (y/n) "))) goto out_good; - check_metatree(ip, &pass2_fxns_delete); + check_metatree(cx, ip, &pass2_fxns_delete); fsck_inode_put(&ip); lgfs2_dirent_del(pernode, fn, strlen(fn)); goto build_it; @@ -1907,7 +1906,7 @@ static int build_quota_change(struct lgfs2_inode *per_node, unsigned int n)
/* Check system directory inode */ /* Should work for all system directories: root, master, jindex, per_node */ -static int check_system_dir(struct lgfs2_inode *sysinode, const char *dirname, +static int check_system_dir(struct fsck_cx *cx, struct lgfs2_inode *sysinode, const char *dirname, int builder(struct lgfs2_sbd *sdp)) { uint64_t iblock = 0; @@ -1928,13 +1927,13 @@ static int check_system_dir(struct lgfs2_inode *sysinode, const char *dirname, pass2_fxns.private = (void *) &ds; if (ds.q == GFS2_BLKST_FREE) { /* First check that the directory's metatree is valid */ - error = check_metatree(sysinode, &pass2_fxns); + error = check_metatree(cx, sysinode, &pass2_fxns); if (error < 0) { stack; return error; } } - error = check_dir(sysinode->i_sbd, sysinode, &pass2_fxns); + error = check_dir(cx, sysinode, &pass2_fxns); if (skip_this_pass || fsck_abort) /* if asked to skip the rest */ return FSCK_OK; if (error < 0) { @@ -1944,7 +1943,7 @@ static int check_system_dir(struct lgfs2_inode *sysinode, const char *dirname, if (error > 0) fsck_bitmap_set(sysinode, iblock, dirname, GFS2_BLKST_FREE);
- if (check_inode_eattr(sysinode, &pass2_fxns)) { + if (check_inode_eattr(cx, sysinode, &pass2_fxns)) { stack; return -1; } @@ -1988,13 +1987,13 @@ static int check_system_dir(struct lgfs2_inode *sysinode, const char *dirname, /* Make sure all the per_node files are there, and valid */ for (j = 0; j < sysinode->i_sbd->md.journals; j++) { sprintf(fn, "inum_range%d", j); - error += check_pernode_for(j, sysinode, fn, 16, 0, + error += check_pernode_for(cx, j, sysinode, fn, 16, 0, NULL, build_inum_range); sprintf(fn, "statfs_change%d", j); - error += check_pernode_for(j, sysinode, fn, 24, 0, + error += check_pernode_for(cx, j, sysinode, fn, 24, 0, NULL, build_statfs_change); sprintf(fn, "quota_change%d", j); - error += check_pernode_for(j, sysinode, fn, 1048576, 1, + error += check_pernode_for(cx, j, sysinode, fn, 1048576, 1, "a_change_fxns, build_quota_change); } @@ -2018,14 +2017,14 @@ static inline int is_system_dir(struct lgfs2_sbd *sdp, uint64_t block) return 0; }
-static int pass2_check_dir(struct lgfs2_sbd *sdp, struct lgfs2_inode *ip) +static int pass2_check_dir(struct fsck_cx *cx, struct lgfs2_inode *ip) { uint64_t dirblk = ip->i_num.in_addr; struct dir_status ds = {0}; int error;
pass2_fxns.private = &ds; - error = check_dir(sdp, ip, &pass2_fxns); + error = check_dir(cx, ip, &pass2_fxns); if (skip_this_pass || fsck_abort) /* if asked to skip the rest */ return FSCK_OK; if (error < 0) { @@ -2042,7 +2041,7 @@ static int pass2_check_dir(struct lgfs2_sbd *sdp, struct lgfs2_inode *ip) } if (query(_("Remove directory entry for bad inode %"PRIu64" (0x%"PRIx64") in %"PRIu64" (0x%"PRIx64")? (y/n)"), dirblk, dirblk, di->treewalk_parent, di->treewalk_parent)) { - error = remove_dentry_from_dir(sdp, di->treewalk_parent, dirblk); + error = remove_dentry_from_dir(cx, di->treewalk_parent, dirblk); if (error < 0) { stack; return FSCK_ERROR; @@ -2057,7 +2056,7 @@ static int pass2_check_dir(struct lgfs2_sbd *sdp, struct lgfs2_inode *ip)
log_debug(_("Directory block %"PRIu64" (0x%"PRIx64") is now marked as 'invalid'\n"), dirblk, dirblk); - check_n_fix_bitmap(sdp, ip->i_rgd, dirblk, 0, GFS2_BLKST_FREE); + check_n_fix_bitmap(cx->sdp, ip->i_rgd, dirblk, 0, GFS2_BLKST_FREE); }
if (!ds.dotdir) { @@ -2067,7 +2066,7 @@ static int pass2_check_dir(struct lgfs2_sbd *sdp, struct lgfs2_inode *ip) if (query( _("Is it okay to add '.' entry? (y/n) "))) { struct lgfs2_inum no = ip->i_num; error = lgfs2_dir_add(ip, ".", 1, &no, - (sdp->gfs1 ? GFS_FILE_DIR : DT_DIR)); + (cx->sdp->gfs1 ? GFS_FILE_DIR : DT_DIR)); if (error) { log_err(_("Error adding directory %s: %s\n"), "'.'", strerror(errno)); @@ -2117,27 +2116,27 @@ int pass2(struct fsck_cx *cx)
/* Check all the system directory inodes. */ if (!sdp->gfs1 && - check_system_dir(sdp->md.jiinode, "jindex", build_jindex)) { + check_system_dir(cx, sdp->md.jiinode, "jindex", build_jindex)) { stack; return FSCK_ERROR; } if (skip_this_pass || fsck_abort) /* if asked to skip the rest */ return FSCK_OK; if (!sdp->gfs1 && - check_system_dir(sdp->md.pinode, "per_node", build_per_node)) { + check_system_dir(cx, sdp->md.pinode, "per_node", build_per_node)) { stack; return FSCK_ERROR; } if (skip_this_pass || fsck_abort) /* if asked to skip the rest */ return FSCK_OK; if (!sdp->gfs1 && - check_system_dir(sdp->master_dir, "master", lgfs2_build_master)) { + check_system_dir(cx, sdp->master_dir, "master", lgfs2_build_master)) { stack; return FSCK_ERROR; } if (skip_this_pass || fsck_abort) /* if asked to skip the rest */ return FSCK_OK; - if (check_system_dir(sdp->md.rooti, "root", lgfs2_build_root)) { + if (check_system_dir(cx, sdp->md.rooti, "root", lgfs2_build_root)) { stack; return FSCK_ERROR; } @@ -2173,7 +2172,7 @@ int pass2(struct fsck_cx *cx) stack; return FSCK_ERROR; } - error = pass2_check_dir(sdp, ip); + error = pass2_check_dir(cx, ip); fsck_inode_put(&ip);
if (skip_this_pass || fsck_abort) diff --git a/gfs2/fsck/pass3.c b/gfs2/fsck/pass3.c index 94d91d19..0495382c 100644 --- a/gfs2/fsck/pass3.c +++ b/gfs2/fsck/pass3.c @@ -54,9 +54,9 @@ static int attach_dotdot_to(struct lgfs2_sbd *sdp, uint64_t newdotdot, return 0; }
-static struct dir_info *mark_and_return_parent(struct lgfs2_sbd *sdp, - struct dir_info *di) +static struct dir_info *mark_and_return_parent(struct fsck_cx *cx, struct dir_info *di) { + struct lgfs2_sbd *sdp = cx->sdp; struct dir_info *pdi; int q_dotdot, q_treewalk; int error = 0; @@ -129,7 +129,7 @@ static struct dir_info *mark_and_return_parent(struct lgfs2_sbd *sdp, log_err( _("Directory entry to invalid inode remains\n")); return NULL; } - error = remove_dentry_from_dir(sdp, di->treewalk_parent, di->dinode.in_addr); + error = remove_dentry_from_dir(cx, di->treewalk_parent, di->dinode.in_addr); if (error < 0) { stack; return NULL; @@ -217,7 +217,7 @@ int pass3(struct fsck_cx *cx) * param */ if (skip_this_pass || fsck_abort) /* if asked to skip the rest */ return FSCK_OK; - tdi = mark_and_return_parent(sdp, di); + tdi = mark_and_return_parent(cx, di);
if (tdi) { log_debug(_("Directory at block %"PRIu64" (0x%"PRIx64") connected\n"), diff --git a/gfs2/fsck/pass4.c b/gfs2/fsck/pass4.c index 5862ca0f..b3441cf9 100644 --- a/gfs2/fsck/pass4.c +++ b/gfs2/fsck/pass4.c @@ -49,9 +49,10 @@ static int fix_link_count(uint32_t counted_links, struct lgfs2_inode *ip) * * Returns: 1 if caller should do "continue", 0 if not. */ -static int handle_unlinked(struct lgfs2_sbd *sdp, uint64_t no_addr, +static int handle_unlinked(struct fsck_cx *cx, uint64_t no_addr, uint32_t *counted_links, int *lf_addition) { + struct lgfs2_sbd *sdp = cx->sdp; struct lgfs2_inode *ip; int q;
@@ -63,8 +64,8 @@ static int handle_unlinked(struct lgfs2_sbd *sdp, uint64_t no_addr, no_addr, no_addr); if (query(_("Delete unlinked inode with bad blocks? (y/n) "))) { ip = fsck_load_inode(sdp, no_addr); - check_inode_eattr(ip, &pass4_fxns_delete); - check_metatree(ip, &pass4_fxns_delete); + check_inode_eattr(cx, ip, &pass4_fxns_delete); + check_metatree(cx, ip, &pass4_fxns_delete); fsck_bitmap_set(ip, no_addr, _("bad unlinked"), GFS2_BLKST_FREE); fsck_inode_put(&ip); @@ -78,8 +79,8 @@ static int handle_unlinked(struct lgfs2_sbd *sdp, uint64_t no_addr, no_addr, no_addr, q); ip = fsck_load_inode(sdp, no_addr); if (query(_("Delete unlinked inode? (y/n) "))) { - check_inode_eattr(ip, &pass4_fxns_delete); - check_metatree(ip, &pass4_fxns_delete); + check_inode_eattr(cx, ip, &pass4_fxns_delete); + check_metatree(cx, ip, &pass4_fxns_delete); fsck_bitmap_set(ip, no_addr, _("invalid unlinked"), GFS2_BLKST_FREE); fsck_inode_put(&ip); @@ -160,8 +161,9 @@ static int adjust_lf_links(int lf_addition) return 0; }
-static int scan_inode_list(struct lgfs2_sbd *sdp) +static int scan_inode_list(struct fsck_cx *cx) { + struct lgfs2_sbd *sdp = cx->sdp; struct osi_node *tmp, *next = NULL; struct inode_info *ii; int lf_addition = 0; @@ -180,7 +182,7 @@ static int scan_inode_list(struct lgfs2_sbd *sdp) (ii->num.in_addr == sdp->md.statfs->i_num.in_addr))) continue; if (ii->counted_links == 0) { - if (handle_unlinked(sdp, ii->num.in_addr, + if (handle_unlinked(cx, ii->num.in_addr, &ii->counted_links, &lf_addition)) continue; } /* if (ii->counted_links == 0) */ @@ -195,8 +197,9 @@ static int scan_inode_list(struct lgfs2_sbd *sdp) return adjust_lf_links(lf_addition); }
-static int scan_dir_list(struct lgfs2_sbd *sdp) +static int scan_dir_list(struct fsck_cx *cx) { + struct lgfs2_sbd *sdp = cx->sdp; struct osi_node *tmp, *next = NULL; struct dir_info *di; int lf_addition = 0; @@ -213,7 +216,7 @@ static int scan_dir_list(struct lgfs2_sbd *sdp) di->dinode.in_addr == sdp->md.jiinode->i_num.in_addr) continue; if (di->counted_links == 0) { - if (handle_unlinked(sdp, di->dinode.in_addr, + if (handle_unlinked(cx, di->dinode.in_addr, &di->counted_links, &lf_addition)) continue; } else if (di->di_nlink != di->counted_links) { @@ -227,7 +230,7 @@ static int scan_dir_list(struct lgfs2_sbd *sdp) return adjust_lf_links(lf_addition); }
-static int scan_nlink1_list(struct lgfs2_sbd *sdp) +static int scan_nlink1_list(struct fsck_cx *cx) { uint64_t blk; uint32_t counted_links; @@ -245,8 +248,7 @@ static int scan_nlink1_list(struct lgfs2_sbd *sdp) to lost+found. In this case, however, there's not a real count, so we fake it out to be 1. */ counted_links = 1; - if (handle_unlinked(sdp, blk, &counted_links, - &lf_addition)) + if (handle_unlinked(cx, blk, &counted_links, &lf_addition)) continue; } } @@ -264,23 +266,21 @@ static int scan_nlink1_list(struct lgfs2_sbd *sdp) */ int pass4(struct fsck_cx *cx) { - struct lgfs2_sbd *sdp = cx->sdp; - if (lf_dip) log_debug( _("At beginning of pass4, lost+found entries is %u\n"), lf_dip->i_entries); log_info( _("Checking inode reference counts: multi-links.\n")); - if (scan_inode_list(sdp)) { + if (scan_inode_list(cx)) { stack; return FSCK_ERROR; } log_info( _("Checking inode reference counts: directories.\n")); - if (scan_dir_list(sdp)) { + if (scan_dir_list(cx)) { stack; return FSCK_ERROR; } log_info( _("Checking inode reference counts: normal links.\n")); - if (scan_nlink1_list(sdp)) { + if (scan_nlink1_list(cx)) { stack; return FSCK_ERROR; } diff --git a/gfs2/fsck/rgrepair.c b/gfs2/fsck/rgrepair.c index 2a8c0eaa..8ce1a32d 100644 --- a/gfs2/fsck/rgrepair.c +++ b/gfs2/fsck/rgrepair.c @@ -510,8 +510,9 @@ static uint64_t hunt_and_peck(struct lgfs2_sbd *sdp, uint64_t blk, * from gfs1 to gfs2 after a gfs_grow operation. In that case, the rgrps * will not be on predictable boundaries. */ -static int rindex_rebuild(struct lgfs2_sbd *sdp, int *num_rgs, int gfs_grow) +static int rindex_rebuild(struct fsck_cx *cx, int *num_rgs, int gfs_grow) { + struct lgfs2_sbd *sdp = cx->sdp; struct osi_node *n, *next = NULL; struct lgfs2_buffer_head *bh; uint64_t rg_dist[MAX_RGSEGMENTS] = {0, }; @@ -532,7 +533,7 @@ static int rindex_rebuild(struct lgfs2_sbd *sdp, int *num_rgs, int gfs_grow) * To make matters worse, journals may span several (small) rgrps, * so we can't go by the rgrps. */ - if (init_jindex(sdp, 0) != 0) { + if (init_jindex(cx, 0) != 0) { log_crit(_("Error: Can't read jindex required for rindex " "repairs.\n")); return -1; @@ -943,8 +944,9 @@ static int expect_rindex_sanity(struct lgfs2_sbd *sdp, int *num_rgs) * was converted from GFS via gfs2_convert, and its rgrps are * not on nice boundaries thanks to previous gfs_grow ops. Lovely. */ -int rindex_repair(struct lgfs2_sbd *sdp, int trust_lvl, int *ok) +int rindex_repair(struct fsck_cx *cx, int trust_lvl, int *ok) { + struct lgfs2_sbd *sdp = cx->sdp; struct osi_node *n, *next = NULL, *e, *enext; int error, discrepancies, percent; int calc_rg_count = 0, rg; @@ -980,7 +982,7 @@ int rindex_repair(struct lgfs2_sbd *sdp, int trust_lvl, int *ok) /* Free previous incarnations in memory, if any. */ lgfs2_rgrp_free(sdp, &sdp->rgtree);
- error = rindex_rebuild(sdp, &calc_rg_count, 0); + error = rindex_rebuild(cx, &calc_rg_count, 0); if (error) { log_crit( _("Error rebuilding rgrp list.\n")); lgfs2_rgrp_free(sdp, &rgcalc); @@ -990,7 +992,7 @@ int rindex_repair(struct lgfs2_sbd *sdp, int trust_lvl, int *ok) /* Free previous incarnations in memory, if any. */ lgfs2_rgrp_free(sdp, &sdp->rgtree);
- error = rindex_rebuild(sdp, &calc_rg_count, 1); + error = rindex_rebuild(cx, &calc_rg_count, 1); if (error) { log_crit( _("Error rebuilding rgrp list.\n")); lgfs2_rgrp_free(sdp, &rgcalc); diff --git a/gfs2/fsck/util.c b/gfs2/fsck/util.c index 9e5608a3..5dafcf9e 100644 --- a/gfs2/fsck/util.c +++ b/gfs2/fsck/util.c @@ -21,7 +21,7 @@ const char *reftypes[REF_TYPES + 1] = {"data", "metadata", "an extended attribute", "an inode", "unimportant"};
-void big_file_comfort(struct lgfs2_inode *ip, uint64_t blks_checked) +void big_file_comfort(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t blks_checked) { static struct timeval tv; static uint32_t seconds = 0; diff --git a/gfs2/fsck/util.h b/gfs2/fsck/util.h index f63a8af1..5742f96f 100644 --- a/gfs2/fsck/util.h +++ b/gfs2/fsck/util.h @@ -10,7 +10,7 @@ #define INODE_INVALID 0
struct di_info *search_list(osi_list_t *list, uint64_t addr); -void big_file_comfort(struct lgfs2_inode *ip, uint64_t blks_checked); +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, enum dup_ref_type reftype, int first, int inode_valid);
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 f5f93c664103cdb4b0692ce34e3dbebce81b555d Author: Andrew Price anprice@redhat.com AuthorDate: Fri Jul 29 17:57:42 2022 +0100
fsck.gfs2: Don't define names in the gfs2_ namespace
It's more consistent and less confusing to only have gfs2_* symbols defined in gfs2_ondisk.h
Signed-off-by: Andrew Price anprice@redhat.com --- gfs2/fsck/block_list.c | 8 ++++---- gfs2/fsck/fs_recovery.c | 20 +++++++++--------- gfs2/fsck/fsck.h | 12 +++++------ gfs2/fsck/initialize.c | 16 +++++++-------- gfs2/fsck/link.c | 6 +++--- gfs2/fsck/link.h | 6 +++--- gfs2/fsck/main.c | 4 ++-- gfs2/fsck/metawalk.c | 2 +- gfs2/fsck/pass1.c | 54 ++++++++++++++++++++++++------------------------- gfs2/fsck/pass5.c | 6 +++--- gfs2/fsck/rgrepair.c | 8 ++++---- gfs2/fsck/util.c | 12 +++++------ gfs2/fsck/util.h | 8 ++++---- 13 files changed, 81 insertions(+), 81 deletions(-)
diff --git a/gfs2/fsck/block_list.c b/gfs2/fsck/block_list.c index 0dca95fe..65c55a1c 100644 --- a/gfs2/fsck/block_list.c +++ b/gfs2/fsck/block_list.c @@ -10,7 +10,7 @@
#include "fsck.h"
-void gfs2_special_free(struct special_blocks *blist) +void special_free(struct special_blocks *blist) { struct special_blocks *f;
@@ -36,7 +36,7 @@ struct special_blocks *blockfind(struct special_blocks *blist, uint64_t num) return NULL; }
-static void gfs2_special_add(struct special_blocks *blocklist, uint64_t block) +static void special_add(struct special_blocks *blocklist, uint64_t block) { struct special_blocks *b;
@@ -48,9 +48,9 @@ static void gfs2_special_add(struct special_blocks *blocklist, uint64_t block) } }
-void gfs2_special_set(struct special_blocks *blocklist, uint64_t block) +void special_set(struct special_blocks *blocklist, uint64_t block) { if (blockfind(blocklist, block)) return; - gfs2_special_add(blocklist, block); + special_add(blocklist, block); } diff --git a/gfs2/fsck/fs_recovery.c b/gfs2/fsck/fs_recovery.c index 607ef9c2..94de748c 100644 --- a/gfs2/fsck/fs_recovery.c +++ b/gfs2/fsck/fs_recovery.c @@ -27,7 +27,7 @@ static unsigned int sd_found_revokes = 0; static osi_list_t sd_revoke_list; static unsigned int sd_replay_tail;
-struct gfs2_revoke_replay { +struct revoke_replay { osi_list_t rr_list; uint64_t rr_blkno; unsigned int rr_where; @@ -36,11 +36,11 @@ struct gfs2_revoke_replay { static int revoke_add(struct lgfs2_sbd *sdp, uint64_t blkno, unsigned int where) { osi_list_t *tmp, *head = &sd_revoke_list; - struct gfs2_revoke_replay *rr; + struct revoke_replay *rr; int found = 0;
osi_list_foreach(tmp, head) { - rr = osi_list_entry(tmp, struct gfs2_revoke_replay, rr_list); + rr = osi_list_entry(tmp, struct revoke_replay, rr_list); if (rr->rr_blkno == blkno) { found = 1; break; @@ -52,7 +52,7 @@ static int revoke_add(struct lgfs2_sbd *sdp, uint64_t blkno, unsigned int where) return 0; }
- rr = malloc(sizeof(struct gfs2_revoke_replay)); + rr = malloc(sizeof(struct revoke_replay)); if (!rr) return -ENOMEM;
@@ -65,12 +65,12 @@ static int revoke_add(struct lgfs2_sbd *sdp, uint64_t blkno, unsigned int where) static int revoke_check(struct lgfs2_sbd *sdp, uint64_t blkno, unsigned int where) { osi_list_t *tmp; - struct gfs2_revoke_replay *rr; + struct revoke_replay *rr; int wrap, a, b; int found = 0;
osi_list_foreach(tmp, &sd_revoke_list) { - rr = osi_list_entry(tmp, struct gfs2_revoke_replay, rr_list); + rr = osi_list_entry(tmp, struct revoke_replay, rr_list); if (rr->rr_blkno == blkno) { found = 1; break; @@ -89,10 +89,10 @@ static int revoke_check(struct lgfs2_sbd *sdp, uint64_t blkno, unsigned int wher static void revoke_clean(struct lgfs2_sbd *sdp) { osi_list_t *head = &sd_revoke_list; - struct gfs2_revoke_replay *rr; + struct revoke_replay *rr;
while (!osi_list_empty(head)) { - rr = osi_list_entry(head->next, struct gfs2_revoke_replay, rr_list); + rr = osi_list_entry(head->next, struct revoke_replay, rr_list); osi_list_del(&rr->rr_list); free(rr); } @@ -476,7 +476,7 @@ int preen_is_safe(struct lgfs2_sbd *sdp, int preen, int force_check) * Returns: errno */
-static int gfs2_recover_journal(struct lgfs2_inode *ip, int j, int preen, +static int recover_journal(struct lgfs2_inode *ip, int j, int preen, int force_check, int *was_clean) { struct lgfs2_sbd *sdp = ip->i_sbd; @@ -711,7 +711,7 @@ int replay_journals(struct fsck_cx *cx, int preen, int force_check, if (sdp->jsize == LGFS2_DEFAULT_JSIZE && jsize && jsize != sdp->jsize) sdp->jsize = jsize; - error = gfs2_recover_journal(sdp->md.journal[i], i, + error = recover_journal(sdp->md.journal[i], i, preen, force_check, &clean); if (!clean) diff --git a/gfs2/fsck/fsck.h b/gfs2/fsck/fsck.h index 382abfab..1d7af191 100644 --- a/gfs2/fsck/fsck.h +++ b/gfs2/fsck/fsck.h @@ -27,7 +27,7 @@
#define BAD_POINTER_TOLERANCE 10 /* How many bad pointers is too many? */
-struct gfs2_bmap { +struct bmap { uint64_t size; uint64_t mapsize; unsigned char *map; @@ -126,7 +126,7 @@ extern int pass1c(struct fsck_cx *cx); extern int pass2(struct fsck_cx *cx); extern int pass3(struct fsck_cx *cx); extern int pass4(struct fsck_cx *cx); -extern int pass5(struct fsck_cx *cx, struct gfs2_bmap *bl); +extern int pass5(struct fsck_cx *cx, struct bmap *bl); 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))); @@ -138,14 +138,14 @@ extern void dirtree_delete(struct dir_info *b); * of pass1 and put somewhere else... */ struct dir_info *dirtree_insert(struct lgfs2_inum inum);
-struct gfs2_options { +struct fsck_options { char *device; unsigned int yes:1; unsigned int no:1; unsigned int query:1; };
-extern struct gfs2_options opts; +extern struct fsck_options opts; extern struct lgfs2_inode *lf_dip; /* Lost and found directory inode */ extern int lf_was_created; extern uint64_t last_fs_block, last_reported_block; @@ -200,8 +200,8 @@ struct special_blocks { };
extern struct special_blocks *blockfind(struct special_blocks *blist, uint64_t num); -extern void gfs2_special_set(struct special_blocks *blocklist, uint64_t block); -extern void gfs2_special_free(struct special_blocks *blist); +extern void special_set(struct special_blocks *blocklist, uint64_t block); +extern void special_free(struct special_blocks *blist); extern int sb_fixed; extern int build_per_node(struct lgfs2_sbd *sdp);
diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c index 9d771a70..b32cfa5a 100644 --- a/gfs2/fsck/initialize.c +++ b/gfs2/fsck/initialize.c @@ -67,7 +67,7 @@ static int block_mounters(struct lgfs2_sbd *sdp, int block_em) return 0; }
-static void gfs2_dup_free(void) +static void dup_free(void) { struct osi_node *n; struct duptree *dt; @@ -78,7 +78,7 @@ static void gfs2_dup_free(void) } }
-static void gfs2_dirtree_free(void) +static void dirtree_free(void) { struct osi_node *n; struct dir_info *dt; @@ -89,7 +89,7 @@ static void gfs2_dirtree_free(void) } }
-static void gfs2_inodetree_free(void) +static void inodetree_free(void) { struct osi_node *n; struct inode_info *dt; @@ -114,9 +114,9 @@ static void empty_super_block(struct lgfs2_sbd *sdp) log_info( _("Freeing buffers.\n")); lgfs2_rgrp_free(sdp, &sdp->rgtree);
- gfs2_inodetree_free(); - gfs2_dirtree_free(); - gfs2_dup_free(); + inodetree_free(); + dirtree_free(); + dup_free(); }
@@ -625,7 +625,7 @@ static void lookup_per_node(struct lgfs2_sbd *sdp, int allow_rebuild)
#define RA_WINDOW 32
-static unsigned gfs2_rgrp_reada(struct lgfs2_sbd *sdp, unsigned cur_window, +static unsigned rgrp_reada(struct lgfs2_sbd *sdp, unsigned cur_window, struct osi_node *n) { struct lgfs2_rgrp_tree *rgd; @@ -673,7 +673,7 @@ static int read_rgrps(struct lgfs2_sbd *sdp, uint64_t expected) rgd = (struct lgfs2_rgrp_tree *)n; /* Readahead resource group headers */ if (ra_window < RA_WINDOW/2) - ra_window = gfs2_rgrp_reada(sdp, ra_window, n); + ra_window = rgrp_reada(sdp, ra_window, n); /* Read resource group header */ errblock = lgfs2_rgrp_read(sdp, rgd); if (errblock) diff --git a/gfs2/fsck/link.c b/gfs2/fsck/link.c index 32893da5..8c377787 100644 --- a/gfs2/fsck/link.c +++ b/gfs2/fsck/link.c @@ -15,10 +15,10 @@ #include "link.h" #include "util.h"
-struct gfs2_bmap nlink1map = { 0 }; /* map of dinodes with nlink == 1 */ -struct gfs2_bmap clink1map = { 0 }; /* map of dinodes w/counted links == 1 */ +struct bmap nlink1map = { 0 }; /* map of dinodes with nlink == 1 */ +struct bmap clink1map = { 0 }; /* map of dinodes w/counted links == 1 */
-int link1_set(struct gfs2_bmap *bmap, uint64_t bblock, int mark) +int link1_set(struct bmap *bmap, uint64_t bblock, int mark) { static unsigned char *byte; static uint64_t b; diff --git a/gfs2/fsck/link.h b/gfs2/fsck/link.h index cd73deba..68723ae6 100644 --- a/gfs2/fsck/link.h +++ b/gfs2/fsck/link.h @@ -1,8 +1,8 @@ #ifndef _LINK_H #define _LINK_H
-extern struct gfs2_bmap nlink1map; /* map of dinodes with nlink == 1 */ -extern struct gfs2_bmap clink1map; /* map of dinodes w/counted links == 1 */ +extern struct bmap nlink1map; /* map of dinodes with nlink == 1 */ +extern struct bmap clink1map; /* map of dinodes w/counted links == 1 */
enum { INCR_LINK_BAD = -1, @@ -11,7 +11,7 @@ enum { INCR_LINK_CHECK_ORIG = 2, };
-int link1_set(struct gfs2_bmap *bmap, uint64_t bblock, int mark); +int link1_set(struct bmap *bmap, uint64_t bblock, int mark); int set_di_nlink(struct lgfs2_inode *ip); int incr_link_count(struct lgfs2_inum no, struct lgfs2_inode *ip, const char *why); int decr_link_count(uint64_t inode_no, uint64_t referenced_from, int gfs1, diff --git a/gfs2/fsck/main.c b/gfs2/fsck/main.c index fff0d32d..bd6563a0 100644 --- a/gfs2/fsck/main.c +++ b/gfs2/fsck/main.c @@ -25,7 +25,7 @@ #include "metawalk.h" #include "util.h"
-struct gfs2_options opts = {0}; +struct fsck_options opts = {0}; struct lgfs2_inode *lf_dip = NULL; /* Lost and found directory inode */ int lf_was_created = 0; uint64_t last_fs_block, last_reported_block = -1; @@ -57,7 +57,7 @@ static void version(void) printf(REDHAT_COPYRIGHT "\n"); }
-static int read_cmdline(int argc, char **argv, struct gfs2_options *gopts) +static int read_cmdline(int argc, char **argv, struct fsck_options *gopts) { int c;
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c index 36f4abcb..abdbb95f 100644 --- a/gfs2/fsck/metawalk.c +++ b/gfs2/fsck/metawalk.c @@ -25,7 +25,7 @@
/* There are two bitmaps: (1) The "blockmap" that fsck uses to keep track of what block type has been discovered, and (2) The rgrp bitmap. Function - gfs2_blockmap_set is used to set the former and gfs2_set_bitmap + blockmap_set is used to set the former and gfs2_set_bitmap is used to set the latter. The two must be kept in sync, otherwise you'll get bitmap mismatches. This function checks the status of the bitmap whenever the blockmap changes, and fixes it accordingly. */ diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c index 44199ac6..fd7a279e 100644 --- a/gfs2/fsck/pass1.c +++ b/gfs2/fsck/pass1.c @@ -30,7 +30,7 @@ #include "fs_recovery.h"
static struct special_blocks gfs1_rindex_blks; -static struct gfs2_bmap *bl = NULL; +static struct bmap *bl = NULL; static struct metawalk_fxns pass1_fxns;
struct block_count { @@ -39,7 +39,7 @@ struct block_count { uint64_t ea_count; };
-static int gfs2_blockmap_set(struct gfs2_bmap *bmap, uint64_t bblock, int mark) +static int blockmap_set(struct bmap *bmap, uint64_t bblock, int mark) { static unsigned char *byte; static uint64_t b; @@ -69,7 +69,7 @@ static int _fsck_blockmap_set(struct lgfs2_inode *ip, uint64_t bblock, if (error) return error;
- return gfs2_blockmap_set(bl, bblock, mark); + return blockmap_set(bl, bblock, mark); }
#define fsck_blockmap_set(ip, b, bt, m) \ @@ -536,7 +536,7 @@ static int p1_check_data(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t me if (ip->i_sbd->gfs1 && ip == ip->i_sbd->md.riinode) { log_info(_("Block %"PRIu64" (0x%"PRIx64") is a GFS1 rindex block\n"), block, block); - gfs2_special_set(&gfs1_rindex_blks, block); + special_set(&gfs1_rindex_blks, block); fsck_blockmap_set(ip, block, "rgrp", GFS2_BLKST_DINODE); } else if (ip->i_sbd->gfs1 && ip->i_flags & GFS2_DIF_JDATA) { log_info(_("Block %"PRIu64" (0x%"PRIx64") is a GFS1 journaled data block\n"), @@ -1115,7 +1115,7 @@ static int alloc_metalist(struct fsck_cx *cx, struct iptr iptr, struct lgfs2_buf if (q == GFS2_BLKST_FREE) { log_debug(_("%s reference to new metadata block %"PRIu64" (0x%"PRIx64") is now marked as indirect.\n"), desc, block, block); - gfs2_blockmap_set(bl, block, ip->i_sbd->gfs1 ? + blockmap_set(bl, block, ip->i_sbd->gfs1 ? GFS2_BLKST_DINODE : GFS2_BLKST_USED); } return META_IS_GOOD; @@ -1135,7 +1135,7 @@ static int alloc_data(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t metab if (q == GFS2_BLKST_FREE) { log_debug(_("%s reference to new data block %"PRIu64" (0x%"PRIx64") is now marked as data.\n"), desc, block, block); - gfs2_blockmap_set(bl, block, GFS2_BLKST_USED); + blockmap_set(bl, block, GFS2_BLKST_USED); } return 0; } @@ -1184,7 +1184,7 @@ static int pass1_check_metatree(struct fsck_cx *cx, struct lgfs2_inode *ip,
error = check_metatree(cx, ip, pass); if (error) - gfs2_blockmap_set(bl, ip->i_num.in_addr, GFS2_BLKST_FREE); + blockmap_set(bl, ip->i_num.in_addr, GFS2_BLKST_FREE); return error; }
@@ -1409,7 +1409,7 @@ static int check_system_inode(struct fsck_cx *cx, if (lgfs2_check_meta((*sysinode)->i_bh->b_data, GFS2_METATYPE_DI)) { log_err(_("Found invalid system dinode at block %"PRIu64" (0x%"PRIx64")\n"), iblock, iblock); - gfs2_blockmap_set(bl, iblock, GFS2_BLKST_FREE); + blockmap_set(bl, iblock, GFS2_BLKST_FREE); check_n_fix_bitmap(cx->sdp, (*sysinode)->i_rgd, iblock, 0, GFS2_BLKST_FREE); lgfs2_inode_put(sysinode); @@ -1445,7 +1445,7 @@ static int check_system_inode(struct fsck_cx *cx, /* Set the blockmap (but not bitmap) back to 'free' so that it gets checked like any normal dinode. */ - gfs2_blockmap_set(bl, iblock, GFS2_BLKST_FREE); + blockmap_set(bl, iblock, GFS2_BLKST_FREE); log_err( _("Removed system inode "%s".\n"), filename); } @@ -1731,7 +1731,7 @@ static int pass1_process_bitmap(struct fsck_cx *cx, struct lgfs2_rgrp_tree *rgd, display_progress(block);
if (fsck_abort) { /* if asked to abort */ - gfs2_special_free(&gfs1_rindex_blks); + special_free(&gfs1_rindex_blks); return FSCK_OK; } if (skip_this_pass) { @@ -1806,7 +1806,7 @@ static int pass1_process_bitmap(struct fsck_cx *cx, struct lgfs2_rgrp_tree *rgd, } else if (handle_di(cx, rgd, bh) < 0) { stack; lgfs2_brelse(bh); - gfs2_special_free(&gfs1_rindex_blks); + special_free(&gfs1_rindex_blks); return FSCK_ERROR; } /* Ignore everything else - they should be hit by the @@ -1852,7 +1852,7 @@ static int pass1_process_rgrp(struct fsck_cx *cx, struct lgfs2_rgrp_tree *rgd)
n = lgfs2_bm_scan(rgd, k, ibuf, GFS2_BLKST_UNLINKED); for (i = 0; i < n; i++) { - gfs2_blockmap_set(bl, ibuf[i], GFS2_BLKST_UNLINKED); + blockmap_set(bl, ibuf[i], GFS2_BLKST_UNLINKED); if (fsck_abort) goto out; } @@ -1863,7 +1863,7 @@ out: return ret; }
-static int gfs2_blockmap_create(struct gfs2_bmap *bmap, uint64_t size) +static int blockmap_create(struct bmap *bmap, uint64_t size) { bmap->size = size;
@@ -1877,7 +1877,7 @@ static int gfs2_blockmap_create(struct gfs2_bmap *bmap, uint64_t size) }
-static int link1_create(struct gfs2_bmap *bmap, uint64_t size) +static int link1_create(struct bmap *bmap, uint64_t size) { bmap->size = size;
@@ -1890,17 +1890,17 @@ static int link1_create(struct gfs2_bmap *bmap, uint64_t size) return 0; }
-static struct gfs2_bmap *gfs2_bmap_create(struct lgfs2_sbd *sdp, uint64_t size, +static struct bmap *bmap_create(struct lgfs2_sbd *sdp, uint64_t size, uint64_t *addl_mem_needed) { - struct gfs2_bmap *il; + struct bmap *il;
*addl_mem_needed = 0L; il = calloc(1, sizeof(*il)); if (!il) return NULL;
- if (gfs2_blockmap_create(il, size)) { + if (blockmap_create(il, size)) { *addl_mem_needed = il->mapsize; free(il); il = NULL; @@ -1908,7 +1908,7 @@ static struct gfs2_bmap *gfs2_bmap_create(struct lgfs2_sbd *sdp, uint64_t size, return il; }
-static void gfs2_blockmap_destroy(struct gfs2_bmap *bmap) +static void blockmap_destroy(struct bmap *bmap) { if (bmap->map) free(bmap->map); @@ -1916,10 +1916,10 @@ static void gfs2_blockmap_destroy(struct gfs2_bmap *bmap) bmap->mapsize = 0; }
-static void *gfs2_bmap_destroy(struct lgfs2_sbd *sdp, struct gfs2_bmap *il) +static void *bmap_destroy(struct lgfs2_sbd *sdp, struct bmap *il) { if (il) { - gfs2_blockmap_destroy(il); + blockmap_destroy(il); free(il); il = NULL; } @@ -1958,7 +1958,7 @@ int pass1(struct fsck_cx *cx) int ret = FSCK_OK; uint64_t addl_mem_needed;
- bl = gfs2_bmap_create(sdp, last_fs_block+1, &addl_mem_needed); + bl = bmap_create(sdp, last_fs_block+1, &addl_mem_needed); if (!bl) { enomem(addl_mem_needed); return FSCK_ERROR; @@ -1966,14 +1966,14 @@ int pass1(struct fsck_cx *cx) addl_mem_needed = link1_create(&nlink1map, last_fs_block+1); if (addl_mem_needed) { enomem(addl_mem_needed); - gfs2_bmap_destroy(sdp, bl); + bmap_destroy(sdp, bl); return FSCK_ERROR; } addl_mem_needed = link1_create(&clink1map, last_fs_block+1); if (addl_mem_needed) { enomem(addl_mem_needed); link1_destroy(&nlink1map); - gfs2_bmap_destroy(sdp, bl); + bmap_destroy(sdp, bl); return FSCK_ERROR; } osi_list_init(&gfs1_rindex_blks.list); @@ -2007,9 +2007,9 @@ int pass1(struct fsck_cx *cx) for (i = 0; i < rgd->rt_length; i++) { log_debug("rgrp block %"PRIu64" (0x%"PRIx64") is now marked as 'rgrp data'\n", rgd->rt_addr + i, rgd->rt_addr + i); - if (gfs2_blockmap_set(bl, rgd->rt_addr + i, GFS2_BLKST_USED)) { + if (blockmap_set(bl, rgd->rt_addr + i, GFS2_BLKST_USED)) { stack; - gfs2_special_free(&gfs1_rindex_blks); + special_free(&gfs1_rindex_blks); ret = FSCK_ERROR; goto out; } @@ -2028,9 +2028,9 @@ int pass1(struct fsck_cx *cx) pass5(cx, bl); print_pass_duration("reconcile_bitmaps", &timer); out: - gfs2_special_free(&gfs1_rindex_blks); + special_free(&gfs1_rindex_blks); if (bl) - gfs2_bmap_destroy(sdp, bl); + bmap_destroy(sdp, bl); return ret; }
diff --git a/gfs2/fsck/pass5.c b/gfs2/fsck/pass5.c index e464fdff..7c8dfce5 100644 --- a/gfs2/fsck/pass5.c +++ b/gfs2/fsck/pass5.c @@ -14,7 +14,7 @@
#define GFS1_BLKST_USEDMETA 4
-static int check_block_status(struct lgfs2_sbd *sdp, struct gfs2_bmap *bl, +static int check_block_status(struct lgfs2_sbd *sdp, struct bmap *bl, char *buffer, unsigned int buflen, uint64_t *rg_block, uint64_t rg_data, uint32_t *count) @@ -114,7 +114,7 @@ static int check_block_status(struct lgfs2_sbd *sdp, struct gfs2_bmap *bl, }
static void update_rgrp(struct lgfs2_sbd *sdp, struct lgfs2_rgrp_tree *rgp, - struct gfs2_bmap *bl, uint32_t *count) + struct bmap *bl, uint32_t *count) { uint32_t i; struct lgfs2_bitmap *bits; @@ -194,7 +194,7 @@ static void update_rgrp(struct lgfs2_sbd *sdp, struct lgfs2_rgrp_tree *rgp, * fix free block maps * fix used inode maps */ -int pass5(struct fsck_cx *cx, struct gfs2_bmap *bl) +int pass5(struct fsck_cx *cx, struct bmap *bl) { struct lgfs2_sbd *sdp = cx->sdp; struct osi_node *n, *next = NULL; diff --git a/gfs2/fsck/rgrepair.c b/gfs2/fsck/rgrepair.c index 8ce1a32d..5f228500 100644 --- a/gfs2/fsck/rgrepair.c +++ b/gfs2/fsck/rgrepair.c @@ -71,7 +71,7 @@ static void find_journaled_rgs(struct lgfs2_sbd *sdp) if (!lgfs2_check_meta(bh->b_data, GFS2_METATYPE_RG)) { /* False rgrp found at block dblock */ false_count++; - gfs2_special_set(&false_rgrps, dblock); + special_set(&false_rgrps, dblock); } lgfs2_brelse(bh); } @@ -249,7 +249,7 @@ static int find_shortest_rgdist(struct lgfs2_sbd *sdp, uint64_t *dist_array, log_debug(_("Adjusted first rgrp distance: 0x%"PRIx64"\n"), *dist_array); } /* if first RG distance is within tolerance */
- gfs2_special_free(&false_rgrps); + special_free(&false_rgrps); return gsegment; }
@@ -805,7 +805,7 @@ static int calc_rgrps(struct lgfs2_sbd *sdp) * Sets: sdp->rglist to a linked list of fsck_rgrp structs representing * what we think the rindex should really look like. */ -static int gfs2_rindex_calculate(struct lgfs2_sbd *sdp, int *num_rgs) +static int rindex_calculate(struct lgfs2_sbd *sdp, int *num_rgs) { uint64_t num_rgrps = 0;
@@ -973,7 +973,7 @@ int rindex_repair(struct fsck_cx *cx, int trust_lvl, int *ok) lgfs2_rgrp_free(sdp, &sdp->rgtree);
/* Calculate our own RG index for comparison */ - error = gfs2_rindex_calculate(sdp, &calc_rg_count); + error = rindex_calculate(sdp, &calc_rg_count); if (error) { /* If calculated RGs don't match the fs */ lgfs2_rgrp_free(sdp, &rgcalc); return -1; diff --git a/gfs2/fsck/util.c b/gfs2/fsck/util.c index 5dafcf9e..3c1b7116 100644 --- a/gfs2/fsck/util.c +++ b/gfs2/fsck/util.c @@ -83,7 +83,7 @@ void display_progress(uint64_t block) } }
-char gfs2_getch(void) +char fsck_getch(void) { struct termios termattr, savetermattr; char ch; @@ -145,7 +145,7 @@ char generic_interrupt(const char *caller, const char *where,
/* Make sure query is printed out */ fflush(NULL); - response = gfs2_getch(); + response = fsck_getch(); printf("\n"); fflush(NULL); if (strchr(answers, response)) @@ -183,7 +183,7 @@ int fsck_query(const char *format, ...)
/* Make sure query is printed out */ fflush(NULL); - response = gfs2_getch(); + response = fsck_getch();
printf("\n"); fflush(NULL); @@ -217,14 +217,14 @@ int fsck_query(const char *format, ...) }
/* - * gfs2_dup_set - Flag a block as a duplicate + * dup_set - Flag a block as a duplicate * We keep the references in a red/black tree. We can't keep track of every * single inode in the file system, so the first time this function is called * will actually be for the second reference to the duplicated block. * 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 *gfs2_dup_set(uint64_t dblock, int create) +static struct duptree *dup_set(uint64_t dblock, int create) { struct osi_node **newn = &dup_blocks.osi_node, *parent = NULL; struct duptree *dt; @@ -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 = gfs2_dup_set(block, !first); + dt = dup_set(block, !first); if (!dt) /* If this isn't a duplicate */ return META_IS_GOOD;
diff --git a/gfs2/fsck/util.h b/gfs2/fsck/util.h index 5742f96f..0eb050e5 100644 --- a/gfs2/fsck/util.h +++ b/gfs2/fsck/util.h @@ -32,7 +32,7 @@ struct fsck_pass { int (*f)(struct fsck_cx *cx); };
-static inline int block_type(struct gfs2_bmap *bl, uint64_t bblock) +static inline int block_type(struct bmap *bl, uint64_t bblock) { static unsigned char *byte; static uint64_t b; @@ -44,7 +44,7 @@ static inline int block_type(struct gfs2_bmap *bl, uint64_t bblock) return btype; }
-static inline int link1_type(struct gfs2_bmap *bl, uint64_t bblock) +static inline int link1_type(struct bmap *bl, uint64_t bblock) { static unsigned char *byte; static uint64_t b; @@ -56,7 +56,7 @@ static inline int link1_type(struct gfs2_bmap *bl, uint64_t bblock) return btype; }
-static inline void link1_destroy(struct gfs2_bmap *bmap) +static inline void link1_destroy(struct bmap *bmap) { if (bmap->map) free(bmap->map); @@ -123,7 +123,7 @@ extern enum dup_ref_type get_ref_type(struct inode_with_dups *id); extern char generic_interrupt(const char *caller, const char *where, const char *progress, const char *question, const char *answers); -extern char gfs2_getch(void); +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);
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__)
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 c8bb893f76338155d8f5d56cde4f1b36a6d7ca8e Author: Andrew Price anprice@redhat.com AuthorDate: Fri Jul 29 19:46:40 2022 +0100
fsck.gfs2: Move the global dirtree into fsck_cx
Signed-off-by: Andrew Price anprice@redhat.com --- gfs2/fsck/afterpass1_common.c | 4 +- gfs2/fsck/fsck.h | 8 ++-- gfs2/fsck/initialize.c | 8 ++-- gfs2/fsck/link.c | 12 ++--- gfs2/fsck/link.h | 8 ++-- gfs2/fsck/lost_n_found.c | 37 ++++++++-------- gfs2/fsck/lost_n_found.h | 4 +- gfs2/fsck/main.c | 1 - gfs2/fsck/metawalk.c | 15 ++++--- gfs2/fsck/metawalk.h | 12 ++--- gfs2/fsck/pass1.c | 98 ++++++++++++++++++++--------------------- gfs2/fsck/pass1b.c | 26 +++++------ gfs2/fsck/pass2.c | 100 +++++++++++++++++++++--------------------- gfs2/fsck/pass3.c | 44 +++++++++---------- gfs2/fsck/pass4.c | 20 ++++----- gfs2/fsck/util.c | 14 +++--- 16 files changed, 207 insertions(+), 204 deletions(-)
diff --git a/gfs2/fsck/afterpass1_common.c b/gfs2/fsck/afterpass1_common.c index e2ebae56..9e27d9ba 100644 --- a/gfs2/fsck/afterpass1_common.c +++ b/gfs2/fsck/afterpass1_common.c @@ -103,7 +103,7 @@ static int delete_block_if_notdup(struct fsck_cx *cx, struct lgfs2_inode *ip, ui "because it's referenced by another inode.\n"), ip->i_num.in_addr, ip->i_num.in_addr, block, block); } else { - check_n_fix_bitmap(ip->i_sbd, ip->i_rgd, block, 0, + check_n_fix_bitmap(cx, ip->i_rgd, block, 0, GFS2_BLKST_FREE); } return META_IS_GOOD; @@ -297,7 +297,7 @@ int delete_eattr_extentry(struct fsck_cx *cx, struct lgfs2_inode *ip, int i, __b lgfs2_bmodified(leaf_bh); /* Endianness doesn't matter in this case because it's a single byte. */ - fsck_bitmap_set(ip, ip->i_eattr, + fsck_bitmap_set(cx, ip, ip->i_eattr, _("extended attribute"), ip->i_sbd->gfs1 ? GFS2_BLKST_DINODE : GFS2_BLKST_USED); diff --git a/gfs2/fsck/fsck.h b/gfs2/fsck/fsck.h index 2588e400..2ae182d5 100644 --- a/gfs2/fsck/fsck.h +++ b/gfs2/fsck/fsck.h @@ -111,6 +111,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; + struct osi_root dirtree; };
extern struct lgfs2_inode *fsck_load_inode(struct lgfs2_sbd *sdp, uint64_t block); @@ -131,13 +132,13 @@ extern int pass5(struct fsck_cx *cx, struct bmap *bl); 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 struct dir_info *dirtree_find(struct fsck_cx *cx, uint64_t block); extern void dup_delete(struct fsck_cx *cx, struct duptree *dt); -extern void dirtree_delete(struct dir_info *b); +extern void dirtree_delete(struct fsck_cx *cx, struct dir_info *b);
/* FIXME: Hack to get this going for pass2 - this should be pulled out * of pass1 and put somewhere else... */ -struct dir_info *dirtree_insert(struct lgfs2_inum inum); +struct dir_info *dirtree_insert(struct fsck_cx *cx, struct lgfs2_inum inum);
struct fsck_options { char *device; @@ -155,7 +156,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 dirtree; extern struct osi_root inodetree; extern int dups_found; /* How many duplicate references have we found? */ extern int dups_found_first; /* How many duplicates have we found the original diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c index f3b909df..f671abba 100644 --- a/gfs2/fsck/initialize.c +++ b/gfs2/fsck/initialize.c @@ -78,14 +78,14 @@ static void dup_free(struct fsck_cx *cx) } }
-static void dirtree_free(void) +static void dirtree_free(struct fsck_cx *cx) { struct osi_node *n; struct dir_info *dt;
- while ((n = osi_first(&dirtree))) { + while ((n = osi_first(&cx->dirtree))) { dt = (struct dir_info *)n; - dirtree_delete(dt); + dirtree_delete(cx, dt); } }
@@ -115,7 +115,7 @@ static void empty_super_block(struct fsck_cx *cx) lgfs2_rgrp_free(cx->sdp, &cx->sdp->rgtree);
inodetree_free(); - dirtree_free(); + dirtree_free(cx); dup_free(cx); }
diff --git a/gfs2/fsck/link.c b/gfs2/fsck/link.c index 8c377787..690d58ef 100644 --- a/gfs2/fsck/link.c +++ b/gfs2/fsck/link.c @@ -35,13 +35,13 @@ int link1_set(struct bmap *bmap, uint64_t bblock, int mark) return 0; }
-int set_di_nlink(struct lgfs2_inode *ip) +int set_di_nlink(struct fsck_cx *cx, struct lgfs2_inode *ip) { struct inode_info *ii; struct dir_info *di;
if (is_dir(ip, ip->i_sbd->gfs1)) { - di = dirtree_find(ip->i_num.in_addr); + di = dirtree_find(cx, ip->i_num.in_addr); if (di == NULL) { log_err(_("Error: directory %"PRIu64" (0x%"PRIx64") is not " "in the dir_tree (set).\n"), @@ -77,14 +77,14 @@ int set_di_nlink(struct lgfs2_inode *ip) "for (0x%"PRIx64") via %s\n"), \ referenced_from, counted_links, no_addr, why);
-int incr_link_count(struct lgfs2_inum no, struct lgfs2_inode *ip, const char *why) +int incr_link_count(struct fsck_cx *cx, struct lgfs2_inum no, struct lgfs2_inode *ip, const char *why) { struct inode_info *ii = NULL; uint64_t referenced_from = ip ? ip->i_num.in_addr : 0; struct dir_info *di; struct lgfs2_inode *link_ip;
- di = dirtree_find(no.in_addr); + di = dirtree_find(cx, no.in_addr); if (di) { if (di->dinode.in_formal_ino != no.in_formal_ino) return INCR_LINK_INO_MISMATCH; @@ -148,13 +148,13 @@ int incr_link_count(struct lgfs2_inum no, struct lgfs2_inode *ip, const char *wh "for (0x%"PRIx64") via %s\n"), \ referenced_from, counted_links, no_addr, why);
-int decr_link_count(uint64_t inode_no, uint64_t referenced_from, int gfs1, +int decr_link_count(struct fsck_cx *cx, uint64_t inode_no, uint64_t referenced_from, int gfs1, const char *why) { struct inode_info *ii = NULL; struct dir_info *di;
- di = dirtree_find(inode_no); + di = dirtree_find(cx, inode_no); if (di) { if (!di->counted_links) { log_debug(_("Dir 0x%"PRIx64"'s link to 0x%"PRIx64" via %s is zero!\n"), diff --git a/gfs2/fsck/link.h b/gfs2/fsck/link.h index 68723ae6..91f63399 100644 --- a/gfs2/fsck/link.h +++ b/gfs2/fsck/link.h @@ -1,6 +1,8 @@ #ifndef _LINK_H #define _LINK_H
+#include "fsck.h" + extern struct bmap nlink1map; /* map of dinodes with nlink == 1 */ extern struct bmap clink1map; /* map of dinodes w/counted links == 1 */
@@ -12,9 +14,9 @@ enum { };
int link1_set(struct bmap *bmap, uint64_t bblock, int mark); -int set_di_nlink(struct lgfs2_inode *ip); -int incr_link_count(struct lgfs2_inum no, struct lgfs2_inode *ip, const char *why); -int decr_link_count(uint64_t inode_no, uint64_t referenced_from, int gfs1, +int set_di_nlink(struct fsck_cx *cx, struct lgfs2_inode *ip); +int incr_link_count(struct fsck_cx *cx, struct lgfs2_inum no, struct lgfs2_inode *ip, const char *why); +int decr_link_count(struct fsck_cx *cx, uint64_t inode_no, uint64_t referenced_from, int gfs1, const char *why);
#endif /* _LINK_H */ diff --git a/gfs2/fsck/lost_n_found.c b/gfs2/fsck/lost_n_found.c index d2064268..ca5ab89e 100644 --- a/gfs2/fsck/lost_n_found.c +++ b/gfs2/fsck/lost_n_found.c @@ -18,7 +18,7 @@ #include "metawalk.h" #include "util.h"
-static void add_dotdot(struct lgfs2_inode *ip) +static void add_dotdot(struct fsck_cx *cx, struct lgfs2_inode *ip) { struct lgfs2_sbd *sdp = ip->i_sbd; struct dir_info *di; @@ -30,7 +30,7 @@ static void add_dotdot(struct lgfs2_inode *ip)
/* If there's a pre-existing .. directory entry, we have to back out the links. */ - di = dirtree_find(ip->i_num.in_addr); + di = dirtree_find(cx, ip->i_num.in_addr); if (di && valid_block(sdp, di->dotdot_parent.in_addr)) { struct lgfs2_inode *dip;
@@ -38,11 +38,11 @@ static void add_dotdot(struct lgfs2_inode *ip) ip->i_num.in_addr, di->dotdot_parent.in_addr); dip = fsck_load_inode(sdp, di->dotdot_parent.in_addr); if (dip->i_num.in_formal_ino == di->dotdot_parent.in_formal_ino) { - decr_link_count(di->dotdot_parent.in_addr, ip->i_num.in_addr, sdp->gfs1, + decr_link_count(cx, di->dotdot_parent.in_addr, ip->i_num.in_addr, sdp->gfs1, _(".. unlinked, moving to lost+found")); if (dip->i_nlink > 0) { dip->i_nlink--; - set_di_nlink(dip); /* keep inode tree in sync */ + set_di_nlink(cx, dip); /* keep inode tree in sync */ log_debug(_("Decrementing its links to %d\n"), dip->i_nlink); lgfs2_bmodified(dip->i_bh); @@ -52,7 +52,7 @@ static void add_dotdot(struct lgfs2_inode *ip) log_debug(_("Its link count is %d! Changing it to 0.\n"), dip->i_nlink); dip->i_nlink = 0; - set_di_nlink(dip); /* keep inode tree in sync */ + set_di_nlink(cx, dip); /* keep inode tree in sync */ lgfs2_bmodified(dip->i_bh); } } else { @@ -90,7 +90,7 @@ static void add_dotdot(struct lgfs2_inode *ip) } }
-void make_sure_lf_exists(struct lgfs2_inode *ip) +void make_sure_lf_exists(struct fsck_cx *cx, struct lgfs2_inode *ip) { struct dir_info *di; struct lgfs2_sbd *sdp = ip->i_sbd; @@ -123,7 +123,7 @@ void make_sure_lf_exists(struct lgfs2_inode *ip) /* lgfs2_createi will have incremented the di_nlink link count for the root directory. We must set the nlink value in the hash table to keep them in sync so that pass4 can detect and fix any descrepancies. */ - set_di_nlink(sdp->md.rooti); + set_di_nlink(cx, sdp->md.rooti);
if (sdp->md.rooti->i_entries > root_entries) { struct lgfs2_inum no = lf_dip->i_num; @@ -133,27 +133,27 @@ void make_sure_lf_exists(struct lgfs2_inode *ip) /* FIXME: i'd feel better about this if fs_mkdir returned whether it created a new directory or just found an old one, and we used that instead of the bitmap_type to run this */ - dirtree_insert(no); + dirtree_insert(cx, no); /* Set the bitmap AFTER the dirtree insert so that function check_n_fix_bitmap will realize it's a dinode and adjust the rgrp counts properly. */ - fsck_bitmap_set(ip, lf_dip->i_num.in_addr, _("lost+found dinode"), GFS2_BLKST_DINODE); + fsck_bitmap_set(cx, ip, lf_dip->i_num.in_addr, _("lost+found dinode"), GFS2_BLKST_DINODE); /* root inode links to lost+found */ no.in_addr = sdp->md.rooti->i_num.in_addr; no.in_formal_ino = sdp->md.rooti->i_num.in_formal_ino; - incr_link_count(no, lf_dip, _("root")); + incr_link_count(cx, no, lf_dip, _("root")); /* lost+found link for '.' from itself */ no.in_addr = lf_dip->i_num.in_addr; no.in_formal_ino = lf_dip->i_num.in_formal_ino; - incr_link_count(no, lf_dip, "".""); + incr_link_count(cx, no, lf_dip, "".""); /* lost+found link for '..' back to root */ - incr_link_count(no, sdp->md.rooti, ""..""); + incr_link_count(cx, no, sdp->md.rooti, ""..""); if (sdp->gfs1) lf_dip->i_di_type = GFS_FILE_DIR; } log_info(_("lost+found directory is dinode %"PRIu64" (0x%"PRIx64")\n"), lf_dip->i_num.in_addr, lf_dip->i_num.in_addr); - di = dirtree_find(lf_dip->i_num.in_addr); + di = dirtree_find(cx, lf_dip->i_num.in_addr); if (di) { log_info( _("Marking lost+found inode connected\n")); di->checked = 1; @@ -170,7 +170,8 @@ void make_sure_lf_exists(struct lgfs2_inode *ip) * * Returns: 0 on success, -1 on failure. */ -int add_inode_to_lf(struct lgfs2_inode *ip){ +int add_inode_to_lf(struct fsck_cx *cx, struct lgfs2_inode *ip) +{ char tmp_name[256]; unsigned inode_type; struct lgfs2_sbd *sdp = ip->i_sbd; @@ -178,7 +179,7 @@ int add_inode_to_lf(struct lgfs2_inode *ip){ int err = 0; uint32_t mode;
- make_sure_lf_exists(ip); + make_sure_lf_exists(cx, ip); if (ip->i_num.in_addr == lf_dip->i_num.in_addr) { log_err( _("Trying to add lost+found to itself...skipping")); return 0; @@ -191,7 +192,7 @@ int add_inode_to_lf(struct lgfs2_inode *ip){
switch (mode) { case S_IFDIR: - add_dotdot(ip); + add_dotdot(cx, ip); sprintf(tmp_name, "lost_dir_%"PRIu64, ip->i_num.in_addr); inode_type = (sdp->gfs1 ? GFS_FILE_DIR : DT_DIR); break; @@ -234,11 +235,11 @@ int add_inode_to_lf(struct lgfs2_inode *ip){ }
/* This inode is linked from lost+found */ - incr_link_count(no, lf_dip, _("from lost+found")); + incr_link_count(cx, no, lf_dip, _("from lost+found")); /* If it's a directory, lost+found is back-linked to it via .. */ if (mode == S_IFDIR) { no = lf_dip->i_num; - incr_link_count(no, ip, _("to lost+found")); + incr_link_count(cx, no, ip, _("to lost+found")); } log_notice(_("Added inode #%"PRIu64" (0x%"PRIx64") to lost+found\n"), ip->i_num.in_addr, ip->i_num.in_addr); diff --git a/gfs2/fsck/lost_n_found.h b/gfs2/fsck/lost_n_found.h index 2e1c5d14..41b7b4de 100644 --- a/gfs2/fsck/lost_n_found.h +++ b/gfs2/fsck/lost_n_found.h @@ -3,7 +3,7 @@
#include "libgfs2.h"
-int add_inode_to_lf(struct lgfs2_inode *ip); -void make_sure_lf_exists(struct lgfs2_inode *ip); +int add_inode_to_lf(struct fsck_cx *cx, struct lgfs2_inode *ip); +void make_sure_lf_exists(struct fsck_cx *cx, struct lgfs2_inode *ip);
#endif /* __LOST_N_FOUND_H__ */ diff --git a/gfs2/fsck/main.c b/gfs2/fsck/main.c index 2bb2233f..34111103 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 dirtree; struct osi_root inodetree; int dups_found = 0, dups_found_first = 0; int sb_fixed = 0; diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c index 2da746c0..25557673 100644 --- a/gfs2/fsck/metawalk.c +++ b/gfs2/fsck/metawalk.c @@ -29,9 +29,10 @@ is used to set the latter. The two must be kept in sync, otherwise you'll get bitmap mismatches. This function checks the status of the bitmap whenever the blockmap changes, and fixes it accordingly. */ -int check_n_fix_bitmap(struct lgfs2_sbd *sdp, struct lgfs2_rgrp_tree *rgd, +int check_n_fix_bitmap(struct fsck_cx *cx, struct lgfs2_rgrp_tree *rgd, uint64_t blk, int error_on_dinode, int new_state) { + struct lgfs2_sbd *sdp = cx->sdp; int old_state; int treat_as_inode = 0; int rewrite_rgrp = 0; @@ -91,9 +92,9 @@ int check_n_fix_bitmap(struct lgfs2_sbd *sdp, struct lgfs2_rgrp_tree *rgd, struct dir_info *dt; struct inode_info *ii;
- dt = dirtree_find(blk); + dt = dirtree_find(cx, blk); if (dt) { - dirtree_delete(dt); + dirtree_delete(cx, dt); treat_as_inode = 1; } ii = inodetree_find(blk); @@ -129,7 +130,7 @@ int check_n_fix_bitmap(struct lgfs2_sbd *sdp, struct lgfs2_rgrp_tree *rgd, struct dir_info *dt; struct inode_info *ii;
- dt = dirtree_find(blk); + dt = dirtree_find(cx, blk); if (dt) treat_as_inode = 1; else { @@ -159,7 +160,7 @@ int check_n_fix_bitmap(struct lgfs2_sbd *sdp, struct lgfs2_rgrp_tree *rgd, /* * _fsck_bitmap_set - Mark a block in the bitmap, and adjust free space. */ -int _fsck_bitmap_set(struct lgfs2_inode *ip, uint64_t bblock, +int _fsck_bitmap_set(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t bblock, const char *btype, int mark, int error_on_dinode, const char *caller, int fline) { @@ -200,7 +201,7 @@ int _fsck_bitmap_set(struct lgfs2_inode *ip, uint64_t bblock, prev_mark = mark; prev_caller = caller; } - error = check_n_fix_bitmap(ip->i_sbd, ip->i_rgd, bblock, + error = check_n_fix_bitmap(cx, ip->i_rgd, bblock, error_on_dinode, mark); if (error < 0) log_err(_("This block is not represented in the bitmap.\n")); @@ -1616,7 +1617,7 @@ undo_metalist: to undo. */ 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); + fsck_bitmap_set(cx, ip, ip->i_num.in_addr, "corrupt", GFS2_BLKST_FREE); log_err(_("The corrupt inode was invalidated.\n")); out: free_metalist(ip, metalist); diff --git a/gfs2/fsck/metawalk.h b/gfs2/fsck/metawalk.h index 90e1b988..f84f5805 100644 --- a/gfs2/fsck/metawalk.h +++ b/gfs2/fsck/metawalk.h @@ -19,10 +19,10 @@ extern int check_linear_dir(struct fsck_cx *cx, struct lgfs2_inode *ip, struct l extern int check_leaf(struct fsck_cx *cx, struct lgfs2_inode *ip, int lindex, struct metawalk_fxns *pass, uint64_t *leaf_no, struct lgfs2_leaf *leaf, int *ref_count); -extern int _fsck_bitmap_set(struct lgfs2_inode *ip, uint64_t bblock, +extern int _fsck_bitmap_set(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t bblock, const char *btype, int mark, int error_on_dinode, const char *caller, int line); -extern int check_n_fix_bitmap(struct lgfs2_sbd *sdp, struct lgfs2_rgrp_tree *rgd, +extern int check_n_fix_bitmap(struct fsck_cx *cx, struct lgfs2_rgrp_tree *rgd, uint64_t blk, int error_on_dinode, int new_state); extern struct duptree *dupfind(struct fsck_cx *cx, uint64_t block); @@ -31,10 +31,10 @@ extern struct lgfs2_inode *fsck_system_inode(struct lgfs2_sbd *sdp,
#define is_duplicate(dblock) ((dupfind(dblock)) ? 1 : 0)
-#define fsck_bitmap_set(ip, b, bt, m) \ - _fsck_bitmap_set(ip, b, bt, m, 0, __FUNCTION__, __LINE__) -#define fsck_bitmap_set_noino(ip, b, bt, m) \ - _fsck_bitmap_set(ip, b, bt, m, 1, __FUNCTION__, __LINE__) +#define fsck_bitmap_set(cx, ip, b, bt, m) \ + _fsck_bitmap_set(cx, ip, b, bt, m, 0, __FUNCTION__, __LINE__) +#define fsck_bitmap_set_noino(cx, ip, b, bt, m) \ + _fsck_bitmap_set(cx, ip, b, bt, m, 1, __FUNCTION__, __LINE__) enum meta_check_rc { META_ERROR = -1, META_IS_GOOD = 0, diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c index 5b900b92..b535ab71 100644 --- a/gfs2/fsck/pass1.c +++ b/gfs2/fsck/pass1.c @@ -60,11 +60,11 @@ static int blockmap_set(struct bmap *bmap, uint64_t bblock, int mark) * _fsck_blockmap_set - Mark a block in the 4-bit blockmap and the 2-bit * bitmap, and adjust free space accordingly. */ -static int _fsck_blockmap_set(struct lgfs2_inode *ip, uint64_t bblock, +static int _fsck_blockmap_set(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t bblock, const char *btype, int mark, int error_on_dinode, const char *caller, int fline) { - int error = _fsck_bitmap_set(ip, bblock, btype, mark, error_on_dinode, + int error = _fsck_bitmap_set(cx, ip, bblock, btype, mark, error_on_dinode, caller, fline); if (error) return error; @@ -72,10 +72,10 @@ static int _fsck_blockmap_set(struct lgfs2_inode *ip, uint64_t bblock, return blockmap_set(bl, bblock, mark); }
-#define fsck_blockmap_set(ip, b, bt, m) \ - _fsck_blockmap_set(ip, b, bt, m, 0, __FUNCTION__, __LINE__) -#define fsck_blkmap_set_noino(ip, b, bt, m) \ - _fsck_blockmap_set(ip, b, bt, m, 1, __FUNCTION__, __LINE__) +#define fsck_blockmap_set(cx, ip, b, bt, m) \ + _fsck_blockmap_set(cx, ip, b, bt, m, 0, __FUNCTION__, __LINE__) +#define fsck_blkmap_set_noino(cx, ip, b, bt, m) \ + _fsck_blockmap_set(cx, ip, b, bt, m, 1, __FUNCTION__, __LINE__)
/** * p1_delete_block - delete a block associated with an inode @@ -85,7 +85,7 @@ static int p1_delete_block(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t void *private) { if (valid_block_ip(ip, block)) { - fsck_blockmap_set(ip, block, btype, GFS2_BLKST_FREE); + fsck_blockmap_set(cx, ip, block, btype, GFS2_BLKST_FREE); return 0; } return -1; @@ -149,7 +149,7 @@ static int resuscitate_metalist(struct fsck_cx *cx, struct iptr iptr, struct lgf *was_duplicate = 0; *bh = NULL; if (!valid_block_ip(ip, block)){ /* blk outside of FS */ - fsck_blockmap_set(ip, ip->i_num.in_addr, _("itself"), GFS2_BLKST_UNLINKED); + fsck_blockmap_set(cx, ip, ip->i_num.in_addr, _("itself"), GFS2_BLKST_UNLINKED); log_err(_("Bad indirect block pointer (invalid or out of " "range) found in system inode %"PRIu64" (0x%"PRIx64").\n"), ip->i_num.in_addr, ip->i_num.in_addr); @@ -157,11 +157,11 @@ static int resuscitate_metalist(struct fsck_cx *cx, struct iptr iptr, struct lgf return META_IS_GOOD; } if (fsck_system_inode(ip->i_sbd, block)) - fsck_blockmap_set(ip, block, _("system file"), + fsck_blockmap_set(cx, ip, block, _("system file"), ip->i_sbd->gfs1 ? GFS2_BLKST_DINODE : GFS2_BLKST_USED); else - check_n_fix_bitmap(ip->i_sbd, ip->i_rgd, block, 0, + check_n_fix_bitmap(cx, ip->i_rgd, block, 0, ip->i_sbd->gfs1 ? GFS2_BLKST_DINODE : GFS2_BLKST_USED); bc->indir_count++; @@ -203,10 +203,10 @@ static int resuscitate_dentry(struct fsck_cx *cx, struct lgfs2_inode *ip, struct since it's in a system directory we need to make sure it's represented in the rgrp bitmap. */ if (fsck_system_inode(sdp, block)) - fsck_blockmap_set(ip, block, _("system file"), + fsck_blockmap_set(cx, ip, block, _("system file"), GFS2_BLKST_DINODE); else - check_n_fix_bitmap(sdp, ip->i_rgd, block, 0, + check_n_fix_bitmap(cx, ip->i_rgd, block, 0, GFS2_BLKST_DINODE); /* Return the number of leaf entries so metawalk doesn't flag this leaf as having none. */ @@ -244,7 +244,7 @@ static int p1_check_leaf(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t bl it was already checked, so don't check again. */ return EEXIST; /* non-fatal */ } - fsck_blockmap_set(ip, block, _("directory leaf"), + fsck_blockmap_set(cx, ip, block, _("directory leaf"), ip->i_sbd->gfs1 ? GFS2_BLKST_DINODE : GFS2_BLKST_USED); return 0; @@ -270,7 +270,7 @@ static int p1_check_metalist(struct fsck_cx *cx, struct iptr iptr, struct lgfs2_ "unrecoverable" errors. The inode itself should be set "free" and removed from the inodetree by undo_check_metalist. */ - fsck_blockmap_set(ip, ip->i_num.in_addr, + fsck_blockmap_set(cx, ip, ip->i_num.in_addr, _("bad block referencing"), GFS2_BLKST_UNLINKED); log_debug(_("Bad indirect block (invalid/out of range) " "found in inode %"PRIu64" (0x%"PRIx64").\n"), @@ -321,7 +321,7 @@ static int p1_check_metalist(struct fsck_cx *cx, struct iptr iptr, struct lgfs2_ lgfs2_brelse(nbh); } else { *bh = nbh; - fsck_blockmap_set(ip, block, _("indirect"), ip->i_sbd->gfs1 ? + fsck_blockmap_set(cx, ip, block, _("indirect"), ip->i_sbd->gfs1 ? GFS2_BLKST_DINODE : GFS2_BLKST_USED); }
@@ -349,7 +349,7 @@ static int undo_reference(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t b struct lgfs2_rgrp_tree *rgd;
if (!valid_block_ip(ip, block)) { /* blk outside of FS */ - fsck_blockmap_set(ip, ip->i_num.in_addr, _("bad block referencing"), GFS2_BLKST_FREE); + fsck_blockmap_set(cx, ip, ip->i_num.in_addr, _("bad block referencing"), GFS2_BLKST_FREE); return 1; }
@@ -384,7 +384,7 @@ static int undo_reference(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t b if (old_bitmap_state == GFS2_BLKST_DINODE) return -1; } - fsck_blockmap_set(ip, block, + fsck_blockmap_set(cx, ip, block, meta ? _("bad indirect") : _("referenced data"), GFS2_BLKST_FREE); return 0; @@ -410,13 +410,13 @@ static int p1_undo_check_data(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64 * Note that previous checks were done for duplicate references, so this * is checking for dinodes that we haven't processed yet. */ -static int blockmap_set_as_data(struct lgfs2_inode *ip, uint64_t block) +static int blockmap_set_as_data(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t block) { int error; struct lgfs2_buffer_head *bh; struct gfs2_dinode *di;
- error = fsck_blkmap_set_noino(ip, block, "data", GFS2_BLKST_USED); + error = fsck_blkmap_set_noino(cx, ip, block, "data", GFS2_BLKST_USED); if (!error) return 0;
@@ -439,7 +439,7 @@ static int blockmap_set_as_data(struct lgfs2_inode *ip, uint64_t block) error = -1; out: if (!error) - fsck_blockmap_set(ip, block, "data", GFS2_BLKST_USED); + fsck_blockmap_set(cx, ip, block, "data", GFS2_BLKST_USED); lgfs2_brelse(bh); return error; } @@ -463,7 +463,7 @@ static int p1_check_data(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t me /* Mark the owner of this block with the bad_block * designator so we know to check it for out of range * blocks later */ - fsck_blockmap_set(ip, ip->i_num.in_addr, _("bad (out of range) data"), GFS2_BLKST_UNLINKED); + fsck_blockmap_set(cx, ip, ip->i_num.in_addr, _("bad (out of range) data"), GFS2_BLKST_UNLINKED); return -1; } bc->data_count++; /* keep the count sane anyway */ @@ -537,13 +537,13 @@ static int p1_check_data(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t me log_info(_("Block %"PRIu64" (0x%"PRIx64") is a GFS1 rindex block\n"), block, block); special_set(&gfs1_rindex_blks, block); - fsck_blockmap_set(ip, block, "rgrp", GFS2_BLKST_DINODE); + fsck_blockmap_set(cx, ip, block, "rgrp", GFS2_BLKST_DINODE); } else if (ip->i_sbd->gfs1 && ip->i_flags & GFS2_DIF_JDATA) { log_info(_("Block %"PRIu64" (0x%"PRIx64") is a GFS1 journaled data block\n"), block, block); - fsck_blockmap_set(ip, block, "jdata", GFS2_BLKST_DINODE); + fsck_blockmap_set(cx, ip, block, "jdata", GFS2_BLKST_DINODE); } else - return blockmap_set_as_data(ip, block); + return blockmap_set_as_data(cx, ip, block); return 0; }
@@ -662,7 +662,7 @@ static int p1_check_eattr_indir(struct fsck_cx *cx, struct lgfs2_inode *ip, uint bc->ea_count++; ret = 0; /* For the same reason stated above. */ } else { - fsck_blockmap_set(ip, indirect, + fsck_blockmap_set(cx, ip, indirect, _("indirect Extended Attribute"), sdp->gfs1 ? GFS2_BLKST_DINODE : GFS2_BLKST_USED); bc->ea_count++; @@ -743,7 +743,7 @@ static int check_ealeaf_block(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64 /* Point of confusion: We've got to set the ea block itself to GFS2_BLKST_USED here. Elsewhere we mark the inode with gfs2_eattr_block meaning it contains an eattr. */ - fsck_blockmap_set(ip, block, _("Extended Attribute"), + fsck_blockmap_set(cx, ip, block, _("Extended Attribute"), sdp->gfs1 ? GFS2_BLKST_DINODE : GFS2_BLKST_USED); bc->ea_count++; *bh = leaf_bh; @@ -779,7 +779,7 @@ static int p1_check_extended_leaf_eattr(struct fsck_cx *cx, struct lgfs2_inode * "%"PRIu64" (0x%"PRIx64") has an extended leaf block #%"PRIu64" " "(0x%"PRIx64") that is invalid or out of range.\n"), ip->i_num.in_addr, ip->i_num.in_addr, ip->i_eattr, ip->i_eattr, el_blk, el_blk); - fsck_blockmap_set(ip, ip->i_eattr, _("bad (out of range) Extended Attribute "), + fsck_blockmap_set(cx, ip, ip->i_eattr, _("bad (out of range) Extended Attribute "), GFS2_BLKST_UNLINKED); error = 1; } else { @@ -798,7 +798,7 @@ static int p1_check_extended_leaf_eattr(struct fsck_cx *cx, struct lgfs2_inode * lgfs2_bmodified(leaf_bh); /* Endianness doesn't matter in this case because it's a single byte. */ - fsck_blockmap_set(ip, ip->i_eattr, + fsck_blockmap_set(cx, ip, ip->i_eattr, _("extended attribute"), sdp->gfs1 ? GFS2_BLKST_DINODE : GFS2_BLKST_USED); @@ -821,7 +821,7 @@ static int p1_check_eattr_leaf(struct fsck_cx *cx, struct lgfs2_inode *ip, uint6 "block #%"PRIu64" (0x%"PRIx64") is invalid or out of " "range.\n"), ip->i_num.in_addr, ip->i_num.in_addr, block, block); - fsck_blockmap_set(ip, ip->i_eattr, _("bad (out of range) extended attribute leaf"), + fsck_blockmap_set(cx, ip, ip->i_eattr, _("bad (out of range) extended attribute leaf"), GFS2_BLKST_UNLINKED); return 1; } @@ -1051,7 +1051,7 @@ static struct metawalk_fxns eattr_undo_fxns = { * * returns: 0 if no error, -EINVAL if dinode has a bad mode, -EPERM on error */ -static int set_ip_blockmap(struct lgfs2_inode *ip) +static int set_ip_blockmap(struct fsck_cx *cx, struct lgfs2_inode *ip) { uint64_t block = ip->i_bh->b_blocknr; struct lgfs2_inum no; @@ -1089,8 +1089,8 @@ static int set_ip_blockmap(struct lgfs2_inode *ip) return -EINVAL; } no = ip->i_num; - if (fsck_blockmap_set(ip, block, ty, GFS2_BLKST_DINODE) || - (mode == S_IFDIR && !dirtree_insert(no))) { + if (fsck_blockmap_set(cx, ip, block, ty, GFS2_BLKST_DINODE) || + (mode == S_IFDIR && !dirtree_insert(cx, no))) { stack; return -EPERM; } @@ -1149,7 +1149,7 @@ static int alloc_leaf(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t block after the bitmap has been set but before the blockmap has. */ q = bitmap_type(ip->i_sbd, block); if (q == GFS2_BLKST_FREE) - fsck_blockmap_set(ip, block, "newly allocated leaf", + fsck_blockmap_set(cx, ip, block, "newly allocated leaf", ip->i_sbd->gfs1 ? GFS2_BLKST_DINODE : GFS2_BLKST_USED); return 0; @@ -1240,11 +1240,11 @@ static int handle_ip(struct fsck_cx *cx, struct lgfs2_inode *ip) if (bad_pointers > BAD_POINTER_TOLERANCE) { log_err(_("Error: inode %"PRIu64" (0x%"PRIx64") has more than %d bad pointers.\n"), ip->i_num.in_addr, ip->i_num.in_addr, BAD_POINTER_TOLERANCE); - fsck_blockmap_set(ip, ip->i_num.in_addr, _("badly corrupt"), GFS2_BLKST_FREE); + fsck_blockmap_set(cx, ip, ip->i_num.in_addr, _("badly corrupt"), GFS2_BLKST_FREE); return 0; }
- error = set_ip_blockmap(ip); + error = set_ip_blockmap(cx, ip); if (error == -EINVAL) { /* We found a dinode that has an invalid mode. At this point set_ip_blockmap returned an error, which means it never @@ -1252,12 +1252,12 @@ static int handle_ip(struct fsck_cx *cx, struct lgfs2_inode *ip) processed its metadata with pass1_fxns, none of its metadata will be flagged as metadata or data blocks yet. Therefore, we don't need to invalidate anything. */ - fsck_blockmap_set(ip, ip->i_num.in_addr, _("invalid mode"), GFS2_BLKST_FREE); + fsck_blockmap_set(cx, ip, ip->i_num.in_addr, _("invalid mode"), GFS2_BLKST_FREE); return 0; } else if (error) goto bad_dinode;
- if (set_di_nlink(ip)) + if (set_di_nlink(cx, ip)) goto bad_dinode;
if (lf_dip) @@ -1410,7 +1410,7 @@ static int check_system_inode(struct fsck_cx *cx, log_err(_("Found invalid system dinode at block %"PRIu64" (0x%"PRIx64")\n"), iblock, iblock); blockmap_set(bl, iblock, GFS2_BLKST_FREE); - check_n_fix_bitmap(cx->sdp, (*sysinode)->i_rgd, iblock, 0, + check_n_fix_bitmap(cx, (*sysinode)->i_rgd, iblock, 0, GFS2_BLKST_FREE); lgfs2_inode_put(sysinode); } @@ -1424,12 +1424,12 @@ static int check_system_inode(struct fsck_cx *cx, if (ds.q == GFS2_BLKST_FREE) { log_info( _("The inode exists but the block is not " "marked 'in use'; fixing it.\n")); - fsck_blockmap_set(*sysinode, (*sysinode)->i_num.in_addr, + fsck_blockmap_set(cx, *sysinode, (*sysinode)->i_num.in_addr, filename, GFS2_BLKST_DINODE); ds.q = GFS2_BLKST_DINODE; if (isdir) { struct lgfs2_inum no = (*sysinode)->i_num; - dirtree_insert(no); + dirtree_insert(cx, no); } } /* Make sure it's marked as a system file/directory */ @@ -1474,12 +1474,12 @@ static int check_system_inode(struct fsck_cx *cx, } if (*sysinode == cx->sdp->md.jiinode) ji_update(cx->sdp); - fsck_blockmap_set(*sysinode, (*sysinode)->i_num.in_addr, + fsck_blockmap_set(cx, *sysinode, (*sysinode)->i_num.in_addr, filename, GFS2_BLKST_DINODE); ds.q = GFS2_BLKST_DINODE; if (isdir) { struct lgfs2_inum no = (*sysinode)->i_num; - dirtree_insert(no); + dirtree_insert(cx, no); } } else { log_err( _("Cannot continue without valid %s inode\n"), @@ -1613,7 +1613,7 @@ static int check_system_inodes(struct fsck_cx *cx) All other system dinodes in master will be taken care of by function resuscitate_metalist. But master won't since it has no parent.*/ if (!sdp->gfs1) { - fsck_blockmap_set(sdp->master_dir, sdp->master_dir->i_num.in_addr, + fsck_blockmap_set(cx, sdp->master_dir, sdp->master_dir->i_num.in_addr, "master", GFS2_BLKST_DINODE); if (check_system_inode(cx, &sdp->master_dir, "master", lgfs2_build_master, 1, NULL, 1)) { @@ -1623,7 +1623,7 @@ static int check_system_inodes(struct fsck_cx *cx) } /* Mark the root dinode as a "dinode" in the block map as we did for master, since it has no parent. */ - fsck_blockmap_set(sdp->md.rooti, sdp->md.rooti->i_num.in_addr, + fsck_blockmap_set(cx, sdp->md.rooti, sdp->md.rooti->i_num.in_addr, "root", GFS2_BLKST_DINODE); if (check_system_inode(cx, &sdp->md.rooti, "root", lgfs2_build_root, 1, NULL, 0)) { @@ -1673,13 +1673,13 @@ static int check_system_inodes(struct fsck_cx *cx) therefore not linked to anything else. We need to adjust the link counts so pass4 doesn't get confused. */ no = sdp->md.statfs->i_num; - incr_link_count(no, NULL, _("gfs1 statfs inode")); + incr_link_count(cx, no, NULL, _("gfs1 statfs inode")); no = sdp->md.jiinode->i_num; - incr_link_count(no, NULL, _("gfs1 jindex inode")); + incr_link_count(cx, no, NULL, _("gfs1 jindex inode")); no = sdp->md.riinode->i_num; - incr_link_count(no, NULL, _("gfs1 rindex inode")); + incr_link_count(cx, no, NULL, _("gfs1 rindex inode")); no = sdp->md.qinode->i_num; - incr_link_count(no, NULL, _("gfs1 quota inode")); + incr_link_count(cx, no, NULL, _("gfs1 quota inode")); return 0; } for (sdp->md.journals = 0; sdp->md.journals < journal_count; @@ -1802,7 +1802,7 @@ static int pass1_process_bitmap(struct fsck_cx *cx, struct lgfs2_rgrp_tree *rgd, } log_err(_("Found invalid inode at block %"PRIu64" (0x%"PRIx64")\n"), block, block); - check_n_fix_bitmap(sdp, rgd, block, 0, GFS2_BLKST_FREE); + check_n_fix_bitmap(cx, rgd, block, 0, GFS2_BLKST_FREE); } else if (handle_di(cx, rgd, bh) < 0) { stack; lgfs2_brelse(bh); diff --git a/gfs2/fsck/pass1b.c b/gfs2/fsck/pass1b.c index 034bfe82..480b2a13 100644 --- a/gfs2/fsck/pass1b.c +++ b/gfs2/fsck/pass1b.c @@ -328,16 +328,16 @@ static void resolve_dup_references(struct fsck_cx *cx, struct duptree *dt, and dirtree entries exist. That way, the bitmap_set will do proper accounting for the rgrp dinode count. */ - fsck_bitmap_set(ip, ip->i_num.in_addr, + fsck_bitmap_set(cx, ip, ip->i_num.in_addr, _("duplicate referencing bad"), GFS2_BLKST_FREE); /* Remove the inode from the inode tree */ ii = inodetree_find(ip->i_num.in_addr); if (ii) inodetree_delete(ii); - di = dirtree_find(ip->i_num.in_addr); + di = dirtree_find(cx, ip->i_num.in_addr); if (di) - dirtree_delete(di); + dirtree_delete(cx, di); link1_set(&nlink1map, ip->i_num.in_addr, 0); /* We delete the dup_handler inode count and @@ -414,7 +414,7 @@ static int clone_data(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t metab if (!error) { clone_bh = lgfs2_bread(ip->i_sbd, clonet->dup_block); if (clone_bh) { - fsck_bitmap_set(ip, cloneblock, _("data"), + fsck_bitmap_set(cx, ip, cloneblock, _("data"), GFS2_BLKST_USED); clone_bh->b_blocknr = cloneblock; lgfs2_bmodified(clone_bh); @@ -472,7 +472,7 @@ static void clone_dup_ref_in_inode(struct fsck_cx *cx, struct lgfs2_inode *ip, s } }
-static int set_ip_bitmap(struct lgfs2_inode *ip) +static int set_ip_bitmap(struct fsck_cx *cx, struct lgfs2_inode *ip) { uint64_t block = ip->i_bh->b_blocknr; uint32_t mode; @@ -508,7 +508,7 @@ static int set_ip_bitmap(struct lgfs2_inode *ip) default: return -EINVAL; } - fsck_bitmap_set(ip, block, ty, GFS2_BLKST_DINODE); + fsck_bitmap_set(cx, ip, block, ty, GFS2_BLKST_DINODE); return 0; }
@@ -545,24 +545,24 @@ static void resolve_last_reference(struct fsck_cx *cx, struct duptree *dt, "already marked free.\n"), id->block_no, id->block_no); } else if (id->reftypecount[REF_IS_INODE]) { - set_ip_bitmap(ip); + set_ip_bitmap(cx, ip); } else if (id->reftypecount[REF_AS_DATA]) { - fsck_bitmap_set(ip, dt->block, _("reference-repaired data"), + fsck_bitmap_set(cx, ip, dt->block, _("reference-repaired data"), GFS2_BLKST_USED); } else if (id->reftypecount[REF_AS_META]) { if (is_dir(ip, sdp->gfs1)) - fsck_bitmap_set(ip, dt->block, + fsck_bitmap_set(cx, ip, dt->block, _("reference-repaired leaf"), sdp->gfs1 ? GFS2_BLKST_DINODE : GFS2_BLKST_USED); else - fsck_bitmap_set(ip, dt->block, + fsck_bitmap_set(cx, ip, dt->block, _("reference-repaired indirect"), sdp->gfs1 ? GFS2_BLKST_DINODE : GFS2_BLKST_USED); } else { if (acceptable_ref == REF_AS_EA) - fsck_bitmap_set(ip, dt->block, + fsck_bitmap_set(cx, ip, dt->block, _("reference-repaired extended " "attribute"), sdp->gfs1 ? GFS2_BLKST_DINODE : @@ -581,7 +581,7 @@ static void resolve_last_reference(struct fsck_cx *cx, struct duptree *dt, ip->i_flags &= ~GFS2_DIF_EA_INDIRECT; ip->i_blocks--; lgfs2_bmodified(ip->i_bh); - fsck_bitmap_set(ip, dt->block, + fsck_bitmap_set(cx, ip, dt->block, _("reference-repaired EA"), GFS2_BLKST_FREE); log_err(_("The bad extended attribute was " @@ -724,7 +724,7 @@ static int handle_dup_blk(struct fsck_cx *cx, struct duptree *dt) dup_blk, dup_blk); if (dh.dt) dup_delete(cx, dh.dt); - check_n_fix_bitmap(cx->sdp, NULL, dup_blk, 0, + check_n_fix_bitmap(cx, NULL, dup_blk, 0, GFS2_BLKST_FREE); } } diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c index e5734fd6..8e07b225 100644 --- a/gfs2/fsck/pass2.c +++ b/gfs2/fsck/pass2.c @@ -33,11 +33,11 @@ static struct metawalk_fxns delete_eattrs = {
/* Set children's parent inode in dir_info structure - ext2 does not set * dotdot inode here, but instead in pass3 - should we? */ -static int set_parent_dir(struct lgfs2_sbd *sdp, struct lgfs2_inum child, struct lgfs2_inum parent) +static int set_parent_dir(struct fsck_cx *cx, struct lgfs2_inum child, struct lgfs2_inum parent) { struct dir_info *di;
- di = dirtree_find(child.in_addr); + di = dirtree_find(cx, child.in_addr); if (!di) { log_err(_("Unable to find block %"PRIu64" (0x%"PRIx64") in dir_info list\n"), child.in_addr, child.in_addr); @@ -63,11 +63,11 @@ static int set_parent_dir(struct lgfs2_sbd *sdp, struct lgfs2_inum child, struct }
/* Set's the child's '..' directory inode number in dir_info structure */ -static int set_dotdot_dir(struct lgfs2_sbd *sdp, uint64_t childblock, struct lgfs2_inum parent) +static int set_dotdot_dir(struct fsck_cx *cx, uint64_t childblock, struct lgfs2_inum parent) { struct dir_info *di;
- di = dirtree_find(childblock); + di = dirtree_find(cx, childblock); if (!di) { log_err( _("Unable to find block %"PRIu64" (0x%" PRIx64 ") in dir_info tree\n"), childblock, childblock); @@ -81,7 +81,7 @@ static int set_dotdot_dir(struct lgfs2_sbd *sdp, uint64_t childblock, struct lgf } /* Special case for root inode because we set it earlier */ if (di->dotdot_parent.in_addr && - sdp->md.rooti->i_num.in_addr != di->dinode.in_addr) { + cx->sdp->md.rooti->i_num.in_addr != di->dinode.in_addr) { /* This should never happen */ log_crit(_("Dotdot parent already set for block %"PRIu64" (0x%"PRIx64") " "-> %"PRIu64" (0x%"PRIx64")\n"), @@ -121,7 +121,7 @@ static const char *de_type_string(uint8_t de_type) return de_types[3]; /* invalid */ }
-static int check_file_type(uint64_t block, uint8_t de_type, int q, +static int check_file_type(struct fsck_cx *cx, uint64_t block, uint8_t de_type, int q, int gfs1, int *isdir) { struct dir_info *dt; @@ -134,7 +134,7 @@ static int check_file_type(uint64_t block, uint8_t de_type, int q, if (de_type == (gfs1 ? GFS_FILE_DIR : DT_DIR)) *isdir = 1; /* Check if the dinode is in the dir tree */ - dt = dirtree_find(block); + dt = dirtree_find(cx, block); /* This is a bit confusing, so let me explain: If the dirent says the inode supposed to be for a directory, it should be in the dir tree. If it is, no problem, return 0. @@ -160,7 +160,7 @@ static struct metawalk_fxns pass2_fxns_delete = { * Returns: 0 if the dirent was repaired * 1 if the caller should delete the dirent */ -static int bad_formal_ino(struct lgfs2_inode *ip, struct gfs2_dirent *dent, +static int bad_formal_ino(struct fsck_cx *cx, struct lgfs2_inode *ip, struct gfs2_dirent *dent, struct lgfs2_inum entry, const char *tmp_name, int q, struct lgfs2_dirent *d, struct lgfs2_buffer_head *bh) @@ -177,7 +177,7 @@ static int bad_formal_ino(struct lgfs2_inode *ip, struct gfs2_dirent *dent, if (ii) inum = ii->num; else { - di = dirtree_find(entry.in_addr); + di = dirtree_find(cx, entry.in_addr); if (di) inum = di->dinode; else if (link1_type(&clink1map, entry.in_addr) == 1) { @@ -216,8 +216,8 @@ static int bad_formal_ino(struct lgfs2_inode *ip, struct gfs2_dirent *dent, d->dr_inum.in_formal_ino = entry.in_formal_ino; lgfs2_dirent_out(d, dent); lgfs2_bmodified(bh); - incr_link_count(entry, ip, _("fixed reference")); - set_parent_dir(sdp, entry, ip->i_num); + incr_link_count(cx, entry, ip, _("fixed reference")); + set_parent_dir(cx, entry, ip->i_num); } else { log_err( _("Directory entry not fixed.\n")); } @@ -363,7 +363,7 @@ static int wrong_leaf(struct fsck_cx *cx, struct lgfs2_inode *ip, struct lgfs2_i log_err(_("The planned leaf was split. The new leaf " "is: %"PRIu64" (0x%"PRIx64"). di_blocks=%"PRIu64"\n"), real_leaf, real_leaf, ip->i_blocks); - fsck_bitmap_set(ip, real_leaf, _("split leaf"), + fsck_bitmap_set(cx, ip, real_leaf, _("split leaf"), sdp->gfs1 ? GFS2_BLKST_DINODE : GFS2_BLKST_USED); } @@ -382,7 +382,7 @@ static int wrong_leaf(struct fsck_cx *cx, struct lgfs2_inode *ip, struct lgfs2_i to nuke the dent from this leaf when we return, but we still need to do the "good dent" accounting. */ if (d->dr_type == (sdp->gfs1 ? GFS_FILE_DIR : DT_DIR)) { - error = set_parent_dir(sdp, d->dr_inum, ip->i_num); + error = set_parent_dir(cx, d->dr_inum, ip->i_num); if (error > 0) /* This is a bit of a kludge, but returning 0 in this case causes the caller to go through @@ -390,9 +390,9 @@ static int wrong_leaf(struct fsck_cx *cx, struct lgfs2_inode *ip, struct lgfs2_i deal properly with the hard link. */ return 0; } - error = incr_link_count(*entry, ip, _("moved valid reference")); + error = incr_link_count(cx, *entry, ip, _("moved valid reference")); if (error > 0 && - bad_formal_ino(ip, dent, *entry, tmp_name, q, d, bh) == 1) + bad_formal_ino(cx, ip, dent, *entry, tmp_name, q, d, bh) == 1) return 1; /* nuke it */
/* You cannot do this: @@ -538,7 +538,7 @@ static int basic_dentry_checks(struct fsck_cx *cx, struct lgfs2_inode *ip, struc return 1; }
- error = check_file_type(entry->in_addr, d->dr_type, *q, sdp->gfs1, isdir); + error = check_file_type(cx, entry->in_addr, d->dr_type, *q, sdp->gfs1, isdir); if (error < 0) { log_err(_("Error: directory entry type is incompatible with block type at block %"PRIu64 " (0x%"PRIx64") in directory inode %"PRIu64" (0x%"PRIx64").\n"), @@ -573,7 +573,7 @@ static int basic_dentry_checks(struct fsck_cx *cx, struct lgfs2_inode *ip, struc if (ii) inum = ii->num; else { - di = dirtree_find(entry->in_addr); + di = dirtree_find(cx, entry->in_addr); if (di) inum = di->dinode; else if (link1_type(&nlink1map, entry->in_addr) == 1) { @@ -654,7 +654,7 @@ static int dirref_find(struct fsck_cx *cx, struct lgfs2_inode *ip, struct gfs2_d log_err(_("The corrupt directory entry was not fixed.\n")); goto out; } - decr_link_count(entry->in_addr, ip->i_num.in_addr, ip->i_sbd->gfs1, + decr_link_count(cx, entry->in_addr, ip->i_num.in_addr, ip->i_sbd->gfs1, _("bad original reference")); lgfs2_dirent2_del(ip, bh, prev, dent); log_err(_("The corrupt directory entry '%s' was deleted.\n"), fn); @@ -693,7 +693,7 @@ static int check_suspicious_dirref(struct fsck_cx *cx, struct lgfs2_inum *entry) log_debug("This dentry is good, but since this is a second " "reference to block 0x%"PRIx64", we need to check the " "original.\n", entry->in_addr); - for (tmp = osi_first(&dirtree); tmp; tmp = next) { + for (tmp = osi_first(&cx->dirtree); tmp; tmp = next) { next = osi_next(tmp); dt = (struct dir_info *)tmp; dirblk = dt->dinode.in_addr; @@ -850,7 +850,7 @@ static int check_dentry(struct fsck_cx *cx, struct lgfs2_inode *ip, struct gfs2_ /* Add the address this entry is pointing to * to this inode's dotdot_parent in * dir_info */ - if (set_dotdot_dir(sdp, ip->i_num.in_addr, entry)) { + if (set_dotdot_dir(cx, ip->i_num.in_addr, entry)) { stack; return -1; } @@ -882,7 +882,7 @@ static int check_dentry(struct fsck_cx *cx, struct lgfs2_inode *ip, struct gfs2_ }
/*log_debug( _("Found plain directory dentry\n"));*/ - error = set_parent_dir(sdp, entry, ip->i_num); + error = set_parent_dir(cx, entry, ip->i_num); if (error > 0) { log_err(_("%s: Hard link to block %"PRIu64" (0x%"PRIx64") detected.\n"), tmp_name, entry.in_addr, entry.in_addr); @@ -899,12 +899,12 @@ static int check_dentry(struct fsck_cx *cx, struct lgfs2_inode *ip, struct gfs2_ } dentry_is_valid: /* This directory inode links to this inode via this dentry */ - error = incr_link_count(entry, ip, _("valid reference")); + error = incr_link_count(cx, entry, ip, _("valid reference")); if (error == INCR_LINK_CHECK_ORIG) { error = check_suspicious_dirref(cx, &entry); } 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, &d, bh) == 1) + if (bad_formal_ino(cx, ip, dent, entry, tmp_name, q, &d, bh) == 1) goto nuke_dentry; } (*count)++; @@ -926,7 +926,7 @@ nuke_dentry: * @before_or_after: desc. of whether this is being added before/after/etc. * @bn: pointer to return the newly allocated leaf's block number */ -static int write_new_leaf(struct lgfs2_inode *dip, int start_lindex, +static int write_new_leaf(struct fsck_cx *cx, struct lgfs2_inode *dip, int start_lindex, int num_copies, const char *before_or_after, uint64_t *bn) { @@ -963,7 +963,7 @@ static int write_new_leaf(struct lgfs2_inode *dip, int start_lindex, free(padbuf); return -1; } - fsck_bitmap_set(dip, *bn, _("directory leaf"), dip->i_sbd->gfs1 ? + fsck_bitmap_set(cx, dip, *bn, _("directory leaf"), dip->i_sbd->gfs1 ? GFS2_BLKST_DINODE : GFS2_BLKST_USED); log_err(_("A new directory leaf was allocated at block %"PRIu64" " "(0x%"PRIx64") to fill the %d (0x%x) pointer gap %s the existing " @@ -1020,7 +1020,7 @@ static int write_new_leaf(struct lgfs2_inode *dip, int start_lindex, * @lindex: index location within the hash table to pad * @len: number of pointers to be padded */ -static void pad_with_leafblks(struct lgfs2_inode *ip, __be64 *tbl, +static void pad_with_leafblks(struct fsck_cx *cx, struct lgfs2_inode *ip, __be64 *tbl, int lindex, int len) { int new_len, i; @@ -1045,11 +1045,11 @@ static void pad_with_leafblks(struct lgfs2_inode *ip, __be64 *tbl, break; new_len <<= 1; } - write_new_leaf(ip, lindex, new_len, "after", &new_leaf_blk); + write_new_leaf(cx, ip, lindex, new_len, "after", &new_leaf_blk); log_err(_("New leaf block was allocated at %"PRIu64" (0x%"PRIx64") for " "index %d (0x%x), length %d\n"), new_leaf_blk, new_leaf_blk, lindex, lindex, new_len); - fsck_bitmap_set(ip, new_leaf_blk, _("pad leaf"), + fsck_bitmap_set(cx, ip, new_leaf_blk, _("pad leaf"), ip->i_sbd->gfs1 ? GFS2_BLKST_DINODE : GFS2_BLKST_USED); /* Fix the hash table in memory to have the new leaf */ @@ -1086,7 +1086,7 @@ static int lost_leaf(struct fsck_cx *cx, struct lgfs2_inode *ip, __be64 *tbl, ui log_err( _("Directory leaf was not fixed.\n")); return 0; } - make_sure_lf_exists(ip); + make_sure_lf_exists(cx, ip);
dent = (struct gfs2_dirent *)(bh->b_data + sizeof(struct gfs2_leaf)); while (1) { @@ -1133,13 +1133,13 @@ static int lost_leaf(struct fsck_cx *cx, struct lgfs2_inode *ip, __be64 *tbl, ui return error; } /* This inode is linked from lost+found */ - incr_link_count(de.dr_inum, lf_dip, + incr_link_count(cx, de.dr_inum, lf_dip, _("from lost+found")); /* If it's a directory, lost+found is back-linked to it via .. */ if (isdir) { struct lgfs2_inum no = lf_dip->i_num; - incr_link_count(no, NULL, _("to lost+found")); + incr_link_count(cx, no, NULL, _("to lost+found")); } log_err(_("Relocated "%s", block %"PRIu64" (0x%"PRIx64") to lost+found.\n"), tmp_name, de.dr_inum.in_addr, de.dr_inum.in_addr); @@ -1152,14 +1152,14 @@ static int lost_leaf(struct fsck_cx *cx, struct lgfs2_inode *ip, __be64 *tbl, ui log_err(_("Directory entries from misplaced leaf block were relocated " "to lost+found.\n")); /* Free the lost leaf. */ - fsck_bitmap_set(ip, leafno, _("lost leaf"), GFS2_BLKST_FREE); + fsck_bitmap_set(cx, ip, leafno, _("lost leaf"), GFS2_BLKST_FREE); ip->i_blocks--; lgfs2_bmodified(ip->i_bh); /* Now we have to deal with the bad hash table entries pointing to the misplaced leaf block. But we can't just fill the gap with a single leaf. We have to write on nice power-of-two boundaries, and we have to pad out any extra pointers. */ - pad_with_leafblks(ip, tbl, lindex, ref_count); + pad_with_leafblks(cx, ip, tbl, lindex, ref_count); return 1; }
@@ -1231,7 +1231,7 @@ static int pass2_repair_leaf(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_ break; refs *= 2; } - error = write_new_leaf(ip, lindex, refs, _("replacing"), &bn); + error = write_new_leaf(cx, ip, lindex, refs, _("replacing"), &bn); if (error) return error;
@@ -1339,7 +1339,7 @@ static int fix_hashtable(struct fsck_cx *cx, struct lgfs2_inode *ip, __be64 *tbl log_err(_("Out of place leaf block %"PRIu64" (0x%"PRIx64") had no " "entries, so it was deleted.\n"), leafblk, leafblk); - pad_with_leafblks(ip, tbl, lindex, len); + pad_with_leafblks(cx, ip, tbl, lindex, len); log_err(_("Reprocessing index 0x%x (case 1).\n"), lindex); return 1; } @@ -1369,7 +1369,7 @@ static int fix_hashtable(struct fsck_cx *cx, struct lgfs2_inode *ip, __be64 *tbl log_err(_("Leaf pointers start at %d (0x%x), should be %d " "(%x).\n"), lindex, lindex, leaf_proper_start, leaf_proper_start); - pad_with_leafblks(ip, tbl, lindex, leaf_proper_start - lindex); + pad_with_leafblks(cx, ip, tbl, lindex, leaf_proper_start - lindex); lgfs2_brelse(lbh); return 1; /* reprocess the starting lindex */ } @@ -1415,7 +1415,7 @@ static int fix_hashtable(struct fsck_cx *cx, struct lgfs2_inode *ip, __be64 *tbl log_err(_("New split-off leaf block was allocated at %"PRIu64" " "(0x%"PRIx64") for index %d (0x%x)\n"), new_leaf_blk, new_leaf_blk, lindex, lindex); - fsck_bitmap_set(ip, new_leaf_blk, _("split leaf"), + fsck_bitmap_set(cx, ip, new_leaf_blk, _("split leaf"), ip->i_sbd->gfs1 ? GFS2_BLKST_DINODE : GFS2_BLKST_USED); log_err(_("Hash table repaired.\n")); @@ -1453,7 +1453,7 @@ static int fix_hashtable(struct fsck_cx *cx, struct lgfs2_inode *ip, __be64 *tbl if (extras) { log_err(_("Found %d extra pointers to leaf %"PRIu64" (0x%"PRIx64")\n"), extras, leafblk, leafblk); - pad_with_leafblks(ip, tbl, lindex, extras); + pad_with_leafblks(cx, ip, tbl, lindex, extras); log_err(_("Reprocessing index 0x%x (case 2).\n"), lindex); return 1; } @@ -1461,7 +1461,7 @@ static int fix_hashtable(struct fsck_cx *cx, struct lgfs2_inode *ip, __be64 *tbl }
/* check_hash_tbl_dups - check for the same leaf in multiple places */ -static int check_hash_tbl_dups(struct lgfs2_inode *ip, __be64 *tbl, +static int check_hash_tbl_dups(struct fsck_cx *cx, struct lgfs2_inode *ip, __be64 *tbl, unsigned hsize, int lindex, int len) { int l, len2; @@ -1526,7 +1526,7 @@ static int check_hash_tbl_dups(struct lgfs2_inode *ip, __be64 *tbl, count to include them. So we must subtract them. */ ip->i_blocks--; lgfs2_bmodified(ip->i_bh); - pad_with_leafblks(ip, tbl, l, len2); + pad_with_leafblks(cx, ip, tbl, l, len2); } else { log_debug(_("Hash index 0x%x is the proper reference to leaf 0x%"PRIx64".\n"), l, leafblk); @@ -1545,7 +1545,7 @@ static int check_hash_tbl_dups(struct lgfs2_inode *ip, __be64 *tbl, } ip->i_blocks--; lgfs2_bmodified(ip->i_bh); - pad_with_leafblks(ip, tbl, lindex, len); + pad_with_leafblks(cx, ip, tbl, lindex, len); /* At this point we know both copies are bad, so we return to start fresh */ return -EFAULT; @@ -1638,7 +1638,7 @@ static int check_hash_tbl(struct fsck_cx *cx, struct lgfs2_inode *ip, __be64 *tb lindex += len; continue; } - error = write_new_leaf(ip, lindex, proper_len, + error = write_new_leaf(cx, ip, lindex, proper_len, _("replacing"), &new_leafblk); if (error) return error; @@ -1649,7 +1649,7 @@ static int check_hash_tbl(struct fsck_cx *cx, struct lgfs2_inode *ip, __be64 *tb continue; }
- if (check_hash_tbl_dups(ip, tbl, hsize, lindex, len)) + if (check_hash_tbl_dups(cx, ip, tbl, hsize, lindex, len)) continue;
/* Make sure they call on proper leaf-split boundaries. This @@ -1869,7 +1869,7 @@ build_it: log_err(_("Error rebuilding %s.\n"), fn); return -1; } - fsck_bitmap_set(ip, ip->i_num.in_addr, fn, GFS2_BLKST_DINODE); + fsck_bitmap_set(cx, ip, ip->i_num.in_addr, fn, GFS2_BLKST_DINODE); log_err(_("System file %s rebuilt.\n"), fn); goto out_good; } @@ -1941,7 +1941,7 @@ static int check_system_dir(struct fsck_cx *cx, struct lgfs2_inode *sysinode, co return -1; } if (error > 0) - fsck_bitmap_set(sysinode, iblock, dirname, GFS2_BLKST_FREE); + fsck_bitmap_set(cx, sysinode, iblock, dirname, GFS2_BLKST_FREE);
if (check_inode_eattr(cx, sysinode, &pass2_fxns)) { stack; @@ -1960,7 +1960,7 @@ static int check_system_dir(struct fsck_cx *cx, struct lgfs2_inode *sysinode, co return -errno; } /* This system inode is linked to itself via '.' */ - incr_link_count(no, sysinode, "sysinode ".""); + incr_link_count(cx, no, sysinode, "sysinode ".""); ds.entry_count++; } else log_err( _("The directory was not fixed.\n")); @@ -2034,7 +2034,7 @@ static int pass2_check_dir(struct fsck_cx *cx, struct lgfs2_inode *ip) if (error > 0) { struct dir_info *di;
- di = dirtree_find(dirblk); + di = dirtree_find(cx, dirblk); if (!di) { stack; return FSCK_ERROR; @@ -2056,7 +2056,7 @@ static int pass2_check_dir(struct fsck_cx *cx, struct lgfs2_inode *ip)
log_debug(_("Directory block %"PRIu64" (0x%"PRIx64") is now marked as 'invalid'\n"), dirblk, dirblk); - check_n_fix_bitmap(cx->sdp, ip->i_rgd, dirblk, 0, GFS2_BLKST_FREE); + check_n_fix_bitmap(cx, ip->i_rgd, dirblk, 0, GFS2_BLKST_FREE); }
if (!ds.dotdir) { @@ -2073,7 +2073,7 @@ static int pass2_check_dir(struct fsck_cx *cx, struct lgfs2_inode *ip) return -errno; } /* directory links to itself via '.' */ - incr_link_count(no, ip, _("". (itself)"")); + incr_link_count(cx, no, ip, _("". (itself)"")); ds.entry_count++; log_err(_("The directory was fixed.\n")); } else { @@ -2144,7 +2144,7 @@ int pass2(struct fsck_cx *cx) return FSCK_OK; log_info( _("Checking directory inodes.\n")); /* Grab each directory inode, and run checks on it */ - for (tmp = osi_first(&dirtree); tmp; tmp = next) { + for (tmp = osi_first(&cx->dirtree); tmp; tmp = next) { next = osi_next(tmp);
dt = (struct dir_info *)tmp; diff --git a/gfs2/fsck/pass3.c b/gfs2/fsck/pass3.c index 0495382c..293a66a8 100644 --- a/gfs2/fsck/pass3.c +++ b/gfs2/fsck/pass3.c @@ -18,7 +18,7 @@ #include "util.h" #include "afterpass1_common.h"
-static int attach_dotdot_to(struct lgfs2_sbd *sdp, uint64_t newdotdot, +static int attach_dotdot_to(struct fsck_cx *cx, uint64_t newdotdot, uint64_t olddotdot, uint64_t block) { const char *filename = ".."; @@ -27,8 +27,8 @@ static int attach_dotdot_to(struct lgfs2_sbd *sdp, uint64_t newdotdot, struct lgfs2_inode *ip, *pip; struct lgfs2_inum no;
- ip = fsck_load_inode(sdp, block); - pip = fsck_load_inode(sdp, newdotdot); + ip = fsck_load_inode(cx->sdp, block); + pip = fsck_load_inode(cx->sdp, newdotdot); /* FIXME: Need to add some interactive * options here and come up with a * good default for non-interactive */ @@ -39,16 +39,16 @@ static int attach_dotdot_to(struct lgfs2_sbd *sdp, uint64_t newdotdot, if (lgfs2_dirent_del(ip, filename, filename_len)) log_warn( _("Unable to remove ".." directory entry.\n")); else - decr_link_count(olddotdot, block, sdp->gfs1, _("old ".."")); + decr_link_count(cx, olddotdot, block, cx->sdp->gfs1, _("old ".."")); no = pip->i_num; err = lgfs2_dir_add(ip, filename, filename_len, &no, - (sdp->gfs1 ? GFS_FILE_DIR : DT_DIR)); + (cx->sdp->gfs1 ? GFS_FILE_DIR : DT_DIR)); if (err) { log_err(_("Error adding directory %s: %s\n"), filename, strerror(errno)); exit(FSCK_ERROR); } - incr_link_count(no, ip, _("new ".."")); + incr_link_count(cx, no, ip, _("new ".."")); fsck_inode_put(&ip); fsck_inode_put(&pip); return 0; @@ -83,9 +83,9 @@ static struct dir_info *mark_and_return_parent(struct fsck_cx *cx, struct dir_in log_notice(_("'..' has %"PRIu64" (0x%"PRIx64"), treewalk has %"PRIu64" (0x%"PRIx64")\n"), di->dotdot_parent.in_addr, di->dotdot_parent.in_addr, di->treewalk_parent, di->treewalk_parent); q_dotdot = bitmap_type(sdp, di->dotdot_parent.in_addr); - dt_dotdot = dirtree_find(di->dotdot_parent.in_addr); + dt_dotdot = dirtree_find(cx, di->dotdot_parent.in_addr); q_treewalk = bitmap_type(sdp, di->treewalk_parent); - dt_treewalk = dirtree_find(di->treewalk_parent); + dt_treewalk = dirtree_find(cx, di->treewalk_parent); /* if the dotdot entry isn't a directory, but the * treewalk is, treewalk is correct - if the treewalk * entry isn't a directory, but the dotdot is, dotdot @@ -101,7 +101,7 @@ static struct dir_info *mark_and_return_parent(struct fsck_cx *cx, struct dir_in } else { log_warn(_("Treewalk parent is correct, fixing dotdot -> %"PRIu64" (0x%"PRIx64")\n"), di->treewalk_parent, di->treewalk_parent); - attach_dotdot_to(sdp, di->treewalk_parent, + attach_dotdot_to(cx, di->treewalk_parent, di->dotdot_parent.in_addr, di->dinode.in_addr); di->dotdot_parent.in_addr = di->treewalk_parent; @@ -111,7 +111,7 @@ static struct dir_info *mark_and_return_parent(struct fsck_cx *cx, struct dir_in if (dt_treewalk) { log_err( _("Both .. and treewalk parents are directories, " "going with treewalk...\n")); - attach_dotdot_to(sdp, di->treewalk_parent, + attach_dotdot_to(cx, di->treewalk_parent, di->dotdot_parent.in_addr, di->dinode.in_addr); di->dotdot_parent.in_addr = di->treewalk_parent; @@ -145,7 +145,7 @@ static struct dir_info *mark_and_return_parent(struct fsck_cx *cx, struct dir_in return NULL;
out: - pdi = dirtree_find(di->dotdot_parent.in_addr); + pdi = dirtree_find(cx, di->dotdot_parent.in_addr);
return pdi; } @@ -164,38 +164,38 @@ int pass3(struct fsck_cx *cx) struct lgfs2_inode *ip; int q;
- di = dirtree_find(sdp->md.rooti->i_num.in_addr); + di = dirtree_find(cx, sdp->md.rooti->i_num.in_addr); if (di) { log_info( _("Marking root inode connected\n")); di->checked = 1; } if (sdp->gfs1) { - di = dirtree_find(sdp->md.statfs->i_num.in_addr); + di = dirtree_find(cx, sdp->md.statfs->i_num.in_addr); if (di) { log_info( _("Marking GFS1 statfs file inode " "connected\n")); di->checked = 1; } - di = dirtree_find(sdp->md.jiinode->i_num.in_addr); + di = dirtree_find(cx, sdp->md.jiinode->i_num.in_addr); if (di) { log_info( _("Marking GFS1 jindex file inode " "connected\n")); di->checked = 1; } - di = dirtree_find(sdp->md.riinode->i_num.in_addr); + di = dirtree_find(cx, sdp->md.riinode->i_num.in_addr); if (di) { log_info( _("Marking GFS1 rindex file inode " "connected\n")); di->checked = 1; } - di = dirtree_find(sdp->md.qinode->i_num.in_addr); + di = dirtree_find(cx, sdp->md.qinode->i_num.in_addr); if (di) { log_info( _("Marking GFS1 quota file inode " "connected\n")); di->checked = 1; } } else { - di = dirtree_find(sdp->master_dir->i_num.in_addr); + di = dirtree_find(cx, sdp->master_dir->i_num.in_addr); if (di) { log_info( _("Marking master directory inode " "connected\n")); @@ -208,7 +208,7 @@ int pass3(struct fsck_cx *cx) * find a parent, put in lost+found. */ log_info( _("Checking directory linkage.\n")); - for (tmp = osi_first(&dirtree); tmp; tmp = next) { + for (tmp = osi_first(&cx->dirtree); tmp; tmp = next) { next = osi_next(tmp); di = (struct dir_info *)tmp; while (!di->checked) { @@ -238,7 +238,7 @@ int pass3(struct fsck_cx *cx) "now marked as free\n"), di->dinode.in_addr, di->dinode.in_addr); - check_n_fix_bitmap(sdp, ip->i_rgd, + check_n_fix_bitmap(cx, ip->i_rgd, di->dinode.in_addr, 0, GFS2_BLKST_FREE); fsck_inode_put(&ip); @@ -259,7 +259,7 @@ int pass3(struct fsck_cx *cx) log_warn( _("inode %"PRIu64" (0x%"PRIx64") is now " "marked as free\n"), di->dinode.in_addr, di->dinode.in_addr); - check_n_fix_bitmap(sdp, ip->i_rgd, + check_n_fix_bitmap(cx, ip->i_rgd, di->dinode.in_addr, 0, GFS2_BLKST_FREE); log_err( _("The block was cleared\n")); @@ -275,7 +275,7 @@ int pass3(struct fsck_cx *cx) "size.\n")); if (query( _("Remove zero-size unlinked " "directory? (y/n) "))) { - fsck_bitmap_set(ip, di->dinode.in_addr, + fsck_bitmap_set(cx, ip, di->dinode.in_addr, _("zero-sized unlinked inode"), GFS2_BLKST_FREE); fsck_inode_put(&ip); @@ -287,7 +287,7 @@ int pass3(struct fsck_cx *cx) } if (query( _("Add unlinked directory to " "lost+found? (y/n) "))) { - if (add_inode_to_lf(ip)) { + if (add_inode_to_lf(cx, ip)) { fsck_inode_put(&ip); stack; return FSCK_ERROR; diff --git a/gfs2/fsck/pass4.c b/gfs2/fsck/pass4.c index b3441cf9..c81f0114 100644 --- a/gfs2/fsck/pass4.c +++ b/gfs2/fsck/pass4.c @@ -66,7 +66,7 @@ static int handle_unlinked(struct fsck_cx *cx, uint64_t no_addr, ip = fsck_load_inode(sdp, no_addr); check_inode_eattr(cx, ip, &pass4_fxns_delete); check_metatree(cx, ip, &pass4_fxns_delete); - fsck_bitmap_set(ip, no_addr, _("bad unlinked"), + fsck_bitmap_set(cx, ip, no_addr, _("bad unlinked"), GFS2_BLKST_FREE); fsck_inode_put(&ip); return 1; @@ -81,7 +81,7 @@ static int handle_unlinked(struct fsck_cx *cx, uint64_t no_addr, if (query(_("Delete unlinked inode? (y/n) "))) { check_inode_eattr(cx, ip, &pass4_fxns_delete); check_metatree(cx, ip, &pass4_fxns_delete); - fsck_bitmap_set(ip, no_addr, _("invalid unlinked"), + fsck_bitmap_set(cx, ip, no_addr, _("invalid unlinked"), GFS2_BLKST_FREE); fsck_inode_put(&ip); log_err( _("The inode was deleted\n")); @@ -98,14 +98,14 @@ static int handle_unlinked(struct fsck_cx *cx, uint64_t no_addr, if (!ip->i_size && !ip->i_eattr){ log_err( _("Unlinked inode has zero size\n")); if (query(_("Clear zero-size unlinked inode? (y/n) "))) { - fsck_bitmap_set(ip, no_addr, _("unlinked zero-length"), + fsck_bitmap_set(cx, ip, no_addr, _("unlinked zero-length"), GFS2_BLKST_FREE); fsck_inode_put(&ip); return 1; } } if (query( _("Add unlinked inode to lost+found? (y/n)"))) { - if (add_inode_to_lf(ip)) { + if (add_inode_to_lf(cx, ip)) { stack; fsck_inode_put(&ip); return -1; @@ -141,7 +141,7 @@ static void handle_inconsist(struct lgfs2_sbd *sdp, uint64_t no_addr, } }
-static int adjust_lf_links(int lf_addition) +static int adjust_lf_links(struct fsck_cx *cx, int lf_addition) { struct dir_info *lf_di;
@@ -151,7 +151,7 @@ static int adjust_lf_links(int lf_addition) if (!lf_addition) return 0;
- if (!(lf_di = dirtree_find(lf_dip->i_num.in_addr))) { + if (!(lf_di = dirtree_find(cx, lf_dip->i_num.in_addr))) { log_crit(_("Unable to find lost+found inode in " "inode_hash!!\n")); return -1; @@ -194,7 +194,7 @@ static int scan_inode_list(struct fsck_cx *cx) ii->num.in_addr, ii->num.in_addr, ii->di_nlink); } /* osi_list_foreach(tmp, list) */
- return adjust_lf_links(lf_addition); + return adjust_lf_links(cx, lf_addition); }
static int scan_dir_list(struct fsck_cx *cx) @@ -206,7 +206,7 @@ static int scan_dir_list(struct fsck_cx *cx)
/* FIXME: should probably factor this out into a generic * scanning fxn */ - for (tmp = osi_first(&dirtree); tmp; tmp = next) { + for (tmp = osi_first(&cx->dirtree); tmp; tmp = next) { if (skip_this_pass || fsck_abort) /* if asked to skip the rest */ return 0; next = osi_next(tmp); @@ -227,7 +227,7 @@ static int scan_dir_list(struct fsck_cx *cx) di->dinode.in_addr, di->dinode.in_addr, di->di_nlink); } /* osi_list_foreach(tmp, list) */
- return adjust_lf_links(lf_addition); + return adjust_lf_links(cx, lf_addition); }
static int scan_nlink1_list(struct fsck_cx *cx) @@ -252,7 +252,7 @@ static int scan_nlink1_list(struct fsck_cx *cx) continue; } } - return adjust_lf_links(lf_addition); + return adjust_lf_links(cx, lf_addition); }
/** diff --git a/gfs2/fsck/util.c b/gfs2/fsck/util.c index df791409..7beb63e9 100644 --- a/gfs2/fsck/util.c +++ b/gfs2/fsck/util.c @@ -424,9 +424,9 @@ int add_duplicate_ref(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t block return META_IS_GOOD; }
-struct dir_info *dirtree_insert(struct lgfs2_inum inum) +struct dir_info *dirtree_insert(struct fsck_cx *cx, struct lgfs2_inum inum) { - struct osi_node **newn = &dirtree.osi_node, *parent = NULL; + struct osi_node **newn = &cx->dirtree.osi_node, *parent = NULL; struct dir_info *data;
/* Figure out where to put new node */ @@ -451,14 +451,14 @@ struct dir_info *dirtree_insert(struct lgfs2_inum inum) data->dinode.in_addr = inum.in_addr; data->dinode.in_formal_ino = inum.in_formal_ino; osi_link_node(&data->node, parent, newn); - osi_insert_color(&data->node, &dirtree); + osi_insert_color(&data->node, &cx->dirtree);
return data; }
-struct dir_info *dirtree_find(uint64_t block) +struct dir_info *dirtree_find(struct fsck_cx *cx, uint64_t block) { - struct osi_node *node = dirtree.osi_node; + struct osi_node *node = cx->dirtree.osi_node;
while (node) { struct dir_info *data = (struct dir_info *)node; @@ -529,9 +529,9 @@ void dup_delete(struct fsck_cx *cx, struct duptree *dt) free(dt); }
-void dirtree_delete(struct dir_info *b) +void dirtree_delete(struct fsck_cx *cx, struct dir_info *b) { - osi_erase(&b->node, &dirtree); + osi_erase(&b->node, &cx->dirtree); free(b); }
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 24a3ebaf1855c408393a80acf93bfb6737361036 Author: Andrew Price anprice@redhat.com AuthorDate: Fri Jul 29 19:55:35 2022 +0100
fsck.gfs2: Move the global inodetree into fsck_cx
Signed-off-by: Andrew Price anprice@redhat.com --- gfs2/fsck/fsck.h | 2 +- gfs2/fsck/initialize.c | 8 ++++---- gfs2/fsck/inode_hash.c | 14 +++++++------- gfs2/fsck/inode_hash.h | 8 +++++--- gfs2/fsck/link.c | 10 +++++----- gfs2/fsck/main.c | 1 - gfs2/fsck/metawalk.c | 6 +++--- gfs2/fsck/pass1b.c | 4 ++-- gfs2/fsck/pass2.c | 4 ++-- gfs2/fsck/pass4.c | 2 +- 10 files changed, 30 insertions(+), 29 deletions(-)
diff --git a/gfs2/fsck/fsck.h b/gfs2/fsck/fsck.h index 2ae182d5..38b73529 100644 --- a/gfs2/fsck/fsck.h +++ b/gfs2/fsck/fsck.h @@ -112,6 +112,7 @@ struct fsck_cx { struct lgfs2_sbd *sdp; struct osi_root dup_blocks; struct osi_root dirtree; + struct osi_root inodetree; };
extern struct lgfs2_inode *fsck_load_inode(struct lgfs2_sbd *sdp, uint64_t block); @@ -156,7 +157,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 inodetree; extern int dups_found; /* How many duplicate references have we found? */ extern int dups_found_first; /* How many duplicates have we found the original reference for? */ diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c index f671abba..efceb271 100644 --- a/gfs2/fsck/initialize.c +++ b/gfs2/fsck/initialize.c @@ -89,14 +89,14 @@ static void dirtree_free(struct fsck_cx *cx) } }
-static void inodetree_free(void) +static void inodetree_free(struct fsck_cx *cx) { struct osi_node *n; struct inode_info *dt;
- while ((n = osi_first(&inodetree))) { + while ((n = osi_first(&cx->inodetree))) { dt = (struct inode_info *)n; - inodetree_delete(dt); + inodetree_delete(cx, dt); } }
@@ -114,7 +114,7 @@ static void empty_super_block(struct fsck_cx *cx) log_info( _("Freeing buffers.\n")); lgfs2_rgrp_free(cx->sdp, &cx->sdp->rgtree);
- inodetree_free(); + inodetree_free(cx); dirtree_free(cx); dup_free(cx); } diff --git a/gfs2/fsck/inode_hash.c b/gfs2/fsck/inode_hash.c index a1e67b23..f32b7c73 100644 --- a/gfs2/fsck/inode_hash.c +++ b/gfs2/fsck/inode_hash.c @@ -12,9 +12,9 @@ #include "fsck.h" #define _(String) gettext(String)
-struct inode_info *inodetree_find(uint64_t block) +struct inode_info *inodetree_find(struct fsck_cx *cx, uint64_t block) { - struct osi_node *node = inodetree.osi_node; + struct osi_node *node = cx->inodetree.osi_node;
while (node) { struct inode_info *data = (struct inode_info *)node; @@ -29,9 +29,9 @@ struct inode_info *inodetree_find(uint64_t block) return NULL; }
-struct inode_info *inodetree_insert(struct lgfs2_inum no) +struct inode_info *inodetree_insert(struct fsck_cx *cx, struct lgfs2_inum no) { - struct osi_node **newn = &inodetree.osi_node, *parent = NULL; + struct osi_node **newn = &cx->inodetree.osi_node, *parent = NULL; struct inode_info *data;
/* Figure out where to put new node */ @@ -55,13 +55,13 @@ struct inode_info *inodetree_insert(struct lgfs2_inum no) /* Add new node and rebalance tree. */ data->num = no; osi_link_node(&data->node, parent, newn); - osi_insert_color(&data->node, &inodetree); + osi_insert_color(&data->node, &cx->inodetree);
return data; }
-void inodetree_delete(struct inode_info *b) +void inodetree_delete(struct fsck_cx *cx, struct inode_info *b) { - osi_erase(&b->node, &inodetree); + osi_erase(&b->node, &cx->inodetree); free(b); } diff --git a/gfs2/fsck/inode_hash.h b/gfs2/fsck/inode_hash.h index da9d15ce..5f6b499f 100644 --- a/gfs2/fsck/inode_hash.h +++ b/gfs2/fsck/inode_hash.h @@ -1,10 +1,12 @@ #ifndef _INODE_HASH_H #define _INODE_HASH_H
+#include "fsck.h" + struct inode_info;
-extern struct inode_info *inodetree_find(uint64_t block); -extern struct inode_info *inodetree_insert(struct lgfs2_inum no); -extern void inodetree_delete(struct inode_info *b); +extern struct inode_info *inodetree_find(struct fsck_cx *cx, uint64_t block); +extern struct inode_info *inodetree_insert(struct fsck_cx *cx, struct lgfs2_inum no); +extern void inodetree_delete(struct fsck_cx *cx, struct inode_info *b);
#endif /* _INODE_HASH_H */ diff --git a/gfs2/fsck/link.c b/gfs2/fsck/link.c index 690d58ef..426552b6 100644 --- a/gfs2/fsck/link.c +++ b/gfs2/fsck/link.c @@ -58,10 +58,10 @@ int set_di_nlink(struct fsck_cx *cx, struct lgfs2_inode *ip) /*log_debug( _("Setting link count to %u for %" PRIu64 " (0x%" PRIx64 ")\n"), count, inode_no, inode_no);*/ /* If the list has entries, look for one that matches inode_no */ - ii = inodetree_find(ip->i_num.in_addr); + ii = inodetree_find(cx, ip->i_num.in_addr); if (!ii) { struct lgfs2_inum no = ip->i_num; - ii = inodetree_insert(no); + ii = inodetree_insert(cx, no); } if (ii) ii->di_nlink = ip->i_nlink; @@ -93,7 +93,7 @@ int incr_link_count(struct fsck_cx *cx, struct lgfs2_inum no, struct lgfs2_inode whyincr(no.in_addr, why, referenced_from, di->counted_links); return INCR_LINK_GOOD; } - ii = inodetree_find(no.in_addr); + ii = inodetree_find(cx, no.in_addr); /* If the list has entries, look for one that matches inode_no */ if (ii) { if (ii->num.in_formal_ino != no.in_formal_ino) @@ -122,7 +122,7 @@ int incr_link_count(struct fsck_cx *cx, struct lgfs2_inum no, struct lgfs2_inode /* If no match was found, it must be a hard link. In theory, it can't be a duplicate because those were resolved in pass1b. Add a new inodetree entry and set its counted links to 2 */ - ii = inodetree_insert(no); + ii = inodetree_insert(cx, no); if (!ii) { log_debug(_("Ref: 0x%"PRIx64" Error incrementing link for 0x%"PRIx64"\n"), referenced_from, no.in_addr); @@ -166,7 +166,7 @@ int decr_link_count(struct fsck_cx *cx, uint64_t inode_no, uint64_t referenced_f return 0; }
- ii = inodetree_find(inode_no); + ii = inodetree_find(cx, inode_no); /* If the list has entries, look for one that matches * inode_no */ if (ii) { diff --git a/gfs2/fsck/main.c b/gfs2/fsck/main.c index 34111103..d980f864 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 inodetree; int dups_found = 0, dups_found_first = 0; int sb_fixed = 0; int print_level = MSG_NOTICE; diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c index 25557673..498a2abe 100644 --- a/gfs2/fsck/metawalk.c +++ b/gfs2/fsck/metawalk.c @@ -97,9 +97,9 @@ int check_n_fix_bitmap(struct fsck_cx *cx, struct lgfs2_rgrp_tree *rgd, dirtree_delete(cx, dt); treat_as_inode = 1; } - ii = inodetree_find(blk); + ii = inodetree_find(cx, blk); if (ii) { - inodetree_delete(ii); + inodetree_delete(cx, ii); treat_as_inode = 1; } else if (!sdp->gfs1) { treat_as_inode = 1; @@ -134,7 +134,7 @@ int check_n_fix_bitmap(struct fsck_cx *cx, struct lgfs2_rgrp_tree *rgd, if (dt) treat_as_inode = 1; else { - ii = inodetree_find(blk); + ii = inodetree_find(cx, blk); if (ii) treat_as_inode = 1; } diff --git a/gfs2/fsck/pass1b.c b/gfs2/fsck/pass1b.c index 480b2a13..b3fe1b4f 100644 --- a/gfs2/fsck/pass1b.c +++ b/gfs2/fsck/pass1b.c @@ -332,9 +332,9 @@ static void resolve_dup_references(struct fsck_cx *cx, struct duptree *dt, _("duplicate referencing bad"), GFS2_BLKST_FREE); /* Remove the inode from the inode tree */ - ii = inodetree_find(ip->i_num.in_addr); + ii = inodetree_find(cx, ip->i_num.in_addr); if (ii) - inodetree_delete(ii); + inodetree_delete(cx, ii); di = dirtree_find(cx, ip->i_num.in_addr); if (di) dirtree_delete(cx, di); diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c index 8e07b225..9d5f2489 100644 --- a/gfs2/fsck/pass2.c +++ b/gfs2/fsck/pass2.c @@ -173,7 +173,7 @@ static int bad_formal_ino(struct fsck_cx *cx, struct lgfs2_inode *ip, struct gfs int error; struct lgfs2_inum inum = {0};
- ii = inodetree_find(entry.in_addr); + ii = inodetree_find(cx, entry.in_addr); if (ii) inum = ii->num; else { @@ -569,7 +569,7 @@ static int basic_dentry_checks(struct fsck_cx *cx, struct lgfs2_inode *ip, struc } /* We need to verify the formal inode number matches. If it doesn't, it needs to be deleted. */ - ii = inodetree_find(entry->in_addr); + ii = inodetree_find(cx, entry->in_addr); if (ii) inum = ii->num; else { diff --git a/gfs2/fsck/pass4.c b/gfs2/fsck/pass4.c index c81f0114..12afabbd 100644 --- a/gfs2/fsck/pass4.c +++ b/gfs2/fsck/pass4.c @@ -170,7 +170,7 @@ static int scan_inode_list(struct fsck_cx *cx)
/* FIXME: should probably factor this out into a generic * scanning fxn */ - for (tmp = osi_first(&inodetree); tmp; tmp = next) { + for (tmp = osi_first(&cx->inodetree); tmp; tmp = next) { if (skip_this_pass || fsck_abort) /* if asked to skip the rest */ return 0; next = osi_next(tmp);
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 5a517177ccb19ffc89d0616fcefec8282813739a Author: Andrew Price anprice@redhat.com AuthorDate: Mon Aug 1 08:47:25 2022 +0100
fsck.gfs2: Move the global preen into fsck_options
Signed-off-by: Andrew Price anprice@redhat.com --- gfs2/fsck/fsck.h | 1 + gfs2/fsck/main.c | 11 +++++------ 2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/gfs2/fsck/fsck.h b/gfs2/fsck/fsck.h index 38b73529..603149b2 100644 --- a/gfs2/fsck/fsck.h +++ b/gfs2/fsck/fsck.h @@ -146,6 +146,7 @@ struct fsck_options { unsigned int yes:1; unsigned int no:1; unsigned int query:1; + unsigned int preen:1; };
extern struct fsck_options opts; diff --git a/gfs2/fsck/main.c b/gfs2/fsck/main.c index d980f864..0b5d2398 100644 --- a/gfs2/fsck/main.c +++ b/gfs2/fsck/main.c @@ -38,7 +38,6 @@ int dups_found = 0, dups_found_first = 0; int sb_fixed = 0; int print_level = MSG_NOTICE;
-static int preen = 0; static int force_check = 0; static const char *pass_name = "";
@@ -67,7 +66,7 @@ static int read_cmdline(int argc, char **argv, struct fsck_options *gopts) fprintf(stderr, _("Options -p/-a, -y and -n may not be used together\n")); return FSCK_USAGE; } - preen = 1; + gopts->preen = 1; gopts->yes = 1; break; case 'f': @@ -78,7 +77,7 @@ static int read_cmdline(int argc, char **argv, struct fsck_options *gopts) exit(FSCK_OK); break; case 'n': - if (gopts->yes || preen) { + if (gopts->yes || gopts->preen) { fprintf(stderr, _("Options -p/-a, -y and -n may not be used together\n")); return FSCK_USAGE; } @@ -95,7 +94,7 @@ static int read_cmdline(int argc, char **argv, struct fsck_options *gopts) exit(FSCK_OK); break; case 'y': - if (gopts->no || preen) { + if (gopts->no || gopts->preen) { fprintf(stderr, _("Options -p/-a, -y and -n may not be used together\n")); return FSCK_USAGE; } @@ -327,10 +326,10 @@ int main(int argc, char **argv) exit(error); setbuf(stdout, NULL); log_notice( _("Initializing fsck\n")); - if ((error = initialize(&cx, force_check, preen, &all_clean))) + if ((error = initialize(&cx, force_check, opts.preen, &all_clean))) exit(error);
- if (!force_check && all_clean && preen) { + if (!force_check && all_clean && opts.preen) { log_err( _("%s: clean.\n"), opts.device); destroy(&cx); exit(FSCK_OK);
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 21a0c1a65db3f61f95cf5eaabeb964fa92b513c1 Author: Andrew Price anprice@redhat.com AuthorDate: Mon Aug 1 08:50:58 2022 +0100
fsck.gfs2: Move the global force_check into fsck_options
Signed-off-by: Andrew Price anprice@redhat.com --- gfs2/fsck/fsck.h | 1 + gfs2/fsck/main.c | 7 +++---- 2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/gfs2/fsck/fsck.h b/gfs2/fsck/fsck.h index 603149b2..306a4ec1 100644 --- a/gfs2/fsck/fsck.h +++ b/gfs2/fsck/fsck.h @@ -147,6 +147,7 @@ struct fsck_options { unsigned int no:1; unsigned int query:1; unsigned int preen:1; + unsigned int force:1; };
extern struct fsck_options opts; diff --git a/gfs2/fsck/main.c b/gfs2/fsck/main.c index 0b5d2398..47f9c287 100644 --- a/gfs2/fsck/main.c +++ b/gfs2/fsck/main.c @@ -38,7 +38,6 @@ int dups_found = 0, dups_found_first = 0; int sb_fixed = 0; int print_level = MSG_NOTICE;
-static int force_check = 0; static const char *pass_name = "";
static void usage(char *name) @@ -70,7 +69,7 @@ static int read_cmdline(int argc, char **argv, struct fsck_options *gopts) gopts->yes = 1; break; case 'f': - force_check = 1; + gopts->force = 1; break; case 'h': usage(argv[0]); @@ -326,10 +325,10 @@ int main(int argc, char **argv) exit(error); setbuf(stdout, NULL); log_notice( _("Initializing fsck\n")); - if ((error = initialize(&cx, force_check, opts.preen, &all_clean))) + if ((error = initialize(&cx, opts.force, opts.preen, &all_clean))) exit(error);
- if (!force_check && all_clean && opts.preen) { + if (!opts.force && all_clean && opts.preen) { log_err( _("%s: clean.\n"), opts.device); destroy(&cx); exit(FSCK_OK);
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 3ea1464f7ecfa124954e2a342a32f2ea416ee70e Author: Andrew Price anprice@redhat.com AuthorDate: Mon Aug 1 09:07:34 2022 +0100
fsck.gfs2: Pass fsck_options into initialize()
Signed-off-by: Andrew Price anprice@redhat.com --- gfs2/fsck/fsck.h | 20 ++++++++++---------- gfs2/fsck/initialize.c | 14 ++++++-------- gfs2/fsck/main.c | 2 +- 3 files changed, 17 insertions(+), 19 deletions(-)
diff --git a/gfs2/fsck/fsck.h b/gfs2/fsck/fsck.h index 306a4ec1..155f4d23 100644 --- a/gfs2/fsck/fsck.h +++ b/gfs2/fsck/fsck.h @@ -108,6 +108,15 @@ enum rgindex_trust_level { /* how far can we trust our RG index? */ must have been converted from gfs2_convert. */ };
+struct fsck_options { + char *device; + unsigned int yes:1; + unsigned int no:1; + unsigned int query:1; + unsigned int preen:1; + unsigned int force:1; +}; + struct fsck_cx { struct lgfs2_sbd *sdp; struct osi_root dup_blocks; @@ -121,7 +130,7 @@ extern struct lgfs2_inode *fsck_inode_get(struct lgfs2_sbd *sdp, struct lgfs2_buffer_head *bh); 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 int initialize(struct fsck_cx *cx, const struct fsck_options * const opts, int *all_clean); extern void destroy(struct fsck_cx *cx); extern int pass1(struct fsck_cx *cx); extern int pass1b(struct fsck_cx *cx); @@ -141,15 +150,6 @@ extern void dirtree_delete(struct fsck_cx *cx, struct dir_info *b); * of pass1 and put somewhere else... */ struct dir_info *dirtree_insert(struct fsck_cx *cx, struct lgfs2_inum inum);
-struct fsck_options { - char *device; - unsigned int yes:1; - unsigned int no:1; - unsigned int query:1; - unsigned int preen:1; - unsigned int force:1; -}; - extern struct fsck_options opts; extern struct lgfs2_inode *lf_dip; /* Lost and found directory inode */ extern int lf_was_created; diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c index efceb271..c5160acc 100644 --- a/gfs2/fsck/initialize.c +++ b/gfs2/fsck/initialize.c @@ -1545,8 +1545,7 @@ static int init_rindex(struct lgfs2_sbd *sdp) * initialize - initialize superblock pointer * */ -int initialize(struct fsck_cx *cx, int force_check, int preen, - int *all_clean) +int initialize(struct fsck_cx *cx, const struct fsck_options * const _opts, int *all_clean) { struct lgfs2_sbd *sdp = cx->sdp; int clean_journals = 0, open_flag; @@ -1601,7 +1600,7 @@ int initialize(struct fsck_cx *cx, int force_check, int preen, return err;
/* Change lock protocol to be fsck_* instead of lock_* */ - if (!opts.no && preen_is_safe(sdp, preen, force_check)) { + if (!opts.no && preen_is_safe(sdp, _opts->preen, _opts->force)) { if (block_mounters(sdp, 1)) { log_err( _("Unable to block other mounters\n")); return FSCK_USAGE; @@ -1653,19 +1652,18 @@ int initialize(struct fsck_cx *cx, int force_check, int preen, if (sdp->gfs1) { if (reconstruct_journals(sdp)) return FSCK_ERROR; - } else if (replay_journals(cx, preen, force_check, - &clean_journals)) { - if (!opts.no && preen_is_safe(sdp, preen, force_check)) + } else if (replay_journals(cx, _opts->preen, _opts->force, &clean_journals)) { + if (!opts.no && preen_is_safe(sdp, _opts->preen, _opts->force)) block_mounters(sdp, 0); stack; return FSCK_ERROR; } if (sdp->md.journals == clean_journals) *all_clean = 1; - else if (force_check || !preen) + else if (_opts->force || !_opts->preen) log_notice( _("\nJournal recovery complete.\n"));
- if (!force_check && *all_clean && preen) + if (!_opts->force && *all_clean && _opts->preen) return FSCK_OK; }
diff --git a/gfs2/fsck/main.c b/gfs2/fsck/main.c index 47f9c287..86375bf4 100644 --- a/gfs2/fsck/main.c +++ b/gfs2/fsck/main.c @@ -325,7 +325,7 @@ int main(int argc, char **argv) exit(error); setbuf(stdout, NULL); log_notice( _("Initializing fsck\n")); - if ((error = initialize(&cx, opts.force, opts.preen, &all_clean))) + if ((error = initialize(&cx, &opts, &all_clean))) exit(error);
if (!opts.force && all_clean && opts.preen) {
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 76dade28bb0eca75108a69fcbc5108d0789be424 Author: Andrew Price anprice@redhat.com AuthorDate: Mon Aug 1 09:15:51 2022 +0100
fsck.gfs2: Pass fsck_options into replay_journals()
Signed-off-by: Andrew Price anprice@redhat.com --- gfs2/fsck/fs_recovery.c | 12 +++++------- gfs2/fsck/fs_recovery.h | 3 +-- gfs2/fsck/initialize.c | 2 +- 3 files changed, 7 insertions(+), 10 deletions(-)
diff --git a/gfs2/fsck/fs_recovery.c b/gfs2/fsck/fs_recovery.c index 94de748c..cbf11325 100644 --- a/gfs2/fsck/fs_recovery.c +++ b/gfs2/fsck/fs_recovery.c @@ -675,8 +675,7 @@ static struct metawalk_fxns rangecheck_journal = { * * Returns: 0 on success, -1 on failure */ -int replay_journals(struct fsck_cx *cx, int preen, int force_check, - int *clean_journals) +int replay_journals(struct fsck_cx *cx, const struct fsck_options * const _opts, int *clean_journals) { struct lgfs2_sbd *sdp = cx->sdp; int dirty_journals = 0; @@ -711,13 +710,12 @@ int replay_journals(struct fsck_cx *cx, int preen, int force_check, if (sdp->jsize == LGFS2_DEFAULT_JSIZE && jsize && jsize != sdp->jsize) sdp->jsize = jsize; - error = recover_journal(sdp->md.journal[i], i, - preen, force_check, - &clean); + error = recover_journal(sdp->md.journal[i], i, _opts->preen, + _opts->force, &clean); if (!clean) dirty_journals++; - if (!gave_msg && dirty_journals == 1 && !opts.no && - preen_is_safe(sdp, preen, force_check)) { + if (!gave_msg && dirty_journals == 1 && !_opts->no && + preen_is_safe(sdp, _opts->preen, _opts->force)) { gave_msg = 1; log_notice( _("Recovering journals (this may " "take a while)\n")); diff --git a/gfs2/fsck/fs_recovery.h b/gfs2/fsck/fs_recovery.h index 51d632ee..1b60c6a8 100644 --- a/gfs2/fsck/fs_recovery.h +++ b/gfs2/fsck/fs_recovery.h @@ -3,8 +3,7 @@
#include "libgfs2.h"
-extern int replay_journals(struct fsck_cx *cx, int preen, int force_check, - int *clean_journals); +extern int replay_journals(struct fsck_cx *cx, const struct fsck_options * const _opts, int *clean_journals); extern int preen_is_safe(struct lgfs2_sbd *sdp, int preen, int force_check);
extern int ji_update(struct lgfs2_sbd *sdp); diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c index c5160acc..dca68c0a 100644 --- a/gfs2/fsck/initialize.c +++ b/gfs2/fsck/initialize.c @@ -1652,7 +1652,7 @@ int initialize(struct fsck_cx *cx, const struct fsck_options * const _opts, int if (sdp->gfs1) { if (reconstruct_journals(sdp)) return FSCK_ERROR; - } else if (replay_journals(cx, _opts->preen, _opts->force, &clean_journals)) { + } else if (replay_journals(cx, _opts, &clean_journals)) { if (!opts.no && preen_is_safe(sdp, _opts->preen, _opts->force)) block_mounters(sdp, 0); stack;
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 57d193dfd9bc902283e067d0325b88f76074c304 Author: Andrew Price anprice@redhat.com AuthorDate: Mon Aug 1 09:20:32 2022 +0100
fsck.gfs2: Pass fsck_options into recover_journal()
Signed-off-by: Andrew Price anprice@redhat.com --- gfs2/fsck/fs_recovery.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/gfs2/fsck/fs_recovery.c b/gfs2/fsck/fs_recovery.c index cbf11325..21917e7a 100644 --- a/gfs2/fsck/fs_recovery.c +++ b/gfs2/fsck/fs_recovery.c @@ -476,8 +476,8 @@ int preen_is_safe(struct lgfs2_sbd *sdp, int preen, int force_check) * Returns: errno */
-static int recover_journal(struct lgfs2_inode *ip, int j, int preen, - int force_check, int *was_clean) +static int recover_journal(struct lgfs2_inode *ip, int j, const struct fsck_options * const _opts, + int *was_clean) { struct lgfs2_sbd *sdp = ip->i_sbd; struct lgfs2_log_header head; @@ -499,12 +499,12 @@ static int recover_journal(struct lgfs2_inode *ip, int j, int preen, } } if (error) { - if (opts.no) { + if (_opts->no) { log_err( _("Journal #%d ("journal%d") is corrupt\n"),j+1, j); log_err( _("Not fixing it due to the -n option.\n")); goto out; } - if (!preen_is_safe(sdp, preen, force_check)) { + if (!preen_is_safe(sdp, _opts->preen, _opts->force)) { log_err(_("Journal #%d ("journal%d") is corrupt.\n"), j+1, j); log_err(_("I'm not fixing it because it may be unsafe:\n" @@ -543,12 +543,12 @@ static int recover_journal(struct lgfs2_inode *ip, int j, int preen, *was_clean = 1; return 0; } - if (opts.no) { + if (_opts->no) { log_err(_("Journal #%d ("journal%d") is dirty\n"),j+1, j); log_err(_("not replaying due to the -n option.\n")); goto out; } - if (!preen_is_safe(sdp, preen, force_check)) { + if (!preen_is_safe(sdp, _opts->preen, _opts->force)) { log_err( _("Journal #%d ("journal%d") is dirty\n"), j+1, j); log_err( _("I'm not replaying it because it may be unsafe:\n" "Locking protocol is not lock_nolock and " @@ -710,8 +710,7 @@ int replay_journals(struct fsck_cx *cx, const struct fsck_options * const _opts, if (sdp->jsize == LGFS2_DEFAULT_JSIZE && jsize && jsize != sdp->jsize) sdp->jsize = jsize; - error = recover_journal(sdp->md.journal[i], i, _opts->preen, - _opts->force, &clean); + error = recover_journal(sdp->md.journal[i], i, _opts, &clean); if (!clean) dirty_journals++; if (!gave_msg && dirty_journals == 1 && !_opts->no &&
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 bfaaee54b7b9c8b9d2266eda6a0f00223c82d950 Author: Andrew Price anprice@redhat.com AuthorDate: Mon Aug 1 09:26:55 2022 +0100
fsck.gfs2: Pass fsck_options into preen_is_safe()
Signed-off-by: Andrew Price anprice@redhat.com --- gfs2/fsck/fs_recovery.c | 12 ++++++------ gfs2/fsck/fs_recovery.h | 2 +- gfs2/fsck/initialize.c | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/gfs2/fsck/fs_recovery.c b/gfs2/fsck/fs_recovery.c index 21917e7a..78c2b591 100644 --- a/gfs2/fsck/fs_recovery.c +++ b/gfs2/fsck/fs_recovery.c @@ -450,11 +450,11 @@ static int check_journal_seq_no(struct lgfs2_inode *ip, int fix) * mounted by other nodes in the cluster, which is dangerous and therefore, * we should warn the user to run fsck.gfs2 manually when it's safe. */ -int preen_is_safe(struct lgfs2_sbd *sdp, int preen, int force_check) +int preen_is_safe(struct lgfs2_sbd *sdp, const struct fsck_options * const _opts) { - if (!preen) /* If preen was not specified */ + if (!_opts->preen) return 1; /* not called by rc.sysinit--we're okay to preen */ - if (force_check) /* If check was forced by the user? */ + if (_opts->force) return 1; /* user's responsibility--we're okay to preen */ if (!memcmp(sdp->sd_lockproto + 5, "nolock", 6)) return 1; /* local file system--preen is okay */ @@ -504,7 +504,7 @@ static int recover_journal(struct lgfs2_inode *ip, int j, const struct fsck_opti log_err( _("Not fixing it due to the -n option.\n")); goto out; } - if (!preen_is_safe(sdp, _opts->preen, _opts->force)) { + if (!preen_is_safe(sdp, _opts)) { log_err(_("Journal #%d ("journal%d") is corrupt.\n"), j+1, j); log_err(_("I'm not fixing it because it may be unsafe:\n" @@ -548,7 +548,7 @@ static int recover_journal(struct lgfs2_inode *ip, int j, const struct fsck_opti log_err(_("not replaying due to the -n option.\n")); goto out; } - if (!preen_is_safe(sdp, _opts->preen, _opts->force)) { + if (!preen_is_safe(sdp, _opts)) { log_err( _("Journal #%d ("journal%d") is dirty\n"), j+1, j); log_err( _("I'm not replaying it because it may be unsafe:\n" "Locking protocol is not lock_nolock and " @@ -714,7 +714,7 @@ int replay_journals(struct fsck_cx *cx, const struct fsck_options * const _opts, if (!clean) dirty_journals++; if (!gave_msg && dirty_journals == 1 && !_opts->no && - preen_is_safe(sdp, _opts->preen, _opts->force)) { + preen_is_safe(sdp, _opts)) { gave_msg = 1; log_notice( _("Recovering journals (this may " "take a while)\n")); diff --git a/gfs2/fsck/fs_recovery.h b/gfs2/fsck/fs_recovery.h index 1b60c6a8..df37dc41 100644 --- a/gfs2/fsck/fs_recovery.h +++ b/gfs2/fsck/fs_recovery.h @@ -4,7 +4,7 @@ #include "libgfs2.h"
extern int replay_journals(struct fsck_cx *cx, const struct fsck_options * const _opts, int *clean_journals); -extern int preen_is_safe(struct lgfs2_sbd *sdp, int preen, int force_check); +extern int preen_is_safe(struct lgfs2_sbd *sdp, const struct fsck_options * const _opts);
extern int ji_update(struct lgfs2_sbd *sdp); extern int build_jindex(struct lgfs2_sbd *sdp); diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c index dca68c0a..0342402a 100644 --- a/gfs2/fsck/initialize.c +++ b/gfs2/fsck/initialize.c @@ -1600,7 +1600,7 @@ int initialize(struct fsck_cx *cx, const struct fsck_options * const _opts, int return err;
/* Change lock protocol to be fsck_* instead of lock_* */ - if (!opts.no && preen_is_safe(sdp, _opts->preen, _opts->force)) { + if (!opts.no && preen_is_safe(sdp, _opts)) { if (block_mounters(sdp, 1)) { log_err( _("Unable to block other mounters\n")); return FSCK_USAGE; @@ -1653,7 +1653,7 @@ int initialize(struct fsck_cx *cx, const struct fsck_options * const _opts, int if (reconstruct_journals(sdp)) return FSCK_ERROR; } else if (replay_journals(cx, _opts, &clean_journals)) { - if (!opts.no && preen_is_safe(sdp, _opts->preen, _opts->force)) + if (!opts.no && preen_is_safe(sdp, _opts)) block_mounters(sdp, 0); stack; return FSCK_ERROR;
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 c354c64abe37e6e769ce566382c754c9eae4173c Author: Andrew Price anprice@redhat.com AuthorDate: Mon Aug 1 09:31:12 2022 +0100
fsck.gfs2: Pass fsck_options into destroy()
Signed-off-by: Andrew Price anprice@redhat.com --- gfs2/fsck/fsck.h | 2 +- gfs2/fsck/initialize.c | 4 ++-- gfs2/fsck/main.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/gfs2/fsck/fsck.h b/gfs2/fsck/fsck.h index 155f4d23..efcde8be 100644 --- a/gfs2/fsck/fsck.h +++ b/gfs2/fsck/fsck.h @@ -131,7 +131,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, const struct fsck_options * const opts, int *all_clean); -extern void destroy(struct fsck_cx *cx); +extern void destroy(struct fsck_cx *cx, const struct fsck_options * const _opts); extern int pass1(struct fsck_cx *cx); extern int pass1b(struct fsck_cx *cx); extern int pass1c(struct fsck_cx *cx); diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c index 0342402a..165ff43f 100644 --- a/gfs2/fsck/initialize.c +++ b/gfs2/fsck/initialize.c @@ -1679,11 +1679,11 @@ mount_fail: return FSCK_USAGE; }
-void destroy(struct fsck_cx *cx) +void destroy(struct fsck_cx *cx, const struct fsck_options * const _opts) { struct lgfs2_sbd *sdp = cx->sdp;
- if (!opts.no) { + if (!_opts->no) { if (block_mounters(sdp, 0)) { log_warn( _("Unable to unblock other mounters - manual intervention required\n")); log_warn( _("Use 'gfs2_tool sb <device> proto' to fix\n")); diff --git a/gfs2/fsck/main.c b/gfs2/fsck/main.c index 86375bf4..9a74b365 100644 --- a/gfs2/fsck/main.c +++ b/gfs2/fsck/main.c @@ -330,7 +330,7 @@ int main(int argc, char **argv)
if (!opts.force && all_clean && opts.preen) { log_err( _("%s: clean.\n"), opts.device); - destroy(&cx); + destroy(&cx, &opts); exit(FSCK_OK); }
@@ -363,7 +363,7 @@ int main(int argc, char **argv) fsync(sb.device_fd); link1_destroy(&nlink1map); link1_destroy(&clink1map); - destroy(&cx); + destroy(&cx, &opts); if (sb_fixed) log_warn(_("Superblock was reset. Use tunegfs2 to manually " "set lock table before mounting.\n"));
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 e83238c71724a27f567b96fb123790465d2d85f1 Author: Andrew Price anprice@redhat.com AuthorDate: Mon Aug 1 09:43:37 2022 +0100
fsck.gfs2: Remove unused query field from fsck_options
Signed-off-by: Andrew Price anprice@redhat.com --- gfs2/fsck/fsck.h | 1 - gfs2/fsck/util.c | 3 --- 2 files changed, 4 deletions(-)
diff --git a/gfs2/fsck/fsck.h b/gfs2/fsck/fsck.h index efcde8be..70ca1231 100644 --- a/gfs2/fsck/fsck.h +++ b/gfs2/fsck/fsck.h @@ -112,7 +112,6 @@ struct fsck_options { char *device; unsigned int yes:1; unsigned int no:1; - unsigned int query:1; unsigned int preen:1; unsigned int force:1; }; diff --git a/gfs2/fsck/util.c b/gfs2/fsck/util.c index 7beb63e9..8ff07d0e 100644 --- a/gfs2/fsck/util.c +++ b/gfs2/fsck/util.c @@ -175,7 +175,6 @@ int fsck_query(const char *format, ...) if (opts.no) return 0;
- opts.query = 1; while (1) { va_start(args, format); vprintf(format, args); @@ -211,8 +210,6 @@ int fsck_query(const char *format, ...) response); } } - - opts.query = 0; return ret; }
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 005df252b702f61e710bb0d67b8b00331f4cda1d Author: Andrew Price anprice@redhat.com AuthorDate: Mon Aug 1 10:02:05 2022 +0100
fsck.gfs2: Add an options pointer to fsck_cx
Signed-off-by: Andrew Price anprice@redhat.com --- gfs2/fsck/fs_recovery.c | 8 ++++---- gfs2/fsck/fs_recovery.h | 2 +- gfs2/fsck/fsck.h | 5 +++-- gfs2/fsck/initialize.c | 28 ++++++++++++++-------------- gfs2/fsck/main.c | 9 +++++---- 5 files changed, 27 insertions(+), 25 deletions(-)
diff --git a/gfs2/fsck/fs_recovery.c b/gfs2/fsck/fs_recovery.c index 78c2b591..0fd92442 100644 --- a/gfs2/fsck/fs_recovery.c +++ b/gfs2/fsck/fs_recovery.c @@ -675,7 +675,7 @@ static struct metawalk_fxns rangecheck_journal = { * * Returns: 0 on success, -1 on failure */ -int replay_journals(struct fsck_cx *cx, const struct fsck_options * const _opts, int *clean_journals) +int replay_journals(struct fsck_cx *cx, int *clean_journals) { struct lgfs2_sbd *sdp = cx->sdp; int dirty_journals = 0; @@ -710,11 +710,11 @@ int replay_journals(struct fsck_cx *cx, const struct fsck_options * const _opts, if (sdp->jsize == LGFS2_DEFAULT_JSIZE && jsize && jsize != sdp->jsize) sdp->jsize = jsize; - error = recover_journal(sdp->md.journal[i], i, _opts, &clean); + error = recover_journal(sdp->md.journal[i], i, cx->opts, &clean); if (!clean) dirty_journals++; - if (!gave_msg && dirty_journals == 1 && !_opts->no && - preen_is_safe(sdp, _opts)) { + if (!gave_msg && dirty_journals == 1 && !cx->opts->no && + preen_is_safe(sdp, cx->opts)) { gave_msg = 1; log_notice( _("Recovering journals (this may " "take a while)\n")); diff --git a/gfs2/fsck/fs_recovery.h b/gfs2/fsck/fs_recovery.h index df37dc41..eda8fce9 100644 --- a/gfs2/fsck/fs_recovery.h +++ b/gfs2/fsck/fs_recovery.h @@ -3,7 +3,7 @@
#include "libgfs2.h"
-extern int replay_journals(struct fsck_cx *cx, const struct fsck_options * const _opts, int *clean_journals); +extern int replay_journals(struct fsck_cx *cx, int *clean_journals); extern int preen_is_safe(struct lgfs2_sbd *sdp, const struct fsck_options * const _opts);
extern int ji_update(struct lgfs2_sbd *sdp); diff --git a/gfs2/fsck/fsck.h b/gfs2/fsck/fsck.h index 70ca1231..b854997e 100644 --- a/gfs2/fsck/fsck.h +++ b/gfs2/fsck/fsck.h @@ -121,6 +121,7 @@ struct fsck_cx { struct osi_root dup_blocks; struct osi_root dirtree; struct osi_root inodetree; + const struct fsck_options * const opts; };
extern struct lgfs2_inode *fsck_load_inode(struct lgfs2_sbd *sdp, uint64_t block); @@ -129,8 +130,8 @@ extern struct lgfs2_inode *fsck_inode_get(struct lgfs2_sbd *sdp, struct lgfs2_buffer_head *bh); extern void fsck_inode_put(struct lgfs2_inode **ip);
-extern int initialize(struct fsck_cx *cx, const struct fsck_options * const opts, int *all_clean); -extern void destroy(struct fsck_cx *cx, const struct fsck_options * const _opts); +extern int initialize(struct fsck_cx *cx, int *all_clean); +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); diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c index 165ff43f..b9fb425f 100644 --- a/gfs2/fsck/initialize.c +++ b/gfs2/fsck/initialize.c @@ -1545,7 +1545,7 @@ static int init_rindex(struct lgfs2_sbd *sdp) * initialize - initialize superblock pointer * */ -int initialize(struct fsck_cx *cx, const struct fsck_options * const _opts, int *all_clean) +int initialize(struct fsck_cx *cx, int *all_clean) { struct lgfs2_sbd *sdp = cx->sdp; int clean_journals = 0, open_flag; @@ -1553,17 +1553,17 @@ int initialize(struct fsck_cx *cx, const struct fsck_options * const _opts, int
*all_clean = 0;
- if (opts.no) + if (cx->opts->no) open_flag = O_RDONLY; else open_flag = O_RDWR | O_EXCL;
- sdp->device_fd = open(opts.device, open_flag); + sdp->device_fd = open(cx->opts->device, open_flag); if (sdp->device_fd < 0) { struct mntent *mnt; if (open_flag == O_RDONLY || errno != EBUSY) { log_crit( _("Unable to open device: %s\n"), - opts.device); + cx->opts->device); return FSCK_USAGE; } /* We can't open it EXCL. It may be already open rw (in which @@ -1574,7 +1574,7 @@ int initialize(struct fsck_cx *cx, const struct fsck_options * const _opts, int This protects against cases where the file system is LVM and perhaps mounted on a different node. Try opening without O_EXCL. */ - sdp->device_fd = lgfs2_open_mnt_dev(opts.device, O_RDWR, &mnt); + sdp->device_fd = lgfs2_open_mnt_dev(cx->opts->device, O_RDWR, &mnt); if (sdp->device_fd < 0) goto mount_fail; /* If the device is mounted, but not mounted RO, fail. This @@ -1590,7 +1590,7 @@ int initialize(struct fsck_cx *cx, const struct fsck_options * const _opts, int }
if (lgfs2_get_dev_info(sdp->device_fd, &sdp->dinfo)) { - perror(opts.device); + perror(cx->opts->device); return FSCK_ERROR; }
@@ -1600,7 +1600,7 @@ int initialize(struct fsck_cx *cx, const struct fsck_options * const _opts, int return err;
/* Change lock protocol to be fsck_* instead of lock_* */ - if (!opts.no && preen_is_safe(sdp, _opts)) { + if (!cx->opts->no && preen_is_safe(sdp, cx->opts)) { if (block_mounters(sdp, 1)) { log_err( _("Unable to block other mounters\n")); return FSCK_USAGE; @@ -1652,18 +1652,18 @@ int initialize(struct fsck_cx *cx, const struct fsck_options * const _opts, int if (sdp->gfs1) { if (reconstruct_journals(sdp)) return FSCK_ERROR; - } else if (replay_journals(cx, _opts, &clean_journals)) { - if (!opts.no && preen_is_safe(sdp, _opts)) + } else if (replay_journals(cx, &clean_journals)) { + if (!cx->opts->no && preen_is_safe(sdp, cx->opts)) block_mounters(sdp, 0); stack; return FSCK_ERROR; } if (sdp->md.journals == clean_journals) *all_clean = 1; - else if (_opts->force || !_opts->preen) + else if (cx->opts->force || !cx->opts->preen) log_notice( _("\nJournal recovery complete.\n"));
- if (!_opts->force && *all_clean && _opts->preen) + if (!cx->opts->force && *all_clean && cx->opts->preen) return FSCK_OK; }
@@ -1675,15 +1675,15 @@ int initialize(struct fsck_cx *cx, const struct fsck_options * const _opts, int close_fail: close(sdp->device_fd); mount_fail: - log_crit( _("Device %s is busy.\n"), opts.device); + log_crit( _("Device %s is busy.\n"), cx->opts->device); return FSCK_USAGE; }
-void destroy(struct fsck_cx *cx, const struct fsck_options * const _opts) +void destroy(struct fsck_cx *cx) { struct lgfs2_sbd *sdp = cx->sdp;
- if (!_opts->no) { + if (!cx->opts->no) { if (block_mounters(sdp, 0)) { log_warn( _("Unable to unblock other mounters - manual intervention required\n")); log_warn( _("Use 'gfs2_tool sb <device> proto' to fix\n")); diff --git a/gfs2/fsck/main.c b/gfs2/fsck/main.c index 9a74b365..b070ec9b 100644 --- a/gfs2/fsck/main.c +++ b/gfs2/fsck/main.c @@ -300,7 +300,8 @@ int main(int argc, char **argv) { struct lgfs2_sbd sb; struct fsck_cx cx = { - .sdp = &sb + .sdp = &sb, + .opts = &opts, }; int j; int i; @@ -325,12 +326,12 @@ int main(int argc, char **argv) exit(error); setbuf(stdout, NULL); log_notice( _("Initializing fsck\n")); - if ((error = initialize(&cx, &opts, &all_clean))) + if ((error = initialize(&cx, &all_clean))) exit(error);
if (!opts.force && all_clean && opts.preen) { log_err( _("%s: clean.\n"), opts.device); - destroy(&cx, &opts); + destroy(&cx); exit(FSCK_OK); }
@@ -363,7 +364,7 @@ int main(int argc, char **argv) fsync(sb.device_fd); link1_destroy(&nlink1map); link1_destroy(&clink1map); - destroy(&cx, &opts); + destroy(&cx); if (sb_fixed) log_warn(_("Superblock was reset. Use tunegfs2 to manually " "set lock table before mounting.\n"));
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 c436ecc8ad104615d012b6bb2cc4bf3a5280576c Author: Andrew Price anprice@redhat.com AuthorDate: Mon Aug 1 10:17:26 2022 +0100
fsck.gfs2: Pass fsck_cx into check_rgrp(s)_integrity()
Signed-off-by: Andrew Price anprice@redhat.com --- gfs2/fsck/initialize.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c index b9fb425f..26f4d33a 100644 --- a/gfs2/fsck/initialize.c +++ b/gfs2/fsck/initialize.c @@ -185,12 +185,13 @@ static int set_block_ranges(struct lgfs2_sbd *sdp) /** * check_rgrp_integrity - verify a rgrp free block count against the bitmap */ -static void check_rgrp_integrity(struct lgfs2_sbd *sdp, struct lgfs2_rgrp_tree *rgd, +static void check_rgrp_integrity(struct fsck_cx *cx, struct lgfs2_rgrp_tree *rgd, int *fixit, int *this_rg_fixed, int *this_rg_bad, int *this_rg_cleaned) { uint32_t rg_free, rg_reclaimed, rg_unlinked, rg_usedmeta, rg_useddi; int rgb, x, y, off, bytes_to_check, total_bytes_to_check, asked = 0; + struct lgfs2_sbd *sdp = cx->sdp; unsigned int state; uint64_t diblock; struct lgfs2_buffer_head *bh; @@ -392,7 +393,7 @@ static void check_rgrp_integrity(struct lgfs2_sbd *sdp, struct lgfs2_rgrp_tree * * * Returns: 0 on success, 1 if errors were detected */ -static void check_rgrps_integrity(struct lgfs2_sbd *sdp) +static void check_rgrps_integrity(struct fsck_cx *cx) { struct osi_node *n, *next = NULL; int rgs_good = 0, rgs_bad = 0, rgs_fixed = 0, rgs_cleaned = 0; @@ -401,12 +402,12 @@ static void check_rgrps_integrity(struct lgfs2_sbd *sdp) int reclaim_unlinked = 0;
log_info( _("Checking the integrity of all resource groups.\n")); - for (n = osi_first(&sdp->rgtree); n; n = next) { + for (n = osi_first(&cx->sdp->rgtree); n; n = next) { next = osi_next(n); rgd = (struct lgfs2_rgrp_tree *)n; if (fsck_abort) return; - check_rgrp_integrity(sdp, rgd, &reclaim_unlinked, + check_rgrp_integrity(cx, rgd, &reclaim_unlinked, &was_fixed, &was_bad, &was_cleaned); if (was_fixed) rgs_fixed++; @@ -765,7 +766,7 @@ static int fetch_rgrps(struct fsck_cx *cx) } log_info( _("%"PRIu64" resource groups found.\n"), rgcount);
- check_rgrps_integrity(cx->sdp); + check_rgrps_integrity(cx); return 0; }
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 fb6cb271c3b3f41603dc4fbf503765f3bb2e6cfd Author: Andrew Price anprice@redhat.com AuthorDate: Mon Aug 1 10:25:44 2022 +0100
fsck.gfs2: Pass fsck_cx into rebuild_master()
Fix up some nomenclature while we're at it.
Signed-off-by: Andrew Price anprice@redhat.com --- gfs2/fsck/initialize.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c index 26f4d33a..7c7ea3ca 100644 --- a/gfs2/fsck/initialize.c +++ b/gfs2/fsck/initialize.c @@ -430,18 +430,16 @@ static void check_rgrps_integrity(struct fsck_cx *cx) } }
-/** - * rebuild_master - rebuild a destroyed master directory - */ -static int rebuild_master(struct lgfs2_sbd *sdp) +static int rebuild_sysdir(struct fsck_cx *cx) { + struct lgfs2_sbd *sdp = cx->sdp; struct lgfs2_inum inum; struct lgfs2_buffer_head *bh = NULL; int err = 0;
- log_err(_("The system master directory seems to be destroyed.\n")); + log_err(_("The system directory seems to be destroyed.\n")); if (!query(_("Okay to rebuild it? (y/n)"))) { - log_err(_("System master not rebuilt; aborting.\n")); + log_err(_("System directory not rebuilt; aborting.\n")); return -1; } log_err(_("Trying to rebuild the master directory.\n")); @@ -1618,7 +1616,7 @@ int initialize(struct fsck_cx *cx, int *all_clean) sdp->master_dir->i_mh_type != GFS2_METATYPE_DI || !sdp->master_dir->i_size)) { lgfs2_inode_put(&sdp->master_dir); - rebuild_master(sdp); + rebuild_sysdir(cx); sdp->master_dir = lgfs2_inode_read(sdp, sdp->sd_meta_dir.in_addr); if (sdp->master_dir == NULL) { log_crit(_("Error reading master directory: %s\n"), strerror(errno));
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 28a1a014f772b1070f8c6fd766e300047f893a2d Author: Andrew Price anprice@redhat.com AuthorDate: Mon Aug 1 10:36:02 2022 +0100
fsck.gfs2: Pass fsck_cx into lookup_per_node()
Signed-off-by: Andrew Price anprice@redhat.com --- gfs2/fsck/initialize.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c index 7c7ea3ca..2ef5ed31 100644 --- a/gfs2/fsck/initialize.c +++ b/gfs2/fsck/initialize.c @@ -589,8 +589,10 @@ static int rebuild_sysdir(struct fsck_cx *cx) * allow_rebuild: 0 if rebuilds are not allowed * 1 if rebuilds are allowed */ -static void lookup_per_node(struct lgfs2_sbd *sdp, int allow_rebuild) +static void lookup_per_node(struct fsck_cx *cx, int allow_rebuild) { + struct lgfs2_sbd *sdp = cx->sdp; + if (sdp->md.pinode) return;
@@ -928,7 +930,7 @@ static int init_system_inodes(struct fsck_cx *cx) /* Try to lookup the per_node inode. If it was missing, it is now safe to rebuild it. */ if (!sdp->gfs1) - lookup_per_node(sdp, 1); + lookup_per_node(cx, 1);
/******************************************************************* ******* Now, set boundary fields in the super block ************* @@ -1628,7 +1630,7 @@ int initialize(struct fsck_cx *cx, int *all_clean) need to figure out what's missing from per_node. And we need all our journals to be there before we can replay them. */ if (!sdp->gfs1) - lookup_per_node(sdp, 0); + lookup_per_node(cx, 0);
/* We need rindex first in case jindex is missing and needs to read in the rgrps before rebuilding it. However, note that if the rindex
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 ff58c0f8eae22a88c1b53e0b0e451e495fd4ede8 Author: Andrew Price anprice@redhat.com AuthorDate: Mon Aug 1 10:52:47 2022 +0100
fsck.gfs2: Pass fsck_cx into fill_super_block()
Signed-off-by: Andrew Price anprice@redhat.com --- gfs2/fsck/initialize.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c index 2ef5ed31..be752d69 100644 --- a/gfs2/fsck/initialize.c +++ b/gfs2/fsck/initialize.c @@ -1333,8 +1333,9 @@ static int sb_repair(struct lgfs2_sbd *sdp) * * Returns: 0 on success, -1 on failure */ -static int fill_super_block(struct lgfs2_sbd *sdp) +static int fill_super_block(struct fsck_cx *cx) { + struct lgfs2_sbd *sdp = cx->sdp; int ret;
sync(); @@ -1596,7 +1597,7 @@ int initialize(struct fsck_cx *cx, int *all_clean) }
/* read in sb from disk */ - err = fill_super_block(sdp); + err = fill_super_block(cx); if (err != FSCK_OK) return err;
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 f75e15788c98c5dc69aab5960dba891036049000 Author: Andrew Price anprice@redhat.com AuthorDate: Mon Aug 1 10:53:52 2022 +0100
fsck.gfs2: Pass fsck_cx into sb_repair()
Signed-off-by: Andrew Price anprice@redhat.com --- gfs2/fsck/initialize.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c index be752d69..2126fe19 100644 --- a/gfs2/fsck/initialize.c +++ b/gfs2/fsck/initialize.c @@ -1221,8 +1221,9 @@ static int peruse_metadata(struct lgfs2_sbd *sdp, uint64_t startblock) * Assumes: device is open. * The biggest RG size is 2GB */ -static int sb_repair(struct lgfs2_sbd *sdp) +static int sb_repair(struct fsck_cx *cx) { + struct lgfs2_sbd *sdp = cx->sdp; uint64_t half; uint32_t known_bsize = 0; int error = 0; @@ -1350,7 +1351,7 @@ static int fill_super_block(struct fsck_cx *cx) } ret = lgfs2_read_sb(sdp); if (ret < 0) { - if (sb_repair(sdp) != 0) + if (sb_repair(cx) != 0) return -1; /* unrepairable, so exit */ /* Now that we've tried to repair it, re-read it. */ ret = lgfs2_read_sb(sdp);
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 3c836469f6a80ea69cb35a55fa18b84833313f48 Author: Andrew Price anprice@redhat.com AuthorDate: Mon Aug 1 10:55:30 2022 +0100
fsck.gfs2: Pass fsck_cx into peruse_metadata()
Signed-off-by: Andrew Price anprice@redhat.com --- gfs2/fsck/initialize.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c index 2126fe19..c1955080 100644 --- a/gfs2/fsck/initialize.c +++ b/gfs2/fsck/initialize.c @@ -1192,8 +1192,9 @@ static int find_rgs_for_bsize(struct lgfs2_sbd *sdp, uint64_t startblock, * peruse_metadata - check a range of blocks for metadata * Assumes: device is open. */ -static int peruse_metadata(struct lgfs2_sbd *sdp, uint64_t startblock) +static int peruse_metadata(struct fsck_cx *cx, uint64_t startblock) { + struct lgfs2_sbd *sdp = cx->sdp; uint64_t blk, max_rg_size; struct lgfs2_buffer_head *bh; struct lgfs2_inode *ip; @@ -1255,7 +1256,7 @@ static int sb_repair(struct fsck_cx *cx) return -1; } /* Step 2 - look for the sytem dinodes */ - error = peruse_metadata(sdp, (GFS2_SB_ADDR * GFS2_BASIC_BLOCK) / + error = peruse_metadata(cx, (GFS2_SB_ADDR * GFS2_BASIC_BLOCK) / LGFS2_DEFAULT_BSIZE); if (error) return error;
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 5e70af16545c670c8dbee3a27ee52f58288b5346 Author: Andrew Price anprice@redhat.com AuthorDate: Mon Aug 1 10:57:32 2022 +0100
fsck.gfs2: Pass fsck_cx into peruse_{system,user}_dinode()
Signed-off-by: Andrew Price anprice@redhat.com --- gfs2/fsck/initialize.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c index c1955080..c84bcb5c 100644 --- a/gfs2/fsck/initialize.c +++ b/gfs2/fsck/initialize.c @@ -970,8 +970,9 @@ static int is_journal_copy(struct lgfs2_inode *ip) * the per_node directory will have a ".." entry that will lead us to * the master dinode if it's been destroyed. */ -static void peruse_system_dinode(struct lgfs2_sbd *sdp, struct lgfs2_inode *ip) +static void peruse_system_dinode(struct fsck_cx *cx, struct lgfs2_inode *ip) { + struct lgfs2_sbd *sdp = cx->sdp; struct lgfs2_inode *child_ip; struct lgfs2_inum inum; int error; @@ -1059,8 +1060,9 @@ out_discard_ip: * peruse_user_dinode - process a user dinode trying to find the root directory * */ -static void peruse_user_dinode(struct lgfs2_sbd *sdp, struct lgfs2_inode *ip) +static void peruse_user_dinode(struct fsck_cx *cx, struct lgfs2_inode *ip) { + struct lgfs2_sbd *sdp = cx->sdp; struct lgfs2_inode *parent_ip; struct lgfs2_inum inum; int error; @@ -1210,9 +1212,9 @@ static int peruse_metadata(struct fsck_cx *cx, uint64_t startblock) ip = lgfs2_inode_get(sdp, bh); ip->bh_owned = 1; /* lgfs2_inode_put() will free the bh */ if (ip->i_flags & GFS2_DIF_SYSTEM) - peruse_system_dinode(sdp, ip); + peruse_system_dinode(cx, ip); else - peruse_user_dinode(sdp, ip); + peruse_user_dinode(cx, ip); } return 0; }
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 f33d1bb5233a2566efd39288dbcc597a63170c1e Author: Andrew Price anprice@redhat.com AuthorDate: Mon Aug 1 11:05:56 2022 +0100
fsck.gfs2: Pass fsck_cx into reconstruct_journals()
Signed-off-by: Andrew Price anprice@redhat.com --- gfs2/fsck/initialize.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c index c84bcb5c..6edab7f8 100644 --- a/gfs2/fsck/initialize.c +++ b/gfs2/fsck/initialize.c @@ -1489,10 +1489,11 @@ out: * * Returns: 0 on success, -1 on failure */ -static int reconstruct_journals(struct lgfs2_sbd *sdp) +static int reconstruct_journals(struct fsck_cx *cx) { int i, count; struct gfs_jindex *ji; + struct lgfs2_sbd *sdp = cx->sdp; char buf[sizeof(struct gfs_jindex)];
/* Ensure that sb_seg_size is valid */ @@ -1656,7 +1657,7 @@ int initialize(struct fsck_cx *cx, int *all_clean) have the smarts to replay GFS1 journals (neither did gfs_fsck). */ if (sdp->gfs1) { - if (reconstruct_journals(sdp)) + if (reconstruct_journals(cx)) return FSCK_ERROR; } else if (replay_journals(cx, &clean_journals)) { if (!cx->opts->no && preen_is_safe(sdp, cx->opts))
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 fdee4537d402c345ccf7e46c55fc005059c523cd Author: Andrew Price anprice@redhat.com AuthorDate: Mon Aug 1 11:07:21 2022 +0100
fsck.gfs2: Pass fsck_cx into correct_journal_seg_size()
Signed-off-by: Andrew Price anprice@redhat.com --- gfs2/fsck/initialize.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c index 6edab7f8..02e92445 100644 --- a/gfs2/fsck/initialize.c +++ b/gfs2/fsck/initialize.c @@ -1436,10 +1436,11 @@ static int reset_journal_seg_size(struct lgfs2_sbd *sdp, unsigned int jsize, uns return 0; }
-static int correct_journal_seg_size(struct lgfs2_sbd *sdp) +static int correct_journal_seg_size(struct fsck_cx *cx) { int count; struct gfs_jindex *ji_0, *ji_1; + struct lgfs2_sbd *sdp = cx->sdp; char buf[sizeof(struct gfs_jindex)]; unsigned int jsize = LGFS2_DEFAULT_JSIZE * 1024 * 1024;
@@ -1497,7 +1498,7 @@ static int reconstruct_journals(struct fsck_cx *cx) char buf[sizeof(struct gfs_jindex)];
/* Ensure that sb_seg_size is valid */ - if (correct_journal_seg_size(sdp)) { + if (correct_journal_seg_size(cx)) { log_crit(_("Failed to set correct journal segment size. Cannot continue\n")); return -1; }
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 15ff4093c04e7090bb548d7f8e3eaab50e22f400 Author: Andrew Price anprice@redhat.com AuthorDate: Mon Aug 1 11:09:14 2022 +0100
fsck.gfs2: Pass fsck_cx into reset_journal_seg_size()
Signed-off-by: Andrew Price anprice@redhat.com --- gfs2/fsck/initialize.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c index 02e92445..c8c1724f 100644 --- a/gfs2/fsck/initialize.c +++ b/gfs2/fsck/initialize.c @@ -1418,9 +1418,11 @@ static int reconstruct_single_journal(struct lgfs2_sbd *sdp, int jnum, return 0; }
-static int reset_journal_seg_size(struct lgfs2_sbd *sdp, unsigned int jsize, unsigned int nsegs) +static int reset_journal_seg_size(struct fsck_cx *cx, unsigned int jsize, unsigned int nsegs) { + struct lgfs2_sbd *sdp = cx->sdp; unsigned int seg_size = jsize / (nsegs * sdp->sd_bsize); + if (!seg_size) seg_size = 16; /* The default with 128MB journal and 4K bsize */ if (seg_size != sdp->sd_seg_size) { @@ -1481,7 +1483,7 @@ static int correct_journal_seg_size(struct fsck_cx *cx)
jsize = (be64_to_cpu(ji_1->ji_addr) - be64_to_cpu(ji_0->ji_addr)) * sdp->sd_bsize; out: - return reset_journal_seg_size(sdp, jsize, be32_to_cpu(ji_0->ji_nsegment)); + return reset_journal_seg_size(cx, jsize, be32_to_cpu(ji_0->ji_nsegment)); }
/*
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 b35124cd1701747f650a8725a7dad87b6e4d7b24 Author: Andrew Price anprice@redhat.com AuthorDate: Mon Aug 1 11:12:10 2022 +0100
fsck.gfs2: Pass fsck_cx into init_rindex()
Signed-off-by: Andrew Price anprice@redhat.com --- gfs2/fsck/initialize.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c index c8c1724f..e08a5169 100644 --- a/gfs2/fsck/initialize.c +++ b/gfs2/fsck/initialize.c @@ -1525,8 +1525,9 @@ static int reconstruct_journals(struct fsck_cx *cx) /** * init_rindex - read in the rindex file */ -static int init_rindex(struct lgfs2_sbd *sdp) +static int init_rindex(struct fsck_cx *cx) { + struct lgfs2_sbd *sdp = cx->sdp; struct lgfs2_inode *ip;
if (sdp->gfs1) @@ -1646,7 +1647,7 @@ int initialize(struct fsck_cx *cx, int *all_clean) is damaged, we need the journals to repair it. That's because the journals likely contain rgrps and bitmaps, which we need to ignore when we're trying to find the rgrps. */ - if (init_rindex(sdp)) + if (init_rindex(cx)) return FSCK_ERROR;
if (fetch_rgrps(cx))
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 1e112d8e14f36db8ecbfaa115bb96037aa8a1fd0 Author: Andrew Price anprice@redhat.com AuthorDate: Mon Aug 1 11:20:11 2022 +0100
fsck.gfs2: Pass fsck_cx into ask_remove_eattr_entry()
Signed-off-by: Andrew Price anprice@redhat.com --- gfs2/fsck/pass1.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c index b535ab71..6d4003ed 100644 --- a/gfs2/fsck/pass1.c +++ b/gfs2/fsck/pass1.c @@ -828,7 +828,7 @@ static int p1_check_eattr_leaf(struct fsck_cx *cx, struct lgfs2_inode *ip, uint6 return check_ealeaf_block(cx, ip, block, GFS2_METATYPE_EA, bh, private); }
-static int ask_remove_eattr_entry(struct lgfs2_sbd *sdp, +static int ask_remove_eattr_entry(struct fsck_cx *cx, struct lgfs2_buffer_head *leaf_bh, struct gfs2_ea_header *curr, struct gfs2_ea_header *prev, @@ -841,7 +841,7 @@ static int ask_remove_eattr_entry(struct lgfs2_sbd *sdp, if (fix_curr) curr->ea_flags |= GFS2_EAFLAG_LAST; if (fix_curr_len) { - uint32_t max_size = sdp->sd_bsize; + uint32_t max_size = cx->sdp->sd_bsize; uint32_t offset = (uint32_t)(((unsigned long)curr) - ((unsigned long)leaf_bh->b_data)); curr->ea_rec_len = cpu_to_be32(max_size - offset); @@ -885,23 +885,23 @@ static int p1_check_eattr_entries(struct fsck_cx *cx, struct lgfs2_inode *ip,
if (!ea_hdr->ea_name_len){ log_err( _("EA has name length of zero\n")); - return ask_remove_eattr_entry(sdp, leaf_bh, ea_hdr, + return ask_remove_eattr_entry(cx, leaf_bh, ea_hdr, ea_hdr_prev, 1, 1); } if (offset + be32_to_cpu(ea_hdr->ea_rec_len) > max_size){ log_err( _("EA rec length too long\n")); - return ask_remove_eattr_entry(sdp, leaf_bh, ea_hdr, + return ask_remove_eattr_entry(cx, leaf_bh, ea_hdr, ea_hdr_prev, 1, 1); } if (offset + be32_to_cpu(ea_hdr->ea_rec_len) == max_size && (ea_hdr->ea_flags & GFS2_EAFLAG_LAST) == 0){ log_err( _("last EA has no last entry flag\n")); - return ask_remove_eattr_entry(sdp, leaf_bh, ea_hdr, + return ask_remove_eattr_entry(cx, leaf_bh, ea_hdr, ea_hdr_prev, 0, 0); } if (!ea_hdr->ea_name_len){ log_err( _("EA has name length of zero\n")); - return ask_remove_eattr_entry(sdp, leaf_bh, ea_hdr, + return ask_remove_eattr_entry(cx, leaf_bh, ea_hdr, ea_hdr_prev, 0, 0); }
@@ -914,7 +914,7 @@ static int p1_check_eattr_entries(struct fsck_cx *cx, struct lgfs2_inode *ip, /* Skip invalid entry */ log_err(_("EA (%s) type is invalid (%d > %d).\n"), ea_name, ea_hdr->ea_type, eatype_max(sdp->sd_fs_format)); - return ask_remove_eattr_entry(sdp, leaf_bh, ea_hdr, + return ask_remove_eattr_entry(cx, leaf_bh, ea_hdr, ea_hdr_prev, 0, 0); }
@@ -929,7 +929,7 @@ static int p1_check_eattr_entries(struct fsck_cx *cx, struct lgfs2_inode *ip, ea_name); log_err(_(" Required: %d\n Reported: %d\n"), max_ptrs, ea_hdr->ea_num_ptrs); - return ask_remove_eattr_entry(sdp, leaf_bh, ea_hdr, + return ask_remove_eattr_entry(cx, leaf_bh, ea_hdr, ea_hdr_prev, 0, 0); } else { log_debug( _(" Pointers Required: %d\n Pointers Reported: %d\n"),
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 b4b5fc4cec503507dfb21511018893670deb5a75 Author: Andrew Price anprice@redhat.com AuthorDate: Mon Aug 1 11:23:34 2022 +0100
fsck.gfs2: Pass fsck_cx into check_i_goal()
Signed-off-by: Andrew Price anprice@redhat.com --- gfs2/fsck/pass1.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c index 6d4003ed..6fabe278 100644 --- a/gfs2/fsck/pass1.c +++ b/gfs2/fsck/pass1.c @@ -1321,13 +1321,13 @@ bad_dinode: return -1; }
-static void check_i_goal(struct lgfs2_sbd *sdp, struct lgfs2_inode *ip) +static void check_i_goal(struct fsck_cx *cx, struct lgfs2_inode *ip) { - if (sdp->gfs1 || ip->i_flags & GFS2_DIF_SYSTEM) + if (cx->sdp->gfs1 || ip->i_flags & GFS2_DIF_SYSTEM) return;
- if (ip->i_goal_meta <= LGFS2_SB_ADDR(sdp) || - ip->i_goal_meta > sdp->fssize) { + if (ip->i_goal_meta <= LGFS2_SB_ADDR(cx->sdp) || + ip->i_goal_meta > cx->sdp->fssize) { log_err(_("Inode #%"PRIu64" (0x%"PRIx64"): Bad allocation goal block " "found: %"PRIu64" (0x%"PRIx64")\n"), ip->i_num.in_addr, ip->i_num.in_addr, ip->i_goal_meta, ip->i_goal_meta); @@ -1379,7 +1379,7 @@ static int handle_di(struct fsck_cx *cx, struct lgfs2_rgrp_tree *rgd, log_err(_("Inode number in inode at block %"PRIu64" (0x%"PRIx64") not fixed\n"), block, block); } - check_i_goal(cx->sdp, ip); + check_i_goal(cx, ip); error = handle_ip(cx, ip); fsck_inode_put(&ip); return error; @@ -1504,7 +1504,7 @@ static int check_system_inode(struct fsck_cx *cx, "directory entries.\n"), filename); } } - check_i_goal(cx->sdp, *sysinode); + check_i_goal(cx, *sysinode); error = handle_ip(cx, *sysinode); return error ? error : err; }
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 05b2c7d3232565a41693aebdd3c80b31779a66ff Author: Andrew Price anprice@redhat.com AuthorDate: Mon Aug 1 11:30:59 2022 +0100
fsck.gfs2: Pass fsck_cx into handle_inconsist()
Signed-off-by: Andrew Price anprice@redhat.com --- gfs2/fsck/pass4.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/gfs2/fsck/pass4.c b/gfs2/fsck/pass4.c index 12afabbd..f63f4ff6 100644 --- a/gfs2/fsck/pass4.c +++ b/gfs2/fsck/pass4.c @@ -119,7 +119,7 @@ static int handle_unlinked(struct fsck_cx *cx, uint64_t no_addr, return 0; }
-static void handle_inconsist(struct lgfs2_sbd *sdp, uint64_t no_addr, +static void handle_inconsist(struct fsck_cx *cx, uint64_t no_addr, uint32_t *di_nlink, uint32_t counted_links) { log_err(_("Link count inconsistent for inode %"PRIu64" (0x%"PRIx64") has %u but fsck found %u.\n"), @@ -129,7 +129,7 @@ static void handle_inconsist(struct lgfs2_sbd *sdp, uint64_t no_addr, no_addr, no_addr)) { struct lgfs2_inode *ip;
- ip = fsck_load_inode(sdp, no_addr); /* lgfs2_bread, inode_get */ + ip = fsck_load_inode(cx->sdp, no_addr); /* lgfs2_bread, inode_get */ fix_link_count(counted_links, ip); *di_nlink = counted_links; fsck_inode_put(&ip); /* out, lgfs2_brelse, free */ @@ -187,7 +187,7 @@ static int scan_inode_list(struct fsck_cx *cx) continue; } /* if (ii->counted_links == 0) */ else if (ii->di_nlink != ii->counted_links) { - handle_inconsist(sdp, ii->num.in_addr, + handle_inconsist(cx, ii->num.in_addr, &ii->di_nlink, ii->counted_links); } log_debug(_("block %"PRIu64" (0x%"PRIx64") has link count %d\n"), @@ -220,7 +220,7 @@ static int scan_dir_list(struct fsck_cx *cx) &di->counted_links, &lf_addition)) continue; } else if (di->di_nlink != di->counted_links) { - handle_inconsist(sdp, di->dinode.in_addr, + handle_inconsist(cx, di->dinode.in_addr, &di->di_nlink, di->counted_links); } log_debug(_("block %"PRIu64" (0x%"PRIx64") has link count %d\n"),
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 96a87624b8768ab1f68d7467883d71cb98b94b32 Author: Andrew Price anprice@redhat.com AuthorDate: Mon Aug 1 11:33:32 2022 +0100
fsck.gfs2: Pass fsck_cx into update_rgrp()
Signed-off-by: Andrew Price anprice@redhat.com --- gfs2/fsck/pass5.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/gfs2/fsck/pass5.c b/gfs2/fsck/pass5.c index 7c8dfce5..1d19bac7 100644 --- a/gfs2/fsck/pass5.c +++ b/gfs2/fsck/pass5.c @@ -113,9 +113,10 @@ static int check_block_status(struct lgfs2_sbd *sdp, struct bmap *bl, return 0; }
-static void update_rgrp(struct lgfs2_sbd *sdp, struct lgfs2_rgrp_tree *rgp, +static void update_rgrp(struct fsck_cx *cx, struct lgfs2_rgrp_tree *rgp, struct bmap *bl, uint32_t *count) { + struct lgfs2_sbd *sdp = cx->sdp; uint32_t i; struct lgfs2_bitmap *bits; uint64_t rg_block = 0; @@ -213,7 +214,7 @@ int pass5(struct fsck_cx *cx, struct bmap *bl)
rg_count++; /* Compare the bitmaps and report the differences */ - update_rgrp(sdp, rgp, bl, count); + update_rgrp(cx, rgp, bl, count); } /* Fix up superblock info based on this - don't think there's * anything to do here... */
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 69428814ec5ce9abf7d07088f4b1800d62371ec8 Author: Andrew Price anprice@redhat.com AuthorDate: Mon Aug 1 11:35:20 2022 +0100
fsck.gfs2: Pass fsck_cx into check_block_status()
Signed-off-by: Andrew Price anprice@redhat.com --- gfs2/fsck/pass5.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/gfs2/fsck/pass5.c b/gfs2/fsck/pass5.c index 1d19bac7..5de3d57c 100644 --- a/gfs2/fsck/pass5.c +++ b/gfs2/fsck/pass5.c @@ -14,11 +14,12 @@
#define GFS1_BLKST_USEDMETA 4
-static int check_block_status(struct lgfs2_sbd *sdp, struct bmap *bl, +static int check_block_status(struct fsck_cx *cx, struct bmap *bl, char *buffer, unsigned int buflen, uint64_t *rg_block, uint64_t rg_data, uint32_t *count) { + struct lgfs2_sbd *sdp = cx->sdp; unsigned char *byte, *end; unsigned int bit; unsigned char rg_status; @@ -126,7 +127,7 @@ static void update_rgrp(struct fsck_cx *cx, struct lgfs2_rgrp_tree *rgp, bits = &rgp->bits[i];
/* update the bitmaps */ - if (check_block_status(sdp, bl, bits->bi_data + bits->bi_offset, + if (check_block_status(cx, bl, bits->bi_data + bits->bi_offset, bits->bi_len, &rg_block, rgp->rt_data0, count)) return; if (skip_this_pass || fsck_abort) /* if asked to skip the rest */
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 22757d1bb3d7f5874fb0b4136b763e9a02bb60d8 Author: Andrew Price anprice@redhat.com AuthorDate: Mon Aug 1 11:38:21 2022 +0100
fsck.gfs2: Pass fsck_cx into rewrite_rg_block()
Signed-off-by: Andrew Price anprice@redhat.com --- gfs2/fsck/rgrepair.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/gfs2/fsck/rgrepair.c b/gfs2/fsck/rgrepair.c index 5f228500..5f3503c4 100644 --- a/gfs2/fsck/rgrepair.c +++ b/gfs2/fsck/rgrepair.c @@ -846,9 +846,10 @@ static int rindex_calculate(struct lgfs2_sbd *sdp, int *num_rgs) * rewrite_rg_block - rewrite ("fix") a buffer with rg or bitmap data * returns: 0 if the rg was repaired, otherwise 1 */ -static int rewrite_rg_block(struct lgfs2_sbd *sdp, struct lgfs2_rgrp_tree *rg, +static int rewrite_rg_block(struct fsck_cx *cx, struct lgfs2_rgrp_tree *rg, uint64_t errblock) { + struct lgfs2_sbd *sdp = cx->sdp; int x = errblock - rg->rt_addr; const char *typedesc = x ? "GFS2_METATYPE_RB" : "GFS2_METATYPE_RG"; ssize_t ret; @@ -1193,7 +1194,7 @@ int rindex_repair(struct fsck_cx *cx, int trust_lvl, int *ok) if (errblock == prev_err) break; prev_err = errblock; - rewrite_rg_block(sdp, rgd, errblock); + rewrite_rg_block(cx, rgd, errblock); } else { lgfs2_rgrp_relse(sdp, rgd); break;
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 2dd2e939c25b12bc4b50faf6f3ed1d14a09a7076 Author: Andrew Price anprice@redhat.com AuthorDate: Mon Aug 1 11:43:37 2022 +0100
fsck.gfs2: Pass fsck_cx into fsck_query()
Signed-off-by: Andrew Price anprice@redhat.com --- gfs2/fsck/afterpass1_common.c | 2 +- gfs2/fsck/fs_recovery.c | 23 ++++++++-------- gfs2/fsck/fsck.h | 6 ++--- gfs2/fsck/initialize.c | 36 ++++++++++++------------- gfs2/fsck/main.c | 2 +- gfs2/fsck/metawalk.c | 10 +++---- gfs2/fsck/pass1.c | 30 ++++++++++----------- gfs2/fsck/pass1b.c | 12 ++++----- gfs2/fsck/pass2.c | 63 +++++++++++++++++++++---------------------- gfs2/fsck/pass3.c | 11 ++++---- gfs2/fsck/pass4.c | 10 +++---- gfs2/fsck/pass5.c | 7 +++-- gfs2/fsck/rgrepair.c | 8 +++--- gfs2/fsck/util.c | 6 ++--- 14 files changed, 110 insertions(+), 116 deletions(-)
diff --git a/gfs2/fsck/afterpass1_common.c b/gfs2/fsck/afterpass1_common.c index 9e27d9ba..999b74dc 100644 --- a/gfs2/fsck/afterpass1_common.c +++ b/gfs2/fsck/afterpass1_common.c @@ -290,7 +290,7 @@ int delete_eattr_extentry(struct fsck_cx *cx, struct lgfs2_inode *ip, int i, __b if (error) { log_err(_("Bad extended attribute found at block %"PRIu64 " (0x%"PRIx64")"), be64_to_cpu(*ea_data_ptr), be64_to_cpu(*ea_data_ptr)); - if (query( _("Repair the bad Extended Attribute? (y/n) "))) { + if (query(cx, _("Repair the bad Extended Attribute? (y/n) "))) { ea_hdr->ea_num_ptrs = i; ea_hdr->ea_data_len = cpu_to_be32(tot_ealen); *ea_data_ptr = 0; diff --git a/gfs2/fsck/fs_recovery.c b/gfs2/fsck/fs_recovery.c index 0fd92442..d778167e 100644 --- a/gfs2/fsck/fs_recovery.c +++ b/gfs2/fsck/fs_recovery.c @@ -476,8 +476,7 @@ int preen_is_safe(struct lgfs2_sbd *sdp, const struct fsck_options * const _opts * Returns: errno */
-static int recover_journal(struct lgfs2_inode *ip, int j, const struct fsck_options * const _opts, - int *was_clean) +static int recover_journal(struct lgfs2_inode *ip, int j, struct fsck_cx *cx, int *was_clean) { struct lgfs2_sbd *sdp = ip->i_sbd; struct lgfs2_log_header head; @@ -499,12 +498,12 @@ static int recover_journal(struct lgfs2_inode *ip, int j, const struct fsck_opti } } if (error) { - if (_opts->no) { + if (cx->opts->no) { log_err( _("Journal #%d ("journal%d") is corrupt\n"),j+1, j); log_err( _("Not fixing it due to the -n option.\n")); goto out; } - if (!preen_is_safe(sdp, _opts)) { + if (!preen_is_safe(sdp, cx->opts)) { log_err(_("Journal #%d ("journal%d") is corrupt.\n"), j+1, j); log_err(_("I'm not fixing it because it may be unsafe:\n" @@ -515,7 +514,7 @@ static int recover_journal(struct lgfs2_inode *ip, int j, const struct fsck_opti "without -a or -p.\n")); goto out; } - if (!query( _("\nJournal #%d ("journal%d") is " + if (!query(cx, _("\nJournal #%d ("journal%d") is " "corrupt. Okay to repair it? (y/n)"), j+1, j)) { log_err( _("jid=%u: The journal was not repaired.\n"), @@ -543,12 +542,12 @@ static int recover_journal(struct lgfs2_inode *ip, int j, const struct fsck_opti *was_clean = 1; return 0; } - if (_opts->no) { + if (cx->opts->no) { log_err(_("Journal #%d ("journal%d") is dirty\n"),j+1, j); log_err(_("not replaying due to the -n option.\n")); goto out; } - if (!preen_is_safe(sdp, _opts)) { + if (!preen_is_safe(sdp, cx->opts)) { log_err( _("Journal #%d ("journal%d") is dirty\n"), j+1, j); log_err( _("I'm not replaying it because it may be unsafe:\n" "Locking protocol is not lock_nolock and " @@ -559,7 +558,7 @@ static int recover_journal(struct lgfs2_inode *ip, int j, const struct fsck_opti error = FSCK_ERROR; goto out; } - if (!query( _("\nJournal #%d ("journal%d") is dirty. Okay to " + if (!query(cx, _("\nJournal #%d ("journal%d") is dirty. Okay to " "replay it? (y/n)"), j+1, j)) goto reinit;
@@ -596,7 +595,7 @@ out: } log_err( _("jid=%u: Failed\n"), j); reinit: - if (query( _("Do you want to clear the journal instead? (y/n)"))) { + if (query(cx, _("Do you want to clear the journal instead? (y/n)"))) { error = lgfs2_write_journal(sdp->md.journal[j], sdp->sd_bsize, sdp->md.journal[j]->i_size / sdp->sd_bsize); @@ -710,7 +709,7 @@ int replay_journals(struct fsck_cx *cx, int *clean_journals) if (sdp->jsize == LGFS2_DEFAULT_JSIZE && jsize && jsize != sdp->jsize) sdp->jsize = jsize; - error = recover_journal(sdp->md.journal[i], i, cx->opts, &clean); + error = recover_journal(sdp->md.journal[i], i, cx, &clean); if (!clean) dirty_journals++; if (!gave_msg && dirty_journals == 1 && !cx->opts->no && @@ -890,7 +889,7 @@ int init_jindex(struct fsck_cx *cx, int allow_ji_rebuild) "corrupt.\n")); return -1; } - if (!query( _("The gfs2 system jindex inode is missing. " + if (!query(cx, _("The gfs2 system jindex inode is missing. " "Okay to rebuild it? (y/n) "))) { log_crit(_("Error: cannot proceed without a valid " "jindex file.\n")); @@ -920,7 +919,7 @@ int init_jindex(struct fsck_cx *cx, int allow_ji_rebuild) &jindex_check_fxns); if (error) { log_err(_("The system journal index is damaged.\n")); - if (!query( _("Okay to rebuild it? (y/n) "))) { + if (!query(cx, _("Okay to rebuild it? (y/n) "))) { log_crit(_("Error: cannot proceed without a " "valid jindex file.\n")); return -1; diff --git a/gfs2/fsck/fsck.h b/gfs2/fsck/fsck.h index b854997e..34faf3ca 100644 --- a/gfs2/fsck/fsck.h +++ b/gfs2/fsck/fsck.h @@ -10,7 +10,7 @@ #define FSCK_HASH_SIZE (1 << FSCK_HASH_SHIFT) #define FSCK_HASH_MASK (FSCK_HASH_SIZE - 1)
-#define query(fmt, args...) fsck_query(fmt, ##args) +#define query(cx, fmt, args...) fsck_query(cx, fmt, ##args)
/* * Exit codes used by fsck-type programs @@ -140,8 +140,8 @@ extern int pass3(struct fsck_cx *cx); extern int pass4(struct fsck_cx *cx); extern int pass5(struct fsck_cx *cx, struct bmap *bl); 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 int fsck_query(struct fsck_cx *cx, const char *format, ...) + __attribute__((format(printf,2,3))); extern struct dir_info *dirtree_find(struct fsck_cx *cx, uint64_t block); extern void dup_delete(struct fsck_cx *cx, struct duptree *dt); extern void dirtree_delete(struct fsck_cx *cx, struct dir_info *b); diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c index e08a5169..671e34f1 100644 --- a/gfs2/fsck/initialize.c +++ b/gfs2/fsck/initialize.c @@ -265,7 +265,7 @@ static void check_rgrp_integrity(struct fsck_cx *cx, struct lgfs2_rgrp_tree *rgd "metadata in resource group " "%"PRIu64" (0x%"PRIx64")? (y/n)"), rgd->rt_addr, rgd->rt_addr); - if (query("%s", msg)) + if (query(cx, "%s", msg)) *fixit = 1; } if (!(*fixit)) { @@ -324,7 +324,7 @@ static void check_rgrp_integrity(struct fsck_cx *cx, struct lgfs2_rgrp_tree *rgd log_err( _("Error: resource group %"PRIu64" (0x%"PRIx64"): " "free space (%d) does not match bitmap (%d)\n"), rgd->rt_addr, rgd->rt_addr, rgd->rt_free, rg_free); - if (query( _("Fix the rgrp free blocks count? (y/n)"))) { + if (query(cx, _("Fix the rgrp free blocks count? (y/n)"))) { rgd->rt_free = rg_free; if (sdp->gfs1) lgfs2_gfs_rgrp_out(rgd, rgd->bits[0].bi_data); @@ -345,7 +345,7 @@ static void check_rgrp_integrity(struct fsck_cx *cx, struct lgfs2_rgrp_tree *rgd log_err(_("Error: resource group %"PRIu64" (0x%"PRIx64"): " "free meta (%d) does not match bitmap (%d)\n"), rgd->rt_addr, rgd->rt_addr, rgd->rt_freemeta, rg_unlinked); - if (query( _("Fix the rgrp free meta blocks count? (y/n)"))) { + if (query(cx, _("Fix the rgrp free meta blocks count? (y/n)"))) { rgd->rt_freemeta = rg_unlinked; lgfs2_gfs_rgrp_out(rgd, rgd->bits[0].bi_data); rgd->bits[0].bi_modified = 1; @@ -360,7 +360,7 @@ static void check_rgrp_integrity(struct fsck_cx *cx, struct lgfs2_rgrp_tree *rgd log_err(_("Error: resource group %"PRIu64" (0x%"PRIx64"): used dinode " "count (%d) does not match bitmap (%d)\n"), rgd->rt_addr, rgd->rt_addr, rgd->rt_useddi, rg_useddi); - if (query( _("Fix the rgrp used dinode block count? (y/n)"))) { + if (query(cx, _("Fix the rgrp used dinode block count? (y/n)"))) { rgd->rt_useddi = rg_useddi; lgfs2_gfs_rgrp_out(rgd, rgd->bits[0].bi_data); rgd->bits[0].bi_modified = 1; @@ -375,7 +375,7 @@ static void check_rgrp_integrity(struct fsck_cx *cx, struct lgfs2_rgrp_tree *rgd log_err(_("Error: resource group %"PRIu64" (0x%"PRIx64"): used " "metadata (%d) does not match bitmap (%d)\n"), rgd->rt_addr, rgd->rt_addr, rgd->rt_usedmeta, rg_usedmeta); - if (query( _("Fix the rgrp used meta blocks count? (y/n)"))) { + if (query(cx, _("Fix the rgrp used meta blocks count? (y/n)"))) { rgd->rt_usedmeta = rg_usedmeta; lgfs2_gfs_rgrp_out(rgd, rgd->bits[0].bi_data); rgd->bits[0].bi_modified = 1; @@ -438,7 +438,7 @@ static int rebuild_sysdir(struct fsck_cx *cx) int err = 0;
log_err(_("The system directory seems to be destroyed.\n")); - if (!query(_("Okay to rebuild it? (y/n)"))) { + if (!query(cx, _("Okay to rebuild it? (y/n)"))) { log_err(_("System directory not rebuilt; aborting.\n")); return -1; } @@ -606,7 +606,7 @@ static void lookup_per_node(struct fsck_cx *cx, int allow_rebuild) return; }
- if (query( _("The gfs2 system per_node directory " + if (query(cx, _("The gfs2 system per_node directory " "inode is missing. Okay to rebuild it? (y/n) "))) { int err;
@@ -800,7 +800,7 @@ static int init_system_inodes(struct fsck_cx *cx) /* Look for "inum" entry in master dinode */ lgfs2_lookupi(sdp->master_dir, "inum", 4, &sdp->md.inum); if (!sdp->md.inum) { - if (!query( _("The gfs2 system inum inode is missing. " + if (!query(cx, _("The gfs2 system inum inode is missing. " "Okay to rebuild it? (y/n) "))) { log_err( _("fsck.gfs2 cannot continue without " "a valid inum file; aborting.\n")); @@ -833,7 +833,7 @@ static int init_system_inodes(struct fsck_cx *cx) /* In gfs1, the license_di is always 3 blocks after the jindex_di */ if ((sdp->sd_license_di.in_addr != sdp->sd_jindex_di.in_addr + 3) || (sdp->sd_license_di.in_formal_ino != sdp->sd_jindex_di.in_addr + 3)) { - if (!query( _("The gfs system statfs inode pointer is incorrect. " + if (!query(cx, _("The gfs system statfs inode pointer is incorrect. " "Okay to correct? (y/n) "))) { log_err( _("fsck.gfs2 cannot continue without a valid " "statfs file; aborting.\n")); @@ -851,7 +851,7 @@ static int init_system_inodes(struct fsck_cx *cx) } else lgfs2_lookupi(sdp->master_dir, "statfs", 6, &sdp->md.statfs); if (!sdp->gfs1 && !sdp->md.statfs) { - if (!query( _("The gfs2 system statfs inode is missing. " + if (!query(cx, _("The gfs2 system statfs inode is missing. " "Okay to rebuild it? (y/n) "))) { log_err( _("fsck.gfs2 cannot continue without a valid " "statfs file; aborting.\n")); @@ -890,7 +890,7 @@ static int init_system_inodes(struct fsck_cx *cx) /* In gfs1, the quota_di is always 2 blocks after the jindex_di */ if ((sdp->sd_quota_di.in_addr != sdp->sd_jindex_di.in_addr + 2) || (sdp->sd_quota_di.in_formal_ino != sdp->sd_jindex_di.in_addr + 2)) { - if (!query( _("The gfs system quota inode pointer is incorrect. " + if (!query(cx, _("The gfs system quota inode pointer is incorrect. " " Okay to correct? (y/n) "))) { log_err( _("fsck.gfs2 cannot continue without a valid " "quota file; aborting.\n")); @@ -908,7 +908,7 @@ static int init_system_inodes(struct fsck_cx *cx) } else lgfs2_lookupi(sdp->master_dir, "quota", 5, &sdp->md.qinode); if (!sdp->gfs1 && !sdp->md.qinode) { - if (!query( _("The gfs2 system quota inode is missing. " + if (!query(cx, _("The gfs2 system quota inode is missing. " "Okay to rebuild it? (y/n) "))) { log_crit(_("System quota inode was not " "rebuilt. Aborting.\n")); @@ -1087,7 +1087,7 @@ static void peruse_user_dinode(struct fsck_cx *cx, struct lgfs2_inode *ip) log_warn(_("Found a copy of the root directory in a journal " "at block: 0x%"PRIx64".\n"), ip->i_bh->b_blocknr); - if (!query(_("Do you want to replace the root dinode from the copy? (y/n)"))) { + if (!query(cx, _("Do you want to replace the root dinode from the copy? (y/n)"))) { log_err(_("Damaged root dinode not fixed.\n")); return; } @@ -1287,7 +1287,7 @@ static int sb_repair(struct fsck_cx *cx) "reinitializing it.\n" "Hopefully everything will later " "be put into lost+found.\n")); - if (!query(_("Okay to reinitialize the root " + if (!query(cx, _("Okay to reinitialize the root " "dinode? (y/n)"))) { log_err(_("The root dinode was not " "reinitialized; aborting.\n")); @@ -1302,7 +1302,7 @@ static int sb_repair(struct fsck_cx *cx) } } /* Step 3 - Rebuild the lock protocol and file system table name */ - if (query(_("Okay to fix the GFS2 superblock? (y/n)"))) { + if (query(cx, _("Okay to fix the GFS2 superblock? (y/n)"))) { log_info(_("Found system master directory at: 0x%"PRIx64"\n"), sdp->sd_meta_dir.in_addr); sdp->master_dir = lgfs2_inode_read(sdp, sdp->sd_meta_dir.in_addr); @@ -1427,7 +1427,7 @@ static int reset_journal_seg_size(struct fsck_cx *cx, unsigned int jsize, unsign seg_size = 16; /* The default with 128MB journal and 4K bsize */ if (seg_size != sdp->sd_seg_size) { sdp->sd_seg_size = seg_size; - if (!query(_("Computed correct journal segment size to %u." + if (!query(cx, _("Computed correct journal segment size to %u." " Reset it? (y/n) "), seg_size)) { log_crit(_("Error: Cannot proceed without a valid journal" " segment size value.\n")); @@ -1456,7 +1456,7 @@ static int correct_journal_seg_size(struct fsck_cx *cx)
if (sdp->md.journals == 1) { if (sdp->sd_seg_size == 0) { - if (!query(_("The gfs2 journal segment size is 0 and a" + if (!query(cx, _("The gfs2 journal segment size is 0 and a" " correct value cannot be determined in a" " single-journal filesystem.\n" "Continue with default? (y/n) "))) { @@ -1538,7 +1538,7 @@ static int init_rindex(struct fsck_cx *cx) if (sdp->md.riinode) return 0;
- if (!query( _("The gfs2 system rindex inode is missing. " + if (!query(cx, _("The gfs2 system rindex inode is missing. " "Okay to rebuild it? (y/n) "))) { log_crit(_("Error: Cannot proceed without a valid rindex.\n")); return -1; diff --git a/gfs2/fsck/main.c b/gfs2/fsck/main.c index b070ec9b..cda02def 100644 --- a/gfs2/fsck/main.c +++ b/gfs2/fsck/main.c @@ -208,7 +208,7 @@ static int check_statfs(struct fsck_cx *cx) sdp->dinodes_alloced, sdp->dinodes_alloced);
errors_found++; - if (!query( _("Okay to fix the master statfs file? (y/n)"))) { + if (!query(cx, _("Okay to fix the master statfs file? (y/n)"))) { log_err( _("The statfs file was not fixed.\n")); return 0; } diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c index 498a2abe..9fb36aac 100644 --- a/gfs2/fsck/metawalk.c +++ b/gfs2/fsck/metawalk.c @@ -69,7 +69,7 @@ int check_n_fix_bitmap(struct fsck_cx *cx, struct lgfs2_rgrp_tree *rgd, huge and unmanageable. */ log_err(_("Block %"PRIu64" (0x%"PRIx64") was '%s', should be %s.\n"), blk, blk, allocdesc[sdp->gfs1][old_state], allocdesc[sdp->gfs1][new_state]); - if (!query( _("Fix the bitmap? (y/n)"))) { + if (!query(cx, _("Fix the bitmap? (y/n)"))) { log_err( _("The bitmap inconsistency was ignored.\n")); return 0; } @@ -421,7 +421,7 @@ static int check_entries(struct fsck_cx *cx, struct lgfs2_inode *ip, struct lgfs "is corrupt.\n"), bh->b_blocknr, bh->b_blocknr, (*count) + 1, ip->i_num.in_addr, ip->i_num.in_addr); - if (query( _("Attempt to repair it? (y/n) "))) { + if (query(cx, _("Attempt to repair it? (y/n) "))) { if (dirent_repair(ip, bh, &d, dent, type, first)) { if (first) /* make a new sentinel */ @@ -455,7 +455,7 @@ static int check_entries(struct fsck_cx *cx, struct lgfs2_inode *ip, struct lgfs "directory %"PRIu64" (0x%"PRIx64")!\n"), bh->b_blocknr, bh->b_blocknr, ip->i_num.in_addr, ip->i_num.in_addr); - if (query(_("Attempt to remove it? (y/n) "))) { + if (query(cx, _("Attempt to remove it? (y/n) "))) { dirblk_truncate(ip, prev, bh); log_err(_("The corrupt directory " "entry was removed.\n")); @@ -604,7 +604,7 @@ int check_leaf(struct fsck_cx *cx, struct lgfs2_inode *ip, int lindex, struct me "number of entries found - is %u, found %u\n"), *leaf_no, *leaf_no, ip->i_num.in_addr, ip->i_num.in_addr, leaf->lf_entries, count); - if (query( _("Update leaf entry count? (y/n) "))) { + if (query(cx, _("Update leaf entry count? (y/n) "))) { leaf->lf_entries = count; lgfs2_leaf_out(leaf, lbh->b_data); lgfs2_bmodified(lbh); @@ -1568,7 +1568,7 @@ undo_metalist: "%"PRIu64" (0x%"PRIx64").\n"), ip->i_num.in_addr, ip->i_num.in_addr, error_blk.metablk, error_blk.metablk, error_blk.metaoff, error_blk.metaoff, error_blk.errblk, error_blk.errblk); - if (!query( _("Remove the invalid inode? (y/n) "))) { + if (!query(cx, _("Remove the invalid inode? (y/n) "))) { free_metalist(ip, metalist); log_err(_("Invalid inode not deleted.\n")); return error; diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c index 6fabe278..deac85cf 100644 --- a/gfs2/fsck/pass1.c +++ b/gfs2/fsck/pass1.c @@ -102,7 +102,7 @@ static int p1_repair_leaf(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t *
log_err(_("Directory Inode %"PRIu64" (0x%"PRIx64") points to leaf %"PRIu64" (0x%"PRIx64") %s.\n"), ip->i_num.in_addr, ip->i_num.in_addr, *leaf_no, *leaf_no, msg); - if (!query( _("Attempt to patch around it? (y/n) "))) { + if (!query(cx, _("Attempt to patch around it? (y/n) "))) { log_err( _("Bad leaf left in place.\n")); goto out; } @@ -303,7 +303,7 @@ static int p1_check_metalist(struct fsck_cx *cx, struct iptr iptr, struct lgfs2_ "pointer %"PRIu64" (0x%"PRIx64") (points to something " "that is not %s).\n"), ip->i_num.in_addr, ip->i_num.in_addr, block, block, blktypedesc); - if (query(_("Zero the indirect block pointer? (y/n) "))){ + if (query(cx, _("Zero the indirect block pointer? (y/n) "))){ *iptr_ptr(iptr) = 0; lgfs2_bmodified(iptr.ipt_bh); *is_valid = 1; @@ -554,7 +554,7 @@ static int ask_remove_inode_eattr(struct fsck_cx *cx, struct lgfs2_inode *ip, return 0; /* eattr was removed prior to this call */ 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) "))){ + if (query(cx, _("Clear all Extended Attributes from the inode? (y/n) "))){ undo_reference(cx, ip, ip->i_eattr, 0, bc); ip->i_eattr = 0; bc->ea_count = 0; @@ -683,7 +683,7 @@ static int p1_finish_eattr_indir(struct fsck_cx *cx, struct lgfs2_inode *ip, int return 0; log_err(_("Inode %"PRIu64" (0x%"PRIx64") has recoverable indirect extended attribute errors.\n"), ip->i_num.in_addr, ip->i_num.in_addr); - if (query( _("Okay to fix the block count for the inode? (y/n) "))) { + if (query(cx, _("Okay to fix the block count for the inode? (y/n) "))) { ip->i_blocks = 1 + bc->indir_count + bc->data_count + bc->ea_count; lgfs2_bmodified(ip->i_bh); log_err(_("Block count fixed: 1+%"PRIu64"+%"PRIu64"+%"PRIu64" = %"PRIu64".\n"), @@ -791,7 +791,7 @@ static int p1_check_extended_leaf_eattr(struct fsck_cx *cx, struct lgfs2_inode * if (error) { log_err(_("Bad extended attribute found at block %"PRIu64" (0x%"PRIx64")"), be64_to_cpu(*data_ptr), be64_to_cpu(*data_ptr)); - if (query( _("Repair the bad Extended Attribute? (y/n) "))) { + if (query(cx, _("Repair the bad Extended Attribute? (y/n) "))) { ea_hdr->ea_num_ptrs = i; ea_hdr->ea_data_len = cpu_to_be32(tot_ealen); *data_ptr = 0; @@ -834,7 +834,7 @@ static int ask_remove_eattr_entry(struct fsck_cx *cx, struct gfs2_ea_header *prev, int fix_curr, int fix_curr_len) { - if (!query( _("Remove the bad Extended Attribute entry? (y/n) "))) { + if (!query(cx, _("Remove the bad Extended Attribute entry? (y/n) "))) { log_err( _("Bad Extended Attribute not removed.\n")); return 0; } @@ -1281,10 +1281,8 @@ static int handle_ip(struct fsck_cx *cx, struct lgfs2_inode *ip) error = check_inode_eattr(cx, ip, &pass1_fxns);
if (error) { - if (!query(_("Clear the bad Extended Attributes? " - "(y/n) "))) { - log_err( _("The bad Extended Attributes were " - "not fixed.\n")); + if (!query(cx, _("Clear the bad Extended Attributes? (y/n) "))) { + log_err(_("The bad Extended Attributes were not fixed.\n")); return 0; } log_err(_("Clearing the bad Extended Attributes in " @@ -1305,7 +1303,7 @@ static int handle_ip(struct fsck_cx *cx, struct lgfs2_inode *ip) log_info(_("inode has: %"PRIu64", but fsck counts: Dinode:1 + " "indir:%"PRIu64" + data: %"PRIu64" + ea: %"PRIu64"\n"), ip->i_blocks, bc.indir_count, bc.data_count, bc.ea_count); - if (query( _("Fix ondisk block count? (y/n) "))) { + if (query(cx, _("Fix ondisk block count? (y/n) "))) { ip->i_blocks = 1 + bc.indir_count + bc.data_count + bc.ea_count; lgfs2_bmodified(ip->i_bh); log_err(_("Block count for #%"PRIu64" (0x%"PRIx64") fixed\n"), @@ -1331,7 +1329,7 @@ static void check_i_goal(struct fsck_cx *cx, struct lgfs2_inode *ip) log_err(_("Inode #%"PRIu64" (0x%"PRIx64"): Bad allocation goal block " "found: %"PRIu64" (0x%"PRIx64")\n"), ip->i_num.in_addr, ip->i_num.in_addr, ip->i_goal_meta, ip->i_goal_meta); - if (query(_("Fix goal block in inode #%"PRIu64" (0x%"PRIx64")? (y/n) "), + if (query(cx, _("Fix goal block in inode #%"PRIu64" (0x%"PRIx64")? (y/n) "), ip->i_num.in_addr, ip->i_num.in_addr)) { ip->i_goal_meta = ip->i_num.in_addr; lgfs2_bmodified(ip->i_bh); @@ -1359,7 +1357,7 @@ static int handle_di(struct fsck_cx *cx, struct lgfs2_rgrp_tree *rgd, log_err(_("Inode #%"PRIu64" (0x%"PRIx64"): Bad inode address found: %"PRIu64 " (0x%"PRIx64")\n"), block, block, ip->i_num.in_addr, ip->i_num.in_addr); - if (query(_("Fix address in inode at block #%"PRIu64" (0x%"PRIx64")? (y/n) "), + if (query(cx, _("Fix address in inode at block #%"PRIu64" (0x%"PRIx64")? (y/n) "), block, block)) { ip->i_num.in_addr = ip->i_num.in_formal_ino = block; lgfs2_bmodified(ip->i_bh); @@ -1371,7 +1369,7 @@ static int handle_di(struct fsck_cx *cx, struct lgfs2_rgrp_tree *rgd, log_err(_("Inode #%"PRIu64" (0x%"PRIx64"): GFS1 formal inode number " "mismatch: was %"PRIu64" (0x%"PRIx64")\n"), block, block, ip->i_num.in_formal_ino, ip->i_num.in_formal_ino); - if (query(_("Fix formal inode number in inode #%"PRIu64" (0x%"PRIx64")? (y/n) "), + if (query(cx, _("Fix formal inode number in inode #%"PRIu64" (0x%"PRIx64")? (y/n) "), block, block)) { ip->i_num.in_formal_ino = block; lgfs2_bmodified(ip->i_bh); @@ -1437,7 +1435,7 @@ static int check_system_inode(struct fsck_cx *cx, !((*sysinode)->i_flags & GFS2_DIF_SYSTEM)) { log_err( _("System inode %s is missing the 'system' " "flag. It should be rebuilt.\n"), filename); - if (sysdir && query(_("Delete the corrupt %s system " + if (sysdir && query(cx, _("Delete the corrupt %s system " "inode? (y/n) "), filename)) { lgfs2_inode_put(sysinode); lgfs2_dirent_del(sysdir, filename, @@ -1462,7 +1460,7 @@ static int check_system_inode(struct fsck_cx *cx, "should be '%s').\n"), filename, block_type_string(ds.q), block_type_string(GFS2_BLKST_DINODE)); - if (query(_("Create new %s system inode? (y/n) "), filename)) { + if (query(cx, _("Create new %s system inode? (y/n) "), filename)) { log_err( _("Rebuilding system file "%s"\n"), filename); error = builder(cx->sdp); diff --git a/gfs2/fsck/pass1b.c b/gfs2/fsck/pass1b.c index b3fe1b4f..5ccbf412 100644 --- a/gfs2/fsck/pass1b.c +++ b/gfs2/fsck/pass1b.c @@ -103,7 +103,7 @@ static void clone_data_block(struct fsck_cx *cx, struct duptree *dt, struct lgfs2_buffer_head *bh; __be64 *ptr;
- if (!(query(_("Okay to clone data block %"PRIu64" (0x%"PRIx64") for inode %"PRIu64" (0x%"PRIx64")? (y/n) "), + if (!(query(cx, _("Okay to clone data block %"PRIu64" (0x%"PRIx64") for inode %"PRIu64" (0x%"PRIx64")? (y/n) "), dt->block, dt->block, id->block_no, id->block_no))) { log_warn(_("The duplicate reference was not cloned.\n")); return; @@ -248,7 +248,7 @@ static void resolve_dup_references(struct fsck_cx *cx, struct duptree *dt, id->name, id->block_no, id->block_no, dt->block, dt->block, reftypes[this_ref], reftypes[acceptable_ref]); if (this_ref == REF_AS_EA) { - if (!(query(_("Okay to remove extended attributes " + if (!(query(cx, _("Okay to remove extended attributes " "from %s inode %"PRIu64" (0x%"PRIx64")? (y/n) "), (inval ? _("invalidated") : ""), id->block_no, id->block_no))) { @@ -269,7 +269,7 @@ static void resolve_dup_references(struct fsck_cx *cx, struct duptree *dt, dup_listent_delete(dt, id); revise_dup_handler(cx, dt->block, dh); continue; - } else if (!(query(_("Okay to delete %s inode %"PRIu64" (0x%"PRIx64")? (y/n) "), + } else if (!(query(cx, _("Okay to delete %s inode %"PRIu64" (0x%"PRIx64")? (y/n) "), (inval ? _("invalidated") : ""), id->block_no, id->block_no))) { log_warn( _("The bad inode was not cleared.")); @@ -409,7 +409,7 @@ static int clone_data(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t metab log_err(_("Error: Inode %"PRIu64" (0x%"PRIx64")'s reference to block %"PRIu64 " (0x%"PRIx64") should be replaced with a clone.\n"), ip->i_num.in_addr, ip->i_num.in_addr, block, block); - if (query( _("Okay to clone the duplicated reference? (y/n) "))) { + if (query(cx, _("Okay to clone the duplicated reference? (y/n) "))) { error = lgfs2_meta_alloc(ip, &cloneblock); if (!error) { clone_bh = lgfs2_bread(ip->i_sbd, clonet->dup_block); @@ -430,7 +430,7 @@ static int clone_data(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t metab } } log_err(_("Error: Unable to allocate a new data block.\n")); - if (!query("Should I zero the reference instead? (y/n)")) { + if (!query(cx, _("Zero the reference instead? (y/n)"))) { log_err(_("Duplicate reference to block %"PRIu64 " (0x%"PRIx64") was not fixed.\n"), block, block); @@ -573,7 +573,7 @@ static void resolve_last_reference(struct fsck_cx *cx, struct duptree *dt, "in inode %"PRIu64" (0x%"PRIx64") but the block is " "not an extended attribute block.\n"), dt->block, dt->block, id->block_no, id->block_no); - if (query(_("Okay to remove the bad extended " + if (query(cx, _("Okay to remove the bad extended " "attribute from inode %"PRIu64" (0x%"PRIx64")? " "(y/n) "), id->block_no, id->block_no)) { diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c index 9d5f2489..a0681ba8 100644 --- a/gfs2/fsck/pass2.c +++ b/gfs2/fsck/pass2.c @@ -197,7 +197,7 @@ static int bad_formal_ino(struct fsck_cx *cx, struct lgfs2_inode *ip, struct gfs entry.in_formal_ino, entry.in_formal_ino, inum.in_formal_ino, inum.in_formal_ino); if (q != GFS2_BLKST_DINODE || !strcmp("..", tmp_name)) { - if (query( _("Remove the corrupt directory entry? (y/n) "))) + if (query(cx, _("Remove the corrupt directory entry? (y/n) "))) return 1; log_err( _("Corrupt directory entry not removed.\n")); return 0; @@ -210,7 +210,7 @@ static int bad_formal_ino(struct fsck_cx *cx, struct lgfs2_inode *ip, struct gfs if (!error && childs_dotdot.in_addr == ip->i_num.in_addr) { log_err( _("The entry points to another directory with intact " "linkage.\n")); - if (query( _("Fix the bad directory entry? (y/n) "))) { + if (query(cx, _("Fix the bad directory entry? (y/n) "))) { log_err( _("Fixing the corrupt directory entry.\n")); entry.in_formal_ino = inum.in_formal_ino; d->dr_inum.in_formal_ino = entry.in_formal_ino; @@ -222,7 +222,7 @@ static int bad_formal_ino(struct fsck_cx *cx, struct lgfs2_inode *ip, struct gfs log_err( _("Directory entry not fixed.\n")); } } else { - if (query( _("Remove the corrupt directory entry? (y/n) "))) { + if (query(cx, _("Remove the corrupt directory entry? (y/n) "))) { lgfs2_inode_put(&child_ip); return 1; } @@ -274,7 +274,7 @@ static int check_leaf_depth(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_t "wrong depth: is %d (length %d), should be %d (length %d).\n"), leaf_no, leaf_no, ip->i_num.in_addr, ip->i_num.in_addr, cur_depth, ref_count, correct_depth, exp_count); - if (!query( _("Fix the leaf block? (y/n)"))) { + if (!query(cx, _("Fix the leaf block? (y/n)"))) { log_err( _("The leaf block was not fixed.\n")); return 0; } @@ -308,8 +308,7 @@ static int wrong_leaf(struct fsck_cx *cx, struct lgfs2_inode *ip, struct lgfs2_i tmp_name, entry->in_addr, entry->in_addr); log_err(_("Leaf index is: 0x%x. The range for this leaf block is " "0x%x - 0x%x\n"), hash_index, *lindex, lindex_max); - if (!query( _("Move the misplaced directory entry to " - "a valid leaf block? (y/n) "))) { + if (!query(cx, _("Move the misplaced directory entry to a valid leaf block? (y/n) "))) { log_err( _("Misplaced directory entry not moved.\n")); return 0; } @@ -439,7 +438,7 @@ static int basic_dentry_checks(struct fsck_cx *cx, struct lgfs2_inode *ip, struc log_err(_("Block # referenced by directory entry %s in inode %"PRIu64 " (0x%"PRIx64") is invalid\n"), tmp_name, ip->i_num.in_addr, ip->i_num.in_addr); - if (query( _("Clear directory entry to out of range block? (y/n) "))) { + if (query(cx, _("Clear directory entry to out of range block? (y/n) "))) { return 1; } else { log_err( _("Directory entry to out of range block remains\n")); @@ -456,7 +455,7 @@ static int basic_dentry_checks(struct fsck_cx *cx, struct lgfs2_inode *ip, struc log_err( _("Dir entry with bad record or name length\n" "\tRecord length = %u\n\tName length = %u\n"), d->dr_rec_len, d->dr_name_len); - if (!query( _("Clear the directory entry? (y/n) "))) { + if (!query(cx, _("Clear the directory entry? (y/n) "))) { log_err( _("Directory entry not fixed.\n")); return 0; } @@ -479,7 +478,7 @@ static int basic_dentry_checks(struct fsck_cx *cx, struct lgfs2_inode *ip, struc log_err( _("\tName length found = %u\n" "\tHash expected = %u (0x%x)\n"), d->dr_name_len, calculated_hash, calculated_hash); - if (!query( _("Fix directory hash for %s? (y/n) "), + if (!query(cx, _("Fix directory hash for %s? (y/n) "), tmp_name)) { log_err( _("Directory entry hash for %s not " "fixed.\n"), tmp_name); @@ -514,7 +513,7 @@ static int basic_dentry_checks(struct fsck_cx *cx, struct lgfs2_inode *ip, struc _("was previously marked invalid") : _("was deleted or is not an inode"));
- if (!query(_("Clear directory entry to non-inode block? (y/n) "))) { + if (!query(cx, _("Clear directory entry to non-inode block? (y/n) "))) { log_err( _("Directory entry to non-inode block remains\n")); return 0; } @@ -554,7 +553,7 @@ static int basic_dentry_checks(struct fsck_cx *cx, struct lgfs2_inode *ip, struc de_type_string(d->dr_type), tmp_name, entry->in_addr, entry->in_addr, block_type_string(*q)); - if (!query( _("Clear stale directory entry? (y/n) "))) { + if (!query(cx, _("Clear stale directory entry? (y/n) "))) { log_err( _("Stale directory entry remains\n")); return 0; } @@ -650,7 +649,7 @@ static int dirref_find(struct fsck_cx *cx, struct lgfs2_inode *ip, struct gfs2_d " (0x%"PRIx64") but the correct value is: %"PRIu64" (0x%"PRIx64")\n"), fn, de->dr_inum.in_formal_ino, de->dr_inum.in_formal_ino, entry->in_formal_ino, entry->in_formal_ino); - if (!query(_("Delete the bad directory entry? (y/n) "))) { + if (!query(cx, _("Delete the bad directory entry? (y/n) "))) { log_err(_("The corrupt directory entry was not fixed.\n")); goto out; } @@ -758,7 +757,7 @@ static int check_dentry(struct fsck_cx *cx, struct lgfs2_inode *ip, struct gfs2_ if (ds->dotdir) { log_err(_("Already found '.' entry in directory %"PRIu64" (0x%"PRIx64")\n"), ip->i_num.in_addr, ip->i_num.in_addr); - if (!query( _("Clear duplicate '.' entry? (y/n) "))) { + if (!query(cx, _("Clear duplicate '.' entry? (y/n) "))) { log_err( _("Duplicate '.' entry remains\n")); /* FIXME: Should we continue on here * and check the rest of the '.' entry? */ @@ -784,7 +783,7 @@ static int check_dentry(struct fsck_cx *cx, struct lgfs2_inode *ip, struct gfs2_ " (0x%"PRIx64").\n"), entry.in_addr, entry.in_addr, entry.in_addr, entry.in_addr, ip->i_num.in_addr, ip->i_num.in_addr); - if (!query( _("Remove '.' reference? (y/n) "))) { + if (!query(cx, _("Remove '.' reference? (y/n) "))) { log_err( _("Invalid '.' reference remains\n")); /* Not setting ds->dotdir here since * this '.' entry is invalid */ @@ -809,7 +808,7 @@ static int check_dentry(struct fsck_cx *cx, struct lgfs2_inode *ip, struct gfs2_ if (ds->dotdotdir) { log_err(_("Already had a '..' entry in directory %"PRIu64" (0x%"PRIx64")\n"), ip->i_num.in_addr, ip->i_num.in_addr); - if (!query( _("Clear duplicate '..' entry? (y/n) "))) { + if (!query(cx, _("Clear duplicate '..' entry? (y/n) "))) { log_err( _("Duplicate '..' entry remains\n")); /* FIXME: Should we continue on here * and check the rest of the '..' @@ -831,7 +830,7 @@ static int check_dentry(struct fsck_cx *cx, struct lgfs2_inode *ip, struct gfs2_ log_err(_("Found '..' entry in directory %"PRIu64" (0x%"PRIx64") " "pointing to something that's not a directory"), ip->i_num.in_addr, ip->i_num.in_addr); - if (!query( _("Clear bad '..' directory entry? (y/n) "))) { + if (!query(cx, _("Clear bad '..' directory entry? (y/n) "))) { log_err( _("Bad '..' directory entry remains\n")); goto dentry_is_valid; } @@ -887,7 +886,7 @@ static int check_dentry(struct fsck_cx *cx, struct lgfs2_inode *ip, struct gfs2_ log_err(_("%s: Hard link to block %"PRIu64" (0x%"PRIx64") detected.\n"), tmp_name, entry.in_addr, entry.in_addr);
- if (query( _("Clear hard link to directory? (y/n) "))) + if (query(cx, _("Clear hard link to directory? (y/n) "))) goto nuke_dentry; else { log_err( _("Hard link to directory remains\n")); @@ -1082,7 +1081,7 @@ static int lost_leaf(struct fsck_cx *cx, struct lgfs2_inode *ip, __be64 *tbl, ui log_err(_("Leaf block %"PRIu64" (0x%"PRIx64") seems to be out of place and its " "contents need to be moved to lost+found.\n"), leafno, leafno); - if (!query( _("Attempt to fix it? (y/n) "))) { + if (!query(cx, _("Attempt to fix it? (y/n) "))) { log_err( _("Directory leaf was not fixed.\n")); return 0; } @@ -1216,7 +1215,7 @@ static int pass2_repair_leaf(struct fsck_cx *cx, struct lgfs2_inode *ip, uint64_
log_err(_("Directory Inode %"PRIu64" (0x%"PRIx64") points to leaf %"PRIu64" (0x%"PRIx64") %s.\n"), ip->i_num.in_addr, ip->i_num.in_addr, *leaf_no, *leaf_no, msg); - if (!query( _("Attempt to patch around it? (y/n) "))) { + if (!query(cx, _("Attempt to patch around it? (y/n) "))) { log_err( _("Bad leaf left in place.\n")); goto out; } @@ -1303,7 +1302,7 @@ static int fix_hashtable(struct fsck_cx *cx, struct lgfs2_inode *ip, __be64 *tbl log_err(_("Dinode %"PRIu64" (0x%"PRIx64") has a hash table error at index " "0x%x, length 0x%x: leaf block %"PRIu64" (0x%"PRIx64")\n"), ip->i_num.in_addr, ip->i_num.in_addr, lindex, len, leafblk, leafblk); - if (!query( _("Fix the hash table? (y/n) "))) { + if (!query(cx, _("Fix the hash table? (y/n) "))) { log_err(_("Hash table not fixed.\n")); return 0; } @@ -1516,7 +1515,7 @@ static int check_hash_tbl_dups(struct fsck_cx *cx, struct lgfs2_inode *ip, __be6 log_err(_("This leaf block has hash index %d, which " "is out of bounds for lindex (%d - %d)\n"), hash_index, l, l + len2); - if (!query( _("Fix the hash table? (y/n) "))) { + if (!query(cx, _("Fix the hash table? (y/n) "))) { log_err(_("Hash table not fixed.\n")); return 0; } @@ -1539,7 +1538,7 @@ static int check_hash_tbl_dups(struct fsck_cx *cx, struct lgfs2_inode *ip, __be6 log_err(_("This leaf block has hash index %d, which " "is out of bounds for lindex (%d - %d).\n"), hash_index, lindex, lindex + len); - if (!query( _("Fix the hash table? (y/n) "))) { + if (!query(cx, _("Fix the hash table? (y/n) "))) { log_err(_("Hash table not fixed.\n")); return 0; } @@ -1633,7 +1632,7 @@ static int check_hash_tbl(struct fsck_cx *cx, struct lgfs2_inode *ip, __be64 *tb log_err(_("Dinode %"PRIu64" (0x%"PRIx64") has bad leaf pointers " "at offset %d for %d\n"), ip->i_num.in_addr, ip->i_num.in_addr, lindex, len); - if (!query( _("Fix the hash table? (y/n) "))) { + if (!query(cx, _("Fix the hash table? (y/n) "))) { log_err(_("Hash table not fixed.\n")); lindex += len; continue; @@ -1715,7 +1714,7 @@ static int check_hash_tbl(struct fsck_cx *cx, struct lgfs2_inode *ip, __be64 *tb "inconsistency at index %d (0x%x) for %d\n"), ip->i_num.in_addr, ip->i_num.in_addr, i, i, len); - if (!query( _("Fix the hash table? (y/n) "))) { + if (!query(cx, _("Fix the hash table? (y/n) "))) { log_err(_("Hash table not fixed.\n")); continue; } @@ -1825,7 +1824,7 @@ static int check_pernode_for(struct fsck_cx *cx, int x, struct lgfs2_inode *pern error = lgfs2_lookupi(pernode, fn, strlen(fn), &ip); if (error) { log_err(_("System file %s is missing.\n"), fn); - if (!query( _("Rebuild the system file? (y/n) "))) + if (!query(cx, _("Rebuild the system file? (y/n) "))) return 0; goto build_it; } @@ -1838,7 +1837,7 @@ static int check_pernode_for(struct fsck_cx *cx, int x, struct lgfs2_inode *pern if (!valid_size) { log_err(_("System file %s has an invalid size. Is %"PRIu64", should be %zu.\n"), fn, ip->i_size, filelen); - if (!query( _("Rebuild the system file? (y/n) "))) + if (!query(cx, _("Rebuild the system file? (y/n) "))) goto out_good; fsck_inode_put(&ip); goto build_it; @@ -1848,7 +1847,7 @@ static int check_pernode_for(struct fsck_cx *cx, int x, struct lgfs2_inode *pern if (!error) goto out_good; log_err(_("System file %s has bad contents.\n"), fn); - if (!query( _("Delete and rebuild the system file? (y/n) "))) + if (!query(cx, _("Delete and rebuild the system file? (y/n) "))) goto out_good; check_metatree(cx, ip, &pass2_fxns_delete); fsck_inode_put(&ip); @@ -1949,7 +1948,7 @@ static int check_system_dir(struct fsck_cx *cx, struct lgfs2_inode *sysinode, co } if (!ds.dotdir) { log_err( _("No '.' entry found for %s directory.\n"), dirname); - if (query( _("Is it okay to add '.' entry? (y/n) "))) { + if (query(cx, _("Is it okay to add '.' entry? (y/n) "))) { struct lgfs2_inum no = sysinode->i_num; log_warn( _("Adding '.' entry\n")); error = lgfs2_dir_add(sysinode, ".", 1, &no, @@ -1969,7 +1968,7 @@ static int check_system_dir(struct fsck_cx *cx, struct lgfs2_inode *sysinode, co log_err(_("%s inode %"PRIu64" (0x%"PRIx64"): Entries is %d - should be %d\n"), dirname, sysinode->i_num.in_addr, sysinode->i_num.in_addr, sysinode->i_entries, ds.entry_count); - if (query( _("Fix entries for %s inode %"PRIu64" (0x%"PRIx64")? (y/n) "), + if (query(cx, _("Fix entries for %s inode %"PRIu64" (0x%"PRIx64")? (y/n) "), dirname, sysinode->i_num.in_addr, sysinode->i_num.in_addr)) { sysinode->i_entries = ds.entry_count; lgfs2_bmodified(sysinode->i_bh); @@ -2039,7 +2038,7 @@ static int pass2_check_dir(struct fsck_cx *cx, struct lgfs2_inode *ip) stack; return FSCK_ERROR; } - if (query(_("Remove directory entry for bad inode %"PRIu64" (0x%"PRIx64") in %"PRIu64" (0x%"PRIx64")? (y/n)"), + if (query(cx, _("Remove directory entry for bad inode %"PRIu64" (0x%"PRIx64") in %"PRIu64" (0x%"PRIx64")? (y/n)"), dirblk, dirblk, di->treewalk_parent, di->treewalk_parent)) { error = remove_dentry_from_dir(cx, di->treewalk_parent, dirblk); if (error < 0) { @@ -2063,7 +2062,7 @@ static int pass2_check_dir(struct fsck_cx *cx, struct lgfs2_inode *ip) log_err(_("No '.' entry found for directory inode at block %"PRIu64" (0x%"PRIx64")\n"), dirblk, dirblk);
- if (query( _("Is it okay to add '.' entry? (y/n) "))) { + if (query(cx, _("Is it okay to add '.' entry? (y/n) "))) { struct lgfs2_inum no = ip->i_num; error = lgfs2_dir_add(ip, ".", 1, &no, (cx->sdp->gfs1 ? GFS_FILE_DIR : DT_DIR)); @@ -2084,7 +2083,7 @@ static int pass2_check_dir(struct fsck_cx *cx, struct lgfs2_inode *ip) if (!fsck_abort && ip->i_entries != ds.entry_count) { log_err(_("Entries is %d - should be %d for inode block %"PRIu64" (0x%"PRIx64")\n"), ip->i_entries, ds.entry_count, ip->i_num.in_addr, ip->i_num.in_addr); - if (query(_("Fix the entry count? (y/n) "))) { + if (query(cx, _("Fix the entry count? (y/n) "))) { ip->i_entries = ds.entry_count; lgfs2_bmodified(ip->i_bh); } else { diff --git a/gfs2/fsck/pass3.c b/gfs2/fsck/pass3.c index 293a66a8..64f309b9 100644 --- a/gfs2/fsck/pass3.c +++ b/gfs2/fsck/pass3.c @@ -122,7 +122,7 @@ static struct dir_info *mark_and_return_parent(struct fsck_cx *cx, struct dir_in
/* FIXME: add a dinode for this entry instead? */
- if (!query(_("Remove directory entry for bad inode %"PRIu64" (0x%"PRIx64") " + if (!query(cx, _("Remove directory entry for bad inode %"PRIu64" (0x%"PRIx64") " "in %"PRIu64" (0x%"PRIx64")? (y/n)"), di->dinode.in_addr, di->dinode.in_addr, di->treewalk_parent, di->treewalk_parent)) { @@ -232,7 +232,7 @@ int pass3(struct fsck_cx *cx) "containing bad block at block %"PRIu64 " (0x%"PRIx64")\n"), di->dinode.in_addr, di->dinode.in_addr); - if (query(_("Clear unlinked directory " + if (query(cx, _("Clear unlinked directory " "with bad blocks? (y/n) "))) { log_warn(_("inode %"PRIu64" (0x%"PRIx64") is " "now marked as free\n"), @@ -249,8 +249,7 @@ int pass3(struct fsck_cx *cx) if (q != GFS2_BLKST_DINODE) { log_err( _("Unlinked block marked as an inode " "is not an inode\n")); - if (!query(_("Clear the unlinked block?" - " (y/n) "))) { + if (!query(cx, _("Clear the unlinked block? (y/n) "))) { log_err( _("The block was not " "cleared\n")); fsck_inode_put(&ip); @@ -273,7 +272,7 @@ int pass3(struct fsck_cx *cx) if (!ip->i_size && !ip->i_eattr){ log_err( _("Unlinked directory has zero " "size.\n")); - if (query( _("Remove zero-size unlinked " + if (query(cx, _("Remove zero-size unlinked " "directory? (y/n) "))) { fsck_bitmap_set(cx, ip, di->dinode.in_addr, _("zero-sized unlinked inode"), @@ -285,7 +284,7 @@ int pass3(struct fsck_cx *cx) "directory remains\n")); } } - if (query( _("Add unlinked directory to " + if (query(cx, _("Add unlinked directory to " "lost+found? (y/n) "))) { if (add_inode_to_lf(cx, ip)) { fsck_inode_put(&ip); diff --git a/gfs2/fsck/pass4.c b/gfs2/fsck/pass4.c index f63f4ff6..021cdf92 100644 --- a/gfs2/fsck/pass4.c +++ b/gfs2/fsck/pass4.c @@ -62,7 +62,7 @@ static int handle_unlinked(struct fsck_cx *cx, uint64_t no_addr, if (q == GFS2_BLKST_FREE) { log_err(_("Unlinked inode %"PRIu64" (0x%"PRIx64") contains bad blocks\n"), no_addr, no_addr); - if (query(_("Delete unlinked inode with bad blocks? (y/n) "))) { + if (query(cx, _("Delete unlinked inode with bad blocks? (y/n) "))) { ip = fsck_load_inode(sdp, no_addr); check_inode_eattr(cx, ip, &pass4_fxns_delete); check_metatree(cx, ip, &pass4_fxns_delete); @@ -78,7 +78,7 @@ static int handle_unlinked(struct fsck_cx *cx, uint64_t no_addr, log_err(_("Unlinked block %"PRIu64" (0x%"PRIx64") marked as inode is not an inode (%d)\n"), no_addr, no_addr, q); ip = fsck_load_inode(sdp, no_addr); - if (query(_("Delete unlinked inode? (y/n) "))) { + if (query(cx, _("Delete unlinked inode? (y/n) "))) { check_inode_eattr(cx, ip, &pass4_fxns_delete); check_metatree(cx, ip, &pass4_fxns_delete); fsck_bitmap_set(cx, ip, no_addr, _("invalid unlinked"), @@ -97,14 +97,14 @@ static int handle_unlinked(struct fsck_cx *cx, uint64_t no_addr, relevent info in them. */ if (!ip->i_size && !ip->i_eattr){ log_err( _("Unlinked inode has zero size\n")); - if (query(_("Clear zero-size unlinked inode? (y/n) "))) { + if (query(cx, _("Clear zero-size unlinked inode? (y/n) "))) { fsck_bitmap_set(cx, ip, no_addr, _("unlinked zero-length"), GFS2_BLKST_FREE); fsck_inode_put(&ip); return 1; } } - if (query( _("Add unlinked inode to lost+found? (y/n)"))) { + if (query(cx, _("Add unlinked inode to lost+found? (y/n)"))) { if (add_inode_to_lf(cx, ip)) { stack; fsck_inode_put(&ip); @@ -125,7 +125,7 @@ static void handle_inconsist(struct fsck_cx *cx, uint64_t no_addr, log_err(_("Link count inconsistent for inode %"PRIu64" (0x%"PRIx64") has %u but fsck found %u.\n"), no_addr, no_addr, *di_nlink, counted_links); /* Read in the inode, adjust the link count, and write it back out */ - if (query(_("Update link count for inode %"PRIu64" (0x%"PRIx64")? (y/n) "), + if (query(cx, _("Update link count for inode %"PRIu64" (0x%"PRIx64")? (y/n) "), no_addr, no_addr)) { struct lgfs2_inode *ip;
diff --git a/gfs2/fsck/pass5.c b/gfs2/fsck/pass5.c index 5de3d57c..6024f4a2 100644 --- a/gfs2/fsck/pass5.c +++ b/gfs2/fsck/pass5.c @@ -67,8 +67,7 @@ static int check_block_status(struct fsck_cx *cx, struct bmap *bl, if (q == GFS2_BLKST_UNLINKED) { log_err(_("Unlinked inode found at block %"PRIu64" (0x%"PRIx64").\n"), block, block); - if (query(_("Do you want to reclaim the block? " - "(y/n) "))) { + if (query(cx, _("Do you want to reclaim the block? (y/n) "))) { lgfs2_rgrp_t rg = lgfs2_blk2rgrpd(sdp, block); if (lgfs2_set_bitmap(rg, block, GFS2_BLKST_FREE)) log_err(_("Unlinked block %"PRIu64" (0x%"PRIx64") bitmap not fixed.\n"), @@ -92,7 +91,7 @@ static int check_block_status(struct fsck_cx *cx, struct bmap *bl, log_err( _("Metadata type is %u (%s)\n"), q, block_type_string(q));
- if (query(_("Fix bitmap for block %"PRIu64" (0x%"PRIx64")? (y/n) "), + if (query(cx, _("Fix bitmap for block %"PRIu64" (0x%"PRIx64")? (y/n) "), block, block)) { lgfs2_rgrp_t rg = lgfs2_blk2rgrpd(sdp, block); if (lgfs2_set_bitmap(rg, block, q)) @@ -177,7 +176,7 @@ static void update_rgrp(struct fsck_cx *cx, struct lgfs2_rgrp_tree *rgp, exit(FSCK_ERROR); } if (update) { - if (query( _("Update resource group counts? (y/n) "))) { + if (query(cx, _("Update resource group counts? (y/n) "))) { log_warn( _("Resource group counts updated\n")); /* write out the rgrp */ if (sdp->gfs1) diff --git a/gfs2/fsck/rgrepair.c b/gfs2/fsck/rgrepair.c index 5f3503c4..7c98bec6 100644 --- a/gfs2/fsck/rgrepair.c +++ b/gfs2/fsck/rgrepair.c @@ -857,7 +857,7 @@ static int rewrite_rg_block(struct fsck_cx *cx, struct lgfs2_rgrp_tree *rg,
log_err(_("Block #%"PRIu64" (0x%"PRIx64") (%d of %"PRIu32") is not %s.\n"), rg->rt_addr + x, rg->rt_addr + x, x+1, rg->rt_length, typedesc); - if (!query( _("Fix the resource group? (y/n)"))) + if (!query(cx, _("Fix the resource group? (y/n)"))) return 1;
log_err(_("Attempting to repair the resource group.\n")); @@ -1005,7 +1005,7 @@ int rindex_repair(struct fsck_cx *cx, int trust_lvl, int *ok) lgfs2_rindex_read(sdp, &sdp->rgrps, ok); if (sdp->md.riinode->i_size % sizeof(struct gfs2_rindex)) { log_warn( _("WARNING: rindex file has an invalid size.\n")); - if (!query( _("Truncate the rindex size? (y/n)"))) { + if (!query(cx, _("Truncate the rindex size? (y/n)"))) { log_err(_("The rindex was not repaired.\n")); lgfs2_rgrp_free(sdp, &rgcalc); lgfs2_rgrp_free(sdp, &sdp->rgtree); @@ -1030,7 +1030,7 @@ int rindex_repair(struct fsck_cx *cx, int trust_lvl, int *ok) number, don't trust it. Complain about the discrepancy, then try again with a little more DISTRUST. */ if ((trust_lvl < DISTRUST) || - !query( _("Attempt to use what rgrps we can? (y/n)"))) { + !query(cx, _("Attempt to use what rgrps we can? (y/n)"))) { lgfs2_rgrp_free(sdp, &rgcalc); lgfs2_rgrp_free(sdp, &sdp->rgtree); log_err(_("The rindex was not repaired.\n")); @@ -1144,7 +1144,7 @@ int rindex_repair(struct fsck_cx *cx, int trust_lvl, int *ok) } /* If we modified the index, write it back to disk. */ if (rindex_modified) { - if (query( _("Fix the index? (y/n)"))) { + if (query(cx, _("Fix the index? (y/n)"))) { lgfs2_rindex_out(expected, (char *)&buf); lgfs2_writei(sdp->md.riinode, (char *)&buf, rg * sizeof(struct gfs2_rindex), diff --git a/gfs2/fsck/util.c b/gfs2/fsck/util.c index 8ff07d0e..47b86077 100644 --- a/gfs2/fsck/util.c +++ b/gfs2/fsck/util.c @@ -160,7 +160,7 @@ char generic_interrupt(const char *caller, const char *where,
/* fsck_query: Same as gfs2_query except it adjusts errors_found and errors_corrected. */ -int fsck_query(const char *format, ...) +int fsck_query(struct fsck_cx *cx, const char *format, ...) { va_list args; char response; @@ -168,11 +168,11 @@ int fsck_query(const char *format, ...)
errors_found++; fsck_abort = 0; - if (opts.yes) { + if (cx->opts->yes) { errors_corrected++; return 1; } - if (opts.no) + if (cx->opts->no) return 0;
while (1) {
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 6983fa9865abc748b6259480ab8d6f686e482559 Author: Andrew Price anprice@redhat.com AuthorDate: Mon Aug 1 11:52:22 2022 +0100
fsck.gfs2: Remove the global opts variable
Signed-off-by: Andrew Price anprice@redhat.com --- gfs2/fsck/fs_recovery.c | 6 +++--- gfs2/fsck/fs_recovery.h | 2 +- gfs2/fsck/fsck.h | 1 - gfs2/fsck/main.c | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/gfs2/fsck/fs_recovery.c b/gfs2/fsck/fs_recovery.c index d778167e..03a2b7ca 100644 --- a/gfs2/fsck/fs_recovery.c +++ b/gfs2/fsck/fs_recovery.c @@ -450,11 +450,11 @@ static int check_journal_seq_no(struct lgfs2_inode *ip, int fix) * mounted by other nodes in the cluster, which is dangerous and therefore, * we should warn the user to run fsck.gfs2 manually when it's safe. */ -int preen_is_safe(struct lgfs2_sbd *sdp, const struct fsck_options * const _opts) +int preen_is_safe(struct lgfs2_sbd *sdp, const struct fsck_options * const opts) { - if (!_opts->preen) + if (!opts->preen) return 1; /* not called by rc.sysinit--we're okay to preen */ - if (_opts->force) + if (opts->force) return 1; /* user's responsibility--we're okay to preen */ if (!memcmp(sdp->sd_lockproto + 5, "nolock", 6)) return 1; /* local file system--preen is okay */ diff --git a/gfs2/fsck/fs_recovery.h b/gfs2/fsck/fs_recovery.h index eda8fce9..9cc6be62 100644 --- a/gfs2/fsck/fs_recovery.h +++ b/gfs2/fsck/fs_recovery.h @@ -4,7 +4,7 @@ #include "libgfs2.h"
extern int replay_journals(struct fsck_cx *cx, int *clean_journals); -extern int preen_is_safe(struct lgfs2_sbd *sdp, const struct fsck_options * const _opts); +extern int preen_is_safe(struct lgfs2_sbd *sdp, const struct fsck_options * const opts);
extern int ji_update(struct lgfs2_sbd *sdp); extern int build_jindex(struct lgfs2_sbd *sdp); diff --git a/gfs2/fsck/fsck.h b/gfs2/fsck/fsck.h index 34faf3ca..fb01a4ab 100644 --- a/gfs2/fsck/fsck.h +++ b/gfs2/fsck/fsck.h @@ -150,7 +150,6 @@ extern void dirtree_delete(struct fsck_cx *cx, struct dir_info *b); * of pass1 and put somewhere else... */ struct dir_info *dirtree_insert(struct fsck_cx *cx, struct lgfs2_inum inum);
-extern struct fsck_options opts; extern struct lgfs2_inode *lf_dip; /* Lost and found directory inode */ extern int lf_was_created; extern uint64_t last_fs_block, last_reported_block; diff --git a/gfs2/fsck/main.c b/gfs2/fsck/main.c index cda02def..42114e53 100644 --- a/gfs2/fsck/main.c +++ b/gfs2/fsck/main.c @@ -25,7 +25,6 @@ #include "metawalk.h" #include "util.h"
-struct fsck_options opts = {0}; struct lgfs2_inode *lf_dip = NULL; /* Lost and found directory inode */ int lf_was_created = 0; uint64_t last_fs_block, last_reported_block = -1; @@ -298,6 +297,7 @@ static void startlog(int argc, char **argv) #ifndef UNITTESTS int main(int argc, char **argv) { + struct fsck_options opts = {0}; struct lgfs2_sbd sb; struct fsck_cx cx = { .sdp = &sb,
cluster-commits@lists.fedorahosted.org