From mboxrd@z Thu Jan 1 00:00:00 1970 From: rpeterso@sourceware.org Date: 15 Jun 2006 18:48:49 -0000 Subject: [Cluster-devel] cluster/gfs2/fsck fs_recovery.c initialize.c m ... Message-ID: <20060615184849.11670.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-15 18:48:45 Modified files: gfs2/fsck : fs_recovery.c initialize.c main.c pass2.c pass3.c pass4.c util.c Log message: Fixed a bug where changes to the root inode are not written to disk. Also, added logging changes for bz 156009. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/fs_recovery.c.diff?cvsroot=cluster&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/initialize.c.diff?cvsroot=cluster&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/main.c.diff?cvsroot=cluster&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/pass2.c.diff?cvsroot=cluster&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/pass3.c.diff?cvsroot=cluster&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/pass4.c.diff?cvsroot=cluster&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/util.c.diff?cvsroot=cluster&r1=1.3&r2=1.4 --- cluster/gfs2/fsck/fs_recovery.c 2006/06/12 20:41:43 1.3 +++ cluster/gfs2/fsck/fs_recovery.c 2006/06/15 18:48:45 1.4 @@ -97,7 +97,7 @@ int reconstruct_journals(struct gfs2_sbd *sdp){ int i; - log_warn("Clearing journals (this may take a while)\n"); + log_notice("Clearing journals (this may take a while)"); for(i=0; i < sdp->md.journals; i++) { /* Journal replay seems to have slowed down quite a bit in * the gfs2_fsck */ @@ -106,6 +106,6 @@ if(reconstruct_single_journal(sdp, i)) return -1; } - log_notice("Cleared journals\n"); + log_notice("\nJournals cleared.\n"); return 0; } --- cluster/gfs2/fsck/initialize.c 2006/06/12 20:41:43 1.3 +++ cluster/gfs2/fsck/initialize.c 2006/06/15 18:48:45 1.4 @@ -348,6 +348,7 @@ log_warn("Unable to unblock other mounters - manual intevention required\n"); log_warn("Use 'gfs_tool sb proto' to fix\n"); } + log_info("Syncing the device.\n"); fsync(sbp->device_fd); } empty_super_block(sbp); --- cluster/gfs2/fsck/main.c 2006/06/12 20:41:43 1.3 +++ cluster/gfs2/fsck/main.c 2006/06/15 18:48:45 1.4 @@ -198,6 +198,7 @@ inode_put(lf_dip, updated); /* print_map(sbp->bl, sbp->last_fs_block); */ + log_notice("Writing changes to disk\n"); bsync(sbp); destroy(sbp); log_notice("gfs2_fsck complete \n"); --- cluster/gfs2/fsck/pass2.c 2006/06/12 20:41:43 1.3 +++ cluster/gfs2/fsck/pass2.c 2006/06/15 18:48:45 1.4 @@ -226,6 +226,7 @@ struct gfs2_inode *entry_ip = NULL; struct metawalk_fxns clear_eattrs = {0}; struct gfs2_dirent dentry, *de; + uint32_t calculated_hash; memset(&dentry, 0, sizeof(struct gfs2_dirent)); gfs2_dirent_in(&dentry, (char *)dent); @@ -250,18 +251,26 @@ /* FIXME: should probably delete the entry here at the * very least - maybe look at attempting to fix it */ } - - if (de->de_hash != gfs2_disk_hash(filename, de->de_name_len)){ + + calculated_hash = gfs2_disk_hash(filename, de->de_name_len); + if (de->de_hash != calculated_hash){ log_err("Dir entry with bad hash or name length\n" - "\tHash found = %u\n" - "\tName found = %s\n" - "\tName length found = %u\n" - "\tHash expected = %u\n", - de->de_hash, - filename, - de->de_name_len, - gfs2_disk_hash(filename, de->de_name_len)); - return 1; + "\tHash found = %u (0x%x)\n" + "\tFilename = %s\n", de->de_hash, de->de_hash, + filename); + log_err("\tName length found = %u\n" + "\tHash expected = %u (0x%x)\n", + de->de_name_len, calculated_hash, calculated_hash); + if(query(&opts, "Fix directory hash for %s? (y/n) ", + filename)) { + de->de_hash = calculated_hash; + gfs2_dirent_out(de, (char *)dent); + log_err("Directory entry hash for %s fixed.\n", filename); + } + else { + log_err("Directory entry hash for %s not fixed.\n", filename); + return 1; + } } /* FIXME: This should probably go to the top of the fxn, and * references to filename should be replaced with tmp_name */ @@ -608,7 +617,6 @@ { uint64_t rootblock; struct dir_status ds = {0}; - struct gfs2_inode *ip; struct gfs2_buffer_head b, *bh = &b; char *filename; int filename_len; @@ -630,10 +638,6 @@ * error out if the root block number is valid, but * gfs2_block_check fails */ return -1; -/* if(build_rooti(sbp)) { - stack; - return -1; - }*/ } /* if there are errors with the root inode here, we need to @@ -660,13 +664,10 @@ pass2_fxns.private = (void *) &ds; if(ds.q.bad_block) { /* First check that the directory's metatree is valid */ - ip = gfs2_load_inode(sbp, rootblock); - if(check_metatree(ip, &pass2_fxns)) { + if(check_metatree(sbp->md.rooti, &pass2_fxns)) { stack; - free(ip); return -1; } - inode_put(ip, not_updated); } error = check_dir(sbp, rootblock, &pass2_fxns); if(error < 0) { @@ -676,10 +677,8 @@ if (error > 0) gfs2_block_set(bl, rootblock, gfs2_meta_inval); - bh = bread(sbp, rootblock); - ip = inode_get(sbp, bh); - - if(check_inode_eattr(ip, &pass2_fxns)) { + bh = bhold(sbp->md.rooti->i_bh); + if(check_inode_eattr(sbp->md.rooti, &pass2_fxns)) { stack; return -1; } @@ -699,36 +698,35 @@ } memcpy(filename, tmp_name, filename_len); log_warn("Adding '.' entry\n"); - dir_add(ip, filename, filename_len, &(ip->i_di.di_num), DT_DIR); - increment_link(ip->i_sbd, ip->i_di.di_num.no_addr); + dir_add(sbp->md.rooti, filename, filename_len, + &(sbp->md.rooti->i_di.di_num), DT_DIR); + increment_link(sbp->md.rooti->i_sbd, + sbp->md.rooti->i_di.di_num.no_addr); ds.entry_count++; free(filename); update = 1; } - inode_put(ip, not_updated); /* does a brelse */ - bh = bread(sbp, rootblock); - ip = inode_get(sbp, bh); - if(ip->i_di.di_entries != ds.entry_count) { - log_err("Inode %" PRIu64 " (0x%" PRIx64 + if(sbp->md.rooti->i_di.di_entries != ds.entry_count) { + log_err("Root 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 " (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; + sbp->md.rooti->i_di.di_num.no_addr, + sbp->md.rooti->i_di.di_num.no_addr, + sbp->md.rooti->i_di.di_entries, ds.entry_count); + if(query(&opts, "Fix entries for root inode %" PRIu64 " (0x%" PRIx64 + ")? (y/n) ", sbp->md.rooti->i_di.di_num.no_addr, + sbp->md.rooti->i_di.di_num.no_addr)) { + sbp->md.rooti->i_di.di_entries = ds.entry_count; log_warn("Entries updated\n"); update = 1; } else { 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); + sbp->md.rooti->i_di.di_num.no_addr, + sbp->md.rooti->i_di.di_num.no_addr); } } - if(update) - gfs2_dinode_out(&ip->i_di, bh->b_data); - inode_put(ip, update); /* does a brelse */ + brelse(bh, update); return 0; } @@ -753,12 +751,12 @@ char *filename; int filename_len; char tmp_name[256]; + int error = 0; + if(check_root_dir(sbp)) { stack; return -1; } - int error = 0; - /* Grab each directory inode, and run checks on it */ for(i = 0; i < last_fs_block; i++) { /* Skip the root inode - it's checked above */ @@ -774,8 +772,8 @@ if(q.block_type != gfs2_inode_dir) continue; - log_info("Checking directory inode at block %"PRIu64" (0x%" - PRIx64 ")\n", i, i); + log_debug("Checking directory inode at block %"PRIu64" (0x%" + PRIx64 ")\n", i, i); memset(&ds, 0, sizeof(ds)); pass2_fxns.private = (void *) &ds; --- cluster/gfs2/fsck/pass3.c 2006/06/12 20:41:43 1.3 +++ cluster/gfs2/fsck/pass3.c 2006/06/15 18:48:45 1.4 @@ -206,6 +206,7 @@ * until we find one that's been checked already. If we don't * find a parent, put in lost+found. */ + log_info("Checking directory linkage.\n"); for(i = 0; i < FSCK_HASH_SIZE; i++) { osi_list_foreach(tmp, &dir_hash[i]) { di = osi_list_entry(tmp, struct dir_info, list); @@ -272,8 +273,8 @@ break; } else { - log_info("Directory@block %" PRIu64 " (0x%" - PRIx64 ") connected\n", di->dinode, di->dinode); + log_debug("Directory at block %" PRIu64 " (0x%" + PRIx64 ") connected\n", di->dinode, di->dinode); } di = tdi; } --- cluster/gfs2/fsck/pass4.c 2006/06/12 20:41:43 1.3 +++ cluster/gfs2/fsck/pass4.c 2006/06/15 18:48:45 1.4 @@ -53,8 +53,8 @@ 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_debug("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", ii->inode, ii->inode); @@ -163,6 +163,7 @@ if(lf_dip) log_debug("At beginning of pass4, lost+found entries is %u\n", lf_dip->i_di.di_entries); + log_info("Checking inode reference counts.\n"); for (i = 0; i < FSCK_HASH_SIZE; i++) { list = &inode_hash[i]; if(scan_inode_list(sbp, list)) { --- cluster/gfs2/fsck/util.c 2006/06/12 20:41:43 1.3 +++ cluster/gfs2/fsck/util.c 2006/06/15 18:48:45 1.4 @@ -54,7 +54,7 @@ return height; } -/* Put out a warm, fuzzy message every second so the customer */ +/* Put out a warm, fuzzy message every second so the user */ /* doesn't think we hung. (This may take a long time). */ void warm_fuzzy_stuff(uint64_t block) { @@ -69,8 +69,7 @@ seconds = tv.tv_sec; percent = (block * 100) / last_fs_block; - printf("\r%" PRIu64 " percent complete.\r", percent); - fflush(stdout); + log_notice("\r%" PRIu64 " percent complete.\r", percent); } }