[Ocfs2-commits] mfasheh commits r1756 - trunk/src
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Tue Jan 11 18:53:01 CST 2005
Author: mfasheh
Date: 2005-01-11 18:52:59 -0600 (Tue, 11 Jan 2005)
New Revision: 1756
Modified:
trunk/src/alloc.c
trunk/src/inode.c
trunk/src/journal.c
trunk/src/localalloc.c
trunk/src/namei.c
trunk/src/suballoc.c
trunk/src/super.c
Log:
* make ourselves consistent wrt endianness of on disk fields. we're not even
close to being all little endian on disk, but at least now if a field is
getting flipped, it *always* is.
Modified: trunk/src/alloc.c
===================================================================
--- trunk/src/alloc.c 2005-01-11 23:35:16 UTC (rev 1755)
+++ trunk/src/alloc.c 2005-01-12 00:52:59 UTC (rev 1756)
@@ -203,16 +203,16 @@
eb = (ocfs2_extent_block *) bhs[i]->b_data;
/* Ok, setup the minimal stuff here. */
strcpy(eb->h_signature, OCFS2_EXTENT_BLOCK_SIGNATURE);
- eb->h_blkno = first_blkno;
- eb->h_fs_generation = osb->fs_generation;
+ eb->h_blkno = cpu_to_le64(first_blkno);
+ eb->h_fs_generation = cpu_to_le32(osb->fs_generation);
#ifndef OCFS_USE_ALL_METADATA_SUBALLOCATORS
/* we always use node zeros suballocator */
eb->h_suballoc_node = 0;
#else
- eb->h_suballoc_node = osb->slot_num;
+ eb->h_suballoc_node = cpu_to_le16(osb->slot_num);
#endif
- eb->h_suballoc_bit = suballoc_bit_start;
+ eb->h_suballoc_bit = cpu_to_le16(suballoc_bit_start);
eb->h_list.l_count = ocfs2_extent_recs_per_eb(osb->sb);
suballoc_bit_start++;
@@ -335,7 +335,7 @@
eb_el->l_recs[0].e_blkno = next_blkno;
eb_el->l_recs[0].e_clusters = 0;
if (!eb_el->l_tree_depth)
- new_last_eb_blk = eb->h_blkno;
+ new_last_eb_blk = le64_to_cpu(eb->h_blkno);
status = ocfs_journal_dirty(handle, bh);
if (status < 0) {
@@ -343,7 +343,7 @@
goto bail;
}
- next_blkno = eb->h_blkno;
+ next_blkno = le64_to_cpu(eb->h_blkno);
}
/* This is a bit hairy. We want to update up to three blocks
@@ -938,7 +938,7 @@
*new_last_eb = bh;
get_bh(*new_last_eb);
- LOG_TRACE_ARGS("returning block %llu\n", eb->h_blkno);
+ LOG_TRACE_ARGS("returning block %llu\n", le64_to_cpu(eb->h_blkno));
bail:
if (bh)
brelse(bh);
@@ -1076,7 +1076,8 @@
i = el->l_next_free_rec - 1;
LOG_TRACE_ARGS("extent block %llu, before: record %d: "
- "(%u, %u, %llu), next = %u\n", eb->h_blkno, i,
+ "(%u, %u, %llu), next = %u\n",
+ le64_to_cpu(eb->h_blkno), i,
el->l_recs[i].e_cpos, el->l_recs[i].e_clusters,
el->l_recs[i].e_blkno, el->l_next_free_rec);
@@ -1095,7 +1096,8 @@
el->l_next_free_rec--;
}
LOG_TRACE_ARGS("extent block %llu, after: record %d: "
- "(%u, %u, %llu), next = %u\n", eb->h_blkno, i,
+ "(%u, %u, %llu), next = %u\n",
+ le64_to_cpu(eb->h_blkno), i,
el->l_recs[i].e_cpos, el->l_recs[i].e_clusters,
el->l_recs[i].e_blkno, el->l_next_free_rec);
Modified: trunk/src/inode.c
===================================================================
--- trunk/src/inode.c 2005-01-11 23:35:16 UTC (rev 1755)
+++ trunk/src/inode.c 2005-01-12 00:52:59 UTC (rev 1756)
@@ -403,12 +403,12 @@
inode->i_nlink = fe->i_links_count;
- if (le32_to_cpu(fe->i_flags) & OCFS2_LOCAL_ALLOC_FL) {
+ if (fe->i_flags & OCFS2_LOCAL_ALLOC_FL) {
OCFS_I(inode)->ip_flags |= OCFS_INODE_BITMAP;
LOG_TRACE_ARGS("local alloc inode: i_ino=%lu\n", inode->i_ino);
- } else if (le32_to_cpu(fe->i_flags) & OCFS2_BITMAP_FL) {
+ } else if (fe->i_flags & OCFS2_BITMAP_FL) {
OCFS_I(inode)->ip_flags |= OCFS_INODE_BITMAP;
- } else if (le32_to_cpu(fe->i_flags) & OCFS2_SUPER_BLOCK_FL) {
+ } else if (fe->i_flags & OCFS2_SUPER_BLOCK_FL) {
LOG_TRACE_ARGS("superblock inode: i_ino=%lu\n", inode->i_ino);
// we can't actually hit this as read_inode can't handle
// superblocks today ;-)
@@ -500,7 +500,7 @@
goto bail;
}
- sysfile = le32_to_cpu(fe->i_flags) & OCFS2_SYSTEM_FL;
+ sysfile = fe->i_flags & OCFS2_SYSTEM_FL;
if (S_ISCHR(fe->i_mode) || S_ISBLK(fe->i_mode))
inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
@@ -1013,7 +1013,6 @@
fe->i_mtime = ocfs_get_seconds(inode->i_mtime);
#warning "do we want to update these here?"
// fe->i_dtime = ocfs_get_seconds(inode->i_dtime);
-// fe->i_generation = inode->i_generation;
status = ocfs_journal_dirty(handle, bh);
if (status < 0)
Modified: trunk/src/journal.c
===================================================================
--- trunk/src/journal.c 2005-01-11 23:35:16 UTC (rev 1755)
+++ trunk/src/journal.c 2005-01-12 00:52:59 UTC (rev 1756)
@@ -1381,8 +1381,8 @@
"%u, name_len = %u, file_type "
"= %u, name='%*s'\n",
(unsigned long long) bh->b_blocknr,
- de->inode,
- de->rec_len,
+ le64_to_cpu(de->inode),
+ le16_to_cpu(de->rec_len),
de->name_len,
de->file_type,
de->name_len,
Modified: trunk/src/localalloc.c
===================================================================
--- trunk/src/localalloc.c 2005-01-11 23:35:16 UTC (rev 1755)
+++ trunk/src/localalloc.c 2005-01-12 00:52:59 UTC (rev 1756)
@@ -182,8 +182,8 @@
LOG_ERROR_ARGS("Local alloc hasn't been recovered!\n"
"found = %u, set = %u, taken = %u, off = %u\n",
num_used,
- alloc->id1.bitmap1.i_used,
- alloc->id1.bitmap1.i_total,
+ le32_to_cpu(alloc->id1.bitmap1.i_used),
+ le32_to_cpu(alloc->id1.bitmap1.i_total),
LOCAL_ALLOC(alloc)->la_bm_off);
status = -EBUSY;
goto bail;
@@ -529,7 +529,7 @@
alloc = (ocfs2_dinode *) osb->local_alloc_bh->b_data;
- OCFS_ASSERT(alloc->id1.bitmap1.i_used ==
+ OCFS_ASSERT(le32_to_cpu(alloc->id1.bitmap1.i_used) ==
ocfs_local_alloc_count_bits(alloc));
free_bits = le32_to_cpu(alloc->id1.bitmap1.i_total) -
@@ -603,7 +603,8 @@
while(bits_wanted--)
ocfs2_set_bit(start++, bitmap);
- alloc->id1.bitmap1.i_used += *num_bits;
+ alloc->id1.bitmap1.i_used = cpu_to_le32(*num_bits +
+ le32_to_cpu(alloc->id1.bitmap1.i_used));
status = ocfs_journal_dirty(handle, osb->local_alloc_bh);
if (status < 0) {
@@ -658,7 +659,7 @@
numfound = bitoff = startoff = 0;
lastzero = -1;
- left = alloc->id1.bitmap1.i_total;
+ left = le32_to_cpu(alloc->id1.bitmap1.i_total);
while ((bitoff = ocfs2_find_next_zero_bit(bitmap, left, startoff)) != -1) {
if (bitoff == left) {
/* LOG_TRACE_ARGS("bitoff (%d) == left", bitoff); */
@@ -755,9 +756,9 @@
void *bitmap;
LOG_ENTRY_ARGS("total = %u, COUNT = %u, used = %u\n",
- alloc->id1.bitmap1.i_total,
+ le32_to_cpu(alloc->id1.bitmap1.i_total),
ocfs_local_alloc_count_bits(alloc),
- alloc->id1.bitmap1.i_used);
+ le32_to_cpu(alloc->id1.bitmap1.i_used));
if (!alloc->id1.bitmap1.i_total) {
LOG_TRACE_STR("nothing to sync!");
@@ -773,7 +774,7 @@
LOCAL_ALLOC(alloc)->la_bm_off);
bitmap = LOCAL_ALLOC(alloc)->la_bitmap;
start = count = bit_off = 0;
- left = alloc->id1.bitmap1.i_total;
+ left = le32_to_cpu(alloc->id1.bitmap1.i_total);
while ((bit_off = ocfs2_find_next_zero_bit(bitmap, left, start))
!= -1) {
@@ -901,7 +902,7 @@
LOG_TRACE_STR("New window allocated:");
LOG_TRACE_ARGS("window la_bm_off = %u\n",
LOCAL_ALLOC(alloc)->la_bm_off);
- LOG_TRACE_ARGS("window bits = %u\n", alloc->id1.bitmap1.i_total);
+ LOG_TRACE_ARGS("window bits = %u\n", le32_to_cpu(alloc->id1.bitmap1.i_total));
bail:
LOG_EXIT_STATUS(status);
Modified: trunk/src/namei.c
===================================================================
--- trunk/src/namei.c 2005-01-11 23:35:16 UTC (rev 1755)
+++ trunk/src/namei.c 2005-01-12 00:52:59 UTC (rev 1756)
@@ -505,7 +505,7 @@
fe->i_generation = cpu_to_le32(inode->i_generation);
fe->i_fs_generation = cpu_to_le32(osb->fs_generation);
fe->i_blkno = fe_blkno;
- fe->i_suballoc_bit = suballoc_bit;
+ fe->i_suballoc_bit = cpu_to_le16(suballoc_bit);
fe->i_suballoc_node = osb->slot_num;
fe->i_uid = current->fsuid;
if (dir->i_mode & S_ISGID) {
@@ -516,7 +516,7 @@
fe->i_gid = current->fsgid;
fe->i_mode = mode;
if (S_ISCHR (mode) || S_ISBLK (mode))
- fe->id1.dev1.i_rdev = huge_encode_dev(dev);
+ fe->id1.dev1.i_rdev = cpu_to_le64(huge_encode_dev(dev));
if (S_ISLNK (mode) || S_ISDIR (mode) || S_ISREG (mode))
atomic_set(GET_INODE_CLEAN_SEQ(inode), atomic_read(&osb->clean_buffer_seq));
Modified: trunk/src/suballoc.c
===================================================================
--- trunk/src/suballoc.c 2005-01-11 23:35:16 UTC (rev 1755)
+++ trunk/src/suballoc.c 2005-01-12 00:52:59 UTC (rev 1756)
@@ -276,7 +276,7 @@
ocfs2_chain_list *cl;
ocfs2_alloc_context *ac = NULL;
ocfs_journal_handle *handle = NULL;
- u32 bit_off, num_bits;
+ u32 bit_off, num_bits, tmp;
u16 alloc_rec;
u64 bg_blkno;
struct buffer_head *bg_bh = NULL;
@@ -372,8 +372,14 @@
if (cl->cl_next_free_rec < cl->cl_count)
cl->cl_next_free_rec++;
- fe->id1.bitmap1.i_used += (bg->bg_bits - bg->bg_free_bits_count);
- fe->id1.bitmap1.i_total += bg->bg_bits;
+ tmp = le32_to_cpu(fe->id1.bitmap1.i_used);
+ tmp += bg->bg_bits - bg->bg_free_bits_count;
+ fe->id1.bitmap1.i_used = cpu_to_le32(tmp);
+
+ tmp = le32_to_cpu(fe->id1.bitmap1.i_total);
+ tmp += bg->bg_bits;
+ fe->id1.bitmap1.i_total = cpu_to_le32(tmp);
+
fe->i_clusters += cl->cl_cpg;
status = ocfs_journal_dirty(handle, bh);
@@ -970,6 +976,7 @@
{
int status;
u16 chain, tmp_bits;
+ u32 tmp_used;
u64 next_group;
ocfs_journal_handle *handle = ac->ac_handle;
struct inode *alloc_inode = ac->ac_inode;
@@ -1068,7 +1075,8 @@
goto bail;
}
- fe->id1.bitmap1.i_used += *num_bits;
+ tmp_used = le32_to_cpu(fe->id1.bitmap1.i_used);
+ fe->id1.bitmap1.i_used = cpu_to_le32(*num_bits + tmp_used);
cl->cl_recs[chain].c_free -= *num_bits;
status = ocfs_journal_dirty(handle,
@@ -1125,7 +1133,8 @@
fe = (ocfs2_dinode *) ac->ac_bh->b_data;
OCFS_ASSERT_RO(IS_VALID_FILE_ENTRY(fe));
- OCFS_ASSERT_RO(fe->id1.bitmap1.i_used < fe->id1.bitmap1.i_total);
+ OCFS_ASSERT_RO(le32_to_cpu(fe->id1.bitmap1.i_used) <
+ le32_to_cpu(fe->id1.bitmap1.i_total));
cl = (ocfs2_chain_list *) &fe->id2.i_chain;
@@ -1440,6 +1449,7 @@
unsigned int count)
{
int status = 0;
+ u32 tmp_used;
ocfs_super *osb = OCFS2_SB(alloc_inode->i_sb);
ocfs2_dinode *fe = (ocfs2_dinode *) alloc_bh->b_data;
ocfs2_chain_list *cl = &fe->id2.i_chain;
@@ -1484,7 +1494,8 @@
}
cl->cl_recs[group->bg_chain].c_free += count;
- fe->id1.bitmap1.i_used -= count;
+ tmp_used = le32_to_cpu(fe->id1.bitmap1.i_used);
+ fe->id1.bitmap1.i_used = cpu_to_le32(tmp_used - count);
status = ocfs_journal_dirty(handle, alloc_bh);
if (status < 0) {
@@ -1512,7 +1523,7 @@
struct buffer_head *inode_alloc_bh,
ocfs2_dinode *di)
{
- u64 blk = le64_to_cpu(di->i_blkno);
+ u64 blk = di->i_blkno;
u16 bit = le16_to_cpu(di->i_suballoc_bit);
u64 bg_blkno = ocfs_which_suballoc_group(blk, bit);
@@ -1578,7 +1589,7 @@
printk("bg_bits: %u\n", bg->bg_bits);
printk("bg_free_bits_count: %u\n", bg->bg_free_bits_count);
printk("bg_chain: %u\n", bg->bg_chain);
- printk("bg_generation: %u\n", bg->bg_generation);
+ printk("bg_generation: %u\n", le32_to_cpu(bg->bg_generation));
printk("bg_next_group: %llu\n", bg->bg_next_group);
printk("bg_parent_dinode: %llu\n", bg->bg_parent_dinode);
printk("bg_blkno: %llu\n", bg->bg_blkno);
@@ -1592,9 +1603,12 @@
printk("i_signature: %s\n", fe->i_signature);
printk("i_size: %llu\n", fe->i_size);
printk("i_clusters: %u\n", fe->i_clusters);
- printk("i_generation: %u\n", fe->i_generation);
- printk("id1.bitmap1.i_used: %u\n", fe->id1.bitmap1.i_used);
- printk("id1.bitmap1.i_total: %u\n", fe->id1.bitmap1.i_total);
+ printk("i_generation: %u\n",
+ le32_to_cpu(fe->i_generation));
+ printk("id1.bitmap1.i_used: %u\n",
+ le32_to_cpu(fe->id1.bitmap1.i_used));
+ printk("id1.bitmap1.i_total: %u\n",
+ le32_to_cpu(fe->id1.bitmap1.i_total));
printk("id2.i_chain.cl_cpg: %u\n", fe->id2.i_chain.cl_cpg);
printk("id2.i_chain.cl_bpc: %u\n", fe->id2.i_chain.cl_bpc);
printk("id2.i_chain.cl_count: %u\n", fe->id2.i_chain.cl_count);
Modified: trunk/src/super.c
===================================================================
--- trunk/src/super.c 2005-01-11 23:35:16 UTC (rev 1755)
+++ trunk/src/super.c 2005-01-12 00:52:59 UTC (rev 1756)
@@ -1191,20 +1191,6 @@
osb->have_local_alloc = 0;
osb->local_alloc_bh = NULL;
- /* not using any of these sb fields yet */
-#if 0
-di->i_ctime = cpu_to_le64(format_time); // use this as s_wtime (write time)
-di->i_mtime = cpu_to_le64(format_time); // use this as s_mtime (mount time)
-di->i_blkno = cpu_to_le64(super_off >> blocksize_bits);
-di->id2.i_super.s_mnt_count = 0;
-di->id2.i_super.s_max_mnt_count = cpu_to_le16(OCFS2_DFL_MAX_MNT_COUNT);
-di->id2.i_super.s_state = 0;
-di->id2.i_super.s_errors = 0;
-di->id2.i_super.s_lastcheck = cpu_to_le64(format_time);
-di->id2.i_super.s_checkinterval = cpu_to_le32(OCFS2_DFL_CHECKINTERVAL);
-di->id2.i_super.s_creator_os = cpu_to_le32(OCFS2_OS_LINUX);
-#endif
-
di = (ocfs2_dinode *) bh->b_data;
/* get some pseudo constants for clustersize bits */
@@ -1213,7 +1199,7 @@
printk("clusterbits=%d\n", osb->s_clustersize_bits);
OCFS_ASSERT(osb->s_clustersize_bits);
- if (ocfs2_clusters_to_blocks(osb->sb, le32_to_cpu(di->i_clusters) - 1)
+ if (ocfs2_clusters_to_blocks(osb->sb, di->i_clusters - 1)
> (u32)~0UL) {
LOG_ERROR_ARGS("Volume might try to write to blocks beyond "
"what jbd can address in 32 bits.\n");
@@ -1286,7 +1272,7 @@
}
di = (ocfs2_dinode *) bitmap_bh->b_data;
- osb->bitmap_cpg = le16_to_cpu(di->id2.i_chain.cl_cpg);
+ osb->bitmap_cpg = di->id2.i_chain.cl_cpg;
osb->num_clusters = le32_to_cpu(di->id1.bitmap1.i_total);
brelse(bitmap_bh);
printk("cluster bitmap inode: %llu, clusters per group: %u\n",
@@ -1352,10 +1338,10 @@
le16_to_cpu(di->id2.i_super.s_minor_rev_level),
OCFS2_MAJOR_REV_LEVEL,
OCFS2_MINOR_REV_LEVEL);
- } else if (bh->b_blocknr != le64_to_cpu(di->i_blkno)) {
+ } else if (bh->b_blocknr != di->i_blkno) {
LOG_ERROR_ARGS("bad block number on superblock: "
"found %llu, should be %llu\n",
- le64_to_cpu(di->i_blkno),
+ di->i_blkno,
(unsigned long long)bh->b_blocknr);
} else if (le32_to_cpu(di->id2.i_super.s_clustersize_bits) < 12 ||
le32_to_cpu(di->id2.i_super.s_clustersize_bits) > 20) {
More information about the Ocfs2-commits
mailing list