[Ocfs2-commits] jlbec commits r1037 - branches/format-changes/src
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Wed Jun 9 15:15:27 CDT 2004
Author: jlbec
Date: 2004-06-09 14:15:25 -0500 (Wed, 09 Jun 2004)
New Revision: 1037
Modified:
branches/format-changes/src/Makefile
branches/format-changes/src/alloc.c
branches/format-changes/src/buffer_head_io.c
branches/format-changes/src/extmap.c
branches/format-changes/src/extmap.h
branches/format-changes/src/file.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/sysfile.c
Log:
o Extent header changes. Fields are in blocks. Names are sane.
All's well.
o This is not the final extent header layout. The static definition
of MAX_DATA_EXTENTS will become a dynamic value based on s_blocksize.
o A few random ocfs.h cleanups as well. Removing unused things, etc.
Modified: branches/format-changes/src/Makefile
===================================================================
--- branches/format-changes/src/Makefile 2004-06-09 10:40:10 UTC (rev 1036)
+++ branches/format-changes/src/Makefile 2004-06-09 19:15:25 UTC (rev 1037)
@@ -122,6 +122,7 @@
CFILES = \
alloc.c \
bitmap.c \
+ buffer_head_io.c \
dcache.c \
dir.c \
dlm.c \
@@ -130,7 +131,6 @@
hash.c \
heartbeat.c \
inode.c \
- buffer_head_io.c \
ioctl.c \
journal.c \
lockres.c \
Modified: branches/format-changes/src/alloc.c
===================================================================
--- branches/format-changes/src/alloc.c 2004-06-09 10:40:10 UTC (rev 1036)
+++ branches/format-changes/src/alloc.c 2004-06-09 19:15:25 UTC (rev 1037)
@@ -79,7 +79,7 @@
ocfs2_dinode * FileEntry,
u32 new_clusters,
struct buffer_head * extent_header_bh,
- __u64 * NewExtentOffset,
+ u64 *new_eh_blkno,
ocfs_journal_handle *handle,
struct inode *inode);
@@ -90,13 +90,15 @@
u32 new_clusters, struct inode *inode);
static int _squish_extent_entries(ocfs_super *osb,
- ocfs_extent_rec *extarr,
+ ocfs2_extent_rec *extarr,
__u16 *freeExtent,
ocfs_journal_handle *handle,
u32 num_clusters, int flag,
struct inode *inode);
-static int ocfs_fix_extent_group(ocfs_super *osb, struct buffer_head *group_bh, struct inode *inode);
+static int ocfs_fix_extent_header(ocfs_super *osb,
+ struct buffer_head *eh_bh,
+ struct inode *inode);
static int ocfs_split_this_tree(ocfs_super * osb,
struct buffer_head *extent_grp_bh,
@@ -104,7 +106,8 @@
ocfs2_dinode *fe,
struct inode *inode);
-static int ocfs_update_last_ext_ptr(ocfs_super *osb, ocfs2_dinode *fe, struct inode *inode);
+static int ocfs_update_last_eh_blk(ocfs_super *osb, ocfs2_dinode *fe,
+ struct inode *inode);
static int ocfs_free_vol_block (ocfs_super * osb, ocfs_journal_handle *handle,
ocfs_free_rec * FreeLog, __u32 NodeNum,
@@ -129,10 +132,10 @@
__u64 * bitoff, __u64 * bitcount,
ocfs_journal_handle *handle);
static int ocfs_local_find_clear_bits(ocfs_super *osb, ocfs_local_alloc *alloc, __u32 numbits);
-static int ocfs_extent_contig(struct inode *inode, ocfs_extent_rec *ext,
+static int ocfs_extent_contig(struct inode *inode, ocfs2_extent_rec *ext,
u64 blkno);
-static int ocfs_extent_contig(struct inode *inode, ocfs_extent_rec *ext,
+static int ocfs_extent_contig(struct inode *inode, ocfs2_extent_rec *ext,
u64 blkno)
{
u64 start_blkno = ext->e_blkno;
@@ -642,7 +645,7 @@
ocfs2_dinode *fe,
u32 new_clusters,
struct buffer_head *extent_header_bh,
- __u64 *NewExtentOffset,
+ u64 *new_eh_blkno,
ocfs_journal_handle *handle,
struct inode *inode)
{
@@ -651,13 +654,12 @@
__u32 k, i;
__u32 depth;
__u32 allocSize;
- __u64 upHeaderPtr;
+ u64 parent_blk;
__u64 physicalOffset;
u64 phys_blkno;
__u64 fileOffset = 0;
__u64 numSectorsAlloc = 0;
- __u64 lastExtPointer;
- ocfs_extent_group* extent_header = NULL;
+ ocfs2_extent_header* extent_header = NULL;
struct buffer_head **header_bhs = NULL;
struct buffer_head *bh = NULL;
int bh_locked = 0;
@@ -678,12 +680,11 @@
bh_locked = 1;
}
if (extent_header != NULL) {
- depth = extent_header->granularity;
- upHeaderPtr = extent_header->this_ext;
+ depth = extent_header->h_tree_depth;
+ parent_blk = extent_header->h_blkno;
} else {
depth = fe->i_tree_depth;
- upHeaderPtr =
- fe->i_blkno << inode->i_sb->s_blocksize_bits;
+ parent_blk = fe->i_blkno;
}
numSectorsAlloc = NUM_SECTORS_IN_LEAF_NODE + depth;
@@ -730,54 +731,51 @@
}
if (extent_header != NULL) {
- k = extent_header->next_free_ext;
+ k = extent_header->h_next_free_rec;
extent_header->extents[k].e_cpos =
fe->i_clusters;
extent_header->extents[k].e_clusters = new_clusters;
extent_header->extents[k].e_blkno = phys_blkno;
- extent_header->next_free_ext++;
+ extent_header->h_next_free_rec++;
} else {
- k = fe->i_next_free_ext;
+ 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_ext++;
+ fe->i_next_free_rec++;
}
-
- lastExtPointer = fe->last_ext_ptr;
-
/* Fill in all the headers and the leaf */
for (i = 0; i <= depth; i++) {
- ocfs_extent_group *ext;
+ ocfs2_extent_header *ext;
ext = OCFS_BH_GET_DATA_WRITE(header_bhs[i]);
- ext->last_ext_ptr = lastExtPointer;
- ext->up_hdr_node_ptr = upHeaderPtr;
- ext->next_free_ext = 1;
- ext->alloc_file_off = fileOffset + (osb->sect_size * i);
- ext->alloc_node = osb->node_num;
+ ext->h_parent_blk = parent_blk;
+ ext->h_next_free_rec = 1;
+ ext->h_suballoc_blkno =
+ (fileOffset >> osb->sb->s_blocksize_bits) + i;
+ ext->h_suballoc_node = osb->node_num;
ext->extents[0].e_cpos = fe->i_clusters;
ext->extents[0].e_clusters = new_clusters;
- ext->this_ext = physicalOffset + (osb->sect_size * i);
+ ext->h_blkno =
+ (physicalOffset >> osb->sb->s_blocksize_bits) + i;
+ ext->h_tree_depth = (depth - 1 - i);
if (i != depth) {
/* fill in each header */
- ext->type = OCFS_EXTENT_HEADER;
ext->extents[0].e_blkno = phys_blkno + (i + 1);
- ext->granularity = (depth - 1 - i);
- strcpy (ext->signature, OCFS_EXTENT_HEADER_SIGNATURE);
+ strcpy(ext->signature,
+ OCFS_EXTENT_HEADER_SIGNATURE);
} else {
/* fill in the leaf */
- ext->type = OCFS_EXTENT_DATA;
ext->extents[0].e_blkno = phys_blkno;
- ext->curr_sect = 1;
- ext->max_sects = NUM_SECTORS_IN_LEAF_NODE;
- strcpy (ext->signature, OCFS_EXTENT_DATA_SIGNATURE);
- (*NewExtentOffset) = fe->last_ext_ptr = ext->this_ext;
+ strcpy(ext->signature,
+ OCFS_EXTENT_DATA_SIGNATURE);
+ *new_eh_blkno = fe->i_last_eh_blk =
+ ext->h_blkno;
}
- upHeaderPtr = lastExtPointer = ext->this_ext;
+ parent_blk = ext->h_blkno;
OCFS_BH_PUT_DATA(header_bhs[i]);
}
@@ -791,8 +789,8 @@
if (extent_header != NULL) {
/* both needed below in for loop */
- __u64 up_hdr_node_ptr = extent_header->up_hdr_node_ptr;
- int tree_depth = extent_header->granularity;
+ u64 tmp_blk = extent_header->h_parent_blk;
+ int tree_depth = extent_header->h_tree_depth;
OCFS_BH_PUT_DATA(extent_header_bh);
bh_locked = 0;
@@ -809,7 +807,10 @@
* longer needed for it's original purpose. */
for (i = tree_depth + 1; i < fe->i_tree_depth; i++) {
bh = NULL;
- status = ocfs_read_bh (osb, up_hdr_node_ptr, &bh, OCFS_BH_COND_CACHED, inode);
+ status = ocfs_read_bh(osb,
+ tmp_blk << osb->sb->s_blocksize_bits,
+ &bh, OCFS_BH_COND_CACHED,
+ inode);
if (status < 0) {
LOG_ERROR_STATUS (status);
goto finally;
@@ -829,18 +830,18 @@
goto finally;
}
- if (extent_header->next_free_ext == 0) {
+ if (extent_header->h_next_free_rec == 0) {
OCFS_BH_PUT_DATA(bh);
brelse(bh);
LOG_ERROR_STATUS (status = -EFAIL);
goto finally;
}
- k = extent_header->next_free_ext - 1;
+ k = extent_header->h_next_free_rec - 1;
extent_header->extents[k].e_clusters +=
new_clusters;
- up_hdr_node_ptr = extent_header->up_hdr_node_ptr;
+ tmp_blk = extent_header->h_parent_blk;
OCFS_BH_PUT_DATA(bh);
status = ocfs_journal_dirty(handle, bh);
@@ -852,7 +853,7 @@
brelse(bh);
}
- k = fe->i_next_free_ext - 1;
+ k = fe->i_next_free_rec - 1;
fe->extents[k].e_clusters += new_clusters;
}
finally:
@@ -879,15 +880,14 @@
{
int status = 0;
__s32 k, i;
- ocfs_extent_group *OcfsExtent = NULL;
- ocfs_extent_group *ExtentHeader = NULL;
- ocfs_extent_group *ext = NULL;
+ ocfs2_extent_header *eh1 = NULL;
+ ocfs2_extent_header *eh2 = NULL;
+ ocfs2_extent_header *eh3 = NULL;
__u64 physicalOffset;
__u64 fileOffset = 0;
- u64 phys_blkno;
- __u64 upHeaderPtr, lastExtentPtr;
+ u64 phys_blkno, parent_blk, last_eh_blkno;
__u32 AllocSize;
- __u64 new_up_hdr_ptr = 0;
+ u64 new_parent_blk = 0;
struct buffer_head **bhs = NULL;
int numbhs = 0;
void *buf;
@@ -950,21 +950,23 @@
goto finally;
}
- OcfsExtent = OCFS_BH_GET_DATA_WRITE(bhs[0]);
+ eh1 = OCFS_BH_GET_DATA_WRITE(bhs[0]);
/* Copy the File Entry information in to the newly allocated sector */
for (k = 0; k < OCFS_MAX_FILE_ENTRY_EXTENTS; k++) {
- OcfsExtent->extents[k].e_cpos = fe->extents[k].e_cpos;
- OcfsExtent->extents[k].e_clusters =
+ eh1->extents[k].e_cpos = fe->extents[k].e_cpos;
+ eh1->extents[k].e_clusters =
fe->extents[k].e_clusters;
- OcfsExtent->extents[k].e_blkno = fe->extents[k].e_blkno;
+ eh1->extents[k].e_blkno = fe->extents[k].e_blkno;
}
- OcfsExtent->last_ext_ptr = fe->last_ext_ptr;
- lastExtentPtr = fe->last_ext_ptr;
- OcfsExtent->this_ext = new_up_hdr_ptr = physicalOffset;
- OcfsExtent->alloc_file_off = fileOffset;
- OcfsExtent->alloc_node = osb->node_num;
- OcfsExtent->next_data_ext = 0;
+ last_eh_blkno = fe->i_last_eh_blk;
+ eh1->h_blkno =
+ physicalOffset >> osb->sb->s_blocksize_bits;
+ new_parent_blk = eh1->h_blkno;
+ eh1->h_suballoc_blkno =
+ fileOffset >> osb->sb->s_blocksize_bits;
+ eh1->h_suballoc_node = osb->node_num;
+ eh1->h_next_leaf_blk = 0;
fe->i_tree_depth++;
LOG_TRACE_ARGS ("Granularity is: %d\n", fe->i_tree_depth);
@@ -974,77 +976,73 @@
/* If tree_depth is zero now, the for loop will not execute. */
/* First time a file is created, tree_depth = -1 */
- upHeaderPtr = fe->i_blkno << osb->sb->s_blocksize_bits;
+ parent_blk = fe->i_blkno;
for (i = 0; i < fe->i_tree_depth; i++) {
- ExtentHeader = OCFS_BH_GET_DATA_WRITE(bhs[i]);
+ eh2 = OCFS_BH_GET_DATA_WRITE(bhs[i]);
- ExtentHeader->type = OCFS_EXTENT_HEADER;
- ExtentHeader->granularity = (fe->i_tree_depth - 1) - i;
+ eh2->h_tree_depth = (fe->i_tree_depth - 1) - i;
- strcpy (ExtentHeader->signature, OCFS_EXTENT_HEADER_SIGNATURE);
+ strcpy(eh2->signature, OCFS_EXTENT_HEADER_SIGNATURE);
if (i == 0) {
- ExtentHeader->extents[OCFS_MAX_FILE_ENTRY_EXTENTS].e_blkno = phys_blkno + 1;
- ExtentHeader->extents[OCFS_MAX_FILE_ENTRY_EXTENTS].e_cpos = fe->i_clusters;
- ExtentHeader->extents[OCFS_MAX_FILE_ENTRY_EXTENTS].e_clusters = new_clusters;
+ eh2->extents[OCFS_MAX_FILE_ENTRY_EXTENTS].e_blkno = phys_blkno + 1;
+ eh2->extents[OCFS_MAX_FILE_ENTRY_EXTENTS].e_cpos = fe->i_clusters;
+ eh2->extents[OCFS_MAX_FILE_ENTRY_EXTENTS].e_clusters = new_clusters;
- ExtentHeader->next_free_ext = OCFS_MAX_FILE_ENTRY_EXTENTS + 1;
- ExtentHeader->this_ext = physicalOffset;
- ExtentHeader->last_ext_ptr = lastExtentPtr;
- ExtentHeader->up_hdr_node_ptr = upHeaderPtr;
+ eh2->h_next_free_rec = OCFS_MAX_FILE_ENTRY_EXTENTS + 1;
+ eh2->h_blkno =
+ physicalOffset >> osb->sb->s_blocksize_bits;
+ eh2->h_parent_blk = parent_blk;
- upHeaderPtr = ExtentHeader->this_ext;
- lastExtentPtr = ExtentHeader->this_ext;
+ parent_blk = last_eh_blkno = eh2->h_blkno;
} else {
- ExtentHeader->extents[0].e_blkno = phys_blkno +
+ eh2->extents[0].e_blkno = phys_blkno +
(i + 1);
- ExtentHeader->extents[0].e_cpos =
+ eh2->extents[0].e_cpos =
fe->i_clusters;
- ExtentHeader->extents[0].e_clusters = new_clusters;
- ExtentHeader->next_free_ext = 1;
- ExtentHeader->alloc_file_off = fileOffset + (osb->sect_size * i);
- ExtentHeader->alloc_node = osb->node_num;
- ExtentHeader->this_ext = physicalOffset + (osb->sect_size * i);
- ExtentHeader->up_hdr_node_ptr = upHeaderPtr;
- ExtentHeader->last_ext_ptr = lastExtentPtr;
+ eh2->extents[0].e_clusters = new_clusters;
+ eh2->h_next_free_rec = 1;
+ eh2->h_suballoc_blkno =
+ (fileOffset >> osb->sb->s_blocksize_bits) + i;
+ eh2->h_suballoc_node = osb->node_num;
+ eh2->h_blkno =
+ (physicalOffset >> osb->sb->s_blocksize_bits) + i;
+ eh2->h_parent_blk = parent_blk;
- upHeaderPtr = ExtentHeader->this_ext;
- lastExtentPtr = ExtentHeader->this_ext;
+ parent_blk = last_eh_blkno = eh2->h_blkno;
}
OCFS_BH_PUT_DATA(bhs[i]);
}
/* Update the Data Segment, which is the last one in our array */
- OcfsExtent = OCFS_BH_GET_DATA_WRITE(bhs[fe->i_tree_depth]);
+ eh1 = OCFS_BH_GET_DATA_WRITE(bhs[fe->i_tree_depth]);
i = (fe->i_tree_depth) ? 0 : OCFS_MAX_FILE_ENTRY_EXTENTS;
- LOG_TRACE_ARGS ("EntryAvailable is: %d\n", OcfsExtent->next_free_ext);
+ LOG_TRACE_ARGS ("EntryAvailable is: %d\n", eh1->h_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 (OcfsExtent->signature, OCFS_EXTENT_DATA_SIGNATURE);
+ strcpy (eh1->signature, OCFS_EXTENT_DATA_SIGNATURE);
+ eh1->h_tree_depth = -1;
- OcfsExtent->extents[i].e_cpos = fe->i_clusters;
- OcfsExtent->extents[i].e_clusters = new_clusters;
- OcfsExtent->extents[i].e_blkno = blkno;
- OcfsExtent->curr_sect = 1;
- OcfsExtent->max_sects = NUM_SECTORS_IN_LEAF_NODE;
- OcfsExtent->type = OCFS_EXTENT_DATA;
- OcfsExtent->next_free_ext = i + 1;
- OcfsExtent->alloc_file_off = fileOffset +
- (fe->i_tree_depth * osb->sect_size);
- OcfsExtent->alloc_node = osb->node_num;
- OcfsExtent->this_ext = physicalOffset +
- (fe->i_tree_depth * osb->sect_size);
- OcfsExtent->up_hdr_node_ptr = upHeaderPtr;
- OcfsExtent->last_ext_ptr = lastExtentPtr;
- OcfsExtent->next_data_ext = 0;
+ eh1->extents[i].e_cpos = fe->i_clusters;
+ eh1->extents[i].e_clusters = new_clusters;
+ eh1->extents[i].e_blkno = blkno;
+ eh1->h_next_free_rec = i + 1;
+ eh1->h_suballoc_blkno =
+ (fileOffset >> osb->sb->s_blocksize_bits) +
+ fe->i_tree_depth;
+ eh1->h_suballoc_node = osb->node_num;
+ eh1->h_blkno =
+ (physicalOffset >> osb->sb->s_blocksize_bits) +
+ fe->i_tree_depth;
+ eh1->h_parent_blk = parent_blk;
+ eh1->h_next_leaf_blk = 0;
- upHeaderPtr = OcfsExtent->this_ext;
- lastExtentPtr = OcfsExtent->this_ext;
+ parent_blk = last_eh_blkno = eh1->h_blkno;
OCFS_BH_PUT_DATA(bhs[fe->i_tree_depth]);
@@ -1057,10 +1055,12 @@
/* Update the Previous Last Data Extent with this new Data
* Extent Pointer */
- if (fe->last_ext_ptr != 0) {
+ if (fe->i_last_eh_blk != 0) {
struct buffer_head *bh = NULL;
- status = ocfs_read_bh(osb, fe->last_ext_ptr, &bh, OCFS_BH_COND_CACHED, inode);
+ status = ocfs_read_bh(osb,
+ fe->i_last_eh_blk << osb->sb->s_blocksize_bits,
+ &bh, OCFS_BH_COND_CACHED, inode);
if (status < 0) {
LOG_ERROR_STATUS (status);
goto finally;
@@ -1073,15 +1073,16 @@
goto finally;
}
- ext = OCFS_BH_GET_DATA_WRITE(bh);
- if (!IS_VALID_EXTENT_DATA(ext)) {
+ eh3 = OCFS_BH_GET_DATA_WRITE(bh);
+ if (!IS_VALID_EXTENT_HEADER(eh3) ||
+ (eh3->h_tree_depth != -1)) {
OCFS_BH_PUT_DATA(bh);
brelse(bh);
LOG_ERROR_STATUS (status = -EINVAL);
goto finally;
}
- ext->next_data_ext = lastExtentPtr;
+ eh3->h_next_leaf_blk = last_eh_blkno;
OCFS_BH_PUT_DATA(bh);
status = ocfs_journal_dirty(handle, bh);
@@ -1095,13 +1096,14 @@
/* Update the uphdrptr of the three extents pointed to by fe */
if (fe->i_tree_depth > 0) {
int i;
- __u64 offset;
struct buffer_head *bh = NULL;
status = 0;
for (i = 0; i < OCFS_MAX_FILE_ENTRY_EXTENTS; ++i) {
- offset = fe->extents[i].e_blkno << osb->sb->s_blocksize_bits;
- status = ocfs_read_bh(osb, offset, &bh, OCFS_BH_COND_CACHED, inode);
+ status = ocfs_read_bh(osb,
+ fe->extents[i].e_blkno << osb->sb->s_blocksize_bits,
+ &bh, OCFS_BH_COND_CACHED,
+ inode);
if (status < 0) {
LOG_ERROR_STATUS(status);
brelse(bh);
@@ -1115,8 +1117,8 @@
goto finally;
}
- ext = OCFS_BH_GET_DATA_WRITE(bh);
- ext->up_hdr_node_ptr = new_up_hdr_ptr;
+ eh3 = OCFS_BH_GET_DATA_WRITE(bh);
+ eh3->h_parent_blk = new_parent_blk;
OCFS_BH_PUT_DATA(bh);
status = ocfs_journal_dirty(handle, bh);
@@ -1140,8 +1142,8 @@
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;
- fe->last_ext_ptr = lastExtentPtr;
- fe->i_next_free_ext = 1;
+ fe->i_last_eh_blk = last_eh_blkno;
+ fe->i_next_free_rec = 1;
finally:
@@ -1169,10 +1171,10 @@
int status = 0;
int IncreaseTreeDepth = 0;
int k = 0, i;
- ocfs_extent_group *extent = NULL, *extent_header = NULL;
- struct buffer_head *extent_bh = NULL, *extent_header_bh = NULL;
+ ocfs2_extent_header *eh1 = NULL, *eh2 = NULL;
+ struct buffer_head *eh1_bh = NULL, *eh2_bh = NULL;
int UpdateParent = 0;
- __u64 newExtentOff, up_ptr;
+ u64 parent_blk, new_eh_blkno;
ocfs2_dinode * fe = NULL;
LOG_ENTRY_ARGS("(blkno=%llu, new_clusters=%u)\n", blkno, new_clusters);
@@ -1188,12 +1190,12 @@
if (fe->i_tree_depth < 0) {
LOG_TRACE_STR("Using local extents");
/* We are still using the local extents of File Entry */
- if (fe->i_next_free_ext > OCFS_MAX_FILE_ENTRY_EXTENTS) {
+ if (fe->i_next_free_rec > OCFS_MAX_FILE_ENTRY_EXTENTS) {
LOG_ERROR_STATUS(status = -EINVAL);
goto finally;
}
- k = fe->i_next_free_ext - 1;
+ k = fe->i_next_free_rec - 1;
if (k >= 0 &&
ocfs_extent_contig(inode, &fe->extents[k], blkno)) {
/* See if we can merge the extents and just increase the length */
@@ -1203,7 +1205,7 @@
}
/* We cannot merge try to give him the next extent */
- k = fe->i_next_free_ext;
+ k = fe->i_next_free_rec;
if (k != OCFS_MAX_FILE_ENTRY_EXTENTS) {
/* file_off for the new extent will be equal
* to the previous allocation size of file */
@@ -1211,7 +1213,7 @@
fe->i_clusters;
fe->extents[k].e_clusters = new_clusters;
fe->extents[k].e_blkno = blkno;
- fe->i_next_free_ext++;
+ fe->i_next_free_rec++;
goto finally;
}
/* We have no more room in the fe, must increase
@@ -1228,116 +1230,125 @@
/* This File is no longer using Local Extents */
IncreaseTreeDepth = 0;
- status = ocfs_read_bh(osb, fe->last_ext_ptr, &extent_bh, OCFS_BH_COND_CACHED, inode);
+ status = ocfs_read_bh(osb,
+ fe->i_last_eh_blk << osb->sb->s_blocksize_bits,
+ &eh1_bh, OCFS_BH_COND_CACHED, inode);
if (status < 0) {
LOG_ERROR_STATUS (status = -EINVAL);
goto finally;
}
- extent = OCFS_BH_GET_DATA_WRITE(extent_bh);
- if (!IS_VALID_EXTENT_DATA(extent)) {
+ eh1 = OCFS_BH_GET_DATA_WRITE(eh1_bh);
+ if (!IS_VALID_EXTENT_HEADER(eh1) ||
+ (eh1->h_tree_depth != -1)) {
LOG_ERROR_STATUS (status = -EINVAL);
goto finally;
}
- k = extent->next_free_ext - 1;
+ k = eh1->h_next_free_rec - 1;
LOG_TRACE_ARGS ("Using local extent for extent Entry = %u\n", k);
- if (extent->next_free_ext < 1)
- LOG_ERROR_ARGS ("next_free_ext=%d", extent->next_free_ext);
+ if (eh1->h_next_free_rec < 1)
+ LOG_ERROR_ARGS ("h_next_free_rec=%d", eh1->h_next_free_rec);
/* See if we can merge the extents and just increase
* the length */
if (k >= 0 &&
- ocfs_extent_contig(inode, &(extent->extents[k]), blkno)) {
- OCFS_BH_PUT_DATA(extent_bh);
+ ocfs_extent_contig(inode, &(eh1->extents[k]), blkno)) {
+ OCFS_BH_PUT_DATA(eh1_bh);
- status = ocfs_journal_access(handle, extent_bh,
+ status = ocfs_journal_access(handle, eh1_bh,
OCFS_JOURNAL_ACCESS_WRITE);
if (status < 0) {
LOG_ERROR_STATUS (status);
goto finally;
}
- extent = OCFS_BH_GET_DATA_WRITE(extent_bh);
+ eh1 = OCFS_BH_GET_DATA_WRITE(eh1_bh);
- extent->extents[k].e_clusters += new_clusters;
+ eh1->extents[k].e_clusters += new_clusters;
status = 0;
UpdateParent = 1;
goto do_update_parent;
}
/* We cannot merge, give him the next extent */
- k = extent->next_free_ext;
+ k = eh1->h_next_free_rec;
if (k != OCFS_MAX_DATA_EXTENTS) {
/* we can just add next extent */
- OCFS_BH_PUT_DATA(extent_bh);
+ OCFS_BH_PUT_DATA(eh1_bh);
- status = ocfs_journal_access(handle, extent_bh,
+ status = ocfs_journal_access(handle, eh1_bh,
OCFS_JOURNAL_ACCESS_WRITE);
if (status < 0) {
LOG_ERROR_STATUS (status);
goto finally;
}
- extent = OCFS_BH_GET_DATA_WRITE(extent_bh);
+ eh1 = OCFS_BH_GET_DATA_WRITE(eh1_bh);
- extent->extents[k].e_cpos = fe->i_clusters;
- extent->extents[k].e_clusters = new_clusters;
- extent->extents[k].e_blkno = blkno;
- extent->next_free_ext++;
+ eh1->extents[k].e_cpos = fe->i_clusters;
+ eh1->extents[k].e_clusters = new_clusters;
+ eh1->extents[k].e_blkno = blkno;
+ eh1->h_next_free_rec++;
UpdateParent = 1;
} else {
- __u64 up_hdr_node_ptr = 0;
-
/* Read the last extent and keep traversing
* 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)
- up_hdr_node_ptr = extent->up_hdr_node_ptr;
+ parent_blk = eh1->h_parent_blk;
+ else
+ parent_blk = 0;
for (i = 0; i < fe->i_tree_depth; i++) {
/* if we loop back around */
- if (extent_header) {
- OCFS_BH_PUT_DATA(extent_header_bh);
- brelse(extent_header_bh);
- extent_header = NULL;
- extent_header_bh =NULL;
+ if (eh2) {
+ OCFS_BH_PUT_DATA(eh2_bh);
+ brelse(eh2_bh);
+ eh2 = NULL;
+ eh2_bh =NULL;
}
- status = ocfs_read_bh (osb, up_hdr_node_ptr, &extent_header_bh, OCFS_BH_COND_CACHED, inode);
+ status = ocfs_read_bh(osb,
+ parent_blk << osb->sb->s_blocksize_bits,
+ &eh2_bh,
+ OCFS_BH_COND_CACHED,
+ inode);
if (status < 0) {
LOG_ERROR_STATUS (status);
goto finally;
}
- extent_header = OCFS_BH_GET_DATA_READ(extent_header_bh);
- if (!IS_VALID_EXTENT_HEADER(extent_header)) {
+ eh2 = OCFS_BH_GET_DATA_READ(eh2_bh);
+ if (!IS_VALID_EXTENT_HEADER(eh2) ||
+ (eh2->h_tree_depth < 0)) {
LOG_ERROR_STATUS (status = -EINVAL);
goto finally;
}
- if (extent_header->granularity != i ||
- extent_header->next_free_ext > OCFS_MAX_DATA_EXTENTS) {
+ if (eh2->h_tree_depth != i ||
+ eh2->h_next_free_rec > OCFS_MAX_DATA_EXTENTS) {
LOG_ERROR_STATUS(status = -EINVAL);
goto finally;
}
- if (extent_header->next_free_ext != OCFS_MAX_DATA_EXTENTS)
+ if (eh2->h_next_free_rec != OCFS_MAX_DATA_EXTENTS)
break;
- up_hdr_node_ptr = extent_header->up_hdr_node_ptr;
+ parent_blk = eh2->h_parent_blk;
} /* for (i = 0; i < fe->i_tree_depth; i++) */
- if (extent_header) {
- OCFS_BH_PUT_DATA(extent_header_bh);
- extent_header = NULL;
+ if (eh2) {
+ OCFS_BH_PUT_DATA(eh2_bh);
+ eh2 = NULL;
/* we may still need the bh so don't brelse */
}
/* 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_ext == OCFS_MAX_FILE_ENTRY_EXTENTS) {
+ if ((i == fe->i_tree_depth) &&
+ (fe->i_next_free_rec ==
+ OCFS_MAX_FILE_ENTRY_EXTENTS)) {
IncreaseTreeDepth = 1;
goto increase_depth;
}
@@ -1346,38 +1357,37 @@
* extent which needs the new leaf */
status = ocfs_allocate_new_data_node(osb, fe,
new_clusters,
- extent_header_bh,
- &newExtentOff,
+ eh2_bh,
+ &new_eh_blkno,
handle, inode);
if (status < 0) {
LOG_ERROR_STATUS(status);
goto finally;
}
- OCFS_BH_PUT_DATA(extent_bh);
+ OCFS_BH_PUT_DATA(eh1_bh);
- status = ocfs_journal_access(handle, extent_bh,
+ status = ocfs_journal_access(handle, eh1_bh,
OCFS_JOURNAL_ACCESS_WRITE);
if (status < 0) {
LOG_ERROR_STATUS (status);
goto finally;
}
- extent = OCFS_BH_GET_DATA_WRITE(extent_bh);
+ eh1 = OCFS_BH_GET_DATA_WRITE(eh1_bh);
- extent->next_data_ext = newExtentOff;
- fe->last_ext_ptr = newExtentOff;
+ eh1->h_next_leaf_blk = fe->i_last_eh_blk = new_eh_blkno;
}
do_update_parent:
- /* before we put the variable away, save off up_ptr as
+ /* before we put the variable away, save off parent_blk as
* we may need it if we update parent */
- up_ptr = extent->up_hdr_node_ptr;
+ parent_blk = eh1->h_parent_blk;
/* gotta put it away to write it ;) */
- OCFS_BH_PUT_DATA(extent_bh);
- extent = NULL;
- status = ocfs_journal_dirty(handle, extent_bh);
+ OCFS_BH_PUT_DATA(eh1_bh);
+ eh1 = NULL;
+ status = ocfs_journal_dirty(handle, eh1_bh);
if (status < 0) {
LOG_ERROR_STATUS(status);
goto finally;
@@ -1387,58 +1397,62 @@
for (i = 0; i < fe->i_tree_depth; i++) {
/* next two if's are for loop around */
- if (extent_header_bh) {
- if (extent_header) {
- OCFS_BH_PUT_DATA(extent_header_bh);
- extent_header = NULL;
+ if (eh2_bh) {
+ if (eh2) {
+ OCFS_BH_PUT_DATA(eh2_bh);
+ eh2 = NULL;
}
- brelse(extent_header_bh);
- extent_header_bh = NULL;
+ brelse(eh2_bh);
+ eh2_bh = NULL;
}
/* TODO: Can we do a cached read here? */
- status = ocfs_read_bh(osb, up_ptr, &extent_header_bh,
- OCFS_BH_COND_CACHED, inode);
+ status = ocfs_read_bh(osb,
+ parent_blk << osb->sb->s_blocksize_bits,
+ &eh2_bh,
+ OCFS_BH_COND_CACHED,
+ inode);
if (status < 0) {
LOG_ERROR_STATUS (status);
goto finally;
}
- status = ocfs_journal_access(handle, extent_header_bh,
+ status = ocfs_journal_access(handle, eh2_bh,
OCFS_JOURNAL_ACCESS_WRITE);
if (status < 0) {
LOG_ERROR_STATUS(status);
goto finally;
}
- extent_header = OCFS_BH_GET_DATA_WRITE(extent_header_bh);
- if (!IS_VALID_EXTENT_HEADER(extent_header)) {
+ eh2 = OCFS_BH_GET_DATA_WRITE(eh2_bh);
+ if (!IS_VALID_EXTENT_HEADER(eh2) ||
+ (eh2->h_tree_depth < 0)) {
LOG_ERROR_STATUS (status = -EINVAL);
goto finally;
}
- if (extent_header->next_free_ext == 0) {
+ if (eh2->h_next_free_rec == 0) {
LOG_ERROR_STATUS (status = -EFAIL);
goto finally;
}
- k = extent_header->next_free_ext - 1;
+ k = eh2->h_next_free_rec - 1;
- extent_header->extents[k].e_clusters +=
+ eh2->extents[k].e_clusters +=
new_clusters;
/* gonna need it if we loop around */
- up_ptr = extent_header->up_hdr_node_ptr;
+ parent_blk = eh2->h_parent_blk;
- OCFS_BH_PUT_DATA(extent_header_bh);
- extent_header = NULL;
+ OCFS_BH_PUT_DATA(eh2_bh);
+ eh2 = NULL;
- status = ocfs_journal_dirty(handle, extent_header_bh);
+ status = ocfs_journal_dirty(handle, eh2_bh);
if (status < 0) {
goto finally;
}
}
- k = fe->i_next_free_ext - 1;
+ k = fe->i_next_free_rec - 1;
fe->extents[k].e_clusters += new_clusters;
}
@@ -1452,13 +1466,13 @@
if (IncreaseTreeDepth) {
OCFS_BH_PUT_DATA(fe_bh);
fe = NULL;
- if (extent_bh && extent) {
- OCFS_BH_PUT_DATA(extent_bh);
- extent = NULL;
+ if (eh1_bh && eh1) {
+ OCFS_BH_PUT_DATA(eh1_bh);
+ eh1 = NULL;
}
- if (extent_header_bh && extent_header) {
- OCFS_BH_PUT_DATA(extent_header_bh);
- extent_header = NULL;
+ if (eh2_bh && eh2) {
+ OCFS_BH_PUT_DATA(eh2_bh);
+ eh2 = NULL;
}
status = ocfs_grow_extent_tree(osb, fe_bh, handle,
@@ -1496,16 +1510,16 @@
/* Buffers are always null if they haven't been mapped and
* non-null if they have.
* Buffer heads are non-NULL if they need to be brelsed */
- if (extent_bh) {
- if (extent)
- OCFS_BH_PUT_DATA(extent_bh);
- brelse(extent_bh);
+ if (eh1_bh) {
+ if (eh1)
+ OCFS_BH_PUT_DATA(eh1_bh);
+ brelse(eh1_bh);
}
- if (extent_header_bh) {
- if (extent_header)
- OCFS_BH_PUT_DATA(extent_header_bh);
- brelse(extent_header_bh);
+ if (eh2_bh) {
+ if (eh2)
+ OCFS_BH_PUT_DATA(eh2_bh);
+ brelse(eh2_bh);
}
if (fe) {
OCFS_BH_PUT_DATA(fe_bh);
@@ -1527,7 +1541,7 @@
* we're gonna have to clear out all of extarr.
*/
static int _squish_extent_entries(ocfs_super *osb,
- ocfs_extent_rec *extarr,
+ ocfs2_extent_rec *extarr,
__u16 *freeExtent,
ocfs_journal_handle *handle,
u32 num_clusters, int flag,
@@ -1536,7 +1550,7 @@
int status = 0;
int FirstTime = 1;
__u64 FileSize = (u64)num_clusters << osb->s_clustersize_bits; /* FIXME get rid of this and use num_clusters!! */
- ocfs_extent_rec *ext;
+ ocfs2_extent_rec *ext;
__u32 i, csize = osb->s_clustersize_bits,
numBitsAllocated = 0, bitmapOffset = 0,
firstfree = *freeExtent;
@@ -1550,7 +1564,7 @@
firstfree = *freeExtent;
- /* loop through the used ocfs_extent_recs */
+ /* loop through the used ocfs2_extent_recs */
for (i = 0; i < firstfree; i++) {
ext = &(extarr[i]);
bytes = (u64)ext->e_clusters << osb->s_clustersize_bits;
@@ -1618,7 +1632,7 @@
* deletion in free_head.
*/
-/* We can't recurse, so we keep a simple stack of ocfs_extent_groups. */
+/* We can't recurse, so we keep a simple stack of ocfs2_extent_headers. */
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;
@@ -1626,11 +1640,12 @@
__u32 victim;
__u64 dstart = osb->vol_layout.data_start_off;
__u64 tmp_off;
- __u32 num_clusters = 0, bitmap_offset = 0;
- ocfs_extent_rec *ext;
+ u32 num_clusters = 0;
+ __u32 bitmap_offset = 0;
+ ocfs2_extent_rec *ext;
struct buffer_head *tmp_bh = NULL;
char * stack[OCFS_TREE_STACK_SIZE];
- ocfs_extent_group * cur_extent; /* convenience, points to TOS */
+ ocfs2_extent_header *cur_eh; /* convenience, points to TOS */
int tos = 0;
LOG_ENTRY();
@@ -1644,19 +1659,18 @@
OCFS_BH_PUT_DATA(extent_grp_bh);
do {
- cur_extent = (ocfs_extent_group *) stack[tos];
+ cur_eh = (ocfs2_extent_header *) stack[tos];
- if (!IS_VALID_EXTENT_DATA(cur_extent) &&
- !IS_VALID_EXTENT_HEADER(cur_extent)) {
- LOG_ERROR_STR("Invalid extent group!");
+ if (!IS_VALID_EXTENT_HEADER(cur_eh)) {
+ LOG_ERROR_STR("Invalid extent header!");
goto bail;
}
- if (IS_VALID_EXTENT_DATA(cur_extent)) {
- LOG_TRACE_ARGS("found some data to free (%llu)\n", cur_extent->this_ext);
- for(i = 0; i < cur_extent->next_free_ext; i++) {
+ if (cur_eh->h_tree_depth == -1) {
+ LOG_TRACE_ARGS("found some data to free (%llu)\n", cur_eh->h_blkno);
+ for(i = 0; i < cur_eh->h_next_free_rec; i++) {
/* Free the data associated with each header */
- ext = &cur_extent->extents[i];
+ ext = &cur_eh->extents[i];
num_clusters = ext->e_clusters;
bitmap_offset =
(u32)(((ext->e_blkno << osb->sb->s_blocksize_bits) - dstart) >> osb->s_clustersize_bits);
@@ -1671,26 +1685,26 @@
/* Did we already kill all his children, or
* are they already dead? */
- if (cur_extent->next_free_ext == 0) {
- LOG_TRACE_ARGS("Popping this header (%llu)\n", cur_extent->this_ext);
+ if (cur_eh->h_next_free_rec == 0) {
+ LOG_TRACE_ARGS("Popping this header (%llu)\n", cur_eh->h_blkno);
goto free_meta;
}
/* We're gonna read in our last used extent
* and put him at the top of the stack. We
- * also update our next_free_ext so that next
+ * also update our h_next_free_rec so that next
* time we read in the next to last one and so
* on until we've finished all of them
*/
/* grow the stack, gotta save off a couple
* things 1st. */
- victim = cur_extent->next_free_ext - 1;
- tmp_off = cur_extent->extents[victim].e_blkno;
+ victim = cur_eh->h_next_free_rec - 1;
+ tmp_off = cur_eh->extents[victim].e_blkno;
tmp_off <<= osb->sb->s_blocksize_bits;
- cur_extent->next_free_ext--;
+ cur_eh->h_next_free_rec--;
- cur_extent = NULL;
+ cur_eh = NULL;
tos++;
/* should already be null, but we can do this
@@ -1716,7 +1730,10 @@
free_meta:
/* Free the metadata associated with this extent group */
- status = ocfs_handle_add_commit_bits(handle, 1, cur_extent->alloc_file_off, cur_extent->alloc_node, DISK_ALLOC_EXTENT_NODE);
+ status = ocfs_handle_add_commit_bits(handle, 1,
+ cur_eh->h_suballoc_blkno << osb->sb->s_blocksize_bits,
+ cur_eh->h_suballoc_node,
+ DISK_ALLOC_EXTENT_NODE);
if (status < 0) {
LOG_ERROR_STATUS (status);
goto bail;
@@ -1724,7 +1741,7 @@
/* Pop one off the stack */
kfree(stack[tos]);
stack[tos] = NULL;
- cur_extent = NULL;
+ cur_eh = NULL;
tos--;
} while (tos >= 0);
@@ -1740,43 +1757,44 @@
#ifndef USERSPACE_TOOL
-static int ocfs_fix_extent_group(ocfs_super *osb, struct buffer_head *group_bh, struct inode *inode)
+static int ocfs_fix_extent_header(ocfs_super *osb,
+ struct buffer_head *eh_bh,
+ struct inode *inode)
{
- ocfs_extent_rec *ext;
- ocfs_extent_group *group = NULL;
- int status=-EFAIL;
+ ocfs2_extent_rec *ext;
+ ocfs2_extent_header *eh = NULL;
+ int status = -EFAIL;
int i;
- LOG_ENTRY ();
+ LOG_ENTRY();
- if (!group_bh) {
- LOG_ERROR_STR("Invalid extent group bh (NULL)!");
+ if (!eh_bh) {
+ LOG_ERROR_STR("Invalid extent header bh (NULL)!");
goto bail;
}
- group = OCFS_BH_GET_DATA_WRITE(group_bh);
+ eh = OCFS_BH_GET_DATA_WRITE(eh_bh);
- if (!IS_VALID_EXTENT_DATA(group) &&
- !IS_VALID_EXTENT_HEADER(group)) {
- LOG_ERROR_STR("Invalid extent group!");
+ if (!IS_VALID_EXTENT_HEADER(eh)) {
+ LOG_ERROR_STR("Invalid extent header!");
goto bail;
}
- ext = group->extents;
+ ext = eh->extents;
- for(i=group->next_free_ext; i < OCFS_MAX_DATA_EXTENTS; i++) {
+ for(i = eh->h_next_free_rec; i < OCFS_MAX_DATA_EXTENTS; i++) {
ext[i].e_clusters = 0;
ext[i].e_blkno = 0;
ext[i].e_cpos = 0;
}
- OCFS_BH_PUT_DATA(group_bh);
- group = NULL;
+ OCFS_BH_PUT_DATA(eh_bh);
+ eh = NULL;
status=0;
bail:
- if (group)
- OCFS_BH_PUT_DATA(group_bh);
+ if (eh)
+ OCFS_BH_PUT_DATA(eh_bh);
LOG_EXIT_STATUS (status);
return(status);
@@ -1800,14 +1818,15 @@
struct inode *inode)
{
int status = -EFAIL;
- ocfs_extent_rec *ext;
+ ocfs2_extent_rec *ext;
struct buffer_head * bh_stack[OCFS_TREE_STACK_SIZE];
- ocfs_extent_group * AllocExtent = NULL;/* convenience, points to TOS */
- ocfs_extent_group *extent_grp;
+ ocfs2_extent_header *alloc_eh = NULL; /* convenience, points to TOS */
+ ocfs2_extent_header *extent_grp;
struct buffer_head *tmp_bh = NULL, *tmp_bh2 = NULL;
int tos = 0;
int i, victim;
- __u64 bytes, doff, orig_bytes, dstart = osb->vol_layout.data_start_off, tmp_off;
+ __u64 bytes, doff, orig_bytes, tmp_off;
+ __u64 dstart = osb->vol_layout.data_start_off;
__u64 total_bytes; /* FIXME needs to be clusters!!! */
__u32 num_clusters, bitmap_offset;
int done = 0;
@@ -1829,7 +1848,7 @@
goto bail;
}
extent_grp = OCFS_BH_GET_DATA_WRITE(extent_grp_bh);
- for(i = (extent_grp->next_free_ext - 1); i>=0; i--) {
+ for(i = (extent_grp->h_next_free_rec - 1); i>=0; i--) {
ext = &extent_grp->extents[i];
if (tmp_bh2)
@@ -1861,7 +1880,7 @@
ext->e_cpos = 0;
ext->e_blkno = 0;
ext->e_clusters = 0;
- extent_grp->next_free_ext = i;
+ extent_grp->h_next_free_rec = i;
} else { /* This is the one we want to split. */
ext->e_clusters =
fe->i_clusters - ext->e_cpos;
@@ -1905,7 +1924,7 @@
}
extent_grp = OCFS_BH_GET_DATA_WRITE(extent_grp_bh);
- for(i = (extent_grp->next_free_ext - 1); i>=0; i--) {
+ for(i = (extent_grp->h_next_free_rec - 1); i>=0; i--) {
ext = &extent_grp->extents[i];
if (tmp_bh)
@@ -1941,7 +1960,7 @@
ext->e_cpos = 0;
ext->e_blkno = 0;
ext->e_clusters = 0;
- extent_grp->next_free_ext = i;
+ extent_grp->h_next_free_rec = i;
} else { /* This is the one we want to split. */
ext->e_clusters =
fe->i_clusters - ext->e_cpos;
@@ -1991,37 +2010,36 @@
goto bail;
}
- AllocExtent = OCFS_BH_GET_DATA_WRITE(bh_stack[tos]);
+ alloc_eh = OCFS_BH_GET_DATA_WRITE(bh_stack[tos]);
- if (!IS_VALID_EXTENT_DATA(AllocExtent) &&
- !IS_VALID_EXTENT_HEADER(AllocExtent)) {
- LOG_ERROR_STR("Invalid extent group!");
+ if (!IS_VALID_EXTENT_HEADER(alloc_eh)) {
+ LOG_ERROR_STR("Invalid extent header!");
goto bail;
}
- if (IS_VALID_EXTENT_DATA(AllocExtent)) {
+ if (alloc_eh->h_tree_depth == -1) {
/* shall we just do away with him? */
- if (AllocExtent->extents[0].e_cpos >=
+ if (alloc_eh->extents[0].e_cpos >=
fe->i_clusters) {
- LOG_TRACE_ARGS("Killing this data extent (%llu)\n", AllocExtent->this_ext);
+ LOG_TRACE_ARGS("Killing this data extent (%llu)\n", alloc_eh->h_blkno);
/* Boundary case - what if this guy is
* the last DAT we should delete
* (i.e., split no more ;) */
OCFS_BH_PUT_DATA(bh_stack[tos]);
- AllocExtent = NULL;
+ alloc_eh = NULL;
status = ocfs_kill_this_tree(osb, bh_stack[tos], handle, inode);
if (status < 0) {
LOG_ERROR_STATUS (status);
goto bail;
}
/* silly, but what to do? */
- AllocExtent = OCFS_BH_GET_DATA_READ(bh_stack[tos]);
+ alloc_eh = OCFS_BH_GET_DATA_READ(bh_stack[tos]);
} else {
/* Alright, we know for sure that
* we're splitting in this guy. */
- LOG_TRACE_ARGS("Splitting this data extent (%llu)\n", AllocExtent->this_ext);
- fe->last_ext_ptr = AllocExtent->this_ext;
- AllocExtent->next_data_ext = 0;
+ LOG_TRACE_ARGS("Splitting this data extent (%llu)\n", alloc_eh->h_blkno);
+ fe->i_last_eh_blk = alloc_eh->h_blkno;
+ alloc_eh->h_next_leaf_blk = 0;
/* total_bytes is used below to know
* how much total we've whacked off
* this extent*/
@@ -2030,15 +2048,15 @@
/* there is a chance the split is at a
* header boundary. this will catch
* it: */
- ext = &AllocExtent->extents[AllocExtent->next_free_ext - 1];
+ ext = &alloc_eh->extents[alloc_eh->h_next_free_rec - 1];
if ((ext->e_cpos + ext->e_clusters) == fe->i_clusters) {
LOG_TRACE_STR("Ok, hit that boundary in the DAT");
goto fix_headers;
}
/* Either kill the data or resize it */
- for(i = (AllocExtent->next_free_ext - 1); i>=0; i--) {
- ext = &AllocExtent->extents[i];
+ for(i = (alloc_eh->h_next_free_rec - 1); i>=0; i--) {
+ ext = &alloc_eh->extents[i];
/* changed this from > to >= */
/* Do we delete it completely? */
@@ -2086,14 +2104,14 @@
skip_bitmap_add:
if (done) {
- AllocExtent->next_free_ext=i+1;
+ alloc_eh->h_next_free_rec=i+1;
break;
}
} /* For loop */
/* Either way, we need to write this back out*/
OCFS_BH_PUT_DATA(bh_stack[tos]);
- AllocExtent = NULL;
+ alloc_eh = NULL;
status = ocfs_journal_dirty(handle, bh_stack[tos]);
if (status < 0) {
@@ -2113,17 +2131,17 @@
goto bail;
}
- AllocExtent = OCFS_BH_GET_DATA_WRITE(bh_stack[tos]);
- victim = AllocExtent->next_free_ext;
- AllocExtent->next_free_ext++;
+ alloc_eh = OCFS_BH_GET_DATA_WRITE(bh_stack[tos]);
+ victim = alloc_eh->h_next_free_rec;
+ alloc_eh->h_next_free_rec++;
/* need to also update
* numbytes on these guys */
- ext = &AllocExtent->extents[victim];
+ ext = &alloc_eh->extents[victim];
ext->e_clusters -=
(u32)(total_bytes >> osb->s_clustersize_bits);
OCFS_BH_PUT_DATA(bh_stack[tos]);
- AllocExtent = NULL;
- status = ocfs_fix_extent_group(osb,
+ alloc_eh = NULL;
+ status = ocfs_fix_extent_header(osb,
bh_stack[tos], inode);
if (status < 0) {
LOG_ERROR_STATUS(status);
@@ -2145,38 +2163,38 @@
/* Did we already kill all his children, or
* are they already dead? */
- if (AllocExtent->next_free_ext == 0) {
+ if (alloc_eh->h_next_free_rec == 0) {
/*Ok, we're done with this guy, pop the stack*/
LOG_TRACE_ARGS("Popping this header (%llu)\n",
- AllocExtent->this_ext);
+ alloc_eh->h_blkno);
- status = ocfs_handle_add_commit_bits(handle, 1, AllocExtent->alloc_file_off, AllocExtent->alloc_node, DISK_ALLOC_EXTENT_NODE);
+ status = ocfs_handle_add_commit_bits(handle, 1, alloc_eh->h_suballoc_blkno << osb->sb->s_blocksize_bits, alloc_eh->h_suballoc_node, DISK_ALLOC_EXTENT_NODE);
if (status < 0) {
LOG_ERROR_STATUS (status);
goto bail;
}
OCFS_BH_PUT_DATA(bh_stack[tos]);
brelse(bh_stack[tos]);
- AllocExtent = NULL;
+ alloc_eh = NULL;
bh_stack[tos] = NULL;
tos--;
continue;
}
/* changed this from > to >= */
/* Do we just delete this whole part of the tree? */
- if (AllocExtent->extents[0].e_cpos >= fe->i_clusters) {
+ if (alloc_eh->extents[0].e_cpos >= fe->i_clusters) {
LOG_TRACE_ARGS("whacking this tree: (%llu)\n",
- AllocExtent->this_ext);
+ alloc_eh->h_blkno);
- if (AllocExtent->extents[0].e_cpos == fe->i_clusters)
+ if (alloc_eh->extents[0].e_cpos == fe->i_clusters)
done = 1;
OCFS_BH_PUT_DATA(bh_stack[tos]);
- AllocExtent = NULL;
+ alloc_eh = NULL;
ocfs_kill_this_tree(osb, bh_stack[tos],
handle, inode);
brelse(bh_stack[tos]);
- AllocExtent = NULL;
+ alloc_eh = NULL;
bh_stack[tos] = NULL;
tos--;
if (tos < 0) {
@@ -2194,15 +2212,15 @@
goto bail;
}
- AllocExtent = OCFS_BH_GET_DATA_WRITE(bh_stack[tos]);
+ alloc_eh = OCFS_BH_GET_DATA_WRITE(bh_stack[tos]);
- victim = AllocExtent->next_free_ext;
- AllocExtent->extents[victim].e_cpos = 0;
- AllocExtent->extents[victim].e_clusters = 0;
- AllocExtent->extents[victim].e_blkno = 0;
- AllocExtent->next_free_ext--;
+ victim = alloc_eh->h_next_free_rec;
+ alloc_eh->extents[victim].e_cpos = 0;
+ alloc_eh->extents[victim].e_clusters = 0;
+ alloc_eh->extents[victim].e_blkno = 0;
+ alloc_eh->h_next_free_rec--;
OCFS_BH_PUT_DATA(bh_stack[tos]);
- AllocExtent = NULL;
+ alloc_eh = NULL;
/* Here's an interesting boundary
* case. What if we're truncating on a
* boundary between two headers and
@@ -2215,7 +2233,7 @@
LOG_TRACE_STR("Found a boundary " \
"header, almost done " \
" (gonna quit)");
- status = ocfs_fix_extent_group(osb,
+ status = ocfs_fix_extent_header(osb,
bh_stack[tos], inode);
if (status < 0) {
LOG_ERROR_STATUS(status);
@@ -2249,12 +2267,12 @@
continue;
}
- AllocExtent->next_free_ext--;
- victim = AllocExtent->next_free_ext;
- ext = &AllocExtent->extents[victim];
+ alloc_eh->h_next_free_rec--;
+ victim = alloc_eh->h_next_free_rec;
+ ext = &alloc_eh->extents[victim];
tmp_off = ext->e_blkno << osb->sb->s_blocksize_bits;
OCFS_BH_PUT_DATA(bh_stack[tos]);
- AllocExtent = NULL;
+ alloc_eh = NULL;
status = ocfs_journal_dirty(handle, bh_stack[tos]);
if (status < 0) {
@@ -2279,11 +2297,11 @@
/* We only want to free on our way up the tree */
continue;
}
- if (AllocExtent)
+ if (alloc_eh)
OCFS_BH_PUT_DATA(bh_stack[tos]);
brelse(bh_stack[tos]);
bh_stack[tos] = NULL;
- AllocExtent = NULL;
+ alloc_eh = NULL;
tos--;
} while (tos >= 0);
@@ -2295,7 +2313,7 @@
bail:
/* brelse the stack. We only brelse the bottom of the stack if
* we know for sure that it wasn't passed from the caller */
- if (AllocExtent)
+ if (alloc_eh)
OCFS_BH_PUT_DATA(bh_stack[tos]);
if (needs_brelse)
brelse(bh_stack[0]);
@@ -2309,28 +2327,30 @@
/*
- * ocfs_update_last_ext_ptr
+ * ocfs_update_last_eh_blk
*
- * Travel all the way to the rightmost DAT and set fe->last_ext_ptr
+ * Travel all the way to the rightmost DAT and set fe->i_last_eh_blk
* to it.
*
* We do cached reads here because we ought to have already read the
* various ext headers and dats off the system previously in the
* truncate path.
*/
-static int ocfs_update_last_ext_ptr(ocfs_super *osb, ocfs2_dinode *fe, struct inode *inode)
+static int ocfs_update_last_eh_blk(ocfs_super *osb,
+ ocfs2_dinode *fe,
+ struct inode *inode)
{
int status = -EFAIL;
- ocfs_extent_group *extent = NULL;
- struct buffer_head *extent_bh = NULL;
- __u64 next_ext;
+ ocfs2_extent_header *eh = NULL;
+ struct buffer_head *eh_bh = NULL;
+ u64 next_blk;
int victim;
LOG_ENTRY ();
- if (fe->i_next_free_ext == 0) {
+ if (fe->i_next_free_rec == 0) {
LOG_TRACE_STR("setting to zero as there isn't any used extents");
- fe->last_ext_ptr = 0;
+ fe->i_last_eh_blk = 0;
status = 0;
goto bail;
}
@@ -2340,58 +2360,59 @@
BUG();
/* Ugly magic -1 */
- victim = fe->i_next_free_ext - 1;
+ victim = fe->i_next_free_rec - 1;
status = ocfs_read_bh(osb,
fe->extents[victim].e_blkno << osb->sb->s_blocksize_bits,
- &extent_bh,
+ &eh_bh,
OCFS_BH_CACHED, inode);
if (status < 0) {
LOG_ERROR_STATUS(status);
goto bail;
}
- extent = OCFS_BH_GET_DATA_READ(extent_bh);
+ eh = OCFS_BH_GET_DATA_READ(eh_bh);
- if (!IS_VALID_EXTENT_DATA(extent) &&
- !IS_VALID_EXTENT_HEADER(extent)) {
- LOG_ERROR_STR("Invalid extent group!");
+ if (!IS_VALID_EXTENT_HEADER(eh)) {
+ LOG_ERROR_STR("Invalid extent header!");
goto bail;
}
- while (!IS_VALID_EXTENT_DATA(extent)) {
- if (!IS_VALID_EXTENT_HEADER(extent)) {
- LOG_ERROR_STR("Invalid extent group!");
+ while (eh->h_tree_depth >= 0) {
+ if (!IS_VALID_EXTENT_HEADER(eh)) {
+ LOG_ERROR_STR("Invalid extent header!");
goto bail;
}
- next_ext = extent->extents[extent->next_free_ext - 1].e_blkno << osb->sb->s_blocksize_bits;
+ next_blk = eh->extents[eh->h_next_free_rec - 1].e_blkno;
- OCFS_BH_PUT_DATA(extent_bh);
- brelse(extent_bh);
- extent = NULL;
- extent_bh = NULL;
+ OCFS_BH_PUT_DATA(eh_bh);
+ brelse(eh_bh);
+ eh = NULL;
+ eh_bh = NULL;
- status = ocfs_read_bh(osb, next_ext, &extent_bh,
+ status = ocfs_read_bh(osb,
+ next_blk << osb->sb->s_blocksize_bits,
+ &eh_bh,
OCFS_BH_CACHED, inode);
if (status < 0) {
LOG_ERROR_STATUS(status);
goto bail;
}
- extent = OCFS_BH_GET_DATA_READ(extent_bh);
+ eh = OCFS_BH_GET_DATA_READ(eh_bh);
}
- fe->last_ext_ptr = extent->this_ext;
+ fe->i_last_eh_blk = eh->h_blkno;
status = 0;
bail:
- if (extent_bh) {
- if (extent)
- OCFS_BH_PUT_DATA(extent_bh);
- brelse(extent_bh);
+ if (eh_bh) {
+ if (eh)
+ OCFS_BH_PUT_DATA(eh_bh);
+ brelse(eh_bh);
}
LOG_EXIT_STATUS(status);
return(status);
-} /* ocfs_update_last_ext_ptr */
+} /* ocfs_update_last_eh_blk */
/*
* ocfs_free_extents_for_truncate()
@@ -2408,7 +2429,7 @@
int status = 0;
struct buffer_head *extent_bh = NULL;
int i, j;
- int updated_lep; /* used to mark whether fe->last_ext_ptr has
+ int updated_leb; /* used to mark whether fe->i_last_eh_blk has
* been updated */
LOG_ENTRY ();
@@ -2416,7 +2437,7 @@
/* local extents */
if (fe->i_tree_depth < 0) {
status = _squish_extent_entries(osb, fe->extents,
- &fe->i_next_free_ext,
+ &fe->i_next_free_rec,
handle, fe->i_clusters,
0, inode);
if (status < 0) {
@@ -2429,10 +2450,10 @@
LOG_TRACE_ARGS("non-local extents. taking that code path, truncating to i_clusters of (%u)\n", fe->i_clusters);
/* non-local extents */
- updated_lep = 0;
+ updated_leb = 0;
/* Loop backwards through only the used free extent headers here */
- for (i = (fe->i_next_free_ext - 1); i >= 0; i--) {
+ for (i = (fe->i_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,
@@ -2456,7 +2477,7 @@
fe->extents[i].e_cpos = 0;
fe->extents[i].e_blkno = 0;
fe->extents[i].e_clusters = 0;
- fe->i_next_free_ext = i;
+ fe->i_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,
@@ -2477,10 +2498,10 @@
fe->extents[i].e_clusters +=
fe->extents[j].e_clusters;
- fe->i_next_free_ext = i + 1;
+ fe->i_next_free_rec = i + 1;
/* We're done - we can't split more than one
* parts of the tree. */
- updated_lep = 1;
+ updated_leb = 1;
break;
}
brelse(extent_bh);
@@ -2489,13 +2510,13 @@
/* Ok, trunc to zero is a special case, doofus */
if (fe->i_clusters == 0) {
- fe->last_ext_ptr = 0;
+ fe->i_last_eh_blk = 0;
fe->i_tree_depth = -1;
- updated_lep = 1;
+ updated_leb = 1;
}
- if (!updated_lep) {
- status = ocfs_update_last_ext_ptr(osb, fe, inode);
+ if (!updated_leb) {
+ status = ocfs_update_last_eh_blk(osb, fe, inode);
if (status < 0) {
LOG_ERROR_STATUS(status);
goto finally;
@@ -2521,14 +2542,16 @@
* decoded and updated in the extent map.
*
*/
-int ocfs_lookup_file_allocation (ocfs_super * osb, __s64 Vbo, __s64 * Lbo, __u32 sectors, u32 *sector_count, struct inode *inode)
+int ocfs_lookup_file_allocation(ocfs_super *osb, __s64 Vbo,
+ __s64 *Lbo, __u32 sectors,
+ u32 *sector_count, struct inode *inode)
{
int status = -EFAIL;
ocfs2_dinode *fe = NULL;
struct buffer_head *fe_bh = NULL;
- ocfs_extent_group *OcfsExtent = NULL;
- struct buffer_head *ext_bh = NULL;
- __u64 next_data_ext;
+ ocfs2_extent_header *eh = NULL;
+ struct buffer_head *eh_bh = NULL;
+ u64 next_leaf;
__u64 remainingLength = 0;
__s64 localVbo;
__u64 cnt;
@@ -2540,8 +2563,11 @@
OCFS_ASSERT (inode);
if (INODE_JOURNAL(inode) || Vbo < OCFS_I(inode)->alloc_size) {
- if (ocfs_lookup_extent_map_entry (osb, &(OCFS_I(inode)->map),
- Vbo, Lbo, &cnt, &NumIndex) && cnt >= sectors) {
+ if (ocfs_lookup_extent_map_entry(osb,
+ &(OCFS_I(inode)->map),
+ Vbo, Lbo, &cnt,
+ &NumIndex) &&
+ (cnt >= sectors)) {
status = 0;
goto finally;
}
@@ -2554,7 +2580,8 @@
/* Thus we have to go to the disk, and update the Map */
/* Read the file Entry corresponding to this */
- status = ocfs_read_bh(osb, GET_INODE_FEOFF(inode), &fe_bh, OCFS_BH_COND_CACHED, inode);
+ status = ocfs_read_bh(osb, GET_INODE_FEOFF(inode), &fe_bh,
+ OCFS_BH_COND_CACHED, inode);
if (status < 0) {
LOG_ERROR_STATUS (status);
goto finally;
@@ -2567,7 +2594,8 @@
goto finally;
}
- if (!INODE_JOURNAL(inode) && Vbo >= (__s64)((u64)fe->i_clusters << osb->s_clustersize_bits)) {
+ if (!INODE_JOURNAL(inode) &&
+ (Vbo >= (__s64)((u64)fe->i_clusters << osb->s_clustersize_bits))) {
LOG_ERROR_ARGS ("vbo=%llu, fe->i_clusters=%u alloc_size=%llu",
Vbo, fe->i_clusters,
OCFS_I(inode)->alloc_size);
@@ -2576,8 +2604,9 @@
}
if (fe->i_tree_depth < 0) {
- status = ocfs_update_extent_map (osb, &OCFS_I(inode)->map, fe,
- NULL, NULL, LOCAL_EXT);
+ status = ocfs_update_extent_map(osb,
+ &OCFS_I(inode)->map, fe,
+ NULL, NULL, LOCAL_EXT);
if (status < 0) {
LOG_ERROR_STATUS (status);
goto finally;
@@ -2586,49 +2615,55 @@
/* Extents are branched and we are no longer using
* Local Extents for this File Entry. */
- status = ocfs_get_leaf_extent (osb, fe, localVbo, &ext_bh, inode);
+ status = ocfs_get_leaf_extent(osb, fe, localVbo,
+ &eh_bh, inode);
if (status < 0) {
LOG_ERROR_STATUS (status);
goto finally;
}
- OcfsExtent = OCFS_BH_GET_DATA_READ(ext_bh);
+ eh = OCFS_BH_GET_DATA_READ(eh_bh);
while (1) {
- status = ocfs_update_extent_map (osb, &OCFS_I(inode)->map, OcfsExtent,
- &localVbo, &remainingLength, NONLOCAL_EXT);
+ status = ocfs_update_extent_map(osb,
+ &OCFS_I(inode)->map,
+ eh, &localVbo,
+ &remainingLength,
+ NONLOCAL_EXT);
if (status < 0) {
LOG_ERROR_STATUS(status);
goto finally;
}
if (remainingLength > 0) {
- if (!OcfsExtent->next_data_ext) {
+ if (!eh->h_next_leaf_blk) {
LOG_ERROR_ARGS ("localVbo=%llu, "
"alloc_size=%llu, "
" thisext=%llu",
localVbo,
OCFS_I(inode)->alloc_size,
- OcfsExtent->this_ext);
+ eh->h_blkno);
status = -EFAIL;
goto finally;
}
- next_data_ext = OcfsExtent->next_data_ext;
+ next_leaf = eh->h_next_leaf_blk;
- OCFS_BH_PUT_DATA(ext_bh);
- brelse(ext_bh);
- ext_bh = NULL;
- OcfsExtent = NULL;
+ OCFS_BH_PUT_DATA(eh_bh);
+ brelse(eh_bh);
+ eh_bh = NULL;
+ eh = NULL;
- status = ocfs_read_bh(osb, next_data_ext,
- &ext_bh,
+ status = ocfs_read_bh(osb,
+ next_leaf << osb->sb->s_blocksize_bits,
+ &eh_bh,
OCFS_BH_COND_CACHED, inode);
if (status < 0) {
LOG_ERROR_STATUS(status);
goto finally;
}
- OcfsExtent = OCFS_BH_GET_DATA_READ(ext_bh);
- if (!IS_VALID_EXTENT_DATA(OcfsExtent)) {
+ eh = OCFS_BH_GET_DATA_READ(eh_bh);
+ if (!IS_VALID_EXTENT_HEADER(eh) ||
+ (eh->h_tree_depth != -1)) {
LOG_ERROR_STATUS (status = -EINVAL);
goto finally;
}
@@ -2655,10 +2690,10 @@
brelse(fe_bh);
}
- if (ext_bh) {
- if (OcfsExtent)
- OCFS_BH_PUT_DATA(ext_bh);
- brelse(ext_bh);
+ if (eh_bh) {
+ if (eh)
+ OCFS_BH_PUT_DATA(eh_bh);
+ brelse(eh_bh);
}
LOG_EXIT_STATUS (status);
return (status);
@@ -2674,14 +2709,14 @@
{
int status = 0, tempstat;
__u32 i, j;
- ocfs_extent_group *eh = NULL;
+ ocfs2_extent_header *eh = NULL;
struct buffer_head *ext_bh = NULL;
- ocfs_extent_group *tmp = NULL;
+ ocfs2_extent_header *tmp = NULL;
__u64 childDiskOffset = 0;
LOG_ENTRY ();
- for (i = 0; i < fe->i_next_free_ext; i++) {
+ 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;
break;
@@ -2706,7 +2741,7 @@
goto finally;
}
- for (j = 0; j < eh->next_free_ext; j++) {
+ for (j = 0; j < eh->h_next_free_rec; j++) {
if ((__s64)((u64)(eh->extents[j].e_cpos + eh->extents[j].e_clusters) << osb->s_clustersize_bits) > Vbo)
{
childDiskOffset =
@@ -2734,7 +2769,8 @@
}
tmp = OCFS_BH_GET_DATA_READ(*data_extent_bh);
- if (!IS_VALID_EXTENT_DATA(tmp)) {
+ if (!IS_VALID_EXTENT_HEADER(tmp) ||
+ (tmp->h_tree_depth != -1)) {
LOG_ERROR_STATUS (status = -EINVAL);
OCFS_BH_PUT_DATA(*data_extent_bh);
brelse(*data_extent_bh);
@@ -3200,7 +3236,7 @@
int status = 0;
__u32 i;
__u32 numBitsAllocated = 0, bitmapOffset = 0;
- ocfs_extent_group *extent = NULL;
+ ocfs2_extent_header *extent = NULL;
struct buffer_head *extent_bh = NULL;
ocfs2_dinode *fe = NULL;
__u64 offset;
@@ -3219,7 +3255,7 @@
fe = OCFS_BH_GET_DATA_READ(fe_bh);
if (fe->i_tree_depth < 0) {
- for (i = 0; i < fe->i_next_free_ext; i++) {
+ for (i = 0; i < fe->i_next_free_rec; i++) {
numBitsAllocated = fe->extents[i].e_clusters;
bitmapOffset =
@@ -3232,7 +3268,7 @@
DISK_ALLOC_VOLUME);
}
} else {
- for (i = 0; i < fe->i_next_free_ext; i++) {
+ for (i = 0; i < fe->i_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);
@@ -3241,7 +3277,7 @@
goto leave;
}
extent = OCFS_BH_GET_DATA_READ(extent_bh);
- if ((fe->i_tree_depth && (!IS_VALID_EXTENT_HEADER(extent))) && !IS_VALID_EXTENT_DATA(extent)) {
+ if (fe->i_tree_depth && !IS_VALID_EXTENT_HEADER(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-09 10:40:10 UTC (rev 1036)
+++ branches/format-changes/src/buffer_head_io.c 2004-06-09 19:15:25 UTC (rev 1037)
@@ -221,8 +221,8 @@
rdtsc (begin.lohi[0], begin.lohi[1]);
#endif
- if (len % 512) {
- LOG_TRACE_ARGS("len %% 512 (len=%llu)\n", len);
+ if (len % osb->sb->s_blocksize) {
+ LOG_TRACE_ARGS("len %% blocksize (len=%llu)\n", len);
status = -EINVAL;
LOG_ERROR_STATUS(status);
goto bail;
Modified: branches/format-changes/src/extmap.c
===================================================================
--- branches/format-changes/src/extmap.c 2004-06-09 10:40:10 UTC (rev 1036)
+++ branches/format-changes/src/extmap.c 2004-06-09 19:15:25 UTC (rev 1037)
@@ -588,7 +588,7 @@
{
int ret = -EFAIL;
ocfs2_dinode *fe;
- ocfs_extent_group *ext;
+ ocfs2_extent_header *ext;
__s64 tempVbo;
__u64 tempSize;
int j;
@@ -600,7 +600,7 @@
OCFS_ASSERT(fe->i_tree_depth < 0);
- for (j = 0; j < fe->i_next_free_ext; j++) {
+ for (j = 0; j < fe->i_next_free_rec; j++) {
/* Add the Extent to extent map list */
ret =
ocfs_add_extent_map_entry_from_rec(osb->sb,
@@ -617,7 +617,7 @@
ext = Buffer;
- for (j = 0; j < ext->next_free_ext; j++) {
+ for (j = 0; j < ext->h_next_free_rec; j++) {
if ((__s64)((u64)(ext->extents[j].e_cpos + ext->extents[j].e_clusters) << osb->s_clustersize_bits) > (*localVbo)) {
tempVbo = (u64)ext->extents[j].e_cpos << osb->s_clustersize_bits;
tempSize = (u64)ext->extents[j].e_clusters << osb->s_clustersize_bits;
@@ -647,10 +647,10 @@
}
}
- if ((ext->next_free_ext != OCFS_MAX_DATA_EXTENTS) &&
+ if ((ext->h_next_free_rec != OCFS_MAX_DATA_EXTENTS) &&
(*remainingLength)) {
- LOG_ERROR_ARGS ("next_free_extent=%d, rem_len=%llu",
- ext->next_free_ext, *remainingLength);
+ LOG_ERROR_ARGS ("h_next_free_rec=%d, rem_len=%llu",
+ ext->h_next_free_rec, *remainingLength);
} else
ret = 0;
}
@@ -664,14 +664,14 @@
/*
* ocfs_add_extent_map_entry_from_rec()
*
- * Add and entry using the fields of an ocfs_extent_rec.
+ * Add and entry using the fields of an ocfs2_extent_rec.
*
* FIXME This should be coalesced with ocfs_add_extent_map_entry
* once all callers use this function.
*/
int ocfs_add_extent_map_entry_from_rec(struct super_block *sb,
ocfs_extent_map *extmap,
- ocfs_extent_rec *rec)
+ ocfs2_extent_rec *rec)
{
u64 vbo = (u64)rec->e_cpos << OCFS_SB(sb)->s_clustersize_bits;
u64 lbo = rec->e_blkno << sb->s_blocksize_bits;
@@ -691,7 +691,7 @@
*/
int ocfs_add_extent_map_entry (ocfs_super * osb, ocfs_extent_map * Map, __s64 Vbo, __s64 Lbo, __u64 ByteCount)
{
- /* FIXME take ocfs_extent_rec */
+ /* FIXME take ocfs2_extent_rec */
int ret;
LOG_ENTRY ();
Modified: branches/format-changes/src/extmap.h
===================================================================
--- branches/format-changes/src/extmap.h 2004-06-09 10:40:10 UTC (rev 1036)
+++ branches/format-changes/src/extmap.h 2004-06-09 19:15:25 UTC (rev 1037)
@@ -29,7 +29,7 @@
int ocfs_add_extent_map_entry_from_rec(struct super_block *sb,
ocfs_extent_map *extmap,
- ocfs_extent_rec *rec);
+ ocfs2_extent_rec *rec);
int ocfs_add_extent_map_entry(ocfs_super *osb, ocfs_extent_map *Map,
__s64 Vbo, __s64 Lbo, __u64 ByteCount);
void ocfs_delete_all_extent_maps(ocfs_super *osb, struct inode *oin);
Modified: branches/format-changes/src/file.c
===================================================================
--- branches/format-changes/src/file.c 2004-06-09 10:40:10 UTC (rev 1036)
+++ branches/format-changes/src/file.c 2004-06-09 19:15:25 UTC (rev 1037)
@@ -422,7 +422,7 @@
int ret = 0;
int j;
__u64 tempoff;
- ocfs_extent_group *extent = NULL;
+ ocfs2_extent_header *extent = NULL;
struct buffer_head *extent_bh = NULL;
ocfs2_dinode *fe = NULL;
void *tmp;
@@ -447,7 +447,7 @@
goto leave;
if (fe->i_tree_depth < 0) {
- for (j = 0; j < fe->i_next_free_ext; j++) {
+ for (j = 0; j < fe->i_next_free_rec; j++) {
/* Add the Extent to extent map */
ret = ocfs_add_extent_map_entry_from_rec(osb->sb,
&OCFS_I(inode)->map,
@@ -458,7 +458,7 @@
}
}
} else {
- __u64 next_data_ext;
+ u64 next_leaf;
/* Extents are branched and we are no longer using */
/* Local Extents for this File Entry. */
@@ -472,12 +472,13 @@
while (1) {
extent = OCFS_BH_GET_DATA_READ(extent_bh);
- if (!IS_VALID_EXTENT_DATA (extent)) {
+ if (!IS_VALID_EXTENT_HEADER(extent) ||
+ (extent->h_tree_depth != -1)) {
LOG_ERROR_STATUS(ret = -EFAIL);
goto leave;
}
- for (j = 0; j < extent->next_free_ext; j++) {
+ for (j = 0; j < extent->h_next_free_rec; j++) {
/* Add the Extent to extent map */
ret = ocfs_add_extent_map_entry_from_rec(osb->sb,
&OCFS_I(inode)->map,
@@ -489,18 +490,18 @@
}
}
- if (extent->next_data_ext > 0) {
- if (!extent->next_data_ext) {
+ if (extent->h_next_leaf_blk > 0) {
+ if (!extent->h_next_leaf_blk) {
LOG_ERROR_STATUS (ret = -EFAIL);
goto leave;
}
- next_data_ext = extent->next_data_ext;
+ next_leaf = extent->h_next_leaf_blk;
OCFS_BH_PUT_DATA(extent_bh);
extent = NULL;
extent_bh = NULL;
ret = ocfs_read_bh(osb,
- next_data_ext,
+ next_leaf << osb->sb->s_blocksize_bits,
&extent_bh,
OCFS_BH_COND_CACHED, inode);
if (ret < 0) {
Modified: branches/format-changes/src/inode.c
===================================================================
--- branches/format-changes/src/inode.c 2004-06-09 10:40:10 UTC (rev 1036)
+++ branches/format-changes/src/inode.c 2004-06-09 19:15:25 UTC (rev 1037)
@@ -374,13 +374,11 @@
{
struct super_block *sb;
ocfs_super *osb;
- __u64 offset;
LOG_ENTRY_ARGS ("(0x%p, size:%llu)\n", inode, fe->i_size);
sb = inode->i_sb;
osb = OCFS_SB(sb);
- offset = fe->i_blkno << osb->sb->s_blocksize_bits;
if (!IS_VALID_FILE_ENTRY(fe)) {
printk("ocfs2: invalid file entry!\n");
@@ -411,7 +409,8 @@
OCFS_SET_INODE_TIME(inode, i_mtime, fe->i_mtime);
OCFS_SET_INODE_TIME(inode, i_ctime, fe->i_ctime);
- SET_INODE_FEOFF(inode, offset);
+ SET_INODE_FEOFF(inode,
+ fe->i_blkno << osb->sb->s_blocksize_bits);
OCFS_I(inode)->alloc_size =
(u64)fe->i_clusters << osb->s_clustersize_bits;
@@ -423,10 +422,12 @@
OCFS_I(inode)->oin_flags |= OCFS_OIN_DIRECTORY;
if (create_ino)
- inode->i_ino = ino_from_off(inode->i_sb, offset);
+ inode->i_ino =
+ ino_from_off(inode->i_sb,
+ fe->i_blkno << osb->sb->s_blocksize_bits);
- LOG_TRACE_ARGS("offset = %llu, ino = %lu, create_ino = %s\n",
- offset, inode->i_ino,
+ LOG_TRACE_ARGS("blkno = %llu, ino = %lu, create_ino = %s\n",
+ fe->i_blkno, inode->i_ino,
create_ino ? "true" : "false");
inode->i_nlink = fe->i_links_count;
@@ -440,7 +441,7 @@
case S_IFDIR:
if (inode->i_nlink < 2) {
LOG_ERROR_ARGS("inlink=%d for %llu\n", inode->i_nlink,
- offset);
+ fe->i_blkno);
inode->i_nlink = 2;
}
atomic_set(GET_INODE_CLEAN_SEQ(inode), atomic_read(&osb->clean_buffer_seq));
@@ -1859,7 +1860,7 @@
__u32 j;
/* Add the Extents to extent map */
- for (j = 0; j < fe->i_next_free_ext; j++) {
+ for (j = 0; j < fe->i_next_free_rec; j++) {
if (!ocfs_add_extent_map_entry_from_rec(osb->sb,
&OCFS_I(inode)->map,
&fe->extents[j]))
Modified: branches/format-changes/src/namei.c
===================================================================
--- branches/format-changes/src/namei.c 2004-06-09 10:40:10 UTC (rev 1036)
+++ branches/format-changes/src/namei.c 2004-06-09 19:15:25 UTC (rev 1037)
@@ -398,8 +398,8 @@
fe->i_links_count = 1;
fe->i_tree_depth = -1;
- fe->i_next_free_ext = 0;
- fe->last_ext_ptr = 0;
+ fe->i_next_free_rec = 0;
+ fe->i_last_eh_blk = 0;
strcpy (fe->i_signature, OCFS_FILE_ENTRY_SIGNATURE);
fe->i_flags |= OCFS2_VALID_FL;
fe->i_flags &= ~(OCFS2_CHANGE_FL);
Modified: branches/format-changes/src/ocfs.h
===================================================================
--- branches/format-changes/src/ocfs.h 2004-06-09 10:40:10 UTC (rev 1036)
+++ branches/format-changes/src/ocfs.h 2004-06-09 19:15:25 UTC (rev 1037)
@@ -256,14 +256,6 @@
NONLOCAL_EXT = 2
} ocfs_ext_flag;
-enum {
- EXTENT_HEADER,
- EXTENT_DATA
-};
-
-#define OCFS_EXTENT_DATA 1
-#define OCFS_EXTENT_HEADER 2
-
#define OCFS_MAX_FILE_ENTRY_EXTENTS 3
#define OCFS_MAX_DATA_EXTENTS 18
#define NUM_SECTORS_IN_LEAF_NODE 1
@@ -335,18 +327,13 @@
#define INVALID_NODE_POINTER -1
-#define OCFS_FILE_ENTRY_SIGNATURE "FIL"
-#define OCFS_EXTENT_HEADER_SIGNATURE "EXTHDR2"
-#define OCFS_EXTENT_DATA_SIGNATURE "EXTDAT1"
+#define OCFS_FILE_ENTRY_SIGNATURE "INODE01"
+#define OCFS_EXTENT_HEADER_SIGNATURE "EXHDR01"
+#define OCFS_EXTENT_DATA_SIGNATURE OCFS_EXTENT_HEADER_SIGNATURE
#define OCFS_LOCAL_ALLOC_SIGNATURE "LCLBMP"
#define MAX_IP_ADDR_LEN 32
-#define OCFS_IP_ADDR "ip_address"
-#define OCFS_IP_PORT "ip_port"
-#define OCFS_IP_MASK "subnet_mask"
-#define OCFS_COMM_TYPE "type"
-
#define SHUTDOWN_SIGS (sigmask(SIGKILL) | sigmask(SIGHUP) | \
sigmask(SIGINT) | sigmask(SIGQUIT))
@@ -376,9 +363,6 @@
#define OCFS_VOLCFG_HDR_SECTORS 2 /* in sectors */
#define OCFS_VOLCFG_NEWCFG_SECTORS 4 /* in sectors */
-#define OCFS_PUBLISH_CLEAR 0
-#define OCFS_PUBLISH_SET 1
-
#define OCFS_NM_HEARTBEAT_TIME 500 /* in ms */
#define OCFS_HEARTBEAT_INIT 10 /* number of NM iterations to stabilize the publish map */
@@ -408,9 +392,6 @@
#define IS_VALID_EXTENT_HEADER(ptr) \
(!strcmp((ptr)->signature, OCFS_EXTENT_HEADER_SIGNATURE))
-#define IS_VALID_EXTENT_DATA(ptr) \
- (!strcmp((ptr)->signature, OCFS_EXTENT_DATA_SIGNATURE))
-
#define IS_VALID_NODE_NUM(node) \
(((node) >= 0) && ((node) < OCFS_MAXIMUM_NODES))
@@ -475,21 +456,6 @@
ocfs_protocol;
-#define OCFS_IS_VALID_EXTENT(__ext, __typ) ({ \
- int __ret = 0; \
- switch (__typ) { \
- case EXTENT_HEADER: \
- if (IS_VALID_EXTENT_HEADER(__ext)) \
- __ret = 1; \
- break; \
- case EXTENT_DATA: \
- if (IS_VALID_EXTENT_DATA(__ext)) \
- __ret = 1; \
- break; \
- } \
- __ret; \
-})
-
#define ocfs_allocate_extent_entry() (ocfs_extent *)kmem_cache_alloc ( \
OcfsGlobalCtxt.extent_cache, GFP_NOFS)
#define ocfs_free_extent_entry(ext) kmem_cache_free(OcfsGlobalCtxt.extent_cache, ext)
@@ -1187,12 +1153,12 @@
*/
extern ocfs_global_ctxt OcfsGlobalCtxt;
-typedef struct _ocfs_extent_rec {
+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*/
-} ocfs_extent_rec;
+} ocfs2_extent_rec;
typedef struct _ocfs_publish // CLASS
{
@@ -1236,15 +1202,16 @@
ocfs_local_alloc;
/*
- * On disk file entry (inode) for OCFS v2
+ * On disk inode for OCFS v2
*/
typedef struct _ocfs2_dinode {
/*00*/ __u8 i_signature[8]; /* Signature for validation */
__u32 i_generation; /* Generation number */
- __u32 i_suballoc_node; /* Node suballocater this inode
+ __u16 i_reserved1;
+ __u16 i_suballoc_node; /* Node suballocater this inode
belongs to */
-/*10*/ __u64 i_suballoc_blkno; /* Node suballocator offset
- (in blocks) */
+/*10*/ __u64 i_suballoc_blkno; /* Node suballocator offset,
+ in blocks */
/*18*/ ocfs_disk_lock disk_lock; /* Lock structure */
/*38*/ __u32 i_uid; /* Owner UID */
__u32 i_gid; /* Owning GID */
@@ -1258,7 +1225,7 @@
__u64 i_dtime; /* Deletion time */
/*70*/ __u64 i_blkno; /* Offset on disk, in blocks */
__u32 i_clusters; /* Cluster count */
- __u32 i_reserved1;
+ __u32 i_reserved2;
/*80*/ union {
__u64 fe_private;
__u64 i_rdev;
@@ -1267,39 +1234,43 @@
__u32 total_bits;
} bitinfo;
} u;
-/*98*/ __s16 i_tree_depth; /* Extent tree depth
- * -1 means data extents hang
- * directly off of the
- * file_entry.
- */
- __u16 i_next_free_ext; /* Next unused extent slot */
+/*98*/ __u64 i_last_eh_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_next_free_rec; /* Next unused extent slot */
__u32 i_reserved3;
-/*A0*/ __u64 last_ext_ptr; /* Pointer to last extdat */
-/*A8*/ ocfs_extent_rec extents[OCFS_MAX_FILE_ENTRY_EXTENTS]; // EXTENT[OCFS_MAX_FILE_ENTRY_EXTENTS]
+/*A8*/ ocfs2_extent_rec extents[OCFS_MAX_FILE_ENTRY_EXTENTS]; // EXTENT[OCFS_MAX_FILE_ENTRY_EXTENTS]
} ocfs2_dinode;
-typedef struct _ocfs_extent_group // CLASS
+/*
+ * On disk extent header (indirect blocks) for OCFSv2
+ */
+typedef struct _ocfs2_extent_header
{
- __u8 signature[8]; // CHAR ARRAY[8]
- /* 0 when init, -1 when full */
- __s32 next_free_ext; // NUMBER RANGE(-1,LONG_MAX)
- /* Currently available sector for use */
- __u32 curr_sect; // NUMBER RANGE(0,ULONG_MAX)
- /* Maximum Number of Sectors */
- __u32 max_sects; // NUMBER RANGE(0,ULONG_MAX)
- /* Type of this sector... either */
- __u32 type; // EXTENTTYPE
- /* Number of leaf levels */
- __s32 granularity; // NUMBER RANGE(-1,LONG_MAX)
- __u32 alloc_node; // NODENUM
- __u64 this_ext; // DISKPTR
- __u64 next_data_ext; // DISKPTR
- __u64 alloc_file_off; // DISKPTR
- __u64 last_ext_ptr; // DISKPTR
- __u64 up_hdr_node_ptr; // DISKPTR
- ocfs_extent_rec extents[OCFS_MAX_DATA_EXTENTS]; // EXTENT[OCFS_MAX_DATA_EXTENTS]
-}
-ocfs_extent_group; // END CLASS
+/*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*/ __s16 h_tree_depth; /* Extent tree depth from this
+ point. -1 means data extents
+ hang directly off this
+ header (a leaf) */
+ __u16 h_next_free_rec; /* Next unused extent slot */
+ __u32 h_reserved3;
+/*38*/ ocfs2_extent_rec extents[OCFS_MAX_DATA_EXTENTS]; // EXTENT[OCFS_MAX_DATA_EXTENTS]
+} ocfs2_extent_header;
typedef struct _ocfs_dlm_msg_hdr
{
@@ -1775,11 +1746,11 @@
}
static inline int ocfs_extent_for_offset(struct super_block *sb,
- ocfs_extent_group *eh,
+ ocfs2_extent_header *eh,
u64 vbo)
{
int k;
- ocfs_extent_rec *ext;
+ ocfs2_extent_rec *ext;
u32 cluster;
u64 byte_off;
Modified: branches/format-changes/src/ocfs_buffer_head.h
===================================================================
--- branches/format-changes/src/ocfs_buffer_head.h 2004-06-09 10:40:10 UTC (rev 1036)
+++ branches/format-changes/src/ocfs_buffer_head.h 2004-06-09 19:15:25 UTC (rev 1037)
@@ -364,7 +364,8 @@
goto bail;
}
- status = ocfs_read_bhs(osb, off, 512, bh, flags, inode);
+ status = ocfs_read_bhs(osb, off, osb->sb->s_blocksize, bh,
+ flags, inode);
bail:
IO_FUNC_TIMING_PRINT("ocfs_read_bh", status);
Modified: branches/format-changes/src/sysfile.c
===================================================================
--- branches/format-changes/src/sysfile.c 2004-06-09 10:40:10 UTC (rev 1036)
+++ branches/format-changes/src/sysfile.c 2004-06-09 19:15:25 UTC (rev 1037)
@@ -475,7 +475,7 @@
__u32 k = 0, j;
__u32 Runs, Runoffset;
struct buffer_head *extent_bh = NULL;
- ocfs_extent_group *extent = NULL;
+ ocfs2_extent_header *extent = NULL;
ocfs_io_runs *IoRuns;
__u64 newOffset = 0, searchVbo, remainingLength = 0;
@@ -592,10 +592,10 @@
}
extent = OCFS_BH_GET_DATA_READ(extent_bh);
- while (extent->type != OCFS_EXTENT_DATA) {
+ while (extent->h_tree_depth >= 0) {
__u64 diskoffset;
- if (!IS_VALID_EXTENT_HEADER (extent)) {
+ if (!IS_VALID_EXTENT_HEADER(extent)) {
LOG_ERROR_STATUS(status = -EFAIL);
goto leave;
}
@@ -629,10 +629,9 @@
searchVbo = newOffset;
- OCFS_ASSERT (extent->type ==
- OCFS_EXTENT_DATA);
+ OCFS_ASSERT(extent->h_tree_depth == -1);
- if (!IS_VALID_EXTENT_DATA (extent)) {
+ if (!IS_VALID_EXTENT_HEADER(extent)) {
LOG_ERROR_STATUS(status = -EFAIL);
goto leave;
}
More information about the Ocfs2-commits
mailing list