From mboxrd@z Thu Jan 1 00:00:00 1970 From: rpeterso@sourceware.org Date: 12 Jun 2006 20:41:49 -0000 Subject: [Cluster-devel] cluster/gfs2/fsck Makefile eattr.c fs_recovery ... Message-ID: <20060612204149.19581.qmail@sourceware.org> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit CVSROOT: /cvs/cluster Module name: cluster Changes by: rpeterso at sourceware.org 2006-06-12 20:41:43 Modified files: gfs2/fsck : Makefile eattr.c fs_recovery.c fsck.h initialize.c link.c lost_n_found.c main.c metawalk.c pass1.c pass1b.c pass1c.c pass2.c pass3.c pass4.c pass5.c util.c Removed files: gfs2/fsck : bitmap.c bitmap.h block_list.c block_list.h fs_bits.c log.c log.h super.c super.h Log message: Made all block numbers show in decimal and hex. Minor bug fixes. Moved some functions to libgfs2. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/Makefile.diff?cvsroot=cluster&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/eattr.c.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/fs_recovery.c.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/fsck.h.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/initialize.c.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/link.c.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/lost_n_found.c.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/main.c.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/metawalk.c.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/pass1.c.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/pass1b.c.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/pass1c.c.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/pass2.c.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/pass3.c.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/pass4.c.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/pass5.c.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/util.c.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/bitmap.c.diff?cvsroot=cluster&r1=1.2&r2=NONE http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/bitmap.h.diff?cvsroot=cluster&r1=1.1&r2=NONE http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/block_list.c.diff?cvsroot=cluster&r1=1.2&r2=NONE http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/block_list.h.diff?cvsroot=cluster&r1=1.1&r2=NONE http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/fs_bits.c.diff?cvsroot=cluster&r1=1.2&r2=NONE http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/log.c.diff?cvsroot=cluster&r1=1.2&r2=NONE http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/log.h.diff?cvsroot=cluster&r1=1.2&r2=NONE http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/super.c.diff?cvsroot=cluster&r1=1.2&r2=NONE http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/super.h.diff?cvsroot=cluster&r1=1.2&r2=NONE --- cluster/gfs2/fsck/Makefile 2006/06/06 14:49:31 1.3 +++ cluster/gfs2/fsck/Makefile 2006/06/12 20:41:43 1.4 @@ -20,9 +20,8 @@ .PHONY: all clean sources = main.c initialize.c pass1.c pass1b.c pass1c.c pass2.c pass3.c \ - pass4.c pass5.c super.c util.c fs_recovery.c \ - log.c lost_n_found.c link.c eattr.c hash.c inode_hash.c \ - metawalk.c + pass4.c pass5.c util.c fs_recovery.c \ + lost_n_found.c link.c eattr.c hash.c inode_hash.c metawalk.c CFLAGS+=-D_FILE_OFFSET_BITS=64 -DHELPER_PROGRAM -DGFS_RELEASE_NAME=\"${RELEASE}\" -Wall -g --- cluster/gfs2/fsck/eattr.c 2006/06/06 14:49:31 1.2 +++ cluster/gfs2/fsck/eattr.c 2006/06/12 20:41:43 1.3 @@ -15,7 +15,7 @@ #include #include "libgfs2.h" -#include "log.h" +#include "fsck.h" static int clear_blk_nodup(struct gfs2_sbd *sbp, uint64_t block) { --- cluster/gfs2/fsck/fs_recovery.c 2006/06/06 14:49:31 1.2 +++ cluster/gfs2/fsck/fs_recovery.c 2006/06/12 20:41:43 1.3 @@ -21,7 +21,6 @@ #include "libgfs2.h" #include "util.h" #include "fs_recovery.h" -#include "log.h" #define RANDOM(values) ((values) * (random() / (RAND_MAX + 1.0))) @@ -64,7 +63,8 @@ block_map(ip, x, &new, &dblock, &extlen); bh = bread(sdp, dblock); if (!bh) { - log_err("Unable to read journal block at %"PRIu64"\n", dblock); + log_err("Unable to read journal block at %" PRIu64 + " (0x%" PRIx64")\n", dblock, dblock); return -1; } --- cluster/gfs2/fsck/fsck.h 2006/06/06 14:49:31 1.2 +++ cluster/gfs2/fsck/fsck.h 2006/06/12 20:41:43 1.3 @@ -19,12 +19,6 @@ #define FSCK_HASH_SIZE (1 << FSCK_HASH_SHIFT) #define FSCK_HASH_MASK (FSCK_HASH_SIZE - 1) -struct options { - char *device; - int yes:1; - int no:1; -}; - struct inode_info { osi_list_t list; @@ -59,7 +53,7 @@ * of pass1 and put somewhere else... */ int add_to_dir_list(struct gfs2_sbd *sbp, uint64_t block); -extern struct options opts; +extern struct gfs2_options opts; extern struct gfs2_inode *lf_dip; /* Lost and found directory inode */ extern osi_list_t dir_hash[FSCK_HASH_SIZE]; extern osi_list_t inode_hash[FSCK_HASH_SIZE]; --- cluster/gfs2/fsck/initialize.c 2006/06/06 14:49:31 1.2 +++ cluster/gfs2/fsck/initialize.c 2006/06/12 20:41:43 1.3 @@ -25,9 +25,7 @@ #include "libgfs2.h" #include "fsck.h" #include "util.h" -#include "super.h" #include "fs_recovery.h" -#include "log.h" #include "linux_endian.h" #define CLEAR_POINTER(x) \ @@ -36,8 +34,6 @@ x = NULL; \ } -extern struct options opts; - /** * init_journals * @@ -167,15 +163,16 @@ if(do_lseek(sdp->device_fd, (last_fs_block * sdp->sd_sb.sb_bsize))){ log_crit("Can't seek to last block in file system: %" - PRIu64"\n", last_fs_block); + PRIu64" (0x%" PRIx64 ")\n", last_fs_block, last_fs_block); goto fail; } memset(buf, 0, sdp->sd_sb.sb_bsize); error = read(sdp->device_fd, buf, sdp->sd_sb.sb_bsize); if (error != sdp->sd_sb.sb_bsize){ - log_crit("Can't read last block in file system (%u), " - "last_fs_block: %"PRIu64"\n", error, last_fs_block); + log_crit("Can't read last block in file system (error %u), " + "last_fs_block: %"PRIu64" (0x%" PRIx64 ")\n", error, + last_fs_block, last_fs_block); goto fail; } @@ -198,6 +195,7 @@ char *buf; uint64_t inumbuf; struct gfs2_statfs_change sc; + int rgcount; sync(); @@ -278,7 +276,7 @@ return -1; } - if(ri_update(sdp)){ + if(ri_update(sdp, &rgcount)){ log_err("Unable to fill in resource group information.\n"); goto fail; } --- cluster/gfs2/fsck/link.c 2006/06/06 14:49:31 1.2 +++ cluster/gfs2/fsck/link.c 2006/06/12 20:41:43 1.3 @@ -21,12 +21,11 @@ #include "fsck.h" #include "inode_hash.h" #include "link.h" -#include "log.h" int set_link_count(struct gfs2_sbd *sbp, uint64_t inode_no, uint32_t count) { struct inode_info *ii = NULL; - log_debug("Setting link count to %u for %" PRIu64 " (0x%" PRIx64")\n", + 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 */ @@ -34,7 +33,7 @@ if(ii) { if(ii->link_count) { log_err("Link count already set for inode #%" PRIu64 " (0x%" - PRIx64")!\n", inode_no, inode_no); + PRIx64 ")!\n", inode_no, inode_no); stack; return -1; } @@ -67,11 +66,11 @@ if(ii) { ii->counted_links++; log_debug("Incremented counted links to %u for %"PRIu64" (0x%" - PRIx64")\n", ii->counted_links, inode_no, inode_no); + PRIx64 ")\n", ii->counted_links, inode_no, inode_no); return 0; } log_debug("No match found when incrementing link for %" PRIu64 - " (0x%" PRIx64")!\n", inode_no, inode_no); + " (0x%" PRIx64 ")!\n", inode_no, inode_no); /* If no match was found, add a new entry and set its * counted links to 1 */ if(!(ii = (struct inode_info *) malloc(sizeof(*ii)))) { @@ -104,7 +103,7 @@ return 0; } log_debug("No match found when decrementing link for %" PRIu64 - " (0x%" PRIx64")!\n", inode_no, inode_no); + " (0x%" PRIx64 ")!\n", inode_no, inode_no); return -1; } --- cluster/gfs2/fsck/lost_n_found.c 2006/06/06 14:49:31 1.2 +++ cluster/gfs2/fsck/lost_n_found.c 2006/06/12 20:41:43 1.3 @@ -20,10 +20,10 @@ #include #include +#include "fsck.h" #include "libgfs2.h" #include "lost_n_found.h" #include "link.h" -#include "log.h" /* add_inode_to_lf - Add dir entry to lost+found for the inode * @ip: inode to add to lost + found @@ -45,13 +45,13 @@ log_info("Locating/Creating lost and found directory\n"); - lf_dip = createi(ip->i_sbd->md.rooti, "l+f", S_IFDIR | 0700, 0); + lf_dip = createi(ip->i_sbd->md.rooti, "lost+found", S_IFDIR | 0700, 0); if(gfs2_block_check(bl, lf_dip->i_di.di_num.no_addr, &q)) { stack; return -1; } if(q.block_type != gfs2_inode_dir) { - /* This is a new l+f directory, so set its + /* This is a new lost+found directory, so set its * block type and increment link counts for * the directories */ /* FIXME: i'd feel better about this if @@ -67,21 +67,21 @@ } } if(ip->i_di.di_num.no_addr == lf_dip->i_di.di_num.no_addr) { - log_err("Trying to add l+f to itself...skipping"); + log_err("Trying to add lost+found to itself...skipping"); return 0; } switch(ip->i_di.di_mode & S_IFMT){ case S_IFDIR: - log_info("Adding .. entry pointing to l+f for %"PRIu64"\n", + log_info("Adding .. entry pointing to lost+found for %"PRIu64"\n", ip->i_di.di_num.no_addr); sprintf(tmp_name, ".."); filename_len = strlen(tmp_name); /* no trailing NULL */ - if(!(filename = malloc(sizeof(char) * filename_len))) { + if(!(filename = malloc((sizeof(char) * filename_len) + 1))) { log_err("Unable to allocate name\n"); stack; return -1; } - if(!memset(filename, 0, sizeof(char) * filename_len)) { + if(!memset(filename, 0, (sizeof(char) * filename_len) + 1)) { log_err("Unable to zero name\n"); stack; return -1; @@ -90,7 +90,7 @@ if(gfs2_dirent_del(ip, NULL, filename, filename_len)) log_warn("add_inode_to_lf: " - "Unable to remove \"..\" directory entry.\n"); + "Unable to remove \"..\" directory entry.\n"); dir_add(ip, filename, filename_len, &(lf_dip->i_di.di_num), DT_DIR); free(filename); @@ -145,6 +145,7 @@ increment_link(ip->i_sbd, lf_dip->i_di.di_num.no_addr); free(filename); - log_notice("Added inode #%"PRIu64" to l+f dir\n", ip->i_di.di_num.no_addr); + log_notice("Added inode #%"PRIu64" to lost+found dir\n", + ip->i_di.di_num.no_addr); return 0; } --- cluster/gfs2/fsck/main.c 2006/06/06 14:49:31 1.2 +++ cluster/gfs2/fsck/main.c 2006/06/12 20:41:43 1.3 @@ -21,10 +21,9 @@ #include "copyright.cf" #include "libgfs2.h" #include "fsck.h" -#include "log.h" #include "osi_list.h" -struct options opts = {0}; +struct gfs2_options opts = {0}; struct gfs2_inode *lf_dip; /* Lost and found directory inode */ osi_list_t dir_hash[FSCK_HASH_SIZE]; osi_list_t inode_hash[FSCK_HASH_SIZE]; @@ -81,7 +80,7 @@ printf("%s\n", REDHAT_COPYRIGHT); } -int read_cmdline(int argc, char **argv, struct options *opts) +int read_cmdline(int argc, char **argv, struct gfs2_options *opts) { char c; --- cluster/gfs2/fsck/metawalk.c 2006/06/06 14:49:31 1.2 +++ cluster/gfs2/fsck/metawalk.c 2006/06/12 20:41:43 1.3 @@ -21,7 +21,6 @@ #include "libgfs2.h" #include "fsck.h" #include "util.h" -#include "log.h" #include "metawalk.h" #include "hash.h" @@ -45,7 +44,8 @@ else if (type == DIR_EXHASH) { dent = (struct gfs2_dirent *)(bh->b_data + sizeof(struct gfs2_leaf)); leaf = (struct gfs2_leaf *)bh->b_data; - log_debug("Checking leaf %"PRIu64"\n", bh->b_blocknr); + log_debug("Checking leaf %" PRIu64 " (0x%" PRIx64 ")\n", + bh->b_blocknr, bh->b_blocknr); } else { log_err("Invalid directory type %d specified\n", type); @@ -68,13 +68,14 @@ } else { /* FIXME: Do something about this */ log_err("Directory entry with inode number of zero in leaf %" - PRIu64" of directory %"PRIu64"!\n", bh->b_blocknr, - ip->i_di.di_num.no_addr); + PRIu64 "(0x%" PRIx64 ") of directory %" PRIu64 + " (0x%" PRIx64 ")!\n", bh->b_blocknr, bh->b_blocknr, + ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr); return 1; } } else { error = pass->check_dentry(ip, dent, prev, bh, filename, update, - count, pass->private); + count, pass->private); if(error < 0) { stack; return -1; @@ -123,10 +124,11 @@ continue; } else { if(ref_count != exp_count){ - log_err("Dir #%"PRIu64" has an incorrect number " - "of pointers to leaf #%"PRIu64"\n" - "\tFound: %u, Expected: %u\n", - ip->i_di.di_num.no_addr, old_leaf, ref_count, exp_count); + log_err("Dir #%" PRIu64 " (0x%" PRIx64 ") has an incorrect " + "number of pointers to leaf #%" PRIu64 " (0x%" PRIx64 + ")\n\tFound: %u, Expected: %u\n", + ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr, + old_leaf, old_leaf, ref_count, exp_count); return 1; } ref_count = 1; @@ -283,7 +285,8 @@ { struct gfs2_buffer_head *bh = NULL; int error = 0; - log_debug("Checking EA leaf block #%"PRIu64".\n", block); + log_debug("Checking EA leaf block #%"PRIu64" (0x%" PRIx64 ").\n", + block, block); if(pass->check_eattr_leaf) { error = pass->check_eattr_leaf(ip, block, parent, &bh, pass->private); @@ -315,7 +318,8 @@ struct gfs2_buffer_head *indirect_buf = NULL; struct gfs2_sbd *sdp = ip->i_sbd; - log_debug("Checking EA indirect block #%"PRIu64".\n", indirect); + log_debug("Checking EA indirect block #%"PRIu64" (0x%" PRIx64 ").\n", + indirect, indirect); if (!pass->check_eattr_indir || !pass->check_eattr_indir(ip, indirect, ip->i_di.di_num.no_addr, @@ -352,8 +356,9 @@ return 0; } - log_debug("Extended attributes exist for inode #%"PRIu64".\n", - ip->i_di.di_num.no_formal_ino); + log_debug("Extended attributes exist for inode #%" PRIu64 " (0x%" PRIx64 + ").\n", ip->i_di.di_num.no_formal_ino, + ip->i_di.di_num.no_formal_ino); if(ip->i_di.di_flags & GFS2_DIF_EA_INDIRECT){ if((error = check_indirect_eattr(ip, ip->i_di.di_eattr, pass))) @@ -416,7 +421,8 @@ goto fail; } if(err > 0) { - log_debug("Skipping block %" PRIu64 "\n", block); + log_debug("Skipping block %" PRIu64 " (0x%" PRIx64 ")\n", + block, block); continue; } subblock = be64_to_cpu(*subptr); @@ -563,8 +569,8 @@ struct gfs2_block_query q; int error; - log_debug("Removing dentry %"PRIu64" from directory %"PRIu64"\n", - dentryblock, dir); + log_debug("Removing dentry %" PRIu64 " (0x%" PRIx64 ") from directory %" + PRIu64" (0x%" PRIx64 ")\n", dentryblock, dentryblock, dir, dir); if(gfs2_check_range(sbp, dir)) { log_err("Parent directory out of range\n"); return 1; --- cluster/gfs2/fsck/pass1.c 2006/06/06 14:49:31 1.2 +++ cluster/gfs2/fsck/pass1.c 2006/06/12 20:41:43 1.3 @@ -33,7 +33,6 @@ #include "libgfs2.h" #include "fsck.h" #include "util.h" -#include "log.h" #include "link.h" #include "linux_endian.h" #include "metawalk.h" @@ -55,8 +54,8 @@ f = not_updated; if(gfs2_check_range(sdp, block)){ - log_warn("Leaf block #%"PRIu64" (0x%" PRIx64 ") is out of range for " - "directory #%"PRIu64" (0x%" PRIx64 ").\n", + log_warn("Leaf block #%" PRIu64 " (0x%" PRIx64 ") is out of range for " + "directory #%" PRIu64 " (0x%" PRIx64 ").\n", block, block, ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr); gfs2_block_set(bl, ip->i_di.di_num.no_addr, gfs2_bad_block); @@ -68,7 +67,7 @@ if(gfs2_check_meta(*bh, GFS2_METATYPE_LF)){ log_err("Bad meta header for leaf block #%" PRIu64 "(0x%" PRIx64 - ") in directory #%"PRIu64". - is %u, should be %u\n", + ") in directory #%" PRIu64 ". - is %u, should be %u\n", (*bh)->b_data, (*bh)->b_data, ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr, (struct gfs2_meta_header *)mh->mh_type, @@ -80,12 +79,12 @@ log_err("Directory inode marked invalid\n"); f = updated; } else - log_err("Invalid block %"PRIu64" (0x%" PRIx64 ") ignored\n", + log_err("Invalid block %" PRIu64 " (0x%" PRIx64 ") ignored\n", ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr); brelse(*bh, f); return 1; } - log_debug("\tLeaf block at %15"PRIu64" (0x%" PRIx64 ")\n", + log_debug("\tLeaf block at %15" PRIu64 " (0x%" PRIx64 ")\n", block, block); gfs2_block_set(bl, block, gfs2_leaf_blk); bc->indir_count++; @@ -160,13 +159,13 @@ return -1; } if(q.block_type != gfs2_block_free) { - log_debug("Found duplicate block at %" PRIu64 " (0x%"PRIx64")\n", + log_debug("Found duplicate block at %" PRIu64 " (0x%"PRIx64 ")\n", block, block); gfs2_block_mark(bl, block, gfs2_dup_block); bc->data_count++; return 1; } - log_debug("Setting %"PRIu64 " (0x%" PRIx64 ") to data block\n", block, + log_debug("Setting %" PRIu64 " (0x%" PRIx64 ") to data block\n", block, block); gfs2_block_set(bl, block, gfs2_block_used); bc->data_count++; @@ -185,7 +184,7 @@ /* This inode contains an eattr - it may be invalid, but the * eattr attributes points to a non-zero block */ - log_debug("Setting %"PRIu64 " (0x%" PRIx64 ") to eattr block\n", block, + log_debug("Setting %" PRIu64 " (0x%" PRIx64 ") to eattr block\n", block, block); gfs2_block_set(bl, ip->i_di.di_num.no_addr, gfs2_eattr_block); @@ -202,7 +201,7 @@ ret = -1; } else if(q.block_type != gfs2_block_free) { - log_debug("Duplicate block found at #%"PRIu64" (0x%" PRIx64 ").\n", + log_debug("Duplicate block found at #%" PRIu64 " (0x%" PRIx64 ").\n", indirect, indirect); gfs2_block_set(bl, indirect, gfs2_dup_block); bc->ea_count++; @@ -219,8 +218,8 @@ } else { /* FIXME: do i need to differentiate this as an ea_indir? */ - log_debug("Setting %"PRIu64 " (0x%" PRIx64 ") to indirect block\n", - block, block); + log_debug("Setting %" PRIu64 " (0x%" PRIx64 + ") to indirect block\n", block, block); gfs2_block_set(bl, block, gfs2_indir_blk); bc->ea_count++; } @@ -253,7 +252,7 @@ struct block_count *bc = (struct block_count *) private; if(gfs2_check_range(sdp, el_blk)){ - log_err("EA extended leaf block #%"PRIu64" (0x%" PRIx64 + log_err("EA extended leaf block #%" PRIu64 " (0x%" PRIx64 ") is out of range.\n", el_blk, el_blk); gfs2_block_set(bl, ip->i_di.di_eattr, gfs2_bad_block); return 1; @@ -272,14 +271,14 @@ el_buf = bread(sdp, el_blk); if(gfs2_check_meta(el_buf, GFS2_METATYPE_ED)) { - log_err("EA extended leaf block %" PRIu64 "(0x%" PRIx64 + log_err("EA extended leaf block %" PRIu64 " (0x%" PRIx64 ") has incorrect type.\n", el_blk, el_blk); brelse(el_buf, not_updated); gfs2_block_set(bl, el_blk, gfs2_meta_inval); return 1; } - log_debug("Setting %"PRIu64 " (0x%" PRIx64 ") to eattr block\n", + log_debug("Setting %" PRIu64 " (0x%" PRIx64 ") to eattr block\n", el_blk, el_blk); gfs2_block_set(bl, el_blk, gfs2_meta_eattr); bc->ea_count++; @@ -298,12 +297,12 @@ /* This inode contains an eattr - it may be invalid, but the * eattr attributes points to a non-zero block */ - log_debug("Setting %"PRIu64 " (0x%" PRIx64 ") to eattr block\n", + log_debug("Setting %" PRIu64 " (0x%" PRIx64 ") to eattr block\n", ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr); gfs2_block_set(bl, ip->i_di.di_num.no_addr, gfs2_eattr_block); if(gfs2_check_range(sdp, block)){ - log_warn("EA leaf block #%"PRIu64" (0x%" PRIx64 ") in inode %"PRIu64 + log_warn("EA leaf block #%" PRIu64 " (0x%" PRIx64 ") in inode %" PRIu64 " (0x%" PRIx64 ") is out of range.\n", ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr, block, block); @@ -315,7 +314,7 @@ return -1; } else if(q.block_type != gfs2_block_free) { - log_debug("Duplicate block found at #%"PRIu64" (0x%" PRIx64 ").\n", + log_debug("Duplicate block found at #%" PRIu64 " (0x%" PRIx64 ").\n", block, block); gfs2_block_set(bl, block, gfs2_dup_block); bc->ea_count++; @@ -329,7 +328,7 @@ ret = 1; } else { - log_debug("Setting %"PRIu64 " (0x%" PRIx64 ") to eattr block\n", + log_debug("Setting %" PRIu64 " (0x%" PRIx64 ") to eattr block\n", (uint64_t)*leaf_bh->b_data, (uint64_t)*leaf_bh->b_data); gfs2_block_set(bl, (uint64_t)*leaf_bh->b_data, gfs2_meta_eattr); bc->ea_count++; @@ -432,7 +431,7 @@ struct gfs2_buffer_head **bh, void *private) { struct gfs2_block_query q = {0}; - log_crit("Clearing leaf %"PRIu64" (0x%" PRIx64 ")\n", block, block); + log_crit("Clearing leaf %" PRIu64 " (0x%" PRIx64 ")\n", block, block); if(gfs2_block_check(bl, block, &q)) { stack; @@ -462,7 +461,7 @@ * matter too much */ find_di(sbp, block, &di); if(di) { - log_err("Attempting to add directory block %"PRIu64 + log_err("Attempting to add directory block %" PRIu64 " (0x%" PRIx64 ") which is already in list\n", block, block); return -1; } @@ -472,7 +471,7 @@ return -1; } if(!memset(newdi, 0, sizeof(*newdi))) { - log_crit("error while zeroing dir_info structure\n"); + log_crit("Error while zeroing dir_info structure\n"); return -1; } @@ -498,17 +497,17 @@ ip = inode_get(sdp, bh); if (ip->i_di.di_num.no_addr != block) { - log_err("inode #%" PRIu64 " (0x%" PRIx64 + log_err("Inode #%" PRIu64 " (0x%" PRIx64 "): Bad inode address found: %" PRIu64 " (0x%" PRIx64 ")\n", block, block, ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr); if(query(&opts, "Fix address in inode at block %" - PRIu64" (0x%" PRIx64 ")? (y/n) ", block, block)) { + PRIu64 " (0x%" PRIx64 ")? (y/n) ", block, block)) { ip->i_di.di_num.no_addr = ip->i_di.di_num.no_formal_ino = block; gfs2_dinode_out(&ip->i_di, ip->i_bh->b_data); f = updated; } else - log_err("Address in inode at block %"PRIu64 + log_err("Address in inode at block %" PRIu64 " (0x%" PRIx64 ") not fixed\n", block, block); } @@ -619,7 +618,7 @@ /* FIXME: fix height and depth here - wasn't implemented in * old fsck either, so no biggy... */ if (ip->i_di.di_height < compute_height(sdp, ip->i_di.di_size)){ - log_warn("Dinode #%"PRIu64" (0x%" PRIx64 ") has bad height " + log_warn("Dinode #%" PRIu64 " (0x%" PRIx64 ") has bad height " "Found %u, Expected >= %u\n", ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr, ip->i_di.di_height, compute_height(sdp, ip->i_di.di_size)); @@ -678,7 +677,7 @@ if (ip->i_di.di_blocks != (1 + bc.indir_count + bc.data_count + bc.ea_count)) { - log_err("inode %" PRIu64 " (0x%" PRIx64 "): Ondisk block count (%" + log_err("Inode %" PRIu64 " (0x%" PRIx64 "): Ondisk block count (%" PRIu64 ") does not match what fsck found (%" PRIu64 ")\n", ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr, ip->i_di.di_blocks, @@ -702,7 +701,7 @@ uint64_t block) { if (gfs2_check_meta(bh, 0)) { - log_debug("Found invalid metadata at %"PRIu64" (0x%" PRIx64 ")\n", + log_debug("Found invalid metadata at %" PRIu64 " (0x%" PRIx64 ")\n", block, block); if(gfs2_block_set(bl, block, gfs2_meta_inval)) { stack; @@ -775,13 +774,14 @@ for (tmp = sbp->rglist.next; tmp != &sbp->rglist; tmp = tmp->next, rg_count++){ - log_info("Checking metadata in Resource Group %"PRIu64"\n", rg_count); + log_info("Checking metadata in Resource Group #%" PRIu64 "\n", + rg_count); rgd = osi_list_entry(tmp, struct rgrp_list, list); if(gfs2_rgrp_read(sbp, rgd)){ stack; return -1; } - log_debug("RG at %"PRIu64" (0x%" PRIx64 ") is %u long\n", + log_debug("RG at %" PRIu64 " (0x%" PRIx64 ") is %u long\n", rgd->ri.ri_addr, rgd->ri.ri_addr, rgd->ri.ri_length); for (i = 0; i < rgd->ri.ri_length; i++) { if(gfs2_block_set(bl, rgd->ri.ri_addr + i, gfs2_meta_other)){ --- cluster/gfs2/fsck/pass1b.c 2006/06/06 14:49:31 1.2 +++ cluster/gfs2/fsck/pass1b.c 2006/06/12 20:41:43 1.3 @@ -21,7 +21,6 @@ #include "fsck.h" #include "osi_list.h" #include "util.h" -#include "log.h" #include "metawalk.h" #include "inode_hash.h" @@ -146,10 +145,11 @@ if(id->block_no == de->de_inum.no_addr) { id->name = strdup(filename); id->parent = ip->i_di.di_num.no_addr; - log_debug("Duplicate block %"PRIu64 - " is in file or directory %"PRIu64 - " named %s\n", id->block_no, - ip->i_di.di_num.no_addr, filename); + log_debug("Duplicate block %" PRIu64 " (0x%" PRIx64 + ") is in file or directory %" PRIu64 + " (0x%" PRIx64 ") named %s\n", id->block_no, + id->block_no, ip->i_di.di_num.no_addr, + ip->i_di.di_num.no_addr, filename); /* If there are duplicates of * duplicates, I guess we'll miss them * here */ @@ -169,12 +169,12 @@ return 1; if(block == dh->b->block_no) { log_err("Found dup in inode \"%s\" (block #%"PRIu64 - ") with block #%"PRIu64"\n", - dh->id->name ? dh->id->name : "unknown name", - ip->i_di.di_num.no_addr, block); - log_err("inode %s is in directory %"PRIu64"\n", - dh->id->name ? dh->id->name : "", - dh->id->parent); + ") with block #%"PRIu64"\n", + dh->id->name ? dh->id->name : "unknown name", + ip->i_di.di_num.no_addr, block); + log_err("Inode %s is in directory %"PRIu64" (0x%" PRIx64 ")\n", + dh->id->name ? dh->id->name : "", + dh->id->parent, dh->id->parent); inode_hash_remove(inode_hash, ip->i_di.di_num.no_addr); /* Setting the block to invalid means the inode is * cleared in pass2 */ @@ -191,12 +191,14 @@ return 1; } if(block == dh->b->block_no) { - log_err("Found dup in inode \"%s\" (block #%"PRIu64 - ") with block #%"PRIu64"\n", + log_err("Found dup in inode \"%s\" for block #%" PRIu64 + " (0x%" PRIx64 ") at block #%" PRIu64 " (0x%" PRIx64 ")\n", dh->id->name ? dh->id->name : "unknown name", - ip->i_di.di_num.no_addr, block); - log_err("inode %s is in directory %"PRIu64"\n", - dh->id->name ? dh->id->name : "", dh->id->parent); + ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr, block, + block); + log_err("Inode %s is in directory %"PRIu64" (0x%" PRIx64 ")\n", + dh->id->name ? dh->id->name : "", dh->id->parent, + dh->id->parent); inode_hash_remove(inode_hash, ip->i_di.di_num.no_addr); /* Setting the block to invalid means the inode is * cleared in pass2 */ @@ -215,18 +217,20 @@ if(dh->ref_count == 1) return 1; if(block == dh->b->block_no) { - log_err("Found dup in inode \"%s\" (block #%"PRIu64 - ") with block #%"PRIu64"\n", - dh->id->name ? dh->id->name : "unknown name", - ip->i_di.di_num.no_addr, block); - log_err("inode %s is in directory %"PRIu64"\n", - dh->id->name ? dh->id->name : "", - dh->id->parent); + log_err("Found dup in inode \"%s\" with address #%" PRIu64 + " (0x%" PRIx64 ") with block #%" PRIu64 " (0x%" PRIx64 ")\n", + dh->id->name ? dh->id->name : "unknown name", + ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr, block, + block); + log_err("Inode %s is in directory %" PRIu64 " (0x%" PRIx64 ")\n", + dh->id->name ? dh->id->name : "", + dh->id->parent, dh->id->parent); gfs2_block_set(bl, ip->i_di.di_eattr, gfs2_meta_inval); } return 0; } + static int clear_dup_eattr_leaf(struct gfs2_inode *ip, uint64_t block, uint64_t parent, struct gfs2_buffer_head **bh, void *private) { @@ -234,13 +238,14 @@ if(dh->ref_count == 1) return 1; if(block == dh->b->block_no) { - log_err("Found dup in inode \"%s\" (block #%"PRIu64 - ") with block #%"PRIu64"\n", + log_err("Found dup in inode \"%s\" with address #%" PRIu64 + " (0x%" PRIx64 ") with block #%" PRIu64 " (0x%" PRIx64 ")\n", dh->id->name ? dh->id->name : "unknown name", - ip->i_di.di_num.no_addr, block); - log_err("inode %s is in directory %"PRIu64"\n", - dh->id->name ? dh->id->name : "", dh->id->parent); - + ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr, block, + block); + log_err("Inode %s is in directory %" PRIu64 " (0x%" PRIx64 ")\n", + dh->id->name ? dh->id->name : "", + dh->id->parent, dh->id->parent); /* mark the main eattr block invalid */ gfs2_block_set(bl, ip->i_di.di_eattr, gfs2_meta_inval); } @@ -299,13 +304,14 @@ if(dh->ref_count == 1) return 1; if(block == dh->b->block_no) { - log_err("Found dup in inode \"%s\" (block #%"PRIu64 - ") with block #%"PRIu64"\n", - dh->id->name ? dh->id->name : "unknown name", - ip->i_di.di_num.no_addr, block); - log_err("inode %s is in directory %"PRIu64"\n", - dh->id->name ? dh->id->name : "", - dh->id->parent); + log_err("Found dup in inode \"%s\" with address #%" PRIu64 + " (0x%" PRIx64 ") with block #%" PRIu64 " (0x%" PRIx64 ")\n", + dh->id->name ? dh->id->name : "unknown name", + ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr, block, + block); + log_err("Inode %s is in directory %" PRIu64 " (0x%" PRIx64 ")\n", + dh->id->name ? dh->id->name : "", + dh->id->parent, dh->id->parent); /* mark the main eattr block invalid */ gfs2_block_set(bl, ip->i_di.di_eattr, gfs2_meta_inval); } @@ -333,8 +339,9 @@ }; ip = gfs2_load_inode(sbp, inode); /* bread, inode_get */ - log_info("Checking inode %"PRIu64"'s metatree for references to block %"PRIu64"\n", - inode, b->block_no); + log_info("Checking inode %" PRIu64 " (0x%" PRIx64 + ")'s metatree for references to block %" PRIu64 " (0x%" PRIx64 + ")\n", inode, inode, b->block_no, b->block_no); if(check_metatree(ip, &find_refs)) { stack; inode_put(ip, not_updated); /* out, brelse, free */ @@ -351,9 +358,9 @@ log_crit("Unable to zero inode_with_dups structure\n"); return -1; } - log_debug("Found %d entries with block %"PRIu64 - " in inode #%"PRIu64"\n", - myfi.found, b->block_no, inode); + log_debug("Found %d entries with block %" PRIu64 + " (0x%" PRIx64 ") in inode #%" PRIu64 " (0x%" PRIx64 ")\n", + myfi.found, b->block_no, b->block_no, inode, inode); id->dup_count = myfi.found; id->block_no = inode; id->ea_only = myfi.ea_only; @@ -380,7 +387,8 @@ } b->block_no = block_no; osi_list_init(&b->ref_inode_list); - log_notice("Found dup block at %"PRIu64"\n", block_no); + log_notice("Found dup block at %"PRIu64" (0x%" PRIx64 ")\n", block_no, + block_no); osi_list_add(&b->list, &dup_list); block_no++; } @@ -412,14 +420,16 @@ dh.ref_inode_count++; dh.ref_count += id->dup_count; } - log_notice("Block %"PRIu64" has %d inodes referencing it for" - "a total of %d duplicate references\n", - b->block_no, dh.ref_inode_count, dh.ref_count); + log_notice("Block %" PRIu64 " (0x%" PRIx64 ") has %d inodes referencing it" + " for a total of %d duplicate references\n", + b->block_no, b->block_no, dh.ref_inode_count, + dh.ref_inode_count, dh.ref_count); osi_list_foreach(tmp, &b->ref_inode_list) { id = osi_list_entry(tmp, struct inode_with_dups, list); log_warn("Inode %s has %d reference(s) to block %"PRIu64 - "\n", id->name, id->dup_count, b->block_no); + " (0x%" PRIx64 ")\n", id->name, id->dup_count, b->block_no, + b->block_no); /* FIXME: User input */ log_warn("Clearing...\n"); ip = gfs2_load_inode(sbp, id->block_no); @@ -471,9 +481,11 @@ /* Rescan the fs looking for pointers to blocks that are in * the duplicate block map */ log_info("Scanning filesystem for inodes containing duplicate blocks...\n"); - log_debug("Filesystem has %"PRIu64" blocks total\n", last_fs_block); + log_debug("Filesystem has %"PRIu64" (0x%" PRIx64 ") blocks total\n", + last_fs_block, last_fs_block); for(i = 0; i < last_fs_block; i += 1) { - log_debug("Scanning block %"PRIu64" for inodes\n", i); + log_debug("Scanning block %" PRIu64 " (0x%" PRIx64 ") for inodes\n", + i, i); if(gfs2_block_check(bl, i, &q)) { stack; return -1; --- cluster/gfs2/fsck/pass1c.c 2006/06/06 14:49:31 1.2 +++ cluster/gfs2/fsck/pass1c.c 2006/06/12 20:41:43 1.3 @@ -19,7 +19,6 @@ #include "libgfs2.h" #include "fsck.h" #include "util.h" -#include "log.h" #include "metawalk.h" static int remove_eattr_entry(struct gfs2_sbd *sdp, @@ -27,7 +26,8 @@ struct gfs2_ea_header *curr, struct gfs2_ea_header *prev) { - log_warn("Removing EA located in block #%"PRIu64".\n", leaf_bh->b_blocknr); + log_warn("Removing EA located in block #%"PRIu64" (0x%" PRIx64 ").\n", + leaf_bh->b_blocknr, leaf_bh->b_blocknr); if(!prev) curr->ea_type = GFS2_EATYPE_UNUSED; else @@ -199,11 +199,13 @@ log_info("Looking for inodes containing ea blocks...\n"); while (!gfs2_find_next_block_type(bl, gfs2_eattr_block, &block_no)) { - log_info("EA in inode %"PRIu64"\n", block_no); + log_info("EA in inode %"PRIu64" (0x%" PRIx64 ")\n", block_no, + block_no); bh = bread(sbp, block_no); ip = inode_get(sbp, bh); - log_debug("Found eattr at %"PRIu64"\n", ip->i_di.di_eattr); + log_debug("Found eattr at %"PRIu64" (0x%" PRIx64 ")\n", + ip->i_di.di_eattr, ip->i_di.di_eattr); /* FIXME: Handle walking the eattr here */ error = check_inode_eattr(ip, &pass1c_fxns); if(error < 0) { --- cluster/gfs2/fsck/pass2.c 2006/06/06 14:49:31 1.2 +++ cluster/gfs2/fsck/pass2.c 2006/06/12 20:41:43 1.3 @@ -21,7 +21,6 @@ #include "libgfs2.h" #include "fsck.h" #include "util.h" -#include "log.h" #include "eattr.h" #include "metawalk.h" #include "link.h" @@ -87,17 +86,18 @@ /* Set children's parent inode in dir_info structure - ext2 does not set * dotdot inode here, but instead in pass3 - should we? */ int set_parent_dir(struct gfs2_sbd *sbp, uint64_t childblock, - uint64_t parentblock) + uint64_t parentblock) { struct dir_info *di; if(!find_di(sbp, childblock, &di)) { if(di->dinode == childblock) { if (di->treewalk_parent) { - log_err("Another directory (%" PRIu64 - ") already contains" - " this child - checking %" PRIu64 "\n", - di->treewalk_parent, parentblock); + log_err("Another directory at block %" PRIu64 + " (0x%" PRIx64 ") already contains" + " this child - checking %" PRIu64 " (0x%" PRIx64 ")\n", + di->treewalk_parent, di->treewalk_parent, + parentblock, parentblock); return 1; } di->treewalk_parent = parentblock; @@ -124,9 +124,9 @@ if(di->dotdot_parent && sbp->md.rooti->i_di.di_num.no_addr != di->dinode) { /* This should never happen */ - log_crit("dotdot parent already set for" + log_crit("Dotdot parent already set for" " block %"PRIu64" (0x%" PRIx64 ") -> %" PRIu64 - " (0x%" PRIx64")\n", childblock, childblock, + " (0x%" PRIx64 ")\n", childblock, childblock, di->dotdot_parent, di->dotdot_parent); return -1; } @@ -273,7 +273,7 @@ if(gfs2_check_range(ip->i_sbd, entryblock)) { log_err("Block # referenced by directory entry %s is out of range\n", - tmp_name); + tmp_name); if(query(&opts, "Clear directory entry tp out of range block? (y/n) ")) { log_err("Clearing %s\n", tmp_name); @@ -375,12 +375,13 @@ } } - if(!strcmp(".", tmp_name)) { log_debug("Found . dentry\n"); if(ds->dotdir) { - log_err("already found '.' entry\n"); + log_err("Already found '.' entry in directory %" PRIu64 " (0x%" + PRIx64 ")\n", + ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr); if(query(&opts, "Clear duplicate '.' entry? (y/n) ")) { entry_ip = gfs2_load_inode(sbp, de->de_inum.no_addr); @@ -407,9 +408,12 @@ /* check that '.' refers to this inode */ if(de->de_inum.no_addr != ip->i_di.di_num.no_addr) { - log_err("'.' entry's value incorrect. Points to %"PRIu64 - " when it should point to %" PRIu64 ".\n", - de->de_inum.no_addr, ip->i_di.di_num.no_addr); + log_err("'.' entry's value incorrect in directory %" PRIu64 + " (0x%" PRIx64 "). Points to %"PRIu64 + " (0x%" PRIx64 ") when it should point to %" PRIu64 + " (0x%" PRIx64 ").\n", + de->de_inum.no_addr, de->de_inum.no_addr, + ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr); if(query(&opts, "Remove '.' reference? (y/n) ")) { entry_ip = gfs2_load_inode(sbp, de->de_inum.no_addr); check_inode_eattr(entry_ip, &clear_eattrs); @@ -441,7 +445,9 @@ if(!strcmp("..", tmp_name)) { log_debug("Found .. dentry\n"); if(ds->dotdotdir) { - log_err("already found '..' entry\n"); + log_err("Already found '..' entry in directory %" PRIu64 " (0x%" + PRIx64 ")\n", + ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr); if(query(&opts, "Clear duplicate '..' entry? (y/n) ")) { entry_ip = gfs2_load_inode(sbp, de->de_inum.no_addr); @@ -465,8 +471,10 @@ } if(q.block_type != gfs2_inode_dir) { - log_err("Found '..' entry pointing to" - " something that's not a directory"); + log_err("Found '..' entry in directory %" PRIu64 " (0x%" + PRIx64 ") pointing to" + " something that's not a directory", + ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr); if(query(&opts, "Clear bad '..' directory entry? (y/n) ")) { entry_ip = gfs2_load_inode(sbp, de->de_inum.no_addr); check_inode_eattr(entry_ip, &clear_eattrs); @@ -517,8 +525,8 @@ log_debug("Found plain directory dentry\n"); error = set_parent_dir(sbp, entryblock, ip->i_di.di_num.no_addr); if(error > 0) { - log_err("%s: Hard link to block %"PRIu64" (0x%" PRIx64 ") detected.\n", - filename, entryblock, entryblock); + log_err("%s: Hard link to block %" PRIu64" (0x%" PRIx64 + ") detected.\n", filename, entryblock, entryblock); if(query(&opts, "Clear hard link to directory? (y/n) ")) { *update = 1; @@ -580,8 +588,8 @@ gfs2_block_set(bl, ip->i_di.di_num.no_addr, gfs2_inode_dir); add_to_dir_list(sbp, ip->i_di.di_num.no_addr); - /* Attach l+f to it */ - lf_dip = createi(sbp->md.rooti, "l+f", 00700, 0); + /* Attach lost+found to it */ + lf_dip = createi(sbp->md.rooti, "lost+found", 00700, 0); if(lf_dip){ inode_put(lf_dip, updated); @@ -630,7 +638,7 @@ /* if there are errors with the root inode here, we need to * create a new root inode and get it all setup - of course, - * everything will be in l+f then, but we *need* a root inode + * everything will be in lost+found then, but we *need* a root inode * before we can do any of that. */ @@ -701,18 +709,20 @@ bh = bread(sbp, rootblock); ip = inode_get(sbp, bh); if(ip->i_di.di_entries != ds.entry_count) { - log_err("inode %" PRIu64 " (0x%" PRIx64 + log_err("Inode %" PRIu64 " (0x%" PRIx64 "): Entries is %d - should be %d\n", ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr, ip->i_di.di_entries, ds.entry_count); - if(query(&opts, "Fix entries for inode %"PRIu64"? (y/n) ", - ip->i_di.di_num.no_addr)) { + if(query(&opts, "Fix entries for inode %" PRIu64 " (0x%" PRIx64 + ")? (y/n) ", ip->i_di.di_num.no_addr, + ip->i_di.di_num.no_addr)) { ip->i_di.di_entries = ds.entry_count; log_warn("Entries updated\n"); update = 1; } else { - log_err("Entries for inode %"PRIu64" left out of sync\n", - ip->i_di.di_num.no_addr); + log_err("Entries for inode %" PRIu64 " (0x%" PRIx64 + ") left out of sync\n", + ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr); } } @@ -796,7 +806,8 @@ /* FIXME: factor */ if(query(&opts, "Remove directory entry for bad" " inode %"PRIu64" (0x%" PRIx64 ") in %"PRIu64 - "? (y/n)", i, i, di->treewalk_parent)) { + " (0x%" PRIx64 ")? (y/n)", i, i, di->treewalk_parent, + di->treewalk_parent)) { error = remove_dentry_from_dir(sbp, di->treewalk_parent, i); if(error < 0) { @@ -805,13 +816,13 @@ } if(error > 0) { log_warn("Unable to find dentry for %" - PRIu64" (0x%" PRIx64 ") in %"PRIu64"\n", - i, i, di->treewalk_parent); + PRIu64 " (0x%" PRIx64 ") in %" PRIu64 + " (0x%" PRIx64 ")\n", i, i, + di->treewalk_parent, di->treewalk_parent); } log_warn("Directory entry removed\n"); - } else { - log_err("Directory entry to invalid inode remains\n"); - } + } else + log_err("Directory entry to invalid inode remains.\n"); } gfs2_block_set(bl, i, gfs2_meta_inval); } --- cluster/gfs2/fsck/pass3.c 2006/06/06 14:49:31 1.2 +++ cluster/gfs2/fsck/pass3.c 2006/06/12 20:41:43 1.3 @@ -22,7 +22,6 @@ #include "fsck.h" #include "lost_n_found.h" #include "link.h" -#include "log.h" #include "metawalk.h" static int attach_dotdot_to(struct gfs2_sbd *sbp, uint64_t newdotdot, @@ -42,14 +41,14 @@ * this case? */ filename_len = strlen(".."); - if(!(filename = malloc(sizeof(char) * filename_len))) { + if(!(filename = malloc((sizeof(char) * filename_len) + 1))) { log_err("Unable to allocate name\n"); inode_put(ip, not_updated); inode_put(pip, not_updated); stack; return -1; } - if(!memset(filename, 0, sizeof(char) * filename_len)) { + if(!memset(filename, 0, (sizeof(char) * filename_len) + 1)) { log_err("Unable to zero name\n"); inode_put(ip, not_updated); inode_put(pip, not_updated); @@ -80,20 +79,22 @@ return NULL; if(di->dotdot_parent != di->treewalk_parent) { - log_warn(".. and treewalk conections are not the same for %"PRIu64 - "\n", di->dinode); - log_notice("%"PRIu64" %"PRIu64"\n", di->dotdot_parent, + log_warn("Directory '..' and treewalk connections disagree for inode %" + PRIu64 " (0x%" PRIx64 ")\n", di->dinode, di->dinode); + log_notice("'..' has %" PRIu64" (0x%" PRIx64 "), treewalk has %" + PRIu64" (0x%" PRIx64 ")\n", di->dotdot_parent, + di->dotdot_parent, di->treewalk_parent, di->treewalk_parent); if(gfs2_block_check(bl, di->dotdot_parent, &q_dotdot)) { log_err("Unable to find block %"PRIu64 - " in block map\n", - di->dotdot_parent); + " (0x%" PRIx64 ") in block map.\n", + di->dotdot_parent, di->dotdot_parent); return NULL; } if(gfs2_block_check(bl, di->treewalk_parent, &q_treewalk)) { log_err("Unable to find block %"PRIu64 - " in block map\n", - di->treewalk_parent); + " (0x%" PRIx64 ") in block map\n", + di->treewalk_parent, di->treewalk_parent); return NULL; } /* if the dotdot entry isn't a directory, but the @@ -101,34 +102,33 @@ * entry isn't a directory, but the dotdot is, dotdot * is correct - if both are directories, which do we * choose? if neither are directories, we have a - * problem - need to move this directory into l+f + * problem - need to move this directory into lost+found */ if(q_dotdot.block_type != gfs2_inode_dir) { if(q_treewalk.block_type != gfs2_inode_dir) { - log_err( "Orphaned directory, move to l+f\n"); + log_err( "Orphaned directory, move to lost+found\n"); return NULL; } else { log_warn("Treewalk parent is correct," - " fixing dotdot -> %"PRIu64"\n", - di->treewalk_parent); + " fixing dotdot -> %"PRIu64" (0x%" PRIx64 ")\n", + di->treewalk_parent, di->treewalk_parent); attach_dotdot_to(sbp, di->treewalk_parent, - di->dotdot_parent, di->dinode); + di->dotdot_parent, di->dinode); di->dotdot_parent = di->treewalk_parent; - } } else { if(q_treewalk.block_type != gfs2_inode_dir) { int error = 0; log_warn(".. parent is valid, but treewalk" - "is bad - reattaching to l+f"); + "is bad - reattaching to lost+found"); /* FIXME: add a dinode for this entry instead? */ if(query(&opts, "Remove directory entry for bad" - " inode %"PRIu64" in %"PRIu64 - "? (y/n)", di->dinode, - di->treewalk_parent)) { + " inode %"PRIu64" (0x%" PRIx64 ") in %"PRIu64 + " (0x%" PRIx64 ")? (y/n)", di->dinode, di->dinode, + di->treewalk_parent, di->treewalk_parent)) { error = remove_dentry_from_dir(sbp, di->treewalk_parent, di->dinode); if(error < 0) { @@ -136,9 +136,10 @@ return NULL; } if(error > 0) { - log_warn("Unable to find dentry for %" - PRIu64" in %"PRIu64"\n", - di->dinode, di->treewalk_parent); + log_warn("Unable to find dentry for block %" + PRIu64" (0x%" PRIx64 ") in %" PRIu64 " (0x%" + PRIx64 ")\n",di->dinode, di->dinode, + di->treewalk_parent, di->treewalk_parent); } log_warn("Directory entry removed\n"); } else { @@ -150,32 +151,30 @@ } else { log_err("Both .. and treewalk parents are " - "directories, going with treewalk for " - "now...\n"); + "directories, going with treewalk for " + "now...\n"); attach_dotdot_to(sbp, di->treewalk_parent, - di->dotdot_parent, di->dinode); + di->dotdot_parent, di->dinode); di->dotdot_parent = di->treewalk_parent; - } } } else { if(gfs2_block_check(bl, di->dotdot_parent, &q_dotdot)) { log_err("Unable to find parent block %"PRIu64 - " in block map\n", - di->dotdot_parent); + " (0x%" PRIx64 ") in block map\n", + di->dotdot_parent, di->dotdot_parent); return NULL; } if(q_dotdot.block_type != gfs2_inode_dir) { - log_err("Orphaned directory, move to l+f (Block #%" - PRIu64")\n", di->dinode); + log_err("Orphaned directory at block %" PRIu64 " (0x%" PRIx64 + ") moved to lost+found\n", di->dinode, di->dinode); return NULL; } } find_di(sbp, di->dotdot_parent, &pdi); return pdi; - } /** @@ -223,15 +222,13 @@ return -1; } if(q.bad_block) { - log_err("Found unlinked directory containing" - "bad block\n"); + log_err("Found unlinked directory containing bad block\n"); if(query(&opts, "Clear unlinked directory with bad blocks? (y/n) ")) { gfs2_block_set(bl, di->dinode, gfs2_block_free); break; - } else { - log_err("Unlinked directory with bad blocks remains\n"); - } + } else + log_err("Unlinked directory with bad block remains\n"); } if(q.block_type != gfs2_inode_dir && q.block_type != gfs2_inode_file && @@ -246,7 +243,8 @@ break; } - log_err("Found unlinked directory %"PRIu64"\n", di->dinode); + log_err("Found unlinked directory at block %" PRIu64 + " (0x%" PRIx64 ")\n", di->dinode, di->dinode); ip = gfs2_load_inode(sbp, di->dinode); /* Don't skip zero size directories * with eattrs */ @@ -260,13 +258,13 @@ log_err("Zero-size unlinked directory remains\n"); } } - if(query(&opts, "Add unlinked directory to l+f? (y/n) ")) { + if(query(&opts, "Add unlinked directory to lost+found? (y/n) ")) { if(add_inode_to_lf(ip)) { inode_put(ip, not_updated); stack; return -1; } - log_warn("Directory relinked to l+f\n"); + log_warn("Directory relinked to lost+found\n"); } else { log_err("Unlinked directory remains unlinked\n"); } @@ -274,15 +272,15 @@ break; } else { - log_info("Directory at block %"PRIu64 - " connected\n", di->dinode); + log_info("Directory at block %" PRIu64 " (0x%" + PRIx64 ") connected\n", di->dinode, di->dinode); } di = tdi; } } } if(lf_dip) - log_debug("At end of pass3, l+f entries is %u\n", + log_debug("At end of pass3, lost+found entries is %u\n", lf_dip->i_di.di_entries); return 0; } --- cluster/gfs2/fsck/pass4.c 2006/06/06 14:49:31 1.2 +++ cluster/gfs2/fsck/pass4.c 2006/06/12 20:41:43 1.3 @@ -18,7 +18,6 @@ #include "libgfs2.h" #include "fsck.h" #include "lost_n_found.h" -#include "log.h" #include "inode_hash.h" /* Updates the link count of an inode to what the fsck has seen for @@ -26,13 +25,13 @@ int fix_inode_count(struct gfs2_sbd *sbp, struct inode_info *ii, struct gfs2_inode *ip) { - log_info("Fixing inode count for %"PRIu64" (0x%" PRIx64") \n", + log_info("Fixing inode count for %" PRIu64 " (0x%" PRIx64 ") \n", ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr); if(ip->i_di.di_nlink == ii->counted_links) return 0; ip->i_di.di_nlink = ii->counted_links; - log_debug("Changing inode %"PRIu64" (0x%" PRIx64") to have %u links\n", + log_debug("Changing inode %" PRIu64 " (0x%" PRIx64 ") to have %u links\n", ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr, ii->counted_links); return 0; @@ -54,10 +53,10 @@ log_crit("osi_list_foreach broken in scan_info_list!!\n"); exit(1); } - log_info("Checking reference count on inode at block %"PRIu64 - " (0x%" PRIx64 "\n", ii->inode, ii->inode); + log_info("Checking reference count on inode at block %" PRIu64 + " (0x%" PRIx64 ")\n", ii->inode, ii->inode); if(ii->counted_links == 0) { - log_err("Found unlinked inode at %"PRIu64" (0x%"PRIx64")\n", + log_err("Found unlinked inode at %" PRIu64 " (0x%" PRIx64 ")\n", ii->inode, ii->inode); if(gfs2_block_check(bl, ii->inode, &q)) { stack; @@ -98,7 +97,7 @@ } } - if(query(&opts, "Add unlinked inode to l+f? (y/n)")) { + if(query(&opts, "Add unlinked inode to lost+found? (y/n)")) { f = updated; if(add_inode_to_lf(ip)) { stack; @@ -114,31 +113,31 @@ inode_put(ip, f); } /* if(ii->counted_links == 0) */ else if(ii->link_count != ii->counted_links) { - log_err("Link count inconsistent for inode %"PRIu64 - " (0x%" PRIx64") - %u %u\n", ii->inode, + log_err("Link count inconsistent for inode %" PRIu64 + " (0x%" PRIx64 ") has %u but fsck found %u.\n", ii->inode, ii->inode, ii->link_count, ii->counted_links); /* Read in the inode, adjust the link count, * and write it back out */ if(query(&opts, "Update link count for inode %" - PRIu64" (0x%" PRIx64") ? (y/n) ", ii->inode, ii->inode)) { + PRIu64 " (0x%" PRIx64 ") ? (y/n) ", ii->inode, ii->inode)) { ip = gfs2_load_inode(sbp, ii->inode); /* bread, inode_get */ fix_inode_count(sbp, ii, ip); inode_put(ip, updated); /* out, brelse, free */ log_warn("Link count updated for inode %" - PRIu64" (0x%" PRIx64") \n", ii->inode, ii->inode); + PRIu64 " (0x%" PRIx64 ") \n", ii->inode, ii->inode); } else { - log_err("Link count for inode %" PRIu64" (0x%" PRIx64 - ") still incorrect\n", ii->inode, ii->inode); + log_err("Link count for inode %" PRIu64 " (0x%" PRIx64 + ") still incorrect\n", ii->inode, ii->inode); } } - log_debug("block %"PRIu64" (0x%" PRIx64") has link count %d\n", + log_debug("block %" PRIu64 " (0x%" PRIx64 ") has link count %d\n", ii->inode, ii->inode, ii->link_count); } /* osi_list_foreach(tmp, list) */ if (lf_addition) { if(!(ii = inode_hash_search(inode_hash, lf_dip->i_di.di_num.no_addr))) { - log_crit("Unable to find l+f inode in inode_hash!!\n"); + log_crit("Unable to find lost+found inode in inode_hash!!\n"); return -1; } else { fix_inode_count(sbp, ii, lf_dip); @@ -162,7 +161,7 @@ uint32_t i; osi_list_t *list; if(lf_dip) - log_debug("At beginning of pass4, l+f entries is %u\n", + log_debug("At beginning of pass4, lost+found entries is %u\n", lf_dip->i_di.di_entries); for (i = 0; i < FSCK_HASH_SIZE; i++) { list = &inode_hash[i]; @@ -173,7 +172,7 @@ } if(lf_dip) - log_debug("At end of pass4, l+f entries is %u\n", + log_debug("At end of pass4, lost+found entries is %u\n", lf_dip->i_di.di_entries); return 0; } --- cluster/gfs2/fsck/pass5.c 2006/06/06 14:49:31 1.2 +++ cluster/gfs2/fsck/pass5.c 2006/06/12 20:41:43 1.3 @@ -18,7 +18,6 @@ #include "libgfs2.h" #include "fsck.h" -#include "log.h" #include "fs_bits.h" #include "util.h" @@ -78,6 +77,7 @@ while(byte < end) { rg_status = ((*byte >> bit) & GFS2_BIT_MASK); block = rg_data + *rg_block; + warm_fuzzy_stuff(block); gfs2_block_check(bl, block, &q); block_status = convert_mark(q.block_type, count); @@ -139,7 +139,7 @@ update = 1; } if(rgp->rg.rg_dinodes != count[1]) { - log_err("inode count inconsistent: is %u should be %u\n", + log_err("Inode count inconsistent: is %u should be %u\n", rgp->rg.rg_dinodes, count[1]); rgp->rg.rg_dinodes = count[1]; update = 1; @@ -180,7 +180,7 @@ for(tmp = sbp->rglist.next; tmp != &sbp->rglist; tmp = tmp->next){ enum update_flags f; - log_info("Verifying Resource Group %"PRIu64"\n", rg_count); + log_info("Verifying Resource Group #%" PRIu64 "\n", rg_count); memset(count, 0, sizeof(count)); rgp = osi_list_entry(tmp, struct rgrp_list, list); --- cluster/gfs2/fsck/util.c 2006/06/06 14:49:31 1.2 +++ cluster/gfs2/fsck/util.c 2006/06/12 20:41:43 1.3 @@ -21,9 +21,7 @@ #include "libgfs2.h" #include "fs_bits.h" - #include "util.h" -#include "log.h" /** * compute_height