[Ocfs2-commits] jlbec commits r1052 - branches/format-changes/src
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Fri Jun 11 06:22:47 CDT 2004
Author: jlbec
Date: 2004-06-11 05:22:45 -0500 (Fri, 11 Jun 2004)
New Revision: 1052
Modified:
branches/format-changes/src/alloc.c
branches/format-changes/src/buffer_head_io.c
branches/format-changes/src/dir.c
branches/format-changes/src/dir.h
branches/format-changes/src/extmap.c
branches/format-changes/src/file.c
branches/format-changes/src/heartbeat.c
branches/format-changes/src/inode.c
branches/format-changes/src/namei.c
branches/format-changes/src/ocfs.h
branches/format-changes/src/ocfs_buffer_head.h
branches/format-changes/src/super.c
branches/format-changes/src/sysfile.c
branches/format-changes/src/vote.h
Log:
o Make the tail of the dinode be an ocfs2_extent_list.
o Clean up some code so that extent_list handling is generic
o Remove some useless ocfs_mallocs() where the code already memcpy()
or memset()s.
o Make the signatures change.
o This should be the OCFS2 disk format for inodes, extent blocks, and
disk locks. Baring any major oopsies, it will be.
Modified: branches/format-changes/src/alloc.c
===================================================================
--- branches/format-changes/src/alloc.c 2004-06-11 09:42:10 UTC (rev 1051)
+++ branches/format-changes/src/alloc.c 2004-06-11 10:22:45 UTC (rev 1052)
@@ -73,8 +73,10 @@
return(status);
}
-static int ocfs_kill_this_tree(ocfs_super *osb, struct buffer_head *extent_grp_bh,
- ocfs_journal_handle *handle, struct inode *inode);
+static int ocfs_kill_this_tree(ocfs_super *osb,
+ struct buffer_head *extent_grp_bh,
+ ocfs_journal_handle *handle,
+ struct inode *inode);
static int ocfs_allocate_new_data_node(ocfs_super *osb,
ocfs2_dinode *fe,
u32 new_clusters,
@@ -427,7 +429,7 @@
}
bm_lock = OCFS_BH_GET_DATA_WRITE(globalbh);
- bm_lock->u.bitinfo.used_bits = ocfs_count_bits(&osb->cluster_bitmap);
+ bm_lock->u.i_bitinfo.b_used = ocfs_count_bits(&osb->cluster_bitmap);
OCFS_BH_PUT_DATA(globalbh);
status = ocfs_journal_dirty(handle, globalbh);
@@ -653,15 +655,15 @@
__u8 *buff = NULL;
__u32 k, i;
__u32 depth;
- __u32 allocSize;
+ int allocSize;
u64 parent_blk;
__u64 physicalOffset;
u64 phys_blkno;
__u64 fileOffset = 0;
- __u64 numSectorsAlloc = 0;
+ int new_blocks = 0;
ocfs2_extent_block *eb = NULL;
- ocfs2_extent_list *el = NULL;
- struct buffer_head **header_bhs = NULL;
+ ocfs2_extent_list *el1, *el2 = NULL;
+ struct buffer_head **eb_bhs = NULL;
struct buffer_head *bh = NULL;
int bh_locked = 0;
int size;
@@ -678,91 +680,85 @@
}
eb = OCFS_BH_GET_DATA_WRITE(eb_bh);
- el = &eb->h_list;
+ el1 = &eb->h_list;
bh_locked = 1;
}
- if (eb != NULL) {
- depth = el->l_tree_depth;
+ else
+ el1 = &fe->u.i_list;
+
+ depth = el1->l_tree_depth;
+
+ if (eb != NULL)
parent_blk = eb->h_blkno;
- } else {
- depth = fe->i_tree_depth;
+ else
parent_blk = fe->i_blkno;
- }
- numSectorsAlloc = depth + 1;
- allocSize = (numSectorsAlloc * osb->sect_size);
+ new_blocks = depth + 1;
+ allocSize = new_blocks << osb->sb->s_blocksize_bits;
/* allocate contiguous blocks on disk */
- status = ocfs_alloc_node_block (osb, allocSize, &physicalOffset,
- &fileOffset, osb->node_num,
- DISK_ALLOC_EXTENT_NODE, handle);
+ status = ocfs_alloc_node_block(osb, allocSize, &physicalOffset,
+ &fileOffset, osb->node_num,
+ DISK_ALLOC_EXTENT_NODE, handle);
if (status < 0) {
LOG_ERROR_STATUS (status);
goto finally;
}
phys_blkno = physicalOffset >> osb->sb->s_blocksize_bits;
- size = sizeof(struct buffer_head *) * numSectorsAlloc;
- header_bhs = ocfs_malloc(size);
- if (header_bhs == NULL) {
+ size = sizeof(struct buffer_head *) * new_blocks;
+ eb_bhs = kmalloc(size, GFP_KERNEL);
+ if (eb_bhs == NULL) {
status = -ENOMEM;
LOG_ERROR_STATUS(status);
goto finally;
}
- memset(header_bhs, 0, size);
+ memset(eb_bhs, 0, size);
- status = ocfs_read_bhs(osb, physicalOffset, numSectorsAlloc * osb->sect_size, header_bhs, OCFS_BH_CACHED, inode);
+ status = ocfs_read_bhs(osb, physicalOffset,
+ (u64)new_blocks << osb->sb->s_blocksize_bits,
+ eb_bhs, OCFS_BH_CACHED, inode);
if (status < 0) {
LOG_ERROR_STATUS (status);
goto finally;
}
/* zero them all out */
- for(i = 0; i < numSectorsAlloc; i++) {
- status = ocfs_journal_access(handle, header_bhs[i],
+ for(i = 0; i < new_blocks; i++) {
+ status = ocfs_journal_access(handle, eb_bhs[i],
OCFS_JOURNAL_ACCESS_CREATE);
if (status < 0) {
LOG_ERROR_STATUS(status);
goto finally;
}
- buff = OCFS_BH_GET_DATA_WRITE(header_bhs[i]);
- memset(buff, 0, osb->sect_size);
- set_buffer_uptodate(header_bhs[i]);
- OCFS_BH_PUT_DATA(header_bhs[i]);
+ buff = OCFS_BH_GET_DATA_WRITE(eb_bhs[i]);
+ memset(buff, 0, osb->sb->s_blocksize);
+ set_buffer_uptodate(eb_bhs[i]);
+ OCFS_BH_PUT_DATA(eb_bhs[i]);
}
- if (eb != NULL) {
- k = el->l_next_free_rec;
- el->l_recs[k].e_cpos =
- fe->i_clusters;
- el->l_recs[k].e_clusters = new_clusters;
- el->l_recs[k].e_blkno = phys_blkno;
- el->l_next_free_rec++;
- } else {
- k = fe->i_next_free_rec;
- fe->extents[k].e_cpos = fe->i_clusters;
- fe->extents[k].e_clusters = new_clusters;
- fe->extents[k].e_blkno = phys_blkno;
- fe->i_next_free_rec++;
- }
+ k = el1->l_next_free_rec;
+ el1->l_recs[k].e_cpos = fe->i_clusters;
+ el1->l_recs[k].e_clusters = new_clusters;
+ el1->l_recs[k].e_blkno = phys_blkno;
+ el1->l_next_free_rec++;
/* Fill in all the headers and the leaf */
for (i = 0; i <= depth; i++) {
- ocfs2_extent_block *ext;
- ocfs2_extent_list *el2;
+ ocfs2_extent_block *eb;
- ext = OCFS_BH_GET_DATA_WRITE(header_bhs[i]);
+ eb = OCFS_BH_GET_DATA_WRITE(eb_bhs[i]);
- ext->h_parent_blk = parent_blk;
- ext->h_suballoc_blkno =
+ eb->h_parent_blk = parent_blk;
+ eb->h_suballoc_blkno =
(fileOffset >> osb->sb->s_blocksize_bits) + i;
- ext->h_suballoc_node = osb->node_num;
- ext->h_blkno =
+ eb->h_suballoc_node = osb->node_num;
+ eb->h_blkno =
(physicalOffset >> osb->sb->s_blocksize_bits) + i;
- strcpy(ext->signature, OCFS_EXTENT_BLOCK_SIGNATURE);
+ strcpy(eb->h_signature, OCFS2_EXTENT_BLOCK_SIGNATURE);
- el2 = &ext->h_list;
+ el2 = &eb->h_list;
el2->l_count = ocfs_extent_recs_per_eb(osb->sb);
el2->l_next_free_rec = 1;
el2->l_recs[0].e_cpos = fe->i_clusters;
@@ -776,15 +772,15 @@
/* fill in the leaf */
el2->l_recs[0].e_blkno = phys_blkno;
*new_eb_blkno = fe->i_last_eb_blk =
- ext->h_blkno;
+ eb->h_blkno;
}
- parent_blk = ext->h_blkno;
- OCFS_BH_PUT_DATA(header_bhs[i]);
+ parent_blk = eb->h_blkno;
+ OCFS_BH_PUT_DATA(eb_bhs[i]);
}
- for(i = 0; i < numSectorsAlloc; i++) {
- status = ocfs_journal_dirty(handle, header_bhs[i]);
+ for(i = 0; i < new_blocks; i++) {
+ status = ocfs_journal_dirty(handle, eb_bhs[i]);
if (status < 0) {
LOG_ERROR_STATUS (status);
goto finally;
@@ -794,13 +790,14 @@
if (eb != NULL) {
/* both needed below in for loop */
u64 tmp_blk = eb->h_parent_blk;
- int tree_depth = el->l_tree_depth;
+ int tree_depth = el1->l_tree_depth;
OCFS_BH_PUT_DATA(eb_bh);
bh_locked = 0;
eb = NULL;
- el = NULL;
+ el1 = &fe->u.i_list;
+
status = ocfs_journal_dirty(handle, eb_bh);
if (status < 0) {
LOG_ERROR_STATUS (status);
@@ -808,9 +805,9 @@
}
/* gotta fix up his parent extents now. We totally
- * reuse the eb and el variables now as they're no
+ * reuse the eb and el2 variables now as they're no
* longer needed for their original purpose. */
- for (i = tree_depth + 1; i < fe->i_tree_depth; i++) {
+ for (i = tree_depth + 1; i < el1->l_tree_depth; i++) {
bh = NULL;
status = ocfs_read_bh(osb,
tmp_blk << osb->sb->s_blocksize_bits,
@@ -834,18 +831,17 @@
LOG_ERROR_STATUS (status = -EINVAL);
goto finally;
}
- el = &eb->h_list;
+ el2 = &eb->h_list;
- if (el->l_next_free_rec == 0) {
+ if (el2->l_next_free_rec == 0) {
OCFS_BH_PUT_DATA(bh);
brelse(bh);
LOG_ERROR_STATUS (status = -EFAIL);
goto finally;
}
- k = el->l_next_free_rec - 1;
- el->l_recs[k].e_clusters +=
- new_clusters;
+ k = el2->l_next_free_rec - 1;
+ el2->l_recs[k].e_clusters += new_clusters;
tmp_blk = eb->h_parent_blk;
OCFS_BH_PUT_DATA(bh);
@@ -859,17 +855,17 @@
brelse(bh);
}
- k = fe->i_next_free_rec - 1;
- fe->extents[k].e_clusters += new_clusters;
+ k = el1->l_next_free_rec - 1;
+ el1->l_recs[k].e_clusters += new_clusters;
}
finally:
if (bh_locked)
OCFS_BH_PUT_DATA(eb_bh);
- if (header_bhs) {
- for (i = 0; i < numSectorsAlloc; i++)
- if (header_bhs[i])
- brelse(header_bhs[i]);
- kfree(header_bhs);
+ if (eb_bhs) {
+ for (i = 0; i < new_blocks; i++)
+ if (eb_bhs[i])
+ brelse(eb_bhs[i]);
+ kfree(eb_bhs);
}
LOG_EXIT_STATUS (status);
return status;
@@ -878,7 +874,7 @@
/* ocfs_grow_extent_tree()
*
*/
-static int ocfs_grow_extent_tree(ocfs_super * osb,
+static int ocfs_grow_extent_tree(ocfs_super *osb,
struct buffer_head *fe_bh,
ocfs_journal_handle *handle,
u64 blkno, u32 new_clusters,
@@ -888,36 +884,35 @@
__s32 k, i;
ocfs2_extent_block *eb1 = NULL;
ocfs2_extent_block *eb2 = NULL;
- ocfs2_extent_list *el;
+ ocfs2_extent_list *ebl, *fel;
__u64 physicalOffset;
__u64 fileOffset = 0;
u64 phys_blkno, parent_blk, last_eb_blkno;
- __u32 AllocSize;
u64 new_parent_blk = 0;
struct buffer_head **bhs = NULL;
int numbhs = 0;
void *buf;
- ocfs2_dinode * fe = NULL, *real_fe = NULL;
+ ocfs2_dinode *fe = NULL, *real_fe = NULL;
LOG_ENTRY_ARGS("(0x%p, 0x%p, %llu, %u\n", osb, fe, blkno,
new_clusters);
/* too complicated to deal with both reads and writes to the structure */
/* just save off a copy and replace the fe_bh with the new data at the end */
- fe = ocfs_allocate_file_entry();
+ fe = kmalloc(osb->sb->s_blocksize, GFP_NOFS);
if (fe == NULL) {
LOG_ERROR_STATUS (status = -ENOMEM);
goto finally;
}
real_fe = OCFS_BH_GET_DATA_READ(fe_bh);
- memcpy(fe, real_fe, osb->sect_size);
+ memcpy(fe, real_fe, osb->sb->s_blocksize);
OCFS_BH_PUT_DATA(fe_bh);
real_fe = NULL;
- AllocSize = ((fe->i_tree_depth + 2) * osb->sect_size);
+ fel = &fe->u.i_list;
+ numbhs = fel->l_tree_depth + 2;
- numbhs = fe->i_tree_depth + 2;
- bhs = ocfs_malloc(numbhs * sizeof(*bhs));
+ bhs = kmalloc(numbhs * sizeof(*bhs), GFP_KERNEL);
if (bhs == NULL) {
status = -ENOMEM;
LOG_ERROR_STATUS(status = -ENOMEM);
@@ -927,9 +922,11 @@
/* Allocate the space from the Extent file. This function should */
/* return contigous disk blocks requested. */
- status = ocfs_alloc_node_block (osb, AllocSize, &physicalOffset,
- &fileOffset, osb->node_num,
- DISK_ALLOC_EXTENT_NODE, handle);
+ status = ocfs_alloc_node_block(osb,
+ numbhs << osb->sb->s_blocksize_bits,
+ &physicalOffset, &fileOffset,
+ osb->node_num,
+ DISK_ALLOC_EXTENT_NODE, handle);
if (status < 0) {
LOG_ERROR_STATUS (status);
goto finally;
@@ -958,11 +955,11 @@
eb1 = OCFS_BH_GET_DATA_WRITE(bhs[0]);
/* Copy the File Entry information in to the newly allocated sector */
- for (k = 0; k < fe->i_records; k++) {
- eb1->h_list.l_recs[k].e_cpos = fe->extents[k].e_cpos;
- eb1->h_list.l_recs[k].e_clusters =
- fe->extents[k].e_clusters;
- eb1->h_list.l_recs[k].e_blkno = fe->extents[k].e_blkno;
+ ebl = &eb1->h_list;
+ for (k = 0; k < fel->l_count; k++) {
+ ebl->l_recs[k].e_cpos = fel->l_recs[k].e_cpos;
+ ebl->l_recs[k].e_clusters = fel->l_recs[k].e_clusters;
+ ebl->l_recs[k].e_blkno = fel->l_recs[k].e_blkno;
}
last_eb_blkno = fe->i_last_eb_blk;
@@ -973,9 +970,9 @@
fileOffset >> osb->sb->s_blocksize_bits;
eb1->h_suballoc_node = osb->node_num;
eb1->h_next_leaf_blk = 0;
- fe->i_tree_depth++;
+ fel->l_tree_depth++;
- LOG_TRACE_ARGS ("Granularity is: %d\n", fe->i_tree_depth);
+ LOG_TRACE_ARGS ("Tree depth is: %d\n", fel->l_tree_depth);
OCFS_BH_PUT_DATA(bhs[0]);
@@ -984,20 +981,23 @@
parent_blk = fe->i_blkno;
- for (i = 0; i < fe->i_tree_depth; i++) {
+ for (i = 0; i < fel->l_tree_depth; i++) {
eb2 = OCFS_BH_GET_DATA_WRITE(bhs[i]);
- el = &eb2->h_list;
+ ebl = &eb2->h_list;
- el->l_tree_depth = (fe->i_tree_depth - 1) - i;
- el->l_count = ocfs_extent_recs_per_eb(osb->sb);
+ ebl->l_tree_depth = (fel->l_tree_depth - 1) - i;
+ ebl->l_count = ocfs_extent_recs_per_eb(osb->sb);
- strcpy(eb2->signature, OCFS_EXTENT_BLOCK_SIGNATURE);
+ strcpy(eb2->h_signature, OCFS2_EXTENT_BLOCK_SIGNATURE);
if (i == 0) {
- el->l_recs[fe->i_records].e_blkno = phys_blkno + 1;
- el->l_recs[fe->i_records].e_cpos = fe->i_clusters;
- el->l_recs[fe->i_records].e_clusters = new_clusters;
- el->l_next_free_rec = fe->i_records + 1;
+ ebl->l_recs[fel->l_count].e_blkno =
+ phys_blkno + 1;
+ ebl->l_recs[fel->l_count].e_cpos =
+ fe->i_clusters;
+ ebl->l_recs[fel->l_count].e_clusters =
+ new_clusters;
+ ebl->l_next_free_rec = fel->l_count + 1;
eb2->h_blkno =
physicalOffset >> osb->sb->s_blocksize_bits;
@@ -1005,10 +1005,10 @@
parent_blk = last_eb_blkno = eb2->h_blkno;
} else {
- el->l_recs[0].e_blkno = phys_blkno + (i + 1);
- el->l_recs[0].e_cpos = fe->i_clusters;
- el->l_recs[0].e_clusters = new_clusters;
- el->l_next_free_rec = 1;
+ ebl->l_recs[0].e_blkno = phys_blkno + (i + 1);
+ ebl->l_recs[0].e_cpos = fe->i_clusters;
+ ebl->l_recs[0].e_clusters = new_clusters;
+ ebl->l_next_free_rec = 1;
eb2->h_suballoc_blkno =
(fileOffset >> osb->sb->s_blocksize_bits) + i;
@@ -1023,38 +1023,38 @@
}
/* Update the Data Segment, which is the last one in our array */
- eb1 = OCFS_BH_GET_DATA_WRITE(bhs[fe->i_tree_depth]);
- el = &eb1->h_list;
+ eb1 = OCFS_BH_GET_DATA_WRITE(bhs[fel->l_tree_depth]);
+ ebl = &eb1->h_list;
- i = (fe->i_tree_depth) ? 0 : fe->i_records;
+ i = (fel->l_tree_depth) ? 0 : fel->l_count;
- LOG_TRACE_ARGS ("EntryAvailable is: %d\n", el->l_next_free_rec);
+ LOG_TRACE_ARGS ("EntryAvailable is: %d\n", ebl->l_next_free_rec);
/* For the time being we are assuming that the newly allocated Extent */
/* will have one more entry to accomodate the latest allocation */
- strcpy(eb1->signature, OCFS_EXTENT_BLOCK_SIGNATURE);
- el->l_tree_depth = -1;
- el->l_count = ocfs_extent_recs_per_eb(osb->sb);
+ strcpy(eb1->h_signature, OCFS2_EXTENT_BLOCK_SIGNATURE);
+ ebl->l_tree_depth = -1;
+ ebl->l_count = ocfs_extent_recs_per_eb(osb->sb);
- el->l_recs[i].e_cpos = fe->i_clusters;
- el->l_recs[i].e_clusters = new_clusters;
- el->l_recs[i].e_blkno = blkno;
- el->l_next_free_rec = i + 1;
+ ebl->l_recs[i].e_cpos = fe->i_clusters;
+ ebl->l_recs[i].e_clusters = new_clusters;
+ ebl->l_recs[i].e_blkno = blkno;
+ ebl->l_next_free_rec = i + 1;
eb1->h_suballoc_blkno =
(fileOffset >> osb->sb->s_blocksize_bits) +
- fe->i_tree_depth;
+ fel->l_tree_depth;
eb1->h_suballoc_node = osb->node_num;
eb1->h_blkno =
(physicalOffset >> osb->sb->s_blocksize_bits) +
- fe->i_tree_depth;
+ fel->l_tree_depth;
eb1->h_parent_blk = parent_blk;
eb1->h_next_leaf_blk = 0;
parent_blk = last_eb_blkno = eb1->h_blkno;
- OCFS_BH_PUT_DATA(bhs[fe->i_tree_depth]);
+ OCFS_BH_PUT_DATA(bhs[fel->l_tree_depth]);
/* This needs to be a sync write OR journalled to be safe. */
status = ocfs_write_bhs(osb, bhs, numbhs, 0, inode);
@@ -1104,14 +1104,14 @@
}
/* Update the uphdrptr of the extents pointed to by fe */
- if (fe->i_tree_depth > 0) {
+ if (fel->l_tree_depth > 0) {
int i;
struct buffer_head *bh = NULL;
status = 0;
- for (i = 0; i < fe->i_records; ++i) {
+ for (i = 0; i < fel->l_count; ++i) {
status = ocfs_read_bh(osb,
- fe->extents[i].e_blkno << osb->sb->s_blocksize_bits,
+ fel->l_recs[i].e_blkno << osb->sb->s_blocksize_bits,
&bh, OCFS_BH_COND_CACHED,
inode);
if (status < 0) {
@@ -1140,30 +1140,31 @@
}
/* Clear all the extent information from File Entry */
- for (i = 0; i < fe->i_records; i++) {
- fe->extents[i].e_cpos = 0;
- fe->extents[i].e_clusters = 0;
- fe->extents[i].e_blkno = 0;
+ for (i = 0; i < fel->l_count; i++) {
+ fel->l_recs[i].e_cpos = 0;
+ fel->l_recs[i].e_clusters = 0;
+ fel->l_recs[i].e_blkno = 0;
}
/* Update the File Entry Extent */
LOG_TRACE_ARGS("fe->i_clusters = %u\n", fe->i_clusters);
- fe->extents[0].e_cpos = 0; /* FIXME: not needed */
- fe->extents[0].e_clusters = fe->i_clusters + new_clusters;
- fe->extents[0].e_blkno = phys_blkno;
+ fel->l_recs[0].e_cpos = 0; /* FIXME: not needed */
+ fel->l_recs[0].e_clusters = fe->i_clusters + new_clusters;
+ fel->l_recs[0].e_blkno = phys_blkno;
+ fel->l_next_free_rec = 1;
fe->i_last_eb_blk = last_eb_blkno;
- fe->i_next_free_rec = 1;
finally:
if (fe) {
real_fe = OCFS_BH_GET_DATA_WRITE(fe_bh);
- memcpy(real_fe, fe, osb->sect_size);
+ memcpy(real_fe, fe, osb->sb->s_blocksize);
OCFS_BH_PUT_DATA(fe_bh);
real_fe = NULL;
- ocfs_release_file_entry(fe);
+ kfree(fe);
}
+#warning Leaking bhs here
LOG_EXIT_STATUS (status);
return (status);
} /* ocfs_grow_extent_tree */
@@ -1182,7 +1183,7 @@
int IncreaseTreeDepth = 0;
int k = 0, i;
ocfs2_extent_block *eb1 = NULL, *eb2 = NULL;
- ocfs2_extent_list *el1 = NULL, *el2 = NULL;
+ ocfs2_extent_list *fel, *el1 = NULL, *el2 = NULL;
struct buffer_head *eb1_bh = NULL, *eb2_bh = NULL;
int UpdateParent = 0;
u64 parent_blk, new_eb_blkno;
@@ -1191,40 +1192,40 @@
LOG_ENTRY_ARGS("(blkno=%llu, new_clusters=%u)\n", blkno, new_clusters);
fe = OCFS_BH_GET_DATA_WRITE(fe_bh);
- OCFS_ASSERT (fe);
+ OCFS_ASSERT(fe);
if (!IS_VALID_FILE_ENTRY (fe)) {
LOG_ERROR_STATUS(status = -EINVAL);
goto finally;
}
+ fel = &fe->u.i_list;
- if (fe->i_tree_depth < 0) {
+ if (fel->l_tree_depth < 0) {
LOG_TRACE_STR("Using local extents");
/* We are still using the local extents of File Entry */
- if (fe->i_next_free_rec > fe->i_records) {
+ if (fel->l_next_free_rec > fel->l_count) {
LOG_ERROR_STATUS(status = -EINVAL);
goto finally;
}
- k = fe->i_next_free_rec - 1;
+ k = fel->l_next_free_rec - 1;
if (k >= 0 &&
- ocfs_extent_contig(inode, &fe->extents[k], blkno)) {
+ ocfs_extent_contig(inode, &fel->l_recs[k], blkno)) {
/* See if we can merge the extents and just increase the length */
LOG_TRACE_ARGS ("Using local extent for extent Entry = %u\n", k);
- fe->extents[k].e_clusters += new_clusters;
+ fel->l_recs[k].e_clusters += new_clusters;
goto finally;
}
/* We cannot merge try to give him the next extent */
- k = fe->i_next_free_rec;
- if (k != fe->i_records) {
+ k = fel->l_next_free_rec;
+ if (k != fel->l_count) {
/* file_off for the new extent will be equal
* to the previous allocation size of file */
- fe->extents[k].e_cpos =
- fe->i_clusters;
- fe->extents[k].e_clusters = new_clusters;
- fe->extents[k].e_blkno = blkno;
- fe->i_next_free_rec++;
+ fel->l_recs[k].e_cpos = fe->i_clusters;
+ fel->l_recs[k].e_clusters = new_clusters;
+ fel->l_recs[k].e_blkno = blkno;
+ fel->l_next_free_rec++;
goto finally;
}
/* We have no more room in the fe, must increase
@@ -1235,8 +1236,9 @@
LOG_TRACE_STR("Using NON-local extents");
/*** Nonlocal Extents ***/
- if (fe->i_tree_depth > 3)
- LOG_ERROR_ARGS ("tree_depth=%d", fe->i_tree_depth);
+ /* This is now less likely with OCFSv2 extent lists */
+ if (fel->l_tree_depth > 3)
+ LOG_ERROR_ARGS ("tree_depth=%d", fel->l_tree_depth);
/* This File is no longer using Local Extents */
IncreaseTreeDepth = 0;
@@ -1259,7 +1261,8 @@
k = el1->l_next_free_rec - 1;
LOG_TRACE_ARGS ("Using local extent for extent Entry = %u\n", k);
if (el1->l_next_free_rec < 1)
- LOG_ERROR_ARGS ("l_next_free_rec=%d", el1->l_next_free_rec);
+ LOG_ERROR_ARGS ("l_next_free_rec=%d",
+ el1->l_next_free_rec);
/* See if we can merge the extents and just increase
* the length */
@@ -1310,12 +1313,12 @@
* upward till we find a free extent or we are
* at the top and need to create another
* level. */
- if (fe->i_tree_depth > 0)
+ if (fel->l_tree_depth > 0)
parent_blk = eb1->h_parent_blk;
else
parent_blk = 0;
- for (i = 0; i < fe->i_tree_depth; i++) {
+ for (i = 0; i < fel->l_tree_depth; i++) {
/* if we loop back around */
if (eb2) {
OCFS_BH_PUT_DATA(eb2_bh);
@@ -1363,8 +1366,8 @@
/* if we got to the top, then we're at the FE. Check
* if the FE is full -- if so, then we need to
* increase the tree_depth. */
- if ((i == fe->i_tree_depth) &&
- (fe->i_next_free_rec == fe->i_records)) {
+ if ((i == fel->l_tree_depth) &&
+ (fel->l_next_free_rec == fel->l_count)) {
IncreaseTreeDepth = 1;
goto increase_depth;
}
@@ -1410,7 +1413,7 @@
}
if (!IncreaseTreeDepth && UpdateParent) {
- for (i = 0; i < fe->i_tree_depth; i++) {
+ for (i = 0; i < fel->l_tree_depth; i++) {
/* next two if's are for loop around */
if (eb2_bh) {
@@ -1434,7 +1437,7 @@
}
status = ocfs_journal_access(handle, eb2_bh,
- OCFS_JOURNAL_ACCESS_WRITE);
+ OCFS_JOURNAL_ACCESS_WRITE);
if (status < 0) {
LOG_ERROR_STATUS(status);
goto finally;
@@ -1470,9 +1473,9 @@
}
}
- k = fe->i_next_free_rec - 1;
+ k = fel->l_next_free_rec - 1;
- fe->extents[k].e_clusters += new_clusters;
+ fel->l_recs[k].e_clusters += new_clusters;
}
if (status < 0) {
@@ -1655,7 +1658,10 @@
/*
* We can't recurse, so we keep a simple stack of ocfs2_extent_blocks.
*/
-static int ocfs_kill_this_tree(ocfs_super *osb, struct buffer_head *extent_grp_bh, ocfs_journal_handle *handle, struct inode *inode)
+static int ocfs_kill_this_tree(ocfs_super *osb,
+ struct buffer_head *extent_grp_bh,
+ ocfs_journal_handle *handle,
+ struct inode *inode)
{
int status = -EFAIL;
int i;
@@ -1676,9 +1682,9 @@
for (i =0; i < OCFS_TREE_STACK_SIZE; i++)
stack[i] = NULL;
- stack[tos] = ocfs_malloc(osb->sect_size);
+ stack[tos] = kmalloc(osb->sb->s_blocksize, GFP_KERNEL);
memcpy(stack[tos], OCFS_BH_GET_DATA_READ(extent_grp_bh),
- osb->sect_size);
+ osb->sb->s_blocksize);
OCFS_BH_PUT_DATA(extent_grp_bh);
do {
@@ -1734,7 +1740,8 @@
/* should already be null, but we can do this
* just in case. */
- stack[tos] = ocfs_malloc(osb->sect_size);
+ stack[tos] = kmalloc(osb->sb->s_blocksize,
+ GFP_KERNEL);
status = ocfs_read_bh(osb, tmp_off, &tmp_bh,
OCFS_BH_COND_CACHED, inode);
@@ -1745,7 +1752,7 @@
memcpy(stack[tos],
OCFS_BH_GET_DATA_READ(tmp_bh),
- osb->sect_size);
+ osb->sb->s_blocksize);
OCFS_BH_PUT_DATA(tmp_bh);
brelse(tmp_bh);
tmp_bh = NULL;
@@ -1857,14 +1864,14 @@
__u64 total_bytes; /* FIXME needs to be clusters!!! */
__u32 num_clusters, bitmap_offset;
int done = 0;
- int gran = fe->i_tree_depth;
+ int depth = fe->u.i_list.l_tree_depth;
int needs_brelse = 0;
LOG_ENTRY();
- /* This is a similar hack to the one below, untested for gran = 3 files
+ /* This is a similar hack to the one below, untested for depth = 3 files
because I can't recreate one. */
- if (gran == 3) {
+ if (depth == 3) {
LOG_ERROR_STR("Truncating file with tree_depth 3, this is not tested and may be unsafe!");
LOG_TRACE_STR("Found a tree_depth 3 tree, trimming it.\n");
@@ -1938,14 +1945,14 @@
eb_bh = tmp_bh2;
/* We want to do the next bit of stuff too */
- gran = 2;
+ depth = 2;
needs_brelse = 1;
}
/* This is a hack, but i have little time to make this function right*/
/* get rid of everything from the top level HDR that we can, then
proceeed as if we're tree_depth 1 (which we know works) */
- if (gran == 2) {
+ if (depth == 2) {
LOG_TRACE_STR("Found a tree_depth 2 tree, trimming it.\n");
status = ocfs_journal_access(handle, eb_bh,
@@ -2021,9 +2028,9 @@
eb_bh = tmp_bh;
- /* Right now, we don't use 'gran' below here, but just
+ /* Right now, we don't use 'depth' below here, but just
* in case */
- gran = 1;
+ depth = 1;
if (needs_brelse)
brelse(tmp_bh2);
needs_brelse = 1;
@@ -2397,13 +2404,14 @@
int status = -EFAIL;
struct buffer_head *eb_bh = NULL;
ocfs2_extent_block *eb = NULL;
- ocfs2_extent_list *el;
+ ocfs2_extent_list *el, *fel;
u64 next_blk;
int victim;
LOG_ENTRY ();
- if (fe->i_next_free_rec == 0) {
+ fel = &fe->u.i_list;
+ if (fel->l_next_free_rec == 0) {
LOG_TRACE_STR("setting to zero as there isn't any used extents");
fe->i_last_eb_blk = 0;
status = 0;
@@ -2411,13 +2419,13 @@
}
/* Can't be called with local extents */
- if (fe->i_tree_depth < 0)
+ if (fel->l_tree_depth < 0)
BUG();
/* Ugly magic -1 */
- victim = fe->i_next_free_rec - 1;
+ victim = fel->l_next_free_rec - 1;
status = ocfs_read_bh(osb,
- fe->extents[victim].e_blkno << osb->sb->s_blocksize_bits,
+ fel->l_recs[victim].e_blkno << osb->sb->s_blocksize_bits,
&eb_bh,
OCFS_BH_CACHED, inode);
if (status < 0) {
@@ -2488,15 +2496,18 @@
int status = 0;
struct buffer_head *extent_bh = NULL;
int i, j;
+ ocfs2_extent_list *fel;
int updated_leb; /* used to mark whether fe->i_last_eb_blk has
* been updated */
LOG_ENTRY ();
+ fel = &fe->u.i_list;
+
/* local extents */
- if (fe->i_tree_depth < 0) {
- status = _squish_extent_entries(osb, fe->extents,
- &fe->i_next_free_rec,
+ if (fel->l_tree_depth < 0) {
+ status = _squish_extent_entries(osb, fel->l_recs,
+ &fel->l_next_free_rec,
handle, fe->i_clusters,
0, inode);
if (status < 0) {
@@ -2512,11 +2523,11 @@
updated_leb = 0;
/* Loop backwards through only the used free extent block here */
- for (i = (fe->i_next_free_rec - 1); i >= 0; i--) {
+ for (i = (fel->l_next_free_rec - 1); i >= 0; i--) {
LOG_TRACE_ARGS("at top of loop, i = %d\n", i);
/* Go ahead and read that bit of the tree - we'll need it. */
status = ocfs_read_bh(osb,
- fe->extents[i].e_blkno << osb->sb->s_blocksize_bits,
+ fel->l_recs[i].e_blkno << osb->sb->s_blocksize_bits,
&extent_bh, OCFS_BH_CACHED,
inode);
if (status < 0) {
@@ -2524,19 +2535,20 @@
goto finally;
}
/* Figure out, do we want to kill this whole tree? */
- if (fe->extents[i].e_cpos >= fe->i_clusters) {
+ if (fel->l_recs[i].e_cpos >= fe->i_clusters) {
LOG_TRACE_ARGS("Found an entire tree to delete!\n");
- status = ocfs_kill_this_tree(osb, extent_bh, handle, inode);
+ status = ocfs_kill_this_tree(osb, extent_bh,
+ handle, inode);
if (status < 0) {
LOG_ERROR_STATUS(status);
goto finally;
}
/* Ok, update the fe */
- fe->extents[i].e_cpos = 0;
- fe->extents[i].e_blkno = 0;
- fe->extents[i].e_clusters = 0;
- fe->i_next_free_rec = i;
+ fel->l_recs[i].e_cpos = 0;
+ fel->l_recs[i].e_blkno = 0;
+ fel->l_recs[i].e_clusters = 0;
+ fel->l_next_free_rec = i;
} else { /* Ok, we only want part of it. */
LOG_TRACE_ARGS("Splitting this tree!\n");
status = ocfs_split_this_tree(osb, extent_bh,
@@ -2549,15 +2561,15 @@
/* Ok, update the FileEntry */
LOG_TRACE_ARGS("Alright. e_clusters = (%u), i_clusters = (%u) e_cpos = (%u)\n",
- fe->extents[i].e_clusters,
+ fel->l_recs[i].e_clusters,
fe->i_clusters,
- fe->extents[i].e_cpos);
- fe->extents[i].e_clusters = fe->i_clusters;
+ fel->l_recs[i].e_cpos);
+ fel->l_recs[i].e_clusters = fe->i_clusters;
for (j=0; j < i; j++)
- fe->extents[i].e_clusters +=
- fe->extents[j].e_clusters;
+ fel->l_recs[i].e_clusters +=
+ fel->l_recs[j].e_clusters;
- fe->i_next_free_rec = i + 1;
+ fel->l_next_free_rec = i + 1;
/* We're done - we can't split more than one
* parts of the tree. */
updated_leb = 1;
@@ -2570,7 +2582,7 @@
/* Ok, trunc to zero is a special case, doofus */
if (fe->i_clusters == 0) {
fe->i_last_eb_blk = 0;
- fe->i_tree_depth = -1;
+ fel->l_tree_depth = -1;
updated_leb = 1;
}
@@ -2662,7 +2674,7 @@
goto finally;
}
- if (fe->i_tree_depth < 0) {
+ if (fe->u.i_list.l_tree_depth < 0) {
status = ocfs_update_extent_map(osb,
&OCFS_I(inode)->map, fe,
NULL, NULL, LOCAL_EXT);
@@ -2770,15 +2782,17 @@
__u32 i, j;
struct buffer_head *ext_bh = NULL;
ocfs2_extent_block *eb = NULL;
- ocfs2_extent_list *el;
+ ocfs2_extent_list *el, *fel;
ocfs2_extent_block *tmp = NULL;
__u64 childDiskOffset = 0;
LOG_ENTRY ();
- for (i = 0; i < fe->i_next_free_rec; i++) {
- if ((__s64)((u64)(fe->extents[i].e_cpos + fe->extents[i].e_clusters) << osb->s_clustersize_bits) > Vbo) {
- childDiskOffset = fe->extents[i].e_blkno << osb->sb->s_blocksize_bits;
+ fel = &fe->u.i_list;
+
+ for (i = 0; i < fel->l_next_free_rec; i++) {
+ if ((__s64)((u64)(fel->l_recs[i].e_cpos + fel->l_recs[i].e_clusters) << osb->s_clustersize_bits) > Vbo) {
+ childDiskOffset = fel->l_recs[i].e_blkno << osb->sb->s_blocksize_bits;
break;
}
}
@@ -2788,8 +2802,9 @@
goto finally;
}
- for (i = 0; i < fe->i_tree_depth; i++) {
- tempstat = ocfs_read_bh(osb, childDiskOffset, &ext_bh, OCFS_BH_COND_CACHED, inode);
+ for (i = 0; i < fel->l_tree_depth; i++) {
+ tempstat = ocfs_read_bh(osb, childDiskOffset, &ext_bh,
+ OCFS_BH_COND_CACHED, inode);
if (tempstat < 0) {
LOG_ERROR_STATUS (status = tempstat);
goto finally;
@@ -3024,7 +3039,7 @@
LOG_TRACE_ARGS("bitoffset = %u, ClusterCount = %u, startbh = %u, numblocks = %u\n", bitoffset, ClusterCount, startbh, numblocks);
/* write the bitmap size info to the lock sector */
- bm_lock->u.bitinfo.used_bits = ocfs_count_bits(&osb->cluster_bitmap);
+ bm_lock->u.i_bitinfo.b_used = ocfs_count_bits(&osb->cluster_bitmap);
OCFS_BH_PUT_DATA(bh);
bm_lock = NULL;
@@ -3299,6 +3314,7 @@
__u32 numBitsAllocated = 0, bitmapOffset = 0;
ocfs2_extent_block *extent = NULL;
struct buffer_head *extent_bh = NULL;
+ ocfs2_extent_list *fel;
ocfs2_dinode *fe = NULL;
__u64 offset;
@@ -3314,13 +3330,14 @@
SET_BH_SEQNUM(inode, fe_bh);
fe = OCFS_BH_GET_DATA_READ(fe_bh);
+ fel = &fe->u.i_list;
- if (fe->i_tree_depth < 0) {
- for (i = 0; i < fe->i_next_free_rec; i++) {
- numBitsAllocated = fe->extents[i].e_clusters;
+ if (fel->l_tree_depth < 0) {
+ for (i = 0; i < fel->l_next_free_rec; i++) {
+ numBitsAllocated = fel->l_recs[i].e_clusters;
bitmapOffset =
- (__u32)(((fe->extents[i].e_blkno << osb->sb->s_blocksize_bits) -
+ (__u32)(((fel->l_recs[i].e_blkno << osb->sb->s_blocksize_bits) -
osb->vol_layout.data_start_off) >>
osb->s_clustersize_bits);
@@ -3329,16 +3346,19 @@
DISK_ALLOC_VOLUME);
}
} else {
- for (i = 0; i < fe->i_next_free_rec; i++) {
+ for (i = 0; i < fel->l_next_free_rec; i++) {
status = ocfs_read_bh(osb,
- fe->extents[i].e_blkno << osb->sb->s_blocksize_bits,
- &extent_bh, OCFS_BH_COND_CACHED, inode);
+ fel->l_recs[i].e_blkno << osb->sb->s_blocksize_bits,
+ &extent_bh,
+ OCFS_BH_COND_CACHED,
+ inode);
if (status < 0) {
LOG_ERROR_STATUS (status);
goto leave;
}
extent = OCFS_BH_GET_DATA_READ(extent_bh);
- if (fe->i_tree_depth && !IS_VALID_EXTENT_BLOCK(extent)) {
+ if (fel->l_tree_depth &&
+ !IS_VALID_EXTENT_BLOCK(extent)) {
status = -EINVAL;
LOG_ERROR_STATUS(status);
goto leave;
Modified: branches/format-changes/src/buffer_head_io.c
===================================================================
--- branches/format-changes/src/buffer_head_io.c 2004-06-11 09:42:10 UTC (rev 1051)
+++ branches/format-changes/src/buffer_head_io.c 2004-06-11 10:22:45 UTC (rev 1052)
@@ -44,7 +44,7 @@
#define OCFS_DEBUG_CONTEXT OCFS_DEBUG_CONTEXT_IO
static void ocfs_end_buffer_io_sync(struct buffer_head *bh,
- int uptodate)
+ int uptodate)
{
// LOG_ENTRY_ARGS("(bh->b_blocknr = %u, uptodate = %d)\n", bh->b_blocknr,
// uptodate);
Modified: branches/format-changes/src/dir.c
===================================================================
--- branches/format-changes/src/dir.c 2004-06-11 09:42:10 UTC (rev 1051)
+++ branches/format-changes/src/dir.c 2004-06-11 10:22:45 UTC (rev 1052)
@@ -186,10 +186,10 @@
*/
/* parent off changed to file entry offset of parent! */
int ocfs_find_files_on_disk(ocfs_super *osb, const char *name,
- int namelen, __u64 *fe_off,
- struct inode *inode, int take_lock,
- struct buffer_head **dirent_bh,
- struct ocfs2_dir_entry **dirent)
+ int namelen, __u64 *fe_off,
+ struct inode *inode, int take_lock,
+ struct buffer_head **dirent_bh,
+ struct ocfs2_dir_entry **dirent)
{
int status = -ENOENT;
int tmpstat;
Modified: branches/format-changes/src/dir.h
===================================================================
--- branches/format-changes/src/dir.h 2004-06-11 09:42:10 UTC (rev 1051)
+++ branches/format-changes/src/dir.h 2004-06-11 10:22:45 UTC (rev 1052)
@@ -29,7 +29,7 @@
int empty_dir(struct inode *inode); /* FIXME: to namei.c */
int ocfs_find_files_on_disk(ocfs_super *osb, const char *name,
- int namelen, __u64 *fe_off,
+ int namelen, __u64 *fe_off,
struct inode *inode, int take_lock,
struct buffer_head **dirent_bh,
struct ocfs2_dir_entry **dirent);
Modified: branches/format-changes/src/extmap.c
===================================================================
--- branches/format-changes/src/extmap.c 2004-06-11 09:42:10 UTC (rev 1051)
+++ branches/format-changes/src/extmap.c 2004-06-11 10:22:45 UTC (rev 1052)
@@ -589,7 +589,7 @@
int ret = -EFAIL;
ocfs2_dinode *fe;
ocfs2_extent_block *eb;
- ocfs2_extent_list *el;
+ ocfs2_extent_list *el;
__s64 tempVbo;
__u64 tempSize;
int j;
@@ -598,15 +598,15 @@
if (Flag == LOCAL_EXT) {
fe = Buffer;
+ el = &fe->u.i_list;
- OCFS_ASSERT(fe->i_tree_depth < 0);
+ OCFS_ASSERT(el->l_tree_depth < 0);
- for (j = 0; j < fe->i_next_free_rec; j++) {
+ for (j = 0; j < el->l_next_free_rec; j++) {
/* Add the Extent to extent map list */
- ret =
- ocfs_add_extent_map_entry_from_rec(osb->sb,
- Map,
- &fe->extents[j]);
+ ret = ocfs_add_extent_map_entry_from_rec(osb->sb,
+ Map,
+ &el->l_recs[j]);
if (!ret) {
LOG_ERROR_STATUS (ret = -ENOMEM);
goto bail;
Modified: branches/format-changes/src/file.c
===================================================================
--- branches/format-changes/src/file.c 2004-06-11 09:42:10 UTC (rev 1051)
+++ branches/format-changes/src/file.c 2004-06-11 10:22:45 UTC (rev 1052)
@@ -434,13 +434,13 @@
/* get a copy of fe, used readonly in this path and */
/* ocfs_create_new_oin will deadlock if fe_bh is locked */
- fe = ocfs_allocate_file_entry();
+ fe = kmalloc(osb->sb->s_blocksize, GFP_NOFS);
if (fe == NULL) {
LOG_ERROR_STATUS(ret = -ENOMEM);
goto leave;
}
tmp = OCFS_BH_GET_DATA_READ(fe_bh);
- memcpy(fe, tmp, sizeof(ocfs2_dinode));
+ memcpy(fe, tmp, osb->sb->s_blocksize_bits);
OCFS_BH_PUT_DATA(fe_bh);
tempoff = fe->i_blkno << osb->sb->s_blocksize_bits;
@@ -448,12 +448,13 @@
if (S_ISDIR(fe->i_mode))
goto leave;
- if (fe->i_tree_depth < 0) {
- for (j = 0; j < fe->i_next_free_rec; j++) {
+ el = &fe->u.i_list;
+ if (el->l_tree_depth < 0) {
+ for (j = 0; j < el->l_next_free_rec; j++) {
/* Add the Extent to extent map */
ret = ocfs_add_extent_map_entry_from_rec(osb->sb,
&OCFS_I(inode)->map,
- &fe->extents[j]);
+ &el->l_recs[j]);
if (!ret) {
LOG_ERROR_STATUS (ret = -ENOMEM);
goto leave;
@@ -519,7 +520,7 @@
leave:
/* this fe was a copy */
if (fe)
- ocfs_release_file_entry (fe);
+ kfree(fe);
if (eb_bh) {
if (eb)
@@ -1092,7 +1093,6 @@
__u64 tempOffset = 0;
__u64 current_alloc;
__u64 alloc_size = 0;
- __u32 size;
__u64 bitmapOffset = 0;
__u64 numClustersAlloc = 0;
__u64 lockId = 0;
@@ -1231,8 +1231,8 @@
unsigned long block;
struct super_block *sb = osb->sb;
- for (block = (unsigned long)(actualDiskOffset >> osb->sect_size_bits);
- block < (unsigned long)((actualDiskOffset+actualLength) >> osb->sect_size_bits);
+ for (block = (unsigned long)(actualDiskOffset >> sb->s_blocksize_bits);
+ block < (unsigned long)((actualDiskOffset+actualLength) >> sb->s_blocksize_bits);
block++) {
LOG_TRACE_ARGS("setting block %lu as new!\n", block);
alloc_bh = getblk(OCFS_GET_BLOCKDEV(sb), block, sb->s_blocksize);
@@ -1284,7 +1284,6 @@
fe->i_mtime = OCFS_CURRENT_TIME;
tempOffset = fe->i_blkno << osb->sb->s_blocksize_bits;
- size = osb->sect_size;
OCFS_BH_PUT_DATA(bh);
Modified: branches/format-changes/src/heartbeat.c
===================================================================
--- branches/format-changes/src/heartbeat.c 2004-06-11 09:42:10 UTC (rev 1051)
+++ branches/format-changes/src/heartbeat.c 2004-06-11 10:22:45 UTC (rev 1052)
@@ -208,7 +208,7 @@
} else {
#if !defined(USERSPACE_TOOL)
if (!ocfs_node_is_alive(&osb->publ_map, i) &&
- (osb->node_num != i))
+ (osb->node_num != i))
printk ("ocfs2: Adding %s (node %d) to clustered device (%u,%u)\n",
osb->node_cfg_info[i]->node_name, i,
MAJOR(osb->sb->s_dev), MINOR(osb->sb->s_dev));
Modified: branches/format-changes/src/inode.c
===================================================================
--- branches/format-changes/src/inode.c 2004-06-11 09:42:10 UTC (rev 1051)
+++ branches/format-changes/src/inode.c 2004-06-11 10:22:45 UTC (rev 1052)
@@ -416,7 +416,9 @@
(u64)fe->i_clusters << osb->s_clustersize_bits;
OCFS_I(inode)->inode = inode;
OCFS_I(inode)->chng_seq_num = DISK_LOCK(fe)->dl_seq_num;
- OCFS_I(inode)->u.fe_private = fe->u.fe_private;
+#if 0 /* This can't be right, can it? */
+ OCFS_I(inode)->u.fe_private = fe->u.i_private;
+#endif
if (S_ISDIR(fe->i_mode))
OCFS_I(inode)->oin_flags |= OCFS_OIN_DIRECTORY;
@@ -543,8 +545,8 @@
fe = OCFS_BH_GET_DATA_READ(bh);
- if (S_ISCHR(fe->i_mode) || S_ISBLK(fe->i_mode))
- inode->i_rdev = ocfs_decode_dev(le64_to_cpu(fe->u.i_rdev));
+ if (S_ISCHR(fe->i_mode) || S_ISBLK(fe->i_mode))
+ inode->i_rdev = ocfs_decode_dev(le64_to_cpu(fe->u.i_rdev));
ocfs_populate_inode (inode, fe, 0);
@@ -843,7 +845,8 @@
goto bail;
}
- map_bh(bh_result, inode->i_sb, fe->extents[0].e_blkno + iblock);
+ map_bh(bh_result, inode->i_sb,
+ fe->u.i_list.l_recs[0].e_blkno + iblock);
OCFS_BH_PUT_DATA(bh);
err = 0;
@@ -1759,6 +1762,7 @@
int status = 0;
struct buffer_head *fe_bh = NULL;
ocfs2_dinode *fe = NULL;
+ ocfs2_extent_list *fel;
__u64 offset;
/* We are setting the oin Updated flag in the end. */
@@ -1847,7 +1851,7 @@
*needs_trunc = 1;
}
- if (S_ISCHR(fe->i_mode) ||
+ if (S_ISCHR(fe->i_mode) ||
S_ISBLK(fe->i_mode) ||
S_ISFIFO(fe->i_mode) ||
S_ISSOCK(fe->i_mode)) {
@@ -1856,14 +1860,15 @@
ocfs_decode_dev(le64_to_cpu(fe->u.i_rdev)));
}
- if (fe->i_tree_depth < 0) {
+ fel = &fe->u.i_list;
+ if (fel->l_tree_depth < 0) {
__u32 j;
/* Add the Extents to extent map */
- for (j = 0; j < fe->i_next_free_rec; j++) {
+ for (j = 0; j < fel->l_next_free_rec; j++) {
if (!ocfs_add_extent_map_entry_from_rec(osb->sb,
- &OCFS_I(inode)->map,
- &fe->extents[j]))
+ &OCFS_I(inode)->map,
+ &fel->l_recs[j]))
goto leave;
}
}
Modified: branches/format-changes/src/namei.c
===================================================================
--- branches/format-changes/src/namei.c 2004-06-11 09:42:10 UTC (rev 1051)
+++ branches/format-changes/src/namei.c 2004-06-11 10:22:45 UTC (rev 1052)
@@ -331,6 +331,7 @@
{
int status = 0;
ocfs2_dinode *fe = NULL;
+ ocfs2_extent_list *fel;
__u64 disk_off = 0;
__u64 fileOffset = 0;
struct inode *inode_alloc_inode = NULL;
@@ -397,11 +398,8 @@
else
fe->i_links_count = 1;
- fe->i_tree_depth = -1;
- fe->i_next_free_rec = 0;
fe->i_last_eb_blk = 0;
- strcpy (fe->i_signature, OCFS_FILE_ENTRY_SIGNATURE);
- fe->i_records = ocfs_extent_recs_per_inode(osb->sb);
+ strcpy (fe->i_signature, OCFS2_FILE_ENTRY_SIGNATURE);
fe->i_flags |= OCFS2_VALID_FL;
fe->i_flags &= ~(OCFS2_CHANGE_FL);
DISK_LOCK(fe)->dl_seq_num = 0;
@@ -410,6 +408,12 @@
ocfs_set_disk_lock_open_map(osb, DISK_LOCK(fe), &just_me);
fe->i_atime = fe->i_ctime = fe->i_mtime = OCFS_CURRENT_TIME;
fe->i_dtime = 0;
+
+ fel = &fe->u.i_list;
+ fel->l_tree_depth = -1;
+ fel->l_next_free_rec = 0;
+ fel->l_count = ocfs_extent_recs_per_inode(osb->sb);
+
OCFS_BH_PUT_DATA(*new_fe_bh);
fe = NULL;
@@ -896,11 +900,8 @@
int status = 0;
struct inode *old_inode = old_dentry->d_inode;
struct inode *new_inode = new_dentry->d_inode;
- ocfs2_dinode *newfe = NULL, *oldfe = NULL;
- struct buffer_head *oldfe_bh = NULL;
+ ocfs2_dinode *newfe = NULL;
struct buffer_head *newfe_bh = NULL;
- struct buffer_head *insert_bh = NULL;
- ocfs2_dinode *tmpfe = NULL;
ocfs_super *osb = NULL;
__u64 oldOffset, newDirOff, oldDirOff;
__u64 newfe_lockid = 0;
@@ -1300,20 +1301,11 @@
iput(new_inode);
}
- if (tmpfe)
- ocfs_release_file_entry (tmpfe);
- if (oldfe_bh) {
- if (oldfe)
- OCFS_BH_PUT_DATA(oldfe_bh);
- brelse(oldfe_bh);
- }
if (newfe_bh) {
if (newfe)
OCFS_BH_PUT_DATA(newfe_bh);
brelse(newfe_bh);
}
- if (insert_bh)
- brelse(insert_bh);
if (old_dir_bh)
brelse(old_dir_bh);
if (new_dir_bh)
Modified: branches/format-changes/src/ocfs.h
===================================================================
--- branches/format-changes/src/ocfs.h 2004-06-11 09:42:10 UTC (rev 1051)
+++ branches/format-changes/src/ocfs.h 2004-06-11 10:22:45 UTC (rev 1052)
@@ -323,8 +323,8 @@
#define INVALID_NODE_POINTER -1
-#define OCFS_FILE_ENTRY_SIGNATURE "INODE01"
-#define OCFS_EXTENT_BLOCK_SIGNATURE "EXBLK01"
+#define OCFS2_FILE_ENTRY_SIGNATURE "INODE01"
+#define OCFS2_EXTENT_BLOCK_SIGNATURE "EXBLK01"
#define OCFS_LOCAL_ALLOC_SIGNATURE "LCLBMP"
#define MAX_IP_ADDR_LEN 32
@@ -383,9 +383,9 @@
/* sm - ocfs 1.0 fails to set fe->sig for dirs */
#define IS_VALID_FILE_ENTRY(ptr) \
- (!strcmp((ptr)->i_signature, OCFS_FILE_ENTRY_SIGNATURE))
+ (!strcmp((ptr)->i_signature, OCFS2_FILE_ENTRY_SIGNATURE))
#define IS_VALID_EXTENT_BLOCK(ptr) \
- (!strcmp((ptr)->signature, OCFS_EXTENT_BLOCK_SIGNATURE))
+ (!strcmp((ptr)->h_signature, OCFS2_EXTENT_BLOCK_SIGNATURE))
#define IS_VALID_NODE_NUM(node) \
(((node) >= 0) && ((node) < OCFS_MAXIMUM_NODES))
@@ -447,21 +447,6 @@
#define ocfs_free_extent_entry(ext) kmem_cache_free(OcfsGlobalCtxt.extent_cache, ext)
-#define ocfs_allocate_file_entry() ((ocfs2_dinode *)({ \
- ocfs2_dinode *FileEntry = NULL; \
- FileEntry = kmem_cache_alloc (OcfsGlobalCtxt.fe_cache, GFP_NOFS); \
- if (FileEntry != NULL) \
- memset (FileEntry, 0, OCFS_SECTOR_SIZE); \
- FileEntry; }))
-
-#define ocfs_release_file_entry(fe) \
- do { \
- if (fe) { \
- kmem_cache_free (OcfsGlobalCtxt.fe_cache, fe); \
- fe = NULL; \
- } \
- } while (0)
-
#define OCFS_NAME "OCFS"
/* ioctl commands */
@@ -570,6 +555,111 @@
} ocfs_bh_sem;
+/*
+ * On disk extent record for OCFSv2. It describes a range of clusters
+ * on disk.
+ */
+typedef struct _ocfs2_extent_rec {
+/*00*/ __u32 e_cpos; /* Offset into the file, in clusters */
+ __u32 e_clusters; /* Clusters covered by this extent */
+ __u64 e_blkno; /* Physical disk offset, in blocks */
+/*10*/
+} ocfs2_extent_rec;
+
+/*
+ * On disk extent list for OCFSv2 (node in the tree)
+ */
+typedef struct _ocfs2_extent_list {
+/*00*/ __s16 l_tree_depth; /* Extent tree depth from this
+ point. -1 means data extents
+ hang directly off this
+ header (a leaf) */
+ __u16 l_count; /* Number of extent records */
+ __u16 l_next_free_rec; /* Next unused extent slot */
+ __u16 l_reserved1;
+ __u64 l_reserved2; /* Pad to
+ sizeof(ocfs2_extent_rec) */
+/*10*/ ocfs2_extent_rec l_recs[0]; /* Extent records */
+} ocfs2_extent_list;
+
+/*
+ * On disk extent block (indirect block) for OCFSv2
+ */
+typedef struct _ocfs2_extent_block
+{
+/*00*/ __u8 h_signature[8]; /* Signature for verification */
+ __u64 h_suballoc_blkno; /* Node suballocator offset,
+ in blocks */
+/*10*/ __u16 h_suballoc_node; /* Node suballocator this
+ extent_header belongs to */
+ __u16 h_reserved1;
+ __u32 h_reserved2;
+ __u64 h_blkno; /* Offset on disk, in blocks */
+/*20*/ __u64 h_parent_blk; /* Offset on disk, in blocks,
+ of this block's parent in the
+ tree */
+ __u64 h_next_leaf_blk; /* Offset on disk, in blocks,
+ of next leaf header pointing
+ to data */
+/*30*/ ocfs2_extent_list h_list; /* Extent record list */
+} ocfs2_extent_block;
+
+/*
+ * On disk lock structure for OCFSv2
+ */
+typedef struct _ocfs2_disk_lock
+{
+/*00*/ __u32 dl_master; /* Node number of current master */
+ __u8 dl_level; /* Lock level */
+ __u8 dl_reserved1[3]; /* Pad to u64 */
+ __u64 dl_seq_num; /* Lock transaction seqnum */
+/*10*/ __u32 dl_node_map[8]; /* Bitmap of interested nodes,
+ was __u32 */
+/*30*/
+} ocfs2_disk_lock;
+
+/*
+ * On disk inode for OCFS v2
+ */
+typedef struct _ocfs2_dinode {
+/*00*/ __u8 i_signature[8]; /* Signature for validation */
+ __u32 i_generation; /* Generation number */
+ __u16 i_reserved1;
+ __u16 i_suballoc_node; /* Node suballocater this inode
+ belongs to */
+/*10*/ __u64 i_suballoc_blkno; /* Node suballocator offset,
+ in blocks */
+/*18*/ ocfs2_disk_lock i_disk_lock; /* Lock structure */
+/*48*/ __u32 i_uid; /* Owner UID */
+ __u32 i_gid; /* Owning GID */
+/*50*/ __u64 i_size; /* Size in bytes */
+ __u16 i_mode; /* File mode */
+ __u16 i_links_count; /* Links count */
+ __u32 i_flags; /* File flags */
+/*60*/ __u64 i_atime; /* Access time */
+ __u64 i_ctime; /* Creation time */
+/*70*/ __u64 i_mtime; /* Modification time */
+ __u64 i_dtime; /* Deletion time */
+/*80*/ __u64 i_blkno; /* Offset on disk, in blocks */
+ __u32 i_clusters; /* Cluster count */
+ __u32 i_reserved2;
+/*90*/ __u64 i_last_eb_blk; /* Pointer to last extent
+ block */
+ __u64 i_reserved3;
+/*A0*/ __u64 i_reserved4;
+ __u64 i_reserved5;
+/*B0*/ union {
+ __u64 i_private;
+ __u64 i_rdev;
+ struct _bitinfo {
+ __u32 b_used;
+ __u32 b_total;
+ } i_bitinfo;
+ ocfs2_extent_list i_list;
+ } u;
+} ocfs2_dinode;
+
+
typedef struct _ocfs_vol_disk_hdr // CLASS
{
__u32 minor_version; // NUMBER RANGE(0,UINT_MAX)
@@ -614,18 +704,6 @@
}
ocfs_vol_disk_hdr; // END CLASS
-
-typedef struct _ocfs2_disk_lock
-{
-/*00*/ __u32 dl_master; /* Node number of current master */
- __u8 dl_level; /* Lock level */
- __u8 dl_pad[3]; /* Pad to u64 */
- __u64 dl_seq_num; /* Lock transaction seqnum */
-/*10*/ __u32 dl_node_map[8]; /* Bitmap of interested nodes,
- was __u32 */
-/*30*/
-} ocfs2_disk_lock;
-
typedef struct _ocfs_vol_label // CLASS
{
ocfs2_disk_lock disk_lock; // DISKLOCK
@@ -1139,13 +1217,6 @@
*/
extern ocfs_global_ctxt OcfsGlobalCtxt;
-typedef struct _ocfs2_extent_rec {
-/*00*/ __u32 e_cpos; /* Offset into the file, in clusters */
- __u32 e_clusters; /* Clusters covered by this extent */
- __u64 e_blkno; /* Physical disk offset, in blocks */
-/*10*/
-} ocfs2_extent_rec;
-
typedef struct _ocfs_publish // CLASS
{
__u64 time; // NUMBER RANGE(0,ULONG_LONG_MAX)
@@ -1187,88 +1258,6 @@
}
ocfs_local_alloc;
-/*
- * On disk extent list for OCFSv2 (node in the tree)
- */
-typedef struct _ocfs2_extent_list {
-/*00*/ __s16 l_tree_depth; /* Extent tree depth from this
- point. -1 means data extents
- hang directly off this
- header (a leaf) */
- __u16 l_count; /* Number of extent records */
- __u16 l_next_free_rec; /* Next unused extent slot */
- __u16 l_reserved1;
- __u64 l_reserved2; /* Pad to
- sizeof(ocfs2_extent_rec) */
-/*10*/ ocfs2_extent_rec l_recs[0]; /* Extent records */
-} ocfs2_extent_list;
-
-/*
- * On disk inode for OCFS v2
- */
-typedef struct _ocfs2_dinode {
-/*00*/ __u8 i_signature[8]; /* Signature for validation */
- __u32 i_generation; /* Generation number */
- __u16 i_reserved1;
- __u16 i_suballoc_node; /* Node suballocater this inode
- belongs to */
-/*10*/ __u64 i_suballoc_blkno; /* Node suballocator offset,
- in blocks */
-/*18*/ ocfs2_disk_lock i_disk_lock; /* Lock structure */
-/*38*/ __u32 i_uid; /* Owner UID */
- __u32 i_gid; /* Owning GID */
-/*40*/ __u64 i_size; /* Size in bytes */
- __u16 i_mode; /* File mode */
- __u16 i_links_count; /* Links count */
- __u32 i_flags; /* File flags */
-/*50*/ __u64 i_atime; /* Access time */
- __u64 i_ctime; /* Creation time */
-/*60*/ __u64 i_mtime; /* Modification time */
- __u64 i_dtime; /* Deletion time */
-/*70*/ __u64 i_blkno; /* Offset on disk, in blocks */
- __u32 i_clusters; /* Cluster count */
- __u32 i_reserved2;
-/*80*/ union {
- __u64 fe_private;
- __u64 i_rdev;
- struct _bitinfo {
- __u32 used_bits;
- __u32 total_bits;
- } bitinfo;
- } u;
-/*98*/ __u64 i_last_eb_blk; /* Pointer to last extdat */
-/*A0*/ __s16 i_tree_depth; /* Extent tree depth
- -1 means data extents hang
- directly off of the
- inode. */
- __u16 i_records; /* Number of extent records */
- __u16 i_next_free_rec; /* Next unused extent slot */
- __u16 i_reserved3;
-/*A8*/ ocfs2_extent_rec extents[0]; /* Extent records */
-} ocfs2_dinode;
-
-/*
- * On disk extent block (indirect block) for OCFSv2
- */
-typedef struct _ocfs2_extent_block
-{
-/*00*/ __u8 signature[8]; /* Signature for verification */
- __u64 h_suballoc_blkno; /* Node suballocator offset,
- in blocks */
-/*10*/ __u16 h_suballoc_node; /* Node suballocator this
- extent_header belongs to */
- __u16 h_reserved1;
- __u32 h_reserved2;
- __u64 h_blkno; /* Offset on disk, in blocks */
-/*20*/ __u64 h_parent_blk; /* Offset on disk, in blocks,
- of this block's parent in the
- tree */
- __u64 h_next_leaf_blk; /* Offset on disk, in blocks,
- of next leaf header pointing
- to data */
-/*30*/ ocfs2_extent_list h_list; /* Extent record list */
-} ocfs2_extent_block;
-
typedef struct _ocfs_dlm_msg_hdr
{
__u64 lock_id;
@@ -1619,7 +1608,7 @@
list_del(&(log->log_list));
kfree(log);
}
- kfree(f);
+ kfree(f);
}
}
@@ -1788,7 +1777,7 @@
int size;
size = sb->s_blocksize -
- offsetof(struct _ocfs2_dinode, extents);
+ offsetof(struct _ocfs2_dinode, u.i_list.l_recs);
return size / sizeof(struct _ocfs2_extent_rec);
}
Modified: branches/format-changes/src/ocfs_buffer_head.h
===================================================================
--- branches/format-changes/src/ocfs_buffer_head.h 2004-06-11 09:42:10 UTC (rev 1051)
+++ branches/format-changes/src/ocfs_buffer_head.h 2004-06-11 10:22:45 UTC (rev 1052)
@@ -365,7 +365,7 @@
}
status = ocfs_read_bhs(osb, off, osb->sb->s_blocksize, bh,
- flags, inode);
+ flags, inode);
bail:
IO_FUNC_TIMING_PRINT("ocfs_read_bh", status);
Modified: branches/format-changes/src/super.c
===================================================================
--- branches/format-changes/src/super.c 2004-06-11 09:42:10 UTC (rev 1051)
+++ branches/format-changes/src/super.c 2004-06-11 10:22:45 UTC (rev 1052)
@@ -712,8 +712,8 @@
return -EIO;
}
bm_lock = OCFS_BH_GET_DATA_READ(bh);
- if (numbits >= bm_lock->u.bitinfo.used_bits)
- freebits = numbits - bm_lock->u.bitinfo.used_bits;
+ if (numbits >= bm_lock->u.i_bitinfo.b_used)
+ freebits = numbits - bm_lock->u.i_bitinfo.b_used;
/* take out the space reserved for system files */
reserved_bits = ocfs_clusters_for_bytes(sb, 8 * ONE_MEGA_BYTE);
Modified: branches/format-changes/src/sysfile.c
===================================================================
--- branches/format-changes/src/sysfile.c 2004-06-11 09:42:10 UTC (rev 1051)
+++ branches/format-changes/src/sysfile.c 2004-06-11 10:22:45 UTC (rev 1052)
@@ -476,6 +476,7 @@
__u32 Runs, Runoffset;
struct buffer_head *extent_bh = NULL;
ocfs2_extent_block *extent = NULL;
+ ocfs2_extent_list *fel;
ocfs_io_runs *IoRuns;
__u64 newOffset = 0, searchVbo, remainingLength = 0;
@@ -489,13 +490,15 @@
goto leave;
}
- if (fe->i_tree_depth < 0)
+ fel = &fe->u.i_list;
+
+ if (fel->l_tree_depth < 0)
{
- size = fe->i_records * sizeof (ocfs_io_runs);
+ size = fel->l_count * sizeof(ocfs_io_runs);
}
else
{
- int pow = fe->i_tree_depth + 1;
+ int pow = fel->l_tree_depth + 1;
/* extent tree looks like
* fe[0] fe[1] fe[2]
* hdr[0]...hdr[n] .....
@@ -530,14 +533,14 @@
Runoffset = 0;
newOffset = file_off;
- if (fe->i_tree_depth < 0) {
- for (j = 0; j < fe->i_records; j++) {
- if (((u64)(fe->extents[j].e_cpos + fe->extents[j].e_clusters) << osb->s_clustersize_bits) > newOffset) {
+ if (fel->l_tree_depth < 0) {
+ for (j = 0; j < fel->l_count; j++) {
+ if (((u64)(fel->l_recs[j].e_cpos + fel->l_recs[j].e_clusters) << osb->s_clustersize_bits) > newOffset) {
IoRuns[Runoffset].disk_off =
- (fe->extents[j].e_blkno << osb->sb->s_blocksize_bits) +
- (newOffset - ((u64)fe->extents[j].e_cpos << osb->s_clustersize_bits));
+ (fel->l_recs[j].e_blkno << osb->sb->s_blocksize_bits) +
+ (newOffset - ((u64)fel->l_recs[j].e_cpos << osb->s_clustersize_bits));
IoRuns[Runoffset].byte_cnt =
- (__u32)(((u64)(fe->extents[j].e_cpos + fe->extents[j].e_clusters) << osb->s_clustersize_bits) - newOffset);
+ (__u32)(((u64)(fel->l_recs[j].e_cpos + fel->l_recs[j].e_clusters) << osb->s_clustersize_bits) - newOffset);
if (IoRuns[Runoffset].byte_cnt >=
remainingLength) {
IoRuns[Runoffset].byte_cnt =
@@ -564,22 +567,22 @@
while (1) {
/* Keep going downwards looking for the Entry, till
* we hit the last Data entry */
- for (k = 0; k < fe->i_records; k++) {
- if ((__s64)((u64)(fe->extents[k].e_cpos + fe->extents[k].e_clusters) << osb->s_clustersize_bits) > newOffset) {
+ for (k = 0; k < fel->l_count; k++) {
+ if ((__s64)((u64)(fel->l_recs[k].e_cpos + fel->l_recs[k].e_clusters) << osb->s_clustersize_bits) > newOffset) {
break;
}
}
- if (k == fe->i_records) {
+ if (k == fel->l_count) {
LOG_ERROR_STR ("data extents maxed");
}
- if (fe->extents[k].e_blkno == 0) {
+ if (fel->l_recs[k].e_blkno == 0) {
LOG_ERROR_STR ("e_blkno=0");
}
status = ocfs_read_bh(osb,
- fe->extents[k].e_blkno << osb->sb->s_blocksize_bits,
+ fel->l_recs[k].e_blkno << osb->sb->s_blocksize_bits,
&extent_bh,
OCFS_BH_COND_CACHED,
NULL);
Modified: branches/format-changes/src/vote.h
===================================================================
--- branches/format-changes/src/vote.h 2004-06-11 09:42:10 UTC (rev 1051)
+++ branches/format-changes/src/vote.h 2004-06-11 10:22:45 UTC (rev 1052)
@@ -35,7 +35,7 @@
int ocfs_lookup_obj_by_lockid(ocfs_vote_obj *obj,
ocfs_vote_obj_lookup_data *data);
int ocfs_lookup_vote_request_obj(ocfs_super *osb,
- ocfs_vote_obj_lookup_data *data);
+ ocfs_vote_obj_lookup_data *data);
void ocfs_process_one_vote_reply(ocfs_super *osb,
ocfs_vote_reply_ctxt *ctxt,
__u32 node_num);
More information about the Ocfs2-commits
mailing list