[Ocfs2-tools-commits] manish commits r1037 - in
branches/ocfs2-tools-1.0: fsck.ocfs2 libocfs2
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Thu Aug 11 22:43:25 CDT 2005
Author: manish
Date: 2005-08-11 22:43:24 -0500 (Thu, 11 Aug 2005)
New Revision: 1037
Modified:
branches/ocfs2-tools-1.0/fsck.ocfs2/pass0.c
branches/ocfs2-tools-1.0/fsck.ocfs2/pass1.c
branches/ocfs2-tools-1.0/libocfs2/chainalloc.c
Log:
Backported from HEAD:
Check i_size in fsck.
o be sure to update i_size and i_clusters for chain allocator inodes as
groups are added and removed, both in fsck and libocfs2.
o check chain allocator i_size/i_clusters in pass0 as we validate the
allocators
o then only check i_size/i_clusters for inodes that have i_list in pass1
Modified: branches/ocfs2-tools-1.0/fsck.ocfs2/pass0.c
===================================================================
--- branches/ocfs2-tools-1.0/fsck.ocfs2/pass0.c 2005-08-12 02:00:54 UTC (rev 1036)
+++ branches/ocfs2-tools-1.0/fsck.ocfs2/pass0.c 2005-08-12 03:43:24 UTC (rev 1037)
@@ -245,6 +245,8 @@
cr->c_total -= bg->bg_bits;
di->id1.bitmap1.i_used -= bg->bg_bits - bg->bg_free_bits_count;
di->id1.bitmap1.i_total -= bg->bg_bits;
+ di->i_clusters -= (bg->bg_bits / cl->cl_bpc);
+ di->i_size = (uint64_t)di->i_clusters * ost->ost_fs->fs_clustersize;
ret = ocfs2_write_inode(ost->ost_fs, di->i_blkno, (char *)di);
if (ret) {
@@ -451,6 +453,7 @@
uint32_t free = 0, total = 0;
int changed = 0, trust_next_free = 1;
errcode_t ret = 0;
+ uint64_t chain_bytes;
if (memcmp(di->i_signature, OCFS2_INODE_SIGNATURE,
strlen(OCFS2_INODE_SIGNATURE))) {
@@ -543,6 +546,7 @@
};
ret = check_chain(ost, di, &cs, cr, buf1, buf2, &changed,
allowed, forbidden);
+ /* XXX what? not checking ret? */
if (cr->c_blkno != 0) {
free += cs.cs_free_bits;
@@ -597,6 +601,30 @@
}
}
+ total /= cl->cl_bpc;
+
+ if (di->i_clusters != total &&
+ prompt(ost, PY, PR_CHAIN_I_CLUSTERS,
+ "Allocator inode %"PRIu64" has %"PRIu32" clusters "
+ "represtented in its allocator chains but has an "
+ "i_clusters value of %"PRIu32". Fix this by updating "
+ "i_clusters?", di->i_blkno, total, di->i_clusters)) {
+ di->i_clusters = total;
+ changed = 1;
+ }
+
+ chain_bytes = (uint64_t)total * ost->ost_fs->fs_clustersize;
+ if (di->i_size != chain_bytes &&
+ prompt(ost, PY, PR_CHAIN_I_SIZE,
+ "Allocator inode %"PRIu64" has %"PRIu32" clusters "
+ "represtented in its allocator chain which accounts for "
+ "%"PRIu64" total bytes, but its i_size is %"PRIu64". "
+ "Fix this by updating i_size?", di->i_blkno,
+ di->id1.bitmap1.i_total, chain_bytes, di->i_size)) {
+ di->i_size = chain_bytes;
+ changed = 1;
+ }
+
if (changed) {
ret = ocfs2_write_inode(ost->ost_fs, di->i_blkno, (char *)di);
if (ret) {
@@ -781,6 +809,9 @@
di->id1.bitmap1.i_used += bg->bg_bits - bg->bg_free_bits_count;
di->id1.bitmap1.i_total += bg->bg_bits;
+ di->i_clusters += (bg->bg_bits / di->id2.i_chain.cl_bpc);
+ di->i_size = (uint64_t)di->i_clusters *
+ ost->ost_fs->fs_clustersize;
ret = ocfs2_write_inode(ost->ost_fs, di->i_blkno, (char *)di);
if (ret) {
Modified: branches/ocfs2-tools-1.0/fsck.ocfs2/pass1.c
===================================================================
--- branches/ocfs2-tools-1.0/fsck.ocfs2/pass1.c 2005-08-12 02:00:54 UTC (rev 1036)
+++ branches/ocfs2-tools-1.0/fsck.ocfs2/pass1.c 2005-08-12 03:43:24 UTC (rev 1037)
@@ -698,22 +698,10 @@
return 0;
}
-/* XXX this is only really building up the vb data so that the caller can
- * verify the chain allocator inode's fields. I wonder if we shouldn't have
- * already done that in pass 0. */
-static int check_gd_block(ocfs2_filesys *fs, uint64_t gd_blkno, int chain_num,
- void *priv_data)
-{
- struct verifying_blocks *vb = priv_data;
- verbosef("found gd block %"PRIu64"\n", gd_blkno);
- /* XXX should arguably be verifying that pass 0 marked the group desc
- * blocks found */
- /* don't have bcount */
- vb_saw_block(vb, vb->vb_num_blocks);
- return 0;
-}
-
-
+/*
+ * this verifies i_size and i_clusters for inodes that use i_list to
+ * reference extents of data.
+ */
static errcode_t o2fsck_check_blocks(ocfs2_filesys *fs, o2fsck_state *ost,
uint64_t blkno, ocfs2_dinode *di)
{
@@ -724,28 +712,21 @@
.vb_di = di,
};
- /*
- * ISLNK && clusters == 0 is the only sign of an inode that doesn't
- * have an extent list when i_flags would have us believe it did.
- * We might be able to be very clever about discovering the
- * difference between i_symlink and i_list, but we don't try yet.
- */
- if (di->i_flags & OCFS2_LOCAL_ALLOC_FL ||
- di->i_flags & OCFS2_DEALLOC_FL)
- ret = 0;
- else if (di->i_flags & OCFS2_CHAIN_FL)
- ret = ocfs2_chain_iterate(fs, blkno, check_gd_block, &vb);
- else if (S_ISLNK(di->i_mode) && di->i_clusters == 0)
- ret = 0;
- else {
- ret = o2fsck_check_extents(ost, di);
- if (ret == 0)
- ret = ocfs2_block_iterate_inode(fs, di, 0,
- verify_block, &vb);
- if (vb.vb_ret)
- ret = vb.vb_ret;
- }
+ /* don't bother to verify for inodes that don't have i_list,
+ * we have to trust i_mode/i_clusters to tell us that a symlink
+ * has put target data in the union instead of i_list */
+ if ((di->i_flags & (OCFS2_SUPER_BLOCK_FL | OCFS2_LOCAL_ALLOC_FL |
+ OCFS2_BITMAP_FL | OCFS2_CHAIN_FL |
+ OCFS2_DEALLOC_FL)) ||
+ (S_ISLNK(di->i_mode) && di->i_clusters == 0))
+ return 0;
+ ret = o2fsck_check_extents(ost, di);
+ if (ret == 0)
+ ret = ocfs2_block_iterate_inode(fs, di, 0, verify_block, &vb);
+ if (vb.vb_ret)
+ ret = vb.vb_ret;
+
if (ret) {
com_err(whoami, ret, "while iterating over the blocks for "
"inode %"PRIu64, di->i_blkno);
@@ -778,19 +759,18 @@
/* XXX clear valid flag and stuff? */
}
-#if 0 /* boy, this is just broken */
if (vb.vb_num_blocks > 0)
expected = (vb.vb_last_block + 1) * fs->fs_blocksize;
/* i_size is checked for symlinks elsewhere */
if (!S_ISLNK(di->i_mode) && di->i_size > expected &&
- prompt(ost, PY, 0, "Inode %"PRIu64" has a size of %"PRIu64" but has "
- "%"PRIu64" bytes of actual data. Correct the file size?",
+ prompt(ost, PY, PR_INODE_SIZE, "Inode %"PRIu64" has a size of "
+ "%"PRIu64" but has %"PRIu64" bytes of actual data. "
+ "Correct the file size?",
di->i_blkno, di->i_size, expected)) {
di->i_size = expected;
o2fsck_write_inode(ost, blkno, di);
}
-#endif
if (vb.vb_num_blocks > 0)
expected = ocfs2_clusters_in_blocks(fs, vb.vb_last_block + 1);
Modified: branches/ocfs2-tools-1.0/libocfs2/chainalloc.c
===================================================================
--- branches/ocfs2-tools-1.0/libocfs2/chainalloc.c 2005-08-12 02:00:54 UTC (rev 1036)
+++ branches/ocfs2-tools-1.0/libocfs2/chainalloc.c 2005-08-12 03:43:24 UTC (rev 1037)
@@ -534,6 +534,8 @@
rec->c_blkno = blkno;
cinode->ci_inode->i_clusters += cinode->ci_inode->id2.i_chain.cl_cpg;
+ cinode->ci_inode->i_size = (uint64_t)cinode->ci_inode->i_clusters *
+ fs->fs_clustersize;
cinode->ci_inode->id1.bitmap1.i_total += gd->bg_bits;
cinode->ci_inode->id1.bitmap1.i_used += gd->bg_bits -
gd->bg_free_bits_count;
@@ -564,6 +566,8 @@
cinode->ci_inode->i_clusters -=
cinode->ci_inode->id2.i_chain.cl_cpg;
+ cinode->ci_inode->i_size = (uint64_t)cinode->ci_inode->i_clusters *
+ fs->fs_clustersize;
cinode->ci_inode->id1.bitmap1.i_total -= gd->bg_bits;
cinode->ci_inode->id1.bitmap1.i_used -= gd->bg_bits -
gd->bg_free_bits_count;
More information about the Ocfs2-tools-commits
mailing list