[Ocfs2-commits] mfasheh commits r1220 - trunk/src
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Mon Jun 28 20:52:38 CDT 2004
Author: mfasheh
Date: 2004-06-28 19:52:36 -0500 (Mon, 28 Jun 2004)
New Revision: 1220
Modified:
trunk/src/alloc.c
trunk/src/extmap.c
trunk/src/file.c
trunk/src/inode.c
trunk/src/namei.c
trunk/src/ocfs2_fs.h
Log:
* tree_depth now starts at 0 and grows upward from there.
Modified: trunk/src/alloc.c
===================================================================
--- trunk/src/alloc.c 2004-06-28 19:51:42 UTC (rev 1219)
+++ trunk/src/alloc.c 2004-06-29 00:52:36 UTC (rev 1220)
@@ -60,6 +60,7 @@
struct inode *inode);
static int ocfs_allocate_new_data_node(ocfs_super *osb,
ocfs2_dinode *fe,
+ u64 new_blkno,
u32 new_clusters,
struct buffer_head *eb_bh,
u64 *new_eb_blkno,
@@ -671,10 +672,11 @@
/* ocfs_allocate_new_data_node()
- *
+ *
*/
static int ocfs_allocate_new_data_node(ocfs_super *osb,
ocfs2_dinode *fe,
+ u64 new_blkno,
u32 new_clusters,
struct buffer_head *eb_bh,
u64 *new_eb_blkno,
@@ -722,7 +724,7 @@
else
parent_blk = fe->i_blkno;
- new_blocks = depth + 1;
+ new_blocks = depth;
allocSize = new_blocks << osb->sb->s_blocksize_bits;
/* allocate contiguous blocks on disk */
@@ -773,7 +775,7 @@
el1->l_next_free_rec++;
/* Fill in all the headers and the leaf */
- for (i = 0; i <= depth; i++) {
+ for (i = 0; i < depth; i++) {
ocfs2_extent_block *eb;
eb = (ocfs2_extent_block *) eb_bhs[i]->b_data;
@@ -790,14 +792,14 @@
el2->l_next_free_rec = 1;
el2->l_recs[0].e_cpos = fe->i_clusters;
el2->l_recs[0].e_clusters = new_clusters;
- el2->l_tree_depth = (depth - 1 - i);
+ el2->l_tree_depth = (depth - (i + 1));
- if (i != depth) {
+ if (el2->l_tree_depth) {
/* fill in each header */
el2->l_recs[0].e_blkno = phys_blkno + (i + 1);
} else {
/* fill in the leaf */
- el2->l_recs[0].e_blkno = phys_blkno;
+ el2->l_recs[0].e_blkno = new_blkno;
*new_eb_blkno = fe->i_last_eb_blk =
eb->h_blkno;
}
@@ -813,7 +815,7 @@
}
}
- if (eb != NULL) {
+ if (eb) {
/* both needed below in for loop */
u64 tmp_blk = eb->h_parent_blk;
int tree_depth = el1->l_tree_depth;
@@ -919,7 +921,7 @@
fe = (ocfs2_dinode *) fe_bh->b_data;
fel = &fe->id2.i_list;
- numbhs = fel->l_tree_depth + 2;
+ numbhs = fel->l_tree_depth + 1;
bhs = kmalloc(numbhs * sizeof(*bhs), GFP_KERNEL);
if (bhs == NULL) {
@@ -979,12 +981,12 @@
LOG_TRACE_ARGS ("Tree depth is: %d\n", fel->l_tree_depth);
- /* If tree_depth is zero now, the for loop will not execute. */
- /* First time a file is created, tree_depth = -1 */
+ /* If tree_depth is one now, the for loop will not execute. */
+ /* First time a file is created, tree_depth = 0 */
parent_blk = fe->i_blkno;
- for (i = 0; i < fel->l_tree_depth; i++) {
+ for (i = 0; i < (fel->l_tree_depth - 1); i++) {
eb2 = (ocfs2_extent_block *) bhs[i]->b_data;
ebl = &eb2->h_list;
@@ -1025,10 +1027,10 @@
}
/* Update the Data Segment, which is the last one in our array */
- eb1 = (ocfs2_extent_block *) bhs[fel->l_tree_depth]->b_data;
+ eb1 = (ocfs2_extent_block *) bhs[numbhs - 1]->b_data;
ebl = &eb1->h_list;
- i = (fel->l_tree_depth) ? 0 : fel->l_count;
+ i = (fel->l_tree_depth > 1) ? 0 : fel->l_count;
LOG_TRACE_ARGS ("EntryAvailable is: %d\n", ebl->l_next_free_rec);
@@ -1036,7 +1038,7 @@
/* will have one more entry to accomodate the latest allocation */
strcpy(eb1->h_signature, OCFS2_EXTENT_BLOCK_SIGNATURE);
- ebl->l_tree_depth = -1;
+ ebl->l_tree_depth = 0;
ebl->l_count = ocfs2_extent_recs_per_eb(osb->sb);
ebl->l_recs[i].e_cpos = fe->i_clusters;
@@ -1046,11 +1048,11 @@
eb1->h_suballoc_blkno =
(fileOffset >> osb->sb->s_blocksize_bits) +
- fel->l_tree_depth;
+ numbhs - 1;
eb1->h_suballoc_node = osb->node_num;
eb1->h_blkno =
(physicalOffset >> osb->sb->s_blocksize_bits) +
- fel->l_tree_depth;
+ numbhs - 1;
eb1->h_parent_blk = parent_blk;
eb1->h_next_leaf_blk = 0;
@@ -1085,7 +1087,7 @@
eb1 = (ocfs2_extent_block *) bh->b_data;
if (!IS_VALID_EXTENT_BLOCK(eb1) ||
- (eb1->h_list.l_tree_depth != -1)) {
+ eb1->h_list.l_tree_depth) {
brelse(bh);
LOG_ERROR_STATUS (status = -EINVAL);
goto finally;
@@ -1102,7 +1104,7 @@
}
/* Update the uphdrptr of the extents pointed to by fe */
- if (fel->l_tree_depth > 0) {
+ if (fel->l_tree_depth > 1) {
int i;
struct buffer_head *bh = NULL;
@@ -1190,7 +1192,7 @@
}
fel = &fe->id2.i_list;
- if (fel->l_tree_depth < 0) {
+ if (!fel->l_tree_depth) {
LOG_TRACE_ARGS("Using local extents: depth=%d, next_free=%u, l_count=%u\n",
fel->l_tree_depth, fel->l_next_free_rec, fel->l_count);
/* We are still using the local extents of File Entry */
@@ -1210,7 +1212,7 @@
/* We cannot merge try to give him the next extent */
k = fel->l_next_free_rec;
- if (k != fel->l_count) {
+ if (k < fel->l_count) {
/* file_off for the new extent will be equal
* to the previous allocation size of file */
fel->l_recs[k].e_cpos = fe->i_clusters;
@@ -1228,8 +1230,9 @@
/*** Nonlocal Extents ***/
/* 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);
+ if (fel->l_tree_depth > 4)
+ LOG_ERROR_ARGS ("inode %llu, tree_depth=%u",
+ OCFS_I(inode)->ip_blkno, fel->l_tree_depth);
/* This File is no longer using Local Extents */
IncreaseTreeDepth = 0;
@@ -1244,7 +1247,7 @@
eb1 = (ocfs2_extent_block *) eb1_bh->b_data;
el1 = &eb1->h_list;
if (!IS_VALID_EXTENT_BLOCK(eb1) ||
- (el1->l_tree_depth != -1)) {
+ el1->l_tree_depth) {
LOG_ERROR_STATUS (status = -EINVAL);
goto finally;
}
@@ -1257,6 +1260,7 @@
/* See if we can merge the extents and just increase
* the length */
+ /* FIXME: If k < 0, shouldn't we ERROR_RO_FS? */
if (k >= 0 && ocfs_extent_contig(inode, &(el1->l_recs[k]), blkno)) {
status = ocfs_journal_access(handle, eb1_bh,
OCFS_JOURNAL_ACCESS_WRITE);
@@ -1265,9 +1269,6 @@
goto finally;
}
- eb1 = (ocfs2_extent_block *) eb1_bh->b_data;
- el1 = &eb1->h_list;
-
el1->l_recs[k].e_clusters += new_clusters;
status = 0;
UpdateParent = 1;
@@ -1277,7 +1278,7 @@
/* We cannot merge, give him the next extent */
k = el1->l_next_free_rec;
- if (k != el1->l_count) {
+ if (k < el1->l_count) {
/* we can just add next extent */
status = ocfs_journal_access(handle, eb1_bh,
OCFS_JOURNAL_ACCESS_WRITE);
@@ -1299,12 +1300,12 @@
* upward till we find a free extent or we are
* at the top and need to create another
* level. */
- if (fel->l_tree_depth > 0)
+ if (fel->l_tree_depth > 1)
parent_blk = eb1->h_parent_blk;
else
parent_blk = 0;
- for (i = 0; i < fel->l_tree_depth; i++) {
+ for (i = 1; i < fel->l_tree_depth; i++) {
/* if we loop back around */
if (eb2) {
brelse(eb2_bh);
@@ -1324,7 +1325,7 @@
eb2 = (ocfs2_extent_block *) eb2_bh->b_data;
el2 = &eb2->h_list;
if (!IS_VALID_EXTENT_BLOCK(eb2) ||
- (el2->l_tree_depth < 0)) {
+ !el2->l_tree_depth) {
LOG_ERROR_STATUS (status = -EINVAL);
goto finally;
}
@@ -1339,7 +1340,7 @@
break;
parent_blk = eb2->h_parent_blk;
- } /* for (i = 0; i < fe->i_tree_depth; i++) */
+ } /* for (i = 1; i < fe->i_tree_depth; i++) */
if (eb2) {
eb2 = NULL;
@@ -1358,8 +1359,8 @@
/* ok, we need to add a branch. pass in NULL
* if we need a whole branch, otherwise the
* extent which needs the new leaf */
- status = ocfs_allocate_new_data_node(osb, fe,
- new_clusters,
+ status = ocfs_allocate_new_data_node(osb, fe, blkno,
+ new_clusters,
eb2_bh,
&new_eb_blkno,
handle, inode);
@@ -1394,7 +1395,7 @@
}
if (!IncreaseTreeDepth && UpdateParent) {
- for (i = 0; i < fel->l_tree_depth; i++) {
+ for (i = 1; i < fel->l_tree_depth; i++) {
/* next two if's are for loop around */
if (eb2_bh) {
@@ -1426,7 +1427,7 @@
eb2 = (ocfs2_extent_block *) eb2_bh->b_data;
el2 = &eb2->h_list;
if (!IS_VALID_EXTENT_BLOCK(eb2) ||
- (el2->l_tree_depth < 0)) {
+ !el2->l_tree_depth) {
LOG_ERROR_STATUS (status = -EINVAL);
goto finally;
}
@@ -1660,7 +1661,7 @@
cur_el = &cur_eb->h_list;
- if (cur_el->l_tree_depth == -1) {
+ if (!cur_el->l_tree_depth) {
LOG_TRACE_ARGS("found some data to free (%llu)\n", cur_eb->h_blkno);
for(i = 0; i < cur_el->l_next_free_rec; i++) {
/* Free the data associated with each header */
@@ -1823,11 +1824,11 @@
LOG_ENTRY();
- /* This is a similar hack to the one below, untested for depth = 3 files
- because I can't recreate one. */
- 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");
+ /* This is a similar hack to the one below, untested for depth
+ = 4 files because I can't recreate one. */
+ if (depth == 4) {
+ LOG_ERROR_STR("Truncating file with tree_depth 4, this is not tested and may be unsafe!");
+ LOG_TRACE_STR("Found a tree_depth 4 tree, trimming it.\n");
status = ocfs_journal_access(handle, eb_bh,
OCFS_JOURNAL_ACCESS_WRITE);
@@ -1896,15 +1897,15 @@
eb_bh = tmp_bh2;
/* We want to do the next bit of stuff too */
- depth = 2;
+ depth = 3;
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 (depth == 2) {
- LOG_TRACE_STR("Found a tree_depth 2 tree, trimming it.\n");
+ proceeed as if we're tree_depth 2 (which we know works) */
+ if (depth == 3) {
+ LOG_TRACE_STR("Found a tree_depth 3 tree, trimming it.\n");
status = ocfs_journal_access(handle, eb_bh,
OCFS_JOURNAL_ACCESS_WRITE);
@@ -1978,7 +1979,7 @@
/* Right now, we don't use 'depth' below here, but just
* in case */
- depth = 1;
+ depth = 2;
if (needs_brelse)
brelse(tmp_bh2);
needs_brelse = 1;
@@ -2009,7 +2010,7 @@
el = &alloc_eb->h_list;
- if (el->l_tree_depth == -1) {
+ if (!el->l_tree_depth) {
/* shall we just do away with him? */
if (el->l_recs[0].e_cpos >= fe->i_clusters) {
LOG_TRACE_ARGS("Killing this data extent (%llu)\n", alloc_eb->h_blkno);
@@ -2200,7 +2201,7 @@
}
/* I just have to fix my parent,
* right? Yes, but only because our
- * max tree_depth is 2. if it were
+ * max tree_depth is 3. if it were
* more, we'd have to fix his
* parents parent. */
status = ocfs_journal_access(handle, bh_stack[tos], OCFS_JOURNAL_ACCESS_WRITE);
@@ -2226,7 +2227,7 @@
* that case we're done, but need to
* write the parent out before we leave
* again, this bit of code depends on
- * tree_depth of 2. */
+ * tree_depth of 3. */
if (done) {
LOG_TRACE_STR("Found a boundary " \
"header, almost done " \
@@ -2356,7 +2357,7 @@
}
/* Can't be called with local extents */
- if (fel->l_tree_depth < 0)
+ if (!fel->l_tree_depth)
BUG();
/* Ugly magic -1 */
@@ -2379,7 +2380,7 @@
el = &eb->h_list;
- while (el->l_tree_depth >= 0) {
+ while (el->l_tree_depth) {
if (!IS_VALID_EXTENT_BLOCK(eb)) {
LOG_ERROR_STR("Invalid extent block!");
goto bail;
@@ -2438,7 +2439,7 @@
fel = &fe->id2.i_list;
/* local extents */
- if (fel->l_tree_depth < 0) {
+ if (!fel->l_tree_depth) {
status = _squish_extent_entries(osb, fel->l_recs,
&fel->l_next_free_rec,
handle, fe->i_clusters,
@@ -2515,7 +2516,7 @@
/* Ok, trunc to zero is a special case, doofus */
if (fe->i_clusters == 0) {
fe->i_last_eb_blk = 0;
- fel->l_tree_depth = -1;
+ fel->l_tree_depth = 0;
updated_leb = 1;
}
@@ -2655,7 +2656,7 @@
goto finally;
}
- if (fe->id2.i_list.l_tree_depth < 0) {
+ if (!fe->id2.i_list.l_tree_depth) {
if (!locked)
down(&(OCFS_I(inode)->ip_sem));
status = ocfs_update_extent_map(osb,
@@ -2723,7 +2724,7 @@
}
eb = (ocfs2_extent_block *) eb_bh->b_data;
if (!IS_VALID_EXTENT_BLOCK(eb) ||
- (eb->h_list.l_tree_depth != -1)) {
+ eb->h_list.l_tree_depth) {
LOG_ERROR_STATUS (status = -EINVAL);
goto finally;
}
@@ -2798,7 +2799,7 @@
goto finally;
}
- for (i = 0; i < fel->l_tree_depth; i++) {
+ for (i = 1; i < fel->l_tree_depth; i++) {
tempstat = ocfs_read_bh(osb,
child_blkno << osb->sb->s_blocksize_bits,
&ext_bh, OCFS_BH_COND_CACHED,
@@ -2845,7 +2846,7 @@
tmp = (ocfs2_extent_block *) (*data_extent_bh)->b_data;
if (!IS_VALID_EXTENT_BLOCK(tmp) ||
- (tmp->h_list.l_tree_depth != -1)) {
+ tmp->h_list.l_tree_depth) {
LOG_ERROR_STATUS (status = -EINVAL);
brelse(*data_extent_bh);
*data_extent_bh = NULL;
@@ -3350,7 +3351,7 @@
fe = (ocfs2_dinode *) fe_bh->b_data;
fel = &fe->id2.i_list;
- if (fel->l_tree_depth < 0) {
+ if (!fel->l_tree_depth) {
for (i = 0; i < fel->l_next_free_rec; i++) {
numBitsAllocated = fel->l_recs[i].e_clusters;
@@ -3374,8 +3375,7 @@
goto leave;
}
extent = (ocfs2_extent_block *) extent_bh->b_data;
- if (fel->l_tree_depth &&
- !IS_VALID_EXTENT_BLOCK(extent)) {
+ if (!IS_VALID_EXTENT_BLOCK(extent)) {
status = -EINVAL;
LOG_ERROR_STATUS(status);
goto leave;
Modified: trunk/src/extmap.c
===================================================================
--- trunk/src/extmap.c 2004-06-28 19:51:42 UTC (rev 1219)
+++ trunk/src/extmap.c 2004-06-29 00:52:36 UTC (rev 1220)
@@ -607,7 +607,7 @@
fe = Buffer;
el = &fe->id2.i_list;
- OCFS_ASSERT(el->l_tree_depth < 0);
+ OCFS_ASSERT(!el->l_tree_depth);
for (j = 0; j < el->l_next_free_rec; j++) {
/* Add the Extent to extent map list */
Modified: trunk/src/file.c
===================================================================
--- trunk/src/file.c 2004-06-28 19:51:42 UTC (rev 1219)
+++ trunk/src/file.c 2004-06-29 00:52:36 UTC (rev 1220)
@@ -445,7 +445,7 @@
#endif
el = &fe->id2.i_list;
- if (el->l_tree_depth < 0) {
+ if (!el->l_tree_depth) {
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,
@@ -473,7 +473,7 @@
el = &eb->h_list;
if (!IS_VALID_EXTENT_BLOCK(eb) ||
- (el->l_tree_depth != -1)) {
+ el->l_tree_depth) {
LOG_ERROR_STATUS(ret = -EFAIL);
goto leave;
}
@@ -1214,6 +1214,7 @@
/* we give a lot more disk space to the file than the alloc_size so */
/* in order to try to use the Extents of File Entry only and ofcourse */
/* the file will have more contigous disk space. */
+
if (!system_file) {
int one_percentish_bits = 7;
__u64 tempSize = current_alloc;
Modified: trunk/src/inode.c
===================================================================
--- trunk/src/inode.c 2004-06-28 19:51:42 UTC (rev 1219)
+++ trunk/src/inode.c 2004-06-29 00:52:36 UTC (rev 1220)
@@ -1995,7 +1995,7 @@
}
fel = &fe->id2.i_list;
- if (fel->l_tree_depth < 0) {
+ if (!fel->l_tree_depth) {
__u32 j;
/* Add the Extents to extent map */
Modified: trunk/src/namei.c
===================================================================
--- trunk/src/namei.c 2004-06-28 19:51:42 UTC (rev 1219)
+++ trunk/src/namei.c 2004-06-29 00:52:36 UTC (rev 1220)
@@ -454,7 +454,7 @@
fe->i_dtime = 0;
fel = &fe->id2.i_list;
- fel->l_tree_depth = -1;
+ fel->l_tree_depth = 0;
fel->l_next_free_rec = 0;
fel->l_count = ocfs2_extent_recs_per_inode(osb->sb);
Modified: trunk/src/ocfs2_fs.h
===================================================================
--- trunk/src/ocfs2_fs.h 2004-06-28 19:51:42 UTC (rev 1219)
+++ trunk/src/ocfs2_fs.h 2004-06-29 00:52:36 UTC (rev 1220)
@@ -231,8 +231,8 @@
* ocfs2_extent_block.h_list, respectively.
*/
typedef struct _ocfs2_extent_list {
-/*00*/ __s16 l_tree_depth; /* Extent tree depth from this
- point. -1 means data extents
+/*00*/ __u16 l_tree_depth; /* Extent tree depth from this
+ point. 0 means data extents
hang directly off this
header (a leaf) */
__u16 l_count; /* Number of extent records */
More information about the Ocfs2-commits
mailing list