[Ocfs2-commits]
jlbec commits r995 - in branches/format-changes/src: . inc
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Thu Jun 3 15:20:46 CDT 2004
Author: jlbec
Date: 2004-06-03 14:20:44 -0500 (Thu, 03 Jun 2004)
New Revision: 995
Modified:
branches/format-changes/src/alloc.c
branches/format-changes/src/dlm.c
branches/format-changes/src/extmap.c
branches/format-changes/src/file.c
branches/format-changes/src/inc/ocfs.h
branches/format-changes/src/inc/ocfs_compat.h
branches/format-changes/src/inode.c
branches/format-changes/src/journal.c
branches/format-changes/src/namei.c
branches/format-changes/src/nm.c
branches/format-changes/src/super.c
branches/format-changes/src/sysfile.c
Log:
o First pass of file_entry reorg. This is everything but the
allocation tree.
Modified: branches/format-changes/src/alloc.c
===================================================================
--- branches/format-changes/src/alloc.c 2004-06-03 01:22:33 UTC (rev 994)
+++ branches/format-changes/src/alloc.c 2004-06-03 19:20:44 UTC (rev 995)
@@ -77,7 +77,7 @@
__u64 length, struct inode *inode);
static int _squish_extent_entries(ocfs_super *osb, ocfs_alloc_ext *extarr,
- __u8 *freeExtent,
+ __u16 *freeExtent,
ocfs_journal_handle *handle,
__u64 FileSize, int flag,
struct inode *inode);
@@ -646,8 +646,9 @@
depth = extent_header->granularity;
upHeaderPtr = extent_header->this_ext;
} else {
- depth = FileEntry->granularity;
- upHeaderPtr = FileEntry->this_sector;
+ depth = FileEntry->i_tree_depth;
+ upHeaderPtr =
+ FileEntry->i_blkno << osb->sb->s_blocksize_bits;
}
numSectorsAlloc = NUM_SECTORS_IN_LEAF_NODE + depth;
@@ -694,16 +695,16 @@
if (extent_header != NULL) {
k = extent_header->next_free_ext;
- extent_header->extents[k].file_off = FileEntry->alloc_size;
+ extent_header->extents[k].file_off = FileEntry->i_clusters << osb->s_clustersize_bits;
extent_header->extents[k].num_bytes = actualLength;
extent_header->extents[k].disk_off = physicalOffset;
extent_header->next_free_ext++;
} else {
- k = FileEntry->next_free_ext;
- FileEntry->extents[k].file_off = FileEntry->alloc_size;
+ k = FileEntry->i_next_free_ext;
+ FileEntry->extents[k].file_off = FileEntry->i_clusters << osb->s_clustersize_bits;
FileEntry->extents[k].num_bytes = actualLength;
FileEntry->extents[k].disk_off = physicalOffset;
- FileEntry->next_free_ext++;
+ FileEntry->i_next_free_ext++;
}
@@ -719,7 +720,7 @@
ext->next_free_ext = 1;
ext->alloc_file_off = fileOffset + (osb->sect_size * i);
ext->alloc_node = osb->node_num;
- ext->extents[0].file_off = FileEntry->alloc_size;
+ ext->extents[0].file_off = FileEntry->i_clusters << osb->s_clustersize_bits;
ext->extents[0].num_bytes = actualLength;
ext->this_ext = (__u64) (physicalOffset + (osb->sect_size * i));
@@ -754,7 +755,7 @@
if (extent_header != NULL) {
/* both needed below in for loop */
__u64 up_hdr_node_ptr = extent_header->up_hdr_node_ptr;
- int granularity = extent_header->granularity;
+ int tree_depth = extent_header->granularity;
OCFS_BH_PUT_DATA(extent_header_bh);
bh_locked = 0;
@@ -769,7 +770,7 @@
/* gotta fix up his parent extents now. We totally
* reuse the extent_header variable now as it's no
* longer needed for it's original purpose. */
- for (i = granularity + 1; i < FileEntry->granularity; i++) {
+ for (i = tree_depth + 1; i < FileEntry->i_tree_depth; i++) {
bh = NULL;
status = ocfs_read_bh (osb, up_hdr_node_ptr, &bh, OCFS_BH_COND_CACHED, inode);
if (status < 0) {
@@ -813,7 +814,7 @@
brelse(bh);
}
- k = FileEntry->next_free_ext - 1;
+ k = FileEntry->i_next_free_ext - 1;
FileEntry->extents[k].num_bytes += actualLength;
}
finally:
@@ -863,9 +864,9 @@
OCFS_BH_PUT_DATA(fe_bh);
real_fe = NULL;
- AllocSize = ((fe->granularity + 2) * osb->sect_size);
+ AllocSize = ((fe->i_tree_depth + 2) * osb->sect_size);
- numbhs = fe->granularity + 2;
+ numbhs = fe->i_tree_depth + 2;
bhs = ocfs_malloc(numbhs * sizeof(*bhs));
if (bhs == NULL) {
status = -ENOMEM;
@@ -919,28 +920,28 @@
OcfsExtent->alloc_file_off = fileOffset;
OcfsExtent->alloc_node = osb->node_num;
OcfsExtent->next_data_ext = 0;
- fe->granularity++;
+ fe->i_tree_depth++;
- LOG_TRACE_ARGS ("Granularity is: %d\n", fe->granularity);
+ LOG_TRACE_ARGS ("Granularity is: %d\n", fe->i_tree_depth);
OCFS_BH_PUT_DATA(bhs[0]);
- /* If granularity is zero now, the for loop will not execute. */
- /* First time a file is created, granularity = -1 */
+ /* If tree_depth is zero now, the for loop will not execute. */
+ /* First time a file is created, tree_depth = -1 */
- upHeaderPtr = fe->this_sector;
+ upHeaderPtr = fe->i_blkno << osb->sb->s_blocksize_bits;
- for (i = 0; i < fe->granularity; i++) {
+ for (i = 0; i < fe->i_tree_depth; i++) {
ExtentHeader = (ocfs_extent_group *) OCFS_BH_GET_DATA_WRITE(bhs[i]); /* write */
ExtentHeader->type = OCFS_EXTENT_HEADER;
- ExtentHeader->granularity = (fe->granularity - 1) - i;
+ ExtentHeader->granularity = (fe->i_tree_depth - 1) - i;
strcpy (ExtentHeader->signature, OCFS_EXTENT_HEADER_SIGNATURE);
if (i == 0) {
ExtentHeader->extents[OCFS_MAX_FILE_ENTRY_EXTENTS].disk_off = physicalOffset + osb->sect_size;
- ExtentHeader->extents[OCFS_MAX_FILE_ENTRY_EXTENTS].file_off = fe->alloc_size;
+ ExtentHeader->extents[OCFS_MAX_FILE_ENTRY_EXTENTS].file_off = fe->i_clusters << osb->s_clustersize_bits;
ExtentHeader->extents[OCFS_MAX_FILE_ENTRY_EXTENTS].num_bytes = length;
ExtentHeader->next_free_ext = OCFS_MAX_FILE_ENTRY_EXTENTS + 1;
@@ -952,7 +953,7 @@
lastExtentPtr = ExtentHeader->this_ext;
} else {
ExtentHeader->extents[0].disk_off = physicalOffset + (osb->sect_size * (i + 1));
- ExtentHeader->extents[0].file_off = fe->alloc_size;
+ ExtentHeader->extents[0].file_off = fe->i_clusters << osb->s_clustersize_bits;
ExtentHeader->extents[0].num_bytes = length;
ExtentHeader->next_free_ext = 1;
ExtentHeader->alloc_file_off = fileOffset + (osb->sect_size * i);
@@ -968,9 +969,9 @@
}
/* Update the Data Segment, which is the last one in our array */
- OcfsExtent = (ocfs_extent_group *) OCFS_BH_GET_DATA_WRITE(bhs[fe->granularity]); /* write */
+ OcfsExtent = (ocfs_extent_group *) OCFS_BH_GET_DATA_WRITE(bhs[fe->i_tree_depth]); /* write */
- i = (fe->granularity) ? 0 : OCFS_MAX_FILE_ENTRY_EXTENTS;
+ i = (fe->i_tree_depth) ? 0 : OCFS_MAX_FILE_ENTRY_EXTENTS;
LOG_TRACE_ARGS ("EntryAvailable is: %d\n", OcfsExtent->next_free_ext);
@@ -979,16 +980,18 @@
strcpy (OcfsExtent->signature, OCFS_EXTENT_DATA_SIGNATURE);
- OcfsExtent->extents[i].file_off = fe->alloc_size;
+ OcfsExtent->extents[i].file_off = fe->i_clusters << osb->s_clustersize_bits;
OcfsExtent->extents[i].num_bytes = length;
OcfsExtent->extents[i].disk_off = disk_off;
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->granularity * osb->sect_size);
+ OcfsExtent->alloc_file_off = fileOffset +
+ (fe->i_tree_depth * osb->sect_size);
OcfsExtent->alloc_node = osb->node_num;
- OcfsExtent->this_ext = physicalOffset + (fe->granularity * osb->sect_size);
+ 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;
@@ -996,7 +999,7 @@
upHeaderPtr = OcfsExtent->this_ext;
lastExtentPtr = OcfsExtent->this_ext;
- OCFS_BH_PUT_DATA(bhs[fe->granularity]);
+ OCFS_BH_PUT_DATA(bhs[fe->i_tree_depth]);
/* This needs to be a sync write OR journalled to be safe. */
status = ocfs_write_bhs(osb, bhs, numbhs, 0, inode);
@@ -1043,7 +1046,7 @@
}
/* Update the uphdrptr of the three extents pointed to by fe */
- if (fe->granularity > 0) {
+ if (fe->i_tree_depth > 0) {
int i;
__u64 offset;
struct buffer_head *bh = NULL;
@@ -1086,12 +1089,12 @@
/* Update the File Entry Extent */
- LOG_TRACE_ARGS("fe->alloc_size = %llu\n", fe->alloc_size);
+ LOG_TRACE_ARGS("fe->i_clusters = %u\n", fe->i_clusters);
fe->extents[0].file_off = 0;
- fe->extents[0].num_bytes = fe->alloc_size + length;
+ fe->extents[0].num_bytes = (fe->i_clusters << osb->s_clustersize_bits) + length;
fe->extents[0].disk_off = physicalOffset;
fe->last_ext_ptr = lastExtentPtr;
- fe->next_free_ext = 1;
+ fe->i_next_free_ext = 1;
finally:
@@ -1132,15 +1135,15 @@
goto finally;
}
- if (FileEntry->granularity < 0) {
+ if (FileEntry->i_tree_depth < 0) {
LOG_TRACE_STR("Using local extents");
/* We are still using the local extents of File Entry */
- if (FileEntry->next_free_ext > OCFS_MAX_FILE_ENTRY_EXTENTS) {
+ if (FileEntry->i_next_free_ext > OCFS_MAX_FILE_ENTRY_EXTENTS) {
LOG_ERROR_STATUS(status = -EINVAL);
goto finally;
}
- k = FileEntry->next_free_ext - 1;
+ k = FileEntry->i_next_free_ext - 1;
if (k >= 0 && OCFS_EXTENT_MERGEABLE (&FileEntry->extents[k], actualDiskOffset)) {
/* See if we can merge the extents and just increase the length */
LOG_TRACE_ARGS ("Using local extent for extent Entry = %u\n", k);
@@ -1149,26 +1152,26 @@
}
/* We cannot merge try to give him the next extent */
- k = FileEntry->next_free_ext;
+ k = FileEntry->i_next_free_ext;
if (k != OCFS_MAX_FILE_ENTRY_EXTENTS) {
/* file_off for the new extent will be equal
* to the previous allocation size of file */
- FileEntry->extents[k].file_off = FileEntry->alloc_size;
+ FileEntry->extents[k].file_off = FileEntry->i_clusters << osb->s_clustersize_bits;
FileEntry->extents[k].num_bytes = actualLength;
FileEntry->extents[k].disk_off = actualDiskOffset;
- FileEntry->next_free_ext++;
+ FileEntry->i_next_free_ext++;
goto finally;
}
/* We have no more room in the fe, must increase
- * granularity */
+ * tree_depth */
IncreaseTreeDepth = 1;
goto increase_depth;
}
LOG_TRACE_STR("Using NON-local extents");
/*** Nonlocal Extents ***/
- if (FileEntry->granularity > 3)
- LOG_ERROR_ARGS ("granularity=%d", FileEntry->granularity);
+ if (FileEntry->i_tree_depth > 3)
+ LOG_ERROR_ARGS ("tree_depth=%d", FileEntry->i_tree_depth);
/* This File is no longer using Local Extents */
IncreaseTreeDepth = 0;
@@ -1213,7 +1216,7 @@
OCFS_JOURNAL_ACCESS_WRITE);
extent = (ocfs_extent_group *) OCFS_BH_GET_DATA_WRITE(extent_bh); /* write */ /* journal access */
- extent->extents[k].file_off = FileEntry->alloc_size;
+ extent->extents[k].file_off = FileEntry->i_clusters << osb->s_clustersize_bits;
extent->extents[k].num_bytes = actualLength;
extent->extents[k].disk_off = actualDiskOffset;
extent->next_free_ext++;
@@ -1225,10 +1228,10 @@
* upward till we find a free extent or we are
* at the top and need to create another
* level. */
- if (FileEntry->granularity > 0)
+ if (FileEntry->i_tree_depth > 0)
up_hdr_node_ptr = extent->up_hdr_node_ptr;
- for (i = 0; i < FileEntry->granularity; i++) {
+ for (i = 0; i < FileEntry->i_tree_depth; i++) {
/* if we loop back around */
if (extent_header) {
OCFS_BH_PUT_DATA(extent_header_bh);
@@ -1257,7 +1260,7 @@
break;
up_hdr_node_ptr = extent_header->up_hdr_node_ptr;
- } /* for (i = 0; i < FileEntry->granularity; i++) */
+ } /* for (i = 0; i < FileEntry->i_tree_depth; i++) */
if (extent_header) {
OCFS_BH_PUT_DATA(extent_header_bh);
@@ -1267,9 +1270,9 @@
/* 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 granularity. */
- if (i == FileEntry->granularity &&
- FileEntry->next_free_ext == OCFS_MAX_FILE_ENTRY_EXTENTS) {
+ * increase the tree_depth. */
+ if (i == FileEntry->i_tree_depth &&
+ FileEntry->i_next_free_ext == OCFS_MAX_FILE_ENTRY_EXTENTS) {
IncreaseTreeDepth = 1;
goto increase_depth;
}
@@ -1310,7 +1313,7 @@
}
if (!IncreaseTreeDepth && UpdateParent) {
- for (i = 0; i < FileEntry->granularity; i++) {
+ for (i = 0; i < FileEntry->i_tree_depth; i++) {
/* next two if's are for loop around */
if (extent_header_bh) {
@@ -1363,7 +1366,7 @@
}
}
- k = FileEntry->next_free_ext - 1;
+ k = FileEntry->i_next_free_ext - 1;
FileEntry->extents[k].num_bytes += actualLength;
}
@@ -1406,7 +1409,7 @@
if (FileEntry == NULL)
FileEntry = (ocfs_file_entry *)OCFS_BH_GET_DATA_READ(fe_bh); /* read */
- Vbo = FileEntry->alloc_size;
+ Vbo = FileEntry->i_clusters << osb->s_clustersize_bits;
Lbo = actualDiskOffset;
/* Add the Entry to the extent map list */
@@ -1448,12 +1451,12 @@
* 'flag' seems to be an indicator that (if true) tells us that we already know
* we're gonna have to clear out all of extarr.
*/
-static int _squish_extent_entries(ocfs_super *osb, ocfs_alloc_ext *extarr, __u8 *freeExtent, ocfs_journal_handle *handle, __u64 FileSize, int flag, struct inode *inode)
+static int _squish_extent_entries(ocfs_super *osb, ocfs_alloc_ext *extarr, __u16 *freeExtent, ocfs_journal_handle *handle, __u64 FileSize, int flag, struct inode *inode)
{
int status = 0;
int FirstTime = 1;
ocfs_alloc_ext *ext;
- __u32 i, csize = osb->cluster_size_bits,
+ __u32 i, csize = osb->s_clustersize_bits,
numBitsAllocated = 0, bitmapOffset = 0,
firstfree = *freeExtent;
__u64 bytes, foff, doff,
@@ -1516,7 +1519,7 @@
/* used by ocfs_kill_this_tree and ocfs_split_this_tree */
/* This value needs to be removed in a future version and set to
- * granularity + 1, dynamically */
+ * tree_depth + 1, dynamically */
#define OCFS_TREE_STACK_SIZE 8
/*
@@ -1524,7 +1527,7 @@
*
* Given an extent_group (can be a DAT or header), delete everything,
* including itself, it's children, and any data blocks they point to.
- * Works fine with any granularity (up to 4, in which case we'd need
+ * Works fine with any tree_depth (up to 4, in which case we'd need
* more stack space)
*
* extent_grp_bh will be unchanged, though it will be marked for
@@ -1537,7 +1540,7 @@
int status = -EFAIL;
int i;
__u32 victim;
- __u32 csize = osb->cluster_size_bits;
+ __u32 csize = osb->s_clustersize_bits;
__u64 dstart = osb->vol_layout.data_start_off;
__u64 tmp_off;
__u32 num_sectors = 0, bitmap_offset = 0;
@@ -1708,7 +1711,7 @@
static int ocfs_split_this_tree(ocfs_super * osb, struct buffer_head *extent_grp_bh, ocfs_journal_handle *handle, ocfs_file_entry *fe, struct inode *inode)
{
int status = -EFAIL;
- __u64 newsize = fe->alloc_size;
+ __u64 newsize = fe->i_clusters << osb->s_clustersize_bits;
ocfs_alloc_ext *ext;
struct buffer_head * bh_stack[OCFS_TREE_STACK_SIZE];
ocfs_extent_group * AllocExtent = NULL;/* convenience, points to TOS */
@@ -1717,10 +1720,10 @@
int tos = 0;
int i, victim;
__u64 bytes, foff, doff, orig_bytes, dstart = osb->vol_layout.data_start_off, total_bytes, tmp_off;
- __u32 csize = osb->cluster_size_bits;
+ __u32 csize = osb->s_clustersize_bits;
__u32 num_sectors, bitmap_offset;
int done = 0;
- int gran = fe->granularity;
+ int gran = fe->i_tree_depth;
int needs_brelse = 0;
LOG_ENTRY();
@@ -1728,8 +1731,8 @@
/* This is a similar hack to the one below, untested for gran = 3 files
because I can't recreate one. */
if (gran == 3) {
- LOG_ERROR_STR("Truncating file with granularity 3, this is not tested and may be unsafe!");
- LOG_TRACE_STR("Found a granularity 3 tree, trimming it.\n");
+ 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");
status = ocfs_journal_access(handle, extent_grp_bh,
OCFS_JOURNAL_ACCESS_WRITE);
@@ -1799,9 +1802,9 @@
/* 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 granularity 1 (which we know works) */
+ proceeed as if we're tree_depth 1 (which we know works) */
if (gran == 2) {
- LOG_TRACE_STR("Found a granularity 2 tree, trimming it.\n");
+ LOG_TRACE_STR("Found a tree_depth 2 tree, trimming it.\n");
status = ocfs_journal_access(handle, extent_grp_bh,
OCFS_JOURNAL_ACCESS_WRITE);
@@ -2077,7 +2080,7 @@
}
/* I just have to fix my parent,
* right? Yes, but only because our
- * max granularity is 2. if it were
+ * max tree_depth is 2. if it were
* more, we'd have to fix his
* parents parent. */
status = ocfs_journal_access(handle, bh_stack[tos], OCFS_JOURNAL_ACCESS_WRITE);
@@ -2102,7 +2105,7 @@
* that case we're done, but need to
* write the parent out before we leave
* again, this bit of code depends on
- * granularity of 2. */
+ * tree_depth of 2. */
if (done) {
LOG_TRACE_STR("Found a boundary " \
"header, almost done " \
@@ -2220,14 +2223,19 @@
LOG_ENTRY ();
- if (fe->next_free_ext == 0) {
+ if (fe->i_next_free_ext == 0) {
LOG_TRACE_STR("setting to zero as there isn't any used extents");
fe->last_ext_ptr = 0;
status = 0;
goto bail;
}
- victim = fe->next_free_ext - 1;
+ /* Can't be called with local extents */
+ if (fe->i_tree_depth < 0)
+ BUG();
+
+ /* Ugly magic -1 */
+ victim = fe->i_next_free_ext - 1;
status = ocfs_read_bh(osb, fe->extents[victim].disk_off, &extent_bh,
OCFS_BH_CACHED, inode);
if (status < 0) {
@@ -2296,12 +2304,12 @@
LOG_ENTRY ();
- alloc_size = FileEntry->alloc_size;
+ alloc_size = FileEntry->i_clusters << osb->s_clustersize_bits;
/* local extents */
- if (FileEntry->granularity < 0) {
+ if (FileEntry->i_tree_depth < 0) {
status = _squish_extent_entries(osb, FileEntry->extents,
- &FileEntry->next_free_ext,
+ &FileEntry->i_next_free_ext,
handle, alloc_size, 0,
inode);
if (status < 0) {
@@ -2317,7 +2325,7 @@
updated_lep = 0;
/* Loop backwards through only the used free extent headers here */
- for (i = (FileEntry->next_free_ext - 1); i >= 0; i--) {
+ for (i = (FileEntry->i_next_free_ext - 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, FileEntry->extents[i].disk_off,
@@ -2339,7 +2347,7 @@
FileEntry->extents[i].file_off = 0;
FileEntry->extents[i].disk_off = 0;
FileEntry->extents[i].num_bytes = 0;
- FileEntry->next_free_ext = i;
+ FileEntry->i_next_free_ext = i;
} else { /* Ok, we only want part of it. */
LOG_TRACE_ARGS("Splitting this tree!\n");
status = ocfs_split_this_tree(osb, extent_bh,
@@ -2356,7 +2364,7 @@
for (j=0; j < i; j++)
FileEntry->extents[i].num_bytes += FileEntry->extents[j].num_bytes;
- FileEntry->next_free_ext = i + 1;
+ FileEntry->i_next_free_ext = i + 1;
/* We're done - we can't split more than one
* parts of the tree. */
updated_lep = 1;
@@ -2369,7 +2377,7 @@
/* Ok, trunc to zero is a special case, doofus */
if (alloc_size == 0) {
FileEntry->last_ext_ptr = 0;
- FileEntry->granularity = -1;
+ FileEntry->i_tree_depth = -1;
updated_lep = 1;
}
@@ -2446,15 +2454,15 @@
goto finally;
}
- if (!INODE_JOURNAL(inode) && Vbo >= (__s64) fe->alloc_size) {
- LOG_ERROR_ARGS ("vbo=%llu, fe->alloc_sz=%llu alloc_size=%llu",
- Vbo, fe->alloc_size,
+ if (!INODE_JOURNAL(inode) && Vbo >= (__s64)(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);
status = -EFAIL;
goto finally;
}
- if (fe->granularity < 0) {
+ if (fe->i_tree_depth < 0) {
status = ocfs_update_extent_map (osb, &OCFS_I(inode)->map, fe,
NULL, NULL, LOCAL_EXT);
if (status < 0) {
@@ -2558,7 +2566,7 @@
LOG_ENTRY ();
- for (i = 0; i < FileEntry->next_free_ext; i++) {
+ for (i = 0; i < FileEntry->i_next_free_ext; i++) {
if ((__s64) (FileEntry->extents[i].file_off +
FileEntry->extents[i].num_bytes) > Vbo) {
childDiskOffset = FileEntry->extents[i].disk_off;
@@ -2571,7 +2579,7 @@
goto finally;
}
- for (i = 0; i < FileEntry->granularity; i++) {
+ for (i = 0; i < FileEntry->i_tree_depth; i++) {
tempstat = ocfs_read_bh(osb, childDiskOffset, &ext_bh, OCFS_BH_COND_CACHED, inode);
if (tempstat < 0) {
LOG_ERROR_STATUS (status = tempstat);
@@ -2707,13 +2715,13 @@
bm_lock = (ocfs_file_entry *)OCFS_BH_GET_DATA_WRITE(bh); /* write */
ClusterCount = (__u32) ((__u64) (file_size + (osb->vol_layout.cluster_size-1)) >>
- osb->cluster_size_bits);
+ osb->s_clustersize_bits);
if (ClusterCount == 0) {
LOG_ERROR_STR ("DISK_FULL?: ClusterCount==0");
status = 0;
goto leave;
}
- ByteCount = ClusterCount << osb->cluster_size_bits;
+ ByteCount = ClusterCount << osb->s_clustersize_bits;
if (ByteCount == 0) {
LOG_ERROR_STR ("DISK_FULL?: Bytecount==0");
status = 0;
@@ -2722,7 +2730,7 @@
if (sysfile ? (ClusterCount > osb->vol_layout.num_clusters) :
(ClusterCount > (osb->vol_layout.num_clusters -
- ((8 * ONE_MEGA_BYTE) >> osb->cluster_size_bits)))){
+ ((8 * ONE_MEGA_BYTE) >> osb->s_clustersize_bits)))){
LOG_ERROR_STR ("Disk Full");
status = -ENOSPC;
goto leave;
@@ -2760,7 +2768,7 @@
LargeAlloc ? LargeAllocOffset :
SmallAllocOffset, sysfile ? 0 :
((8 * ONE_MEGA_BYTE) >>
- osb->cluster_size_bits));
+ osb->s_clustersize_bits));
/* if fails we should try again from the beginning of the disk. */
/* in the end we pass # of bits we want to keep for system
@@ -2919,8 +2927,8 @@
/* Read in the bitmap file for the dir alloc and look for the
* required space, if found */
fe = (ocfs_file_entry *) OCFS_BH_GET_DATA_READ(bh); /* read */
- fileSize = fe->file_size;
- allocSize = fe->alloc_size;
+ fileSize = fe->i_size;
+ allocSize = fe->i_clusters << osb->s_clustersize_bits;
OCFS_BH_PUT_DATA(bh);
prevFileSize = fileSize;
@@ -2990,8 +2998,8 @@
fe = (ocfs_file_entry *) OCFS_BH_GET_DATA_READ(bh); /* read */
/* we wrote it back out in ocfs_extend_system_file so
* we can trust the sizes here */
- fileSize = fe->file_size;
- allocSize = fe->alloc_size;
+ fileSize = fe->i_size;
+ allocSize = fe->i_clusters << osb->s_clustersize_bits;
OCFS_BH_PUT_DATA(bh);
if (needs_uninit)
@@ -3074,7 +3082,7 @@
offset = GET_INODE_FEOFF(inode);
fe = (ocfs_file_entry *)OCFS_BH_GET_DATA_READ(fe_bh); /* read */
- if (offset != fe->this_sector)
+ if (offset != (fe->i_blkno << osb->sb->s_blocksize_bits))
BUG();
OCFS_BH_PUT_DATA(fe_bh);
@@ -3083,22 +3091,22 @@
fe = (ocfs_file_entry *)OCFS_BH_GET_DATA_READ(fe_bh); /* read */
- if (fe->granularity < 0) {
- for (i = 0; i < fe->next_free_ext; i++) {
+ if (fe->i_tree_depth < 0) {
+ for (i = 0; i < fe->i_next_free_ext; i++) {
numBitsAllocated = (__u32) (fe->extents[i].num_bytes >>
- osb->cluster_size_bits);
+ osb->s_clustersize_bits);
bitmapOffset =
(__u32) ((fe->extents[i].disk_off -
osb->vol_layout.data_start_off) >>
- osb->cluster_size_bits);
+ osb->s_clustersize_bits);
ocfs_handle_add_commit_bits(handle, numBitsAllocated,
bitmapOffset, -1,
DISK_ALLOC_VOLUME);
}
} else {
- for (i = 0; i < fe->next_free_ext; i++) {
+ for (i = 0; i < fe->i_next_free_ext; i++) {
status = ocfs_read_bh(osb, fe->extents[i].disk_off,
&extent_bh, OCFS_BH_COND_CACHED, inode);
if (status < 0) {
@@ -3106,7 +3114,7 @@
goto leave;
}
extent = (ocfs_extent_group *) OCFS_BH_GET_DATA_READ(extent_bh); /* read */
- if ((fe->granularity && (!IS_VALID_EXTENT_HEADER(extent))) && !IS_VALID_EXTENT_DATA(extent)) {
+ if ((fe->i_tree_depth && (!IS_VALID_EXTENT_HEADER(extent))) && !IS_VALID_EXTENT_DATA(extent)) {
status = -EINVAL;
LOG_ERROR_STATUS(status);
goto leave;
@@ -3322,7 +3330,7 @@
OCFS_BH_PUT_DATA(osb->local_alloc_bh);
/* we try to use find_contig_space_from_bitmap here for now. */
- alloc_bytes = ocfs_local_alloc_window_bits(osb) << osb->cluster_size_bits;
+ alloc_bytes = ocfs_local_alloc_window_bits(osb) << osb->s_clustersize_bits;
LOG_TRACE_ARGS("Allocating %llu bytes (%u clusters) for a "
"new window.\n", alloc_bytes,
ocfs_local_alloc_window_bits(osb));
Modified: branches/format-changes/src/dlm.c
===================================================================
--- branches/format-changes/src/dlm.c 2004-06-03 01:22:33 UTC (rev 994)
+++ branches/format-changes/src/dlm.c 2004-06-03 19:20:44 UTC (rev 995)
@@ -276,7 +276,7 @@
struct buffer_head *bh = NULL;
__u32 curr_master;
__u8 lock_level;
- int is_dir = 0, disk_vote = 0;
+ int disk_vote = 0;
ocfs_lock_res *lockres = GET_INODE_LOCKRES(inode);
LOG_ENTRY_ARGS ("(0x%p, %llu, %u, 0x%p, %u)\n",
@@ -295,7 +295,6 @@
fe = (ocfs_file_entry *)OCFS_BH_GET_DATA_READ(bh); /* read */
curr_master = DISK_LOCK(fe)->curr_master;
lock_level = DISK_LOCK(fe)->file_lock;
- is_dir = (fe->attribs & OCFS_ATTRIB_DIRECTORY);
OCFS_BH_PUT_DATA(bh);
if ((curr_master == OCFS_INVALID_NODE_NUM) ||
@@ -324,7 +323,7 @@
lockres->lock_type = lock_level;
lockres->master_node_num = curr_master;
- if (is_dir) {
+ if (S_ISDIR(fe->i_mode)) {
if (lockres->readonly_node != OCFS_INVALID_NODE_NUM) {
if (lockres->readonly_node == curr_master) {
// readonly cachelock already on this dir
Modified: branches/format-changes/src/extmap.c
===================================================================
--- branches/format-changes/src/extmap.c 2004-06-03 01:22:33 UTC (rev 994)
+++ branches/format-changes/src/extmap.c 2004-06-03 19:20:44 UTC (rev 995)
@@ -596,9 +596,9 @@
if (Flag == LOCAL_EXT) {
FileEntry = (ocfs_file_entry *) Buffer;
- OCFS_ASSERT(FileEntry->granularity < 0);
+ OCFS_ASSERT(FileEntry->i_tree_depth < 0);
- for (j = 0; j < FileEntry->next_free_ext; j++) {
+ for (j = 0; j < FileEntry->i_next_free_ext; j++) {
tempVbo = FileEntry->extents[j].file_off;
tempLbo = FileEntry->extents[j].disk_off;
tempSize = FileEntry->extents[j].num_bytes;
Modified: branches/format-changes/src/file.c
===================================================================
--- branches/format-changes/src/file.c 2004-06-03 01:22:33 UTC (rev 994)
+++ branches/format-changes/src/file.c 2004-06-03 19:20:44 UTC (rev 995)
@@ -44,26 +44,23 @@
static int ocfs_change_file_attrib (ocfs_super * osb, __u64 file_off, struct iattr *attr, struct inode *inode);
static int ocfs_truncate_file (ocfs_super * osb, __u64 file_off, __u64 file_size, struct inode *inode);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
-#define ocfs_get_seconds(t) (t).tv_sec
-#else
-#define ocfs_get_seconds(t) (t)
-#endif
static void ocfs_fe_set_attributes(ocfs_file_entry *fe, struct iattr *attr)
{
if (attr->ia_valid & ATTR_SIZE)
- fe->file_size = attr->ia_size;
+ fe->i_size = attr->ia_size;
if (attr->ia_valid & ATTR_UID)
- fe->uid = attr->ia_uid;
+ fe->i_uid = attr->ia_uid;
if (attr->ia_valid & ATTR_GID)
- fe->gid = attr->ia_gid;
+ fe->i_gid = attr->ia_gid;
if (attr->ia_valid & ATTR_MODE)
- fe->prot_bits = attr->ia_mode & 0007777;
+ fe->i_mode = attr->ia_mode;
if (attr->ia_valid & ATTR_CTIME)
- fe->create_time = ocfs_get_seconds(attr->ia_ctime);
+ fe->i_ctime = ocfs_get_seconds(attr->ia_ctime);
+ if (attr->ia_valid & ATTR_ATIME)
+ fe->i_atime = ocfs_get_seconds(attr->ia_atime);
if (attr->ia_valid & ATTR_MTIME)
- fe->modify_time = ocfs_get_seconds(attr->ia_mtime);
+ fe->i_mtime = ocfs_get_seconds(attr->ia_mtime);
}
static inline int ocfs_sync_inode(struct inode *inode)
@@ -111,9 +108,10 @@
}
/* why do we update these here? */
- OCFS_I(inode)->alloc_size = fe->alloc_size;
+ OCFS_I(inode)->alloc_size =
+ fe->i_clusters << osb->s_clustersize_bits;
OCFS_I(inode)->chng_seq_num = DISK_LOCK(fe)->dlock_seq_num;
- if (fe->this_sector == 0)
+ if (fe->i_blkno == 0)
LOG_ERROR_STR ("this_sector=0");
OCFS_BH_PUT_DATA(fe_bh);
@@ -436,14 +434,14 @@
tmp = OCFS_BH_GET_DATA_READ(fe_bh); /* read */
memcpy(fe, tmp, sizeof(ocfs_file_entry));
OCFS_BH_PUT_DATA(fe_bh);
- tempoff = fe->this_sector;
+ tempoff = fe->i_blkno << osb->sb->s_blocksize_bits;
/* we don't want to do the extent map stuff for a directory. */
- if (fe->attribs & OCFS_ATTRIB_DIRECTORY)
+ if (S_ISDIR(fe->i_mode))
goto leave;
- if (fe->granularity < 0) {
- for (j = 0; j < fe->next_free_ext; j++) {
+ if (fe->i_tree_depth < 0) {
+ for (j = 0; j < fe->i_next_free_ext; j++) {
tempVbo = fe->extents[j].file_off;
tempLbo = fe->extents[j].disk_off;
tempSize = fe->extents[j].num_bytes;
@@ -590,7 +588,6 @@
__u32 lockFlags = 0, locktype = 0;
struct buffer_head *bh = NULL;
ocfs_journal_handle *handle = NULL;
- int flags = 0;
LOG_ENTRY ();
@@ -616,7 +613,7 @@
locktype = OCFS_DLM_EXCLUSIVE_LOCK;
/* now we always take an UPDATE lock */
- lockId = fileEntry->this_sector;
+ lockId = fileEntry->i_blkno << osb->sb->s_blocksize_bits;
lockFlags = FLAG_FILE_UPDATE;
OCFS_BH_PUT_DATA(bh);
@@ -647,16 +644,15 @@
fileEntry = (ocfs_file_entry *)OCFS_BH_GET_DATA_WRITE(bh); /* write */
- fileEntry->modify_time = OCFS_CURRENT_TIME;
+ fileEntry->i_mtime = OCFS_CURRENT_TIME;
DISK_LOCK(fileEntry)->dlock_seq_num = 0;
ocfs_fe_set_attributes(fileEntry, attr);
/* Set the valid bit here */
- SET_VALID_BIT (fileEntry->sync_flags);
- fileEntry->sync_flags &= ~(OCFS_SYNC_FLAG_CHANGE);
+ SET_VALID_BIT(fileEntry->i_flags);
+ fileEntry->i_flags &= ~(OCFS2_CHANGE_FL);
- flags = OCFS_FE_CACHE_FLAGS(osb, fileEntry);
OCFS_BH_PUT_DATA(bh);
status = ocfs_journal_dirty(handle, bh);
@@ -950,7 +946,6 @@
int have_disk_lock = 0;
__u64 new_alloc_size;
struct buffer_head *bh = NULL;
- int flags = 0;
ocfs_journal_handle *handle = NULL;
LOG_ENTRY_ARGS ("(file_off = %llu, file_size = %llu\n",
@@ -982,7 +977,7 @@
goto leave;
}
- lockId = fe->this_sector;
+ lockId = fe->i_blkno << osb->sb->s_blocksize_bits;
lockFlags = FLAG_FILE_TRUNCATE;
if ((DISK_LOCK(fe)->file_lock == OCFS_DLM_ENABLE_CACHE_LOCK)
@@ -1018,9 +1013,9 @@
* waiting on the lock). make sure the size is still a valid
* one. This really ought to check for other things too, like
* a valid bit, etc. */
- if (file_size > fe->file_size) {
+ if (file_size > fe->i_size) {
LOG_TRACE_ARGS("asked to truncate file with size (%llu) "
- "to size (%llu)!\n", fe->file_size,
+ "to size (%llu)!\n", fe->i_size,
file_size);
OCFS_BH_PUT_DATA(bh);
up(&OCFS_I(inode)->priv_sem);
@@ -1029,8 +1024,8 @@
goto leave;
}
- fe->file_size = file_size;
- fe->alloc_size = new_alloc_size;
+ fe->i_size = file_size;
+ fe->i_clusters = new_alloc_size >> osb->s_clustersize_bits;
status = ocfs_free_extents_for_truncate (osb, fe, handle, inode);
if (status < 0) {
@@ -1041,11 +1036,10 @@
}
DISK_LOCK(fe)->dlock_seq_num = 0;
- SET_VALID_BIT (fe->sync_flags);
- fe->sync_flags &= ~(OCFS_SYNC_FLAG_CHANGE);
- fe->modify_time = OCFS_CURRENT_TIME;
+ SET_VALID_BIT(fe->i_flags);
+ fe->i_flags &= ~(OCFS2_CHANGE_FL);
+ fe->i_mtime = OCFS_CURRENT_TIME;
- flags = OCFS_FE_CACHE_FLAGS(osb, fe);
OCFS_BH_PUT_DATA(bh);
status = ocfs_journal_dirty(handle, bh);
@@ -1093,9 +1087,10 @@
{
int status = 0;
int tmpstat;
- ocfs_file_entry *fileEntry = NULL;
+ ocfs_file_entry *fe = NULL;
__u64 tempOffset = 0;
- __u64 allocSize = 0;
+ __u64 current_alloc;
+ __u64 alloc_size = 0;
__u32 size;
__u64 bitmapOffset = 0;
__u64 numClustersAlloc = 0;
@@ -1106,7 +1101,6 @@
__u64 actualDiskOffset = 0;
__u64 actualLength = 0;
struct buffer_head *bh = NULL;
- int flags = 0;
ocfs_journal_handle *handle = NULL;
int credits;
struct inode *ext_alloc_inode = NULL;
@@ -1125,23 +1119,24 @@
goto leave;
}
- fileEntry = (ocfs_file_entry *)OCFS_BH_GET_DATA_READ(bh); /* read */
+ fe = (ocfs_file_entry *)OCFS_BH_GET_DATA_READ(bh); /* read */
- if (!IS_VALID_FILE_ENTRY(fileEntry)) {
- printk("fe->signature=%8s\n", fileEntry->signature);
+ if (!IS_VALID_FILE_ENTRY(fe)) {
+ printk("fe->signature=%8s\n", fe->i_signature);
LOG_ERROR_ARGS ("Invalid fe at offset %llu", file_off);
status = -EFAIL;
OCFS_BH_PUT_DATA(bh);
goto leave;
}
- allocSize = file_size - fileEntry->alloc_size;
+ current_alloc = fe->i_clusters << osb->s_clustersize_bits;
+ alloc_size = file_size - current_alloc;
OCFS_BH_PUT_DATA(bh);
- fileEntry = NULL;
+ fe = NULL;
if (passed_handle == NULL) {
- credits = ocfs_calc_extend_credits(((__u32) allocSize),
+ credits = ocfs_calc_extend_credits(((__u32) alloc_size),
osb->vol_layout.cluster_size);
/* cannot call start_trans with a locked buffer head. */
@@ -1157,10 +1152,10 @@
/* Grab a lock on the entry found if we have more than
* 1 extents and also make this node the master*/
- fileEntry = (ocfs_file_entry *)OCFS_BH_GET_DATA_READ(bh); /* read */
+ fe = (ocfs_file_entry *)OCFS_BH_GET_DATA_READ(bh); /* read */
/* now we always take an EXTEND lock */
- lockId = fileEntry->this_sector;
+ lockId = fe->i_blkno << osb->sb->s_blocksize_bits;
lockFlags = FLAG_FILE_EXTEND;
OCFS_BH_PUT_DATA(bh);
@@ -1184,36 +1179,37 @@
goto leave;
}
- fileEntry = (ocfs_file_entry *)OCFS_BH_GET_DATA_WRITE(bh); /* write */ /* journal access */
+ fe = (ocfs_file_entry *)OCFS_BH_GET_DATA_WRITE(bh); /* write */ /* journal access */
- if (file_size > (__s64) fileEntry->alloc_size) {
- allocSize = file_size - fileEntry->alloc_size;
+ if (file_size > (__s64)current_alloc) {
+ alloc_size = file_size - current_alloc;
/* TODO: We can add something here so that after 2-3 allocations, */
- /* we give a lot more disk space to the file than the allocSize so */
+ /* 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. */
{
int one_percentish_bits = 7;
- __u64 tempSize = fileEntry->alloc_size;
+ __u64 tempSize = current_alloc;
if (tempSize > ONE_MEGA_BYTE)
tempSize = ONE_MEGA_BYTE;
- allocSize += (tempSize * 2);
+ alloc_size += (tempSize * 2);
- if (allocSize < fileEntry->alloc_size >> one_percentish_bits) {
- allocSize = fileEntry->alloc_size >> one_percentish_bits;
- tempSize = allocSize;
+ if (alloc_size <
+ (current_alloc >> one_percentish_bits)) {
+ alloc_size = current_alloc >> one_percentish_bits;
+ tempSize = alloc_size;
// avoid using 64 bit mod
while (tempSize > (10*ONE_MEGA_BYTE))
tempSize -= (10*ONE_MEGA_BYTE);
tempSize = (10*ONE_MEGA_BYTE) - tempSize;
- allocSize += tempSize;
+ alloc_size += tempSize;
}
}
- status = ocfs_find_space(osb, allocSize, &bitmapOffset,
+ status = ocfs_find_space(osb, alloc_size, &bitmapOffset,
&numClustersAlloc, 0, handle);
if (status < 0) {
OCFS_BH_PUT_DATA(bh);
@@ -1223,13 +1219,13 @@
}
actualDiskOffset =
- (bitmapOffset << osb->cluster_size_bits) +
+ (bitmapOffset << osb->s_clustersize_bits) +
osb->vol_layout.data_start_off;
actualLength =
- (__u64) (numClustersAlloc << osb->cluster_size_bits);
+ (__u64) (numClustersAlloc << osb->s_clustersize_bits);
OCFS_BH_PUT_DATA(bh);
- fileEntry = NULL;
+ fe = NULL;
{
struct buffer_head *alloc_bh;
@@ -1254,41 +1250,42 @@
}
ocfs_handle_add_inode(handle, ext_alloc_inode);
- status = ocfs_allocate_extent (osb, bh, handle,
- actualDiskOffset, actualLength, inode);
+ status = ocfs_allocate_extent(osb, bh, handle,
+ actualDiskOffset,
+ actualLength, inode);
if (status < 0) {
LOG_ERROR_STATUS (status);
goto leave;
}
- fileEntry = (ocfs_file_entry *)OCFS_BH_GET_DATA_WRITE(bh); /* write */ /* journal access */
+ fe = (ocfs_file_entry *)OCFS_BH_GET_DATA_WRITE(bh); /* write */ /* journal access */
/* update the total allocation size here */
- fileEntry->alloc_size += actualLength;
+ fe->i_clusters +=
+ (actualLength >> osb->s_clustersize_bits);
down (&(OCFS_I(inode)->priv_sem));
- OCFS_I(inode)->alloc_size = fileEntry->alloc_size;
+ OCFS_I(inode)->alloc_size =
+ fe->i_clusters << osb->s_clustersize_bits;
up (&(OCFS_I(inode)->priv_sem));
/* no need to do OCFS_SECTOR_ALIGN once the allocation size is correct. */
- DISK_LOCK(fileEntry)->dlock_seq_num = 0;
+ DISK_LOCK(fe)->dlock_seq_num = 0;
}
/* Update tha file size and add the new one to old one. */
- fileEntry->file_size = file_size;
- LOG_TRACE_ARGS("fileEntry->alloc_size = %llu\n", fileEntry->alloc_size);
+ fe->i_size = file_size;
+ LOG_TRACE_ARGS("fe->i_clusters = %u\n", fe->i_clusters);
if (attr)
- ocfs_fe_set_attributes(fileEntry, attr);
+ ocfs_fe_set_attributes(fe, attr);
/* Set the Valid bit and reset the change bit here... TODO */
- SET_VALID_BIT (fileEntry->sync_flags);
- fileEntry->sync_flags &= ~(OCFS_SYNC_FLAG_CHANGE);
- fileEntry->modify_time = OCFS_CURRENT_TIME;
+ SET_VALID_BIT(fe->i_flags);
+ fe->i_flags &= ~(OCFS2_CHANGE_FL);
+ fe->i_mtime = OCFS_CURRENT_TIME;
- tempOffset = fileEntry->this_sector;
+ tempOffset = fe->i_blkno << osb->sb->s_blocksize_bits;
size = osb->sect_size;
- flags = OCFS_FE_CACHE_FLAGS(osb, fileEntry);
-
OCFS_BH_PUT_DATA(bh);
status = ocfs_journal_dirty(handle, bh);
Modified: branches/format-changes/src/inc/ocfs.h
===================================================================
--- branches/format-changes/src/inc/ocfs.h 2004-06-03 01:22:33 UTC (rev 994)
+++ branches/format-changes/src/inc/ocfs.h 2004-06-03 19:20:44 UTC (rev 995)
@@ -334,22 +334,17 @@
/*
** File Entry contains this information
*/
-// SYNCFLAG MASK
-#define OCFS_SYNC_FLAG_DELETED (0)
-#define OCFS_SYNC_FLAG_VALID (0x1)
-#define OCFS_SYNC_FLAG_CHANGE (0x2)
-#define OCFS_SYNC_FLAG_MARK_FOR_DELETION (0x4)
-#define OCFS_SYNC_FLAG_NAME_DELETED (0x8)
+/* OCFS2 file flags */
+#define OCFS2_DELETED_FL (0)
+#define OCFS2_VALID_FL (0x1)
+#define OCFS2_CHANGE_FL (0x2)
+#define OCFS2_MARK_FOR_DELETION_FL (0x4)
+#define OCFS2_NAME_DELETED_FL (0x8)
-// ATTRIBS MASK
-#define OCFS_ATTRIB_DIRECTORY (0x1)
-#define OCFS_ATTRIB_CHAR (0x10)
-#define OCFS_ATTRIB_BLOCK (0x20)
-#define OCFS_ATTRIB_REG (0x40)
-#define OCFS_ATTRIB_FIFO (0x80)
-#define OCFS_ATTRIB_SYMLINK (0x100)
-#define OCFS_ATTRIB_SOCKET (0x200)
+#define IS_VALIDBIT_SET(flags) ((flags) & OCFS2_VALID_FL)
+#define SET_VALID_BIT(flags) ((flags) |= OCFS2_VALID_FL)
+
#define INVALID_NODE_POINTER -1
#define OCFS_FILE_ENTRY_SIGNATURE "FIL"
#define OCFS_EXTENT_HEADER_SIGNATURE "EXTHDR2"
@@ -410,25 +405,24 @@
/* sm - ocfs 1.0 fails to set fe->sig for dirs */
#define IS_VALID_FILE_ENTRY(ptr) \
- (((ptr)->attribs & OCFS_ATTRIB_DIRECTORY) || \
- (!strcmp((ptr)->signature, OCFS_FILE_ENTRY_SIGNATURE)))
+ (!strcmp((ptr)->i_signature, OCFS_FILE_ENTRY_SIGNATURE))
#define IS_VALID_EXTENT_HEADER(ptr) \
- (!strcmp((ptr)->signature, OCFS_EXTENT_HEADER_SIGNATURE))
+ (!strcmp((ptr)->signature, OCFS_EXTENT_HEADER_SIGNATURE))
#define IS_VALID_EXTENT_DATA(ptr) \
- (!strcmp((ptr)->signature, OCFS_EXTENT_DATA_SIGNATURE))
+ (!strcmp((ptr)->signature, OCFS_EXTENT_DATA_SIGNATURE))
#define IS_VALID_NODE_NUM(node) \
- (((node) >= 0) && ((node) < OCFS_MAXIMUM_NODES))
+ (((node) >= 0) && ((node) < OCFS_MAXIMUM_NODES))
-#define OCFS_GET_EXTENT(vbo, extent, k) \
- do { \
+#define OCFS_GET_EXTENT(vbo, extent, k) \
+ do { \
for ((k) = 0; (k) < OCFS_MAX_DATA_EXTENTS; (k)++) { \
- if((__s64)((extent)->extents[(k)].file_off + \
- (extent)->extents[(k)].num_bytes) > (vbo)) \
- break; \
- } \
- } while(0)
+ if((__s64)((extent)->extents[(k)].file_off + \
+ (extent)->extents[(k)].num_bytes) > (vbo)) \
+ break; \
+ } \
+ } while(0)
#define OCFS_GET_FILE_ENTRY_EXTENT(vbo, fileentry, k) \
do { \
@@ -487,10 +481,6 @@
#define NODE_NEEDS_RECOVERY(osb,i) (((i)!=OCFS_INVALID_NODE_NUM) && (i)!=(osb)->node_num && \
!IS_NODE_ALIVE((osb)->publ_map,i,OCFS_MAXIMUM_NODES))
-#define IS_VALIDBIT_SET(flags) ((flags) & 0x1)
-
-#define SET_VALID_BIT(flags) ((flags) |= 0x1)
-
/*
** All structures have a type, and a size associated with it.
** The type serves to identify the structure. The size is used for
@@ -736,8 +726,6 @@
/* Offset to Node Config Lock */
__u64 new_cfg_off; // NUMBER RANGE(0,ULONG_LONG_MAX)
__u32 prot_bits; // PERMS
- __u32 uid; // UID
- __u32 gid; // GID
__s32 excl_mount; // NODENUM
}
ocfs_vol_disk_hdr; // END CLASS
@@ -1036,8 +1024,6 @@
__u64 node_cfg_size;
__u64 new_cfg_off;
__u32 prot_bits;
- __u32 uid;
- __u32 gid;
}
ocfs_vol_layout;
@@ -1150,7 +1136,8 @@
__u32 hbt;
__u32 sect_size;
__u32 sect_size_bits;
- __u32 cluster_size_bits;
+ unsigned long s_clustersize;
+ int s_clustersize_bits;
__u32 dir_alloc_bits;
__u32 file_alloc_bits;
__u32 inode_alloc_bits;
@@ -1332,45 +1319,49 @@
}
ocfs_local_alloc;
-typedef struct _ocfs_file_entry // CLASS
+/*
+ * On disk file entry (inode) for OCFS v2
+ */
+typedef struct _ocfs_file_entry
{
- ocfs_disk_lock disk_lock; // DISKLOCK
- __u8 signature[8]; // CHAR[8]
- __u8 next_free_ext; // NUMBER RANGE(0,OCFS_MAX_FILE_ENTRY_EXTENTS)
- __s8 next_del; // DIRNODEINDEX
- __s32 granularity; // NUMBER RANGE(-1,3)
- __u8 reserved0[257]; // CHAR[OCFS_MAX_FILENAME_LENGTH]
- __u64 file_size; // NUMBER RANGE(0,ULONG_LONG_MAX)
- __u64 alloc_size; // NUMBER RANGE(0,ULONG_LONG_MAX)
- __u64 create_time; // DATE
- __u64 modify_time; // DATE
- ocfs_alloc_ext extents[OCFS_MAX_FILE_ENTRY_EXTENTS]; // EXTENT[OCFS_MAX_FILE_ENTRY_EXTENTS]
- __u64 dir_node_ptr; // NUMBER RANGE(0,ULONG_LONG_MAX)
- __u64 this_sector; // NUMBER RANGE(0,ULONG_LONG_MAX)
- __u64 last_ext_ptr; /* NUMBER RANGE(0,ULONG_LONG_MAX)
- Points to the last
- allocated extent */
- __u32 sync_flags; // NUMBER RANGE(0,0)
- __u32 link_cnt; // NUMBER RANGE(0,UINT_MAX)
- __u32 attribs; // ATTRIBS
- __u32 prot_bits; // PERMS
- __u32 uid; // UID
- __u32 gid; // GID
- __u16 dev_major; // NUMBER RANGE(0,65535)
- __u16 dev_minor; // NUMBER RANGE(0,65535)
- __u8 fe_reserved1[4]; // UNUSED
- union {
+/*00*/ __u8 i_signature[8]; /* Signature for validation */
+ __u64 i_reserved1;
+/*10*/ ocfs_disk_lock disk_lock; /* Lock structure */
+/*30*/ __u32 i_uid; /* Owner UID */
+ __u32 i_gid; /* Owning GID */
+ __u64 i_size; /* Size in bytes */
+/*40*/ __u16 i_mode; /* File mode */
+ __u16 i_links_count; /* Links count */
+ __u32 i_flags; /* File flags */
+ __u64 i_atime; /* Access time */
+/*50*/ __u64 i_ctime; /* Creation time */
+ __u64 i_mtime; /* Modification time */
+/*60*/ __u64 i_dtime; /* Deletion time */
+ __u64 i_blkno; /* Offset on disk, in blocks */
+/*70*/ __u32 i_clusters; /* Cluster count */
+ __u32 i_suballoc_node; /* Node suballocater this inode
+ belongs to */
+ __u64 i_suballoc_blkno; /* Node suballocator offset
+ (in blocks) */
+/*80*/ union {
__u64 fe_private;
+ __u64 i_rdev;
struct _bitinfo {
__u32 used_bits;
__u32 total_bits;
} bitinfo;
} u;
- __u64 alloc_file_off; // NUMBER RANGE(0,ULONG_LONG_MAX)
- __u32 alloc_node; // NUMBER RANGE(0,31)
-/* sizeof(fe) = 508 bytes */
-}
-ocfs_file_entry; // END CLASS
+ __u64 i_reserved2;
+/*90*/ __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 */
+ __u32 i_reserved3;
+ __u64 last_ext_ptr; /* Pointer to last extdat */
+/*A0*/ ocfs_alloc_ext extents[OCFS_MAX_FILE_ENTRY_EXTENTS]; // EXTENT[OCFS_MAX_FILE_ENTRY_EXTENTS]
+} ocfs_file_entry;
typedef struct _ocfs_extent_group // CLASS
{
@@ -1710,17 +1701,6 @@
-
-#define OCFS_FE_CACHE_FLAGS(__osb, __fe) \
-({ \
- int __ret = 0; \
- if ((DISK_LOCK(__fe)->file_lock == OCFS_DLM_ENABLE_CACHE_LOCK) && \
- (DISK_LOCK(__fe)->curr_master == osb->node_num) && \
- (__fe->this_sector >= __osb->vol_layout.bitmap_off)) \
- __ret = OCFS_BH_CACHED; \
- __ret; \
-})
-
static inline unsigned long ino_from_fe_off(struct inode *inode)
{
__u64 block_off = GET_INODE_FEOFF(inode) >> inode->i_sb->s_blocksize_bits;
@@ -1775,10 +1755,10 @@
static inline unsigned int ocfs_clusters_for_bytes(struct super_block *sb,
__u64 bytes)
{
- int cl_bits = OCFS_SB(sb)->cluster_size_bits;
+ int cl_bits = OCFS_SB(sb)->s_clustersize_bits;
unsigned int clusters;
- bytes += OCFS_SB(sb)->vol_layout.cluster_size - 1;
+ bytes += OCFS_SB(sb)->s_clustersize - 1;
/* OCFS2 just cannot have enough clusters to overflow this */
clusters = (unsigned int)(bytes >> cl_bits);
@@ -1788,7 +1768,7 @@
static inline __u64 ocfs_align_bytes_to_clusters(struct super_block *sb,
__u64 bytes)
{
- int cl_bits = OCFS_SB(sb)->cluster_size_bits;
+ int cl_bits = OCFS_SB(sb)->s_clustersize_bits;
unsigned int clusters;
clusters = ocfs_clusters_for_bytes(sb, bytes);
Modified: branches/format-changes/src/inc/ocfs_compat.h
===================================================================
--- branches/format-changes/src/inc/ocfs_compat.h 2004-06-03 01:22:33 UTC (rev 994)
+++ branches/format-changes/src/inc/ocfs_compat.h 2004-06-03 19:20:44 UTC (rev 995)
@@ -28,6 +28,8 @@
#define OCFS_COMPAT_H
#include <linux/version.h>
+#include <linux/types.h>
+#include <linux/kdev_t.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
@@ -52,12 +54,33 @@
#define unlock_page(p) UnlockPage(p)
#define Page_Uptodate(p) PageUptodate(p)
+static inline dev_t ocfs_decode_dev(u64 val)
+{
+ u16 val16 = (u16)(val & 0xFFFFULL);
+ return MKDEV((val16 >> 8) & 0xFF, val16 & 0xFF);
+}
+
+static inline u64 ocfs_encode_dev(dev_t dev)
+{
+ return (u64)((MAJOR(dev) << 8) | MINOR(dev));
+}
+
#else /* LINUX_VERSION_CODE < 2.6 */
#define OCFS_GENERIC_SB_MEMBER(sb) ((sb)->s_fs_info)
#define ocfs_get_seconds(t) ((t).tv_sec)
+static inline dev_t ocfs_decode_dev(u64 val)
+{
+ return huge_decode_dev(val);
+}
+
+static inline u64 ocfs_encode_dev(dev_t dev)
+{
+ return huge_encode_dev(dev);
+}
+
#endif /* LINUX_VERSION_CODE < 2.6 */
#endif /* OCFS_COMPAT_H */
Modified: branches/format-changes/src/inode.c
===================================================================
--- branches/format-changes/src/inode.c 2004-06-03 01:22:33 UTC (rev 994)
+++ branches/format-changes/src/inode.c 2004-06-03 19:20:44 UTC (rev 995)
@@ -32,6 +32,8 @@
#include <linux/highmem.h>
#include <linux/pagemap.h>
+#include <asm/byteorder.h>
+
#include "inc/ocfs_log.h"
#include "inc/ocfs.h"
#include "inc/ocfs_journal.h"
@@ -221,7 +223,7 @@
LOG_ERROR_STATUS(-EINVAL);
goto bail;
}
- feoff = fe->this_sector;
+ feoff = fe->i_blkno << osb->sb->s_blocksize_bits;
OCFS_BH_PUT_DATA(fe_bh);
}
@@ -372,11 +374,11 @@
ocfs_super *osb;
__u64 offset;
- LOG_ENTRY_ARGS ("(0x%p, %u, size:%llu)\n", inode, mode, fe->file_size);
+ LOG_ENTRY_ARGS ("(0x%p, %u, size:%llu)\n", inode, mode, fe->i_size);
sb = inode->i_sb;
osb = OCFS_SB(sb);
- offset = fe->this_sector;
+ offset = fe->i_blkno << osb->sb->s_blocksize_bits;
if (!IS_VALID_FILE_ENTRY(fe)) {
printk("ocfs2: invalid file entry!\n");
@@ -394,29 +396,30 @@
inode->i_version = 1;
#endif
- inode->i_rdev = MKDEV (fe->dev_major, fe->dev_minor);
+ inode->i_rdev = ocfs_decode_dev(le64_to_cpu(fe->u.i_rdev));
inode->i_mode = mode;
- inode->i_uid = fe->uid;
- inode->i_gid = fe->gid;
- inode->i_blksize = (__u32) osb->vol_layout.cluster_size; // sb->s_blocksize;
- inode->i_blocks = (fe->file_size + sb->s_blocksize) >> sb->s_blocksize_bits;
+ inode->i_uid = fe->i_uid;
+ inode->i_gid = fe->i_gid;
+ inode->i_blksize = (u32)osb->vol_layout.cluster_size; // sb->s_blocksize;
+ inode->i_blocks = (fe->i_size + sb->s_blocksize) >> sb->s_blocksize_bits;
inode->i_mapping->a_ops = &ocfs_aops;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
inode->i_attr_flags |= ATTR_FLAG_NOATIME;
#endif
inode->i_flags |= S_NOATIME;
- OCFS_SET_INODE_TIME(inode, i_atime, fe->modify_time);
- OCFS_SET_INODE_TIME(inode, i_mtime, fe->modify_time);
- OCFS_SET_INODE_TIME(inode, i_ctime, fe->create_time);
+ OCFS_SET_INODE_TIME(inode, i_atime, fe->i_atime);
+ 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);
- OCFS_I(inode)->alloc_size = fe->alloc_size;
+ OCFS_I(inode)->alloc_size =
+ (fe->i_clusters << osb->s_clustersize_bits);
OCFS_I(inode)->inode = inode;
OCFS_I(inode)->chng_seq_num = DISK_LOCK(fe)->dlock_seq_num;
OCFS_I(inode)->u.fe_private = fe->u.fe_private;
- if (fe->attribs & OCFS_ATTRIB_DIRECTORY)
+ if (S_ISDIR(fe->i_mode))
OCFS_I(inode)->oin_flags |= OCFS_OIN_DIRECTORY;
if (create_ino)
@@ -426,13 +429,13 @@
offset, inode->i_ino,
create_ino ? "true" : "false");
- inode->i_nlink = fe->link_cnt;
+ inode->i_nlink = fe->i_links_count;
switch (inode->i_mode & S_IFMT) {
case S_IFREG:
atomic_set(GET_INODE_CLEAN_SEQ(inode), atomic_read(&osb->clean_buffer_seq));
inode->i_fop = &ocfs_fops;
inode->i_op = &ocfs_file_iops;
- inode->i_size = fe->file_size;
+ inode->i_size = fe->i_size;
break;
case S_IFDIR:
if (inode->i_nlink < 2) {
@@ -443,13 +446,13 @@
atomic_set(GET_INODE_CLEAN_SEQ(inode), atomic_read(&osb->clean_buffer_seq));
inode->i_op = &ocfs_dir_iops;
inode->i_fop = &ocfs_dops;
- inode->i_size = fe->file_size;
+ inode->i_size = fe->i_size;
break;
case S_IFLNK:
atomic_set(GET_INODE_CLEAN_SEQ(inode), atomic_read(&osb->clean_buffer_seq));
inode->i_op = &ocfs_symlink_inode_operations;
//inode->i_fop = &ocfs_fops;
- inode->i_size = fe->file_size;
+ inode->i_size = fe->i_size;
break;
default:
init_special_inode (inode, mode, inode->i_rdev);
@@ -502,7 +505,6 @@
{
struct super_block *sb;
ocfs_super *osb;
- umode_t mode;
__u64 feoff = 0ULL;
ocfs_file_entry *fe = NULL;
struct buffer_head *bh = NULL;
@@ -543,38 +545,13 @@
fe = (ocfs_file_entry *) OCFS_BH_GET_DATA_READ(bh); /* read */
- mode = fe->prot_bits;
+ if (S_ISCHR(fe->i_mode) || S_ISBLK(fe->i_mode))
+ inode->i_rdev = ocfs_decode_dev(le64_to_cpu(fe->u.i_rdev));
- switch (fe->attribs) {
- case OCFS_ATTRIB_DIRECTORY:
- mode |= S_IFDIR;
- break;
- case OCFS_ATTRIB_CHAR:
- inode->i_rdev = MKDEV (fe->dev_major, fe->dev_minor);
- mode |= S_IFCHR;
- break;
- case OCFS_ATTRIB_BLOCK:
- inode->i_rdev = MKDEV (fe->dev_major, fe->dev_minor);
- mode |= S_IFBLK;
- break;
- case OCFS_ATTRIB_FIFO:
- mode |= S_IFIFO;
- break;
- case OCFS_ATTRIB_SYMLINK:
- mode |= S_IFLNK;
- break;
- case OCFS_ATTRIB_SOCKET:
- mode |= S_IFSOCK;
- break;
- case OCFS_ATTRIB_REG:
- default:
- mode |= S_IFREG;
- break;
- }
- ocfs_populate_inode (inode, fe, mode, 0);
+ ocfs_populate_inode (inode, fe, fe->i_mode, 0);
/* eventually this case has to GO! */
- if (feoff != fe->this_sector)
+ if (feoff != (fe->i_blkno << osb->sb->s_blocksize_bits))
BUG();
if (sysfile)
@@ -861,7 +838,8 @@
goto bail;
}
- if ((iblock << 9) >= (__s64)fe->alloc_size) {
+ if ((iblock << 9) >=
+ (__s64)(fe->i_clusters << osb->s_clustersize_bits)) {
OCFS_BH_PUT_DATA(bh);
LOG_ERROR_ARGS ("file offset is outside the allocated size: %lu",
iblock << 9);
@@ -919,7 +897,7 @@
*err = -ENOSPC;
return NULL;
}
- // fe->file_size will be vbo+512 here, and alloc_size will be whatever
+ // fe->i_size will be vbo+512 here, and alloc_size will be whatever
// i_size will be changed by caller (ocfs_add_entry) if we return !NULL
}
@@ -1822,9 +1800,9 @@
goto leave;
/* Add checks as needed */
- if ((fe->sync_flags & OCFS_SYNC_FLAG_MARK_FOR_DELETION) ||
- (!(fe->sync_flags & OCFS_SYNC_FLAG_VALID))) {
- if (fe->sync_flags & OCFS_SYNC_FLAG_MARK_FOR_DELETION) {
+ if ((fe->i_flags & OCFS2_MARK_FOR_DELETION_FL) ||
+ (!(fe->i_flags & OCFS2_VALID_FL))) {
+ if (fe->i_flags & OCFS2_MARK_FOR_DELETION_FL) {
LOG_TRACE_STR
("File Entry is marked for deletion");
} else {
@@ -1834,98 +1812,61 @@
goto leave;
}
- if ((OCFS_I(inode)->alloc_size != (__s64) fe->alloc_size) ||
- (inode->i_size != (__s64) fe->file_size) ||
+ if ((OCFS_I(inode)->alloc_size !=
+ (__s64)(fe->i_clusters << osb->s_clustersize_bits)) ||
+ (inode->i_size != (__s64) fe->i_size) ||
(OCFS_I(inode)->chng_seq_num != DISK_LOCK(fe)->dlock_seq_num) ||
- inode->i_uid != fe->uid ||
- inode->i_gid != fe->gid ||
- inode->i_mode != fe->prot_bits ||
- inode->i_nlink != fe->link_cnt){
+ inode->i_uid != fe->i_uid ||
+ inode->i_gid != fe->i_gid ||
+ inode->i_mode != fe->i_mode ||
+ inode->i_nlink != fe->i_links_count){
- if (OCFS_I(inode)->alloc_size > (__s64)fe->alloc_size){
+ if (OCFS_I(inode)->alloc_size >
+ (__s64)(fe->i_clusters << osb->s_clustersize_bits)) {
ocfs_extent_map_destroy (&OCFS_I(inode)->map);
ocfs_extent_map_init (&OCFS_I(inode)->map);
}
LOG_TRACE_STR("Allocsize, filesize or seq no did not match");
- OCFS_I(inode)->alloc_size = fe->alloc_size;
- inode->i_size = fe->file_size;
-printk("verifyupdate: setting nlink from %d to %d for %llu\n", inode->i_nlink, fe->link_cnt, GET_INODE_FEOFF(inode));
- inode->i_nlink = fe->link_cnt;
+ OCFS_I(inode)->alloc_size =
+ (fe->i_clusters << osb->s_clustersize_bits);
+ inode->i_size = fe->i_size;
+printk("verifyupdate: setting nlink from %d to %d for %llu\n", inode->i_nlink, fe->i_links_count, GET_INODE_FEOFF(inode));
+ inode->i_nlink = fe->i_links_count;
OCFS_I(inode)->chng_seq_num = DISK_LOCK(fe)->dlock_seq_num;
inode->i_blocks = (inode->i_size + osb->sect_size) >> osb->sect_size_bits;
- inode->i_uid = fe->uid;
- inode->i_gid = fe->gid;
- inode->i_mode = fe->prot_bits;
+ inode->i_uid = fe->i_uid;
+ inode->i_gid = fe->i_gid;
+ inode->i_mode = fe->i_mode;
inode->i_blksize = (__u32) osb->vol_layout.cluster_size;
- OCFS_SET_INODE_TIME(inode, i_ctime, fe->create_time);
- OCFS_SET_INODE_TIME(inode, i_atime, fe->modify_time);
- OCFS_SET_INODE_TIME(inode, i_mtime, fe->modify_time);
+ OCFS_SET_INODE_TIME(inode, i_ctime, fe->i_ctime);
+ OCFS_SET_INODE_TIME(inode, i_atime, fe->i_atime);
+ OCFS_SET_INODE_TIME(inode, i_mtime, fe->i_mtime);
if (!S_ISDIR (inode->i_mode) &&
- (OCFS_I(inode)->alloc_size != (__s64) fe->alloc_size ||
- inode->i_size != (__s64) fe->file_size ||
+ (OCFS_I(inode)->alloc_size !=
+ (__s64)(fe->i_clusters << osb->s_clustersize_bits) ||
+ inode->i_size != (__s64) fe->i_size ||
OCFS_I(inode)->chng_seq_num != DISK_LOCK(fe)->dlock_seq_num)) {
*needs_trunc = 1;
}
- switch (fe->attribs) {
- case OCFS_ATTRIB_DIRECTORY:
- inode->i_mode |= S_IFDIR;
- break;
- case OCFS_ATTRIB_SYMLINK:
- inode->i_mode |= S_IFLNK;
- break;
- case OCFS_ATTRIB_REG:
- inode->i_mode |= S_IFREG;
- break;
- case OCFS_ATTRIB_CHAR:
- case OCFS_ATTRIB_BLOCK:
- case OCFS_ATTRIB_FIFO:
- case OCFS_ATTRIB_SOCKET:
- {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
- dev_t dev;
-#else
- kdev_t kdev;
-#endif
- if (fe->attribs == OCFS_ATTRIB_CHAR)
- inode->i_mode |= S_IFCHR;
- else if (fe->attribs == OCFS_ATTRIB_BLOCK)
- inode->i_mode |= S_IFBLK;
- else if (fe->attribs == OCFS_ATTRIB_FIFO)
- inode->i_mode |= S_IFIFO;
- else if (fe->attribs == OCFS_ATTRIB_SOCKET)
- inode->i_mode |= S_IFSOCK;
-
+ if (S_ISCHR(fe->i_mode) ||
+ S_ISBLK(fe->i_mode) ||
+ S_ISFIFO(fe->i_mode) ||
+ S_ISSOCK(fe->i_mode)) {
inode->i_rdev = OCFS_NODEV;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
- dev = MKDEV (fe->dev_major, fe->dev_minor);
-#else
- kdev = MKDEV (fe->dev_major, fe->dev_minor);
-#endif
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
- init_special_inode (inode, inode->i_mode, dev);
-#else
- init_special_inode (inode, inode->i_mode,
- kdev_t_to_nr(kdev));
-#endif
- break;
+ init_special_inode(inode, inode->i_mode,
+ ocfs_decode_dev(le64_to_cpu(fe->u.i_rdev)));
}
- default:
- LOG_ERROR_ARGS ("attribs=%d", fe->attribs);
- inode->i_mode |= S_IFREG;
- break;
- }
- if (fe->granularity < 0) {
+ if (fe->i_tree_depth < 0) {
__s64 tempVbo;
__s64 tempLbo;
__u64 tempSize;
__u32 j;
/* Add the Extents to extent map */
- for (j = 0; j < fe->next_free_ext; j++) {
+ for (j = 0; j < fe->i_next_free_ext; j++) {
tempVbo = fe->extents[j].file_off;
tempLbo = fe->extents[j].disk_off;
tempSize = fe->extents[j].num_bytes;
Modified: branches/format-changes/src/journal.c
===================================================================
--- branches/format-changes/src/journal.c 2004-06-03 01:22:33 UTC (rev 994)
+++ branches/format-changes/src/journal.c 2004-06-03 19:20:44 UTC (rev 995)
@@ -951,10 +951,10 @@
fe = (ocfs_file_entry *) OCFS_BH_GET_DATA_READ(bh); /* read */
/* should be exactly eight megs. need to run tuneocfs otherwise. */
- if (fe->file_size != OCFS_JOURNAL_DEFAULT_SIZE) {
+ if (fe->i_size != OCFS_JOURNAL_DEFAULT_SIZE) {
LOG_ERROR_ARGS("Journal file size (%llu) is not the default (%u). "
"You must run tuneocfs to add a journal for this node.\n",
- fe->file_size, OCFS_JOURNAL_DEFAULT_SIZE);
+ fe->i_size, OCFS_JOURNAL_DEFAULT_SIZE);
status = -EINVAL;
}
@@ -964,13 +964,13 @@
goto done;
}
- LOG_TRACE_ARGS("fe->file_size = %llu\n", fe->file_size);
- LOG_TRACE_ARGS("fe->alloc_size = %llu\n", fe->alloc_size);
+ LOG_TRACE_ARGS("fe->i_size = %llu\n", fe->i_size);
+ LOG_TRACE_ARGS("fe->i_clusters = %u\n", fe->i_clusters);
/* gonna need this later */
- alloc_size = fe->alloc_size;
- LOG_TRACE_ARGS("fe->this_sector = %llu\n", fe->this_sector);
- inode->i_size = fe->file_size;
+ alloc_size = fe->i_clusters << osb->s_clustersize_bits;
+ LOG_TRACE_ARGS("fe->i_blkno = %llu\n", fe->i_blkno);
+ inode->i_size = fe->i_size;
OCFS_BH_PUT_DATA(bh);
fe = NULL;
@@ -1408,7 +1408,7 @@
fe = (ocfs_file_entry *)OCFS_BH_GET_DATA_READ(bh); /* read */
/* gonna need this later */
- alloc_size = fe->alloc_size;
+ alloc_size = fe->i_clusters << osb->s_clustersize_bits;
OCFS_BH_PUT_DATA(bh);
fe = NULL;
Modified: branches/format-changes/src/namei.c
===================================================================
--- branches/format-changes/src/namei.c 2004-06-03 01:22:33 UTC (rev 994)
+++ branches/format-changes/src/namei.c 2004-06-03 19:20:44 UTC (rev 995)
@@ -208,8 +208,9 @@
ocfs_populate_inode (inode, fe, mode, 1);
insert_inode_hash (inode);
- file_off = fe->this_sector;
- handle->new_file_lockid = fe->this_sector;
+ file_off = fe->i_blkno << osb->sb->s_blocksize_bits;
+ handle->new_file_lockid =
+ fe->i_blkno << osb->sb->s_blocksize_bits;
OCFS_BH_PUT_DATA(new_fe_bh);
fe = NULL;
@@ -262,7 +263,7 @@
goto leave;
}
fe = (ocfs_file_entry *) OCFS_BH_GET_DATA_WRITE(parent_fe_bh); /* write */
- fe->link_cnt++;
+ fe->i_links_count++;
OCFS_BH_PUT_DATA(parent_fe_bh);
fe = NULL;
status = ocfs_journal_dirty(handle, parent_fe_bh);
@@ -320,7 +321,7 @@
{
int status = 0;
ocfs_file_entry *fe = NULL;
- __u64 bitmapOffset = 0;
+ __u64 disk_off = 0;
__u64 fileOffset = 0;
struct inode *inode_alloc_inode = NULL;
@@ -338,17 +339,17 @@
}
ocfs_handle_add_inode(handle, inode_alloc_inode);
- status = ocfs_alloc_node_block (osb, osb->inode_size,
- &bitmapOffset, &fileOffset,
- osb->node_num, DISK_ALLOC_INODE,
- handle);
+ status = ocfs_alloc_node_block(osb, osb->inode_size,
+ &disk_off, &fileOffset,
+ osb->node_num, DISK_ALLOC_INODE,
+ handle);
if (status < 0) {
LOG_ERROR_STATUS (status);
goto leave;
}
- status = ocfs_read_bh(osb, bitmapOffset, new_fe_bh,
- OCFS_BH_CACHED, inode);
+ status = ocfs_read_bh(osb, disk_off, new_fe_bh,
+ OCFS_BH_CACHED, inode);
status = ocfs_journal_access(handle, *new_fe_bh, OCFS_JOURNAL_ACCESS_CREATE);
if (status < 0) {
@@ -358,56 +359,36 @@
fe = (ocfs_file_entry *) OCFS_BH_GET_DATA_WRITE(*new_fe_bh); /* write */
memset (fe, 0, osb->sect_size);
- inode->i_ino = ino_from_off(osb->sb, bitmapOffset);
- fe->this_sector = bitmapOffset;
- fe->alloc_file_off = fileOffset;
- fe->alloc_node = osb->node_num;
- fe->uid = current->fsuid;
- fe->gid = current->fsgid;
- fe->prot_bits = mode & 0007777;
- if (S_ISCHR (mode) || S_ISBLK (mode)) {
- fe->dev_major = MAJOR (dev);
- fe->dev_minor = MINOR (dev);
- } else {
- fe->dev_major = MAJOR (dir->i_sb->s_dev);
- fe->dev_minor = MINOR (dir->i_sb->s_dev);
- }
+ inode->i_ino = ino_from_off(osb->sb, disk_off);
+ fe->i_blkno = disk_off >> osb->sb->s_blocksize_bits;
+ fe->i_suballoc_blkno = fileOffset >> osb->sb->s_blocksize_bits;
+ fe->i_suballoc_node = osb->node_num;
+ fe->i_uid = current->fsuid;
+ fe->i_gid = current->fsgid;
+ fe->i_mode = mode;
+ if (S_ISCHR (mode) || S_ISBLK (mode))
+ fe->u.i_rdev = ocfs_encode_dev(dev);
if (S_ISLNK (mode) || S_ISDIR (mode) || S_ISREG (mode))
atomic_set(GET_INODE_CLEAN_SEQ(inode), atomic_read(&osb->clean_buffer_seq));
- if (S_ISLNK (mode))
- fe->attribs |= OCFS_ATTRIB_SYMLINK;
- else if (S_ISCHR (mode))
- fe->attribs |= OCFS_ATTRIB_CHAR;
- else if (S_ISBLK (mode))
- fe->attribs |= OCFS_ATTRIB_BLOCK;
- else if (S_ISFIFO (mode))
- fe->attribs |= OCFS_ATTRIB_FIFO;
- else if (S_ISSOCK (mode))
- fe->attribs |= OCFS_ATTRIB_SOCKET;
- else if (S_ISDIR (mode))
- fe->attribs |= OCFS_ATTRIB_DIRECTORY;
- else
- fe->attribs |= OCFS_ATTRIB_REG;
-
if (S_ISDIR (mode))
- fe->link_cnt = 2;
+ fe->i_links_count = 2;
else
- fe->link_cnt = 1;
+ fe->i_links_count = 1;
- fe->granularity = -1;
- fe->next_free_ext = 0;
+ fe->i_tree_depth = -1;
+ fe->i_next_free_ext = 0;
fe->last_ext_ptr = 0;
- strcpy (fe->signature, OCFS_FILE_ENTRY_SIGNATURE);
- SET_VALID_BIT (fe->sync_flags);
- fe->sync_flags &= ~(OCFS_SYNC_FLAG_CHANGE);
+ strcpy (fe->i_signature, OCFS_FILE_ENTRY_SIGNATURE);
+ SET_VALID_BIT(fe->i_flags);
+ fe->i_flags &= ~(OCFS2_CHANGE_FL);
DISK_LOCK(fe)->dlock_seq_num = 0;
DISK_LOCK(fe)->curr_master = osb->node_num;
DISK_LOCK(fe)->file_lock = OCFS_DLM_ENABLE_CACHE_LOCK;
DISK_LOCK(fe)->oin_node_map = (1 << osb->node_num);
- fe->create_time = fe->modify_time = OCFS_CURRENT_TIME;
- fe->dir_node_ptr = GET_INODE_FEOFF(dir);
+ fe->i_atime = fe->i_ctime = fe->i_mtime = OCFS_CURRENT_TIME;
+ fe->i_dtime = 0;
OCFS_BH_PUT_DATA(*new_fe_bh);
fe = NULL;
@@ -421,7 +402,8 @@
* for add_entry. */
inode->i_mode = mode;
- status = ocfs_add_entry (handle, dentry, inode, bitmapOffset, parent_fe_bh);
+ status = ocfs_add_entry(handle, dentry, inode, disk_off,
+ parent_fe_bh);
if (status < 0) {
LOG_ERROR_STATUS (status);
goto leave;
@@ -622,13 +604,13 @@
* after the abort_trans. */
fe = (ocfs_file_entry *) OCFS_BH_GET_DATA_WRITE(fe_bh); /* write */
if (S_ISDIR (inode->i_mode))
- fe->link_cnt = 0;
+ fe->i_links_count = 0;
else
- fe->link_cnt--;
- if (!fe->link_cnt) {
+ fe->i_links_count--;
+ if (!fe->i_links_count) {
drop_inode = 1;
- OCFS_SET_FLAG (fe->sync_flags, OCFS_SYNC_FLAG_MARK_FOR_DELETION);
- fe->sync_flags &= (~OCFS_SYNC_FLAG_VALID);
+ OCFS_SET_FLAG(fe->i_flags, OCFS2_MARK_FOR_DELETION_FL);
+ fe->i_flags &= (~OCFS2_VALID_FL);
}
OCFS_BH_PUT_DATA(fe_bh);
@@ -666,7 +648,7 @@
goto leave;
}
dirfe = (ocfs_file_entry *) OCFS_BH_GET_DATA_WRITE(parent_node_bh);
- dirfe->link_cnt--;
+ dirfe->i_links_count--;
OCFS_BH_PUT_DATA(parent_node_bh);
status = ocfs_journal_dirty(handle, fe_bh);
if (status < 0) {
@@ -1041,10 +1023,11 @@
if (new_de) {
/* TODO: change this block to the ext3-style orphan model */
newfe = (ocfs_file_entry *) OCFS_BH_GET_DATA_READ(newfe_bh); /* read */
- if (newfe->attribs & OCFS_ATTRIB_DIRECTORY)
+ if (S_ISDIR(newfe->i_mode))
newfe_flags = FLAG_DIR;
newfe_flags |= FLAG_FILE_DELETE;
- newfe_lockid = newfe->this_sector;
+ newfe_lockid =
+ newfe->i_blkno << osb->sb->s_blocksize_bits;
OCFS_BH_PUT_DATA(newfe_bh);
newfe = NULL;
@@ -1088,12 +1071,13 @@
}
if (S_ISDIR (new_inode->i_mode))
- newfe->link_cnt = 0;
+ newfe->i_links_count = 0;
else
- newfe->link_cnt--;
- if (!newfe->link_cnt) {
- OCFS_SET_FLAG (newfe->sync_flags, OCFS_SYNC_FLAG_MARK_FOR_DELETION);
- newfe->sync_flags &= (~OCFS_SYNC_FLAG_VALID);
+ newfe->i_links_count--;
+ if (!newfe->i_links_count) {
+ OCFS_SET_FLAG(newfe->i_flags,
+ OCFS2_MARK_FOR_DELETION_FL);
+ newfe->i_flags &= (~OCFS2_VALID_FL);
drop_inode = 1;
}
OCFS_BH_PUT_DATA(newfe_bh);
@@ -1341,7 +1325,7 @@
}
fe = (ocfs_file_entry *) OCFS_BH_GET_DATA_READ(new_fe_bh); /* read */
- file_off = fe->this_sector;
+ file_off = fe->i_blkno << osb->sb->s_blocksize_bits;
OCFS_BH_PUT_DATA(new_fe_bh);
fe = NULL;
@@ -1505,7 +1489,7 @@
status = ocfs_journal_access(handle, parent_fe_bh, OCFS_JOURNAL_ACCESS_WRITE);
buf = OCFS_BH_GET_DATA_WRITE(parent_fe_bh); /* write */
fe = (ocfs_file_entry *)buf;
- fe->file_size = dir->i_size;
+ fe->i_size = dir->i_size;
OCFS_BH_PUT_DATA(parent_fe_bh);
buf = NULL;
status = ocfs_journal_dirty(handle, parent_fe_bh);
@@ -1844,8 +1828,8 @@
goto bail;
fe = (ocfs_file_entry *) OCFS_BH_GET_DATA_WRITE(bh);
- fe->link_cnt++;
- inode->i_nlink = fe->link_cnt;
+ fe->i_links_count++;
+ inode->i_nlink = fe->i_links_count;
inode->i_ctime = CURRENT_TIME;
atomic_inc(&inode->i_count);
OCFS_BH_PUT_DATA(bh);
Modified: branches/format-changes/src/nm.c
===================================================================
--- branches/format-changes/src/nm.c 2004-06-03 01:22:33 UTC (rev 994)
+++ branches/format-changes/src/nm.c 2004-06-03 19:20:44 UTC (rev 995)
@@ -994,7 +994,7 @@
}
fe = (ocfs_file_entry *) OCFS_BH_GET_DATA_READ(fe_bh); /* read */
- is_dir = fe->attribs & OCFS_ATTRIB_DIRECTORY;
+ is_dir = S_ISDIR(fe->i_mode);
is_locked = DISK_LOCK(fe)->file_lock > OCFS_DLM_NO_LOCK;
if (vote_type == CHANGE_MASTER) {
OCFS_BH_PUT_DATA(fe_bh);
@@ -1046,8 +1046,8 @@
}
fe = (ocfs_file_entry *)OCFS_BH_GET_DATA_READ(fe_bh); /* read */
- if ((fe->sync_flags & OCFS_SYNC_FLAG_NAME_DELETED) ||
- (!(fe->sync_flags & OCFS_SYNC_FLAG_VALID))) {
+ if ((fe->i_flags & OCFS2_NAME_DELETED_FL) ||
+ (!(fe->i_flags & OCFS2_VALID_FL))) {
vote_response = FLAG_VOTE_FILE_DEL;
OCFS_BH_PUT_DATA(fe_bh);
} else {
Modified: branches/format-changes/src/super.c
===================================================================
--- branches/format-changes/src/super.c 2004-06-03 01:22:33 UTC (rev 994)
+++ branches/format-changes/src/super.c 2004-06-03 19:20:44 UTC (rev 995)
@@ -1412,11 +1412,7 @@
vol_layout->node_cfg_size = vdh->node_cfg_size;
vol_layout->new_cfg_off = vdh->new_cfg_off;
vol_layout->prot_bits = vdh->prot_bits;
- vol_layout->uid = vdh->uid;
- vol_layout->gid = vdh->gid;
-
-
memcpy (vol_layout->vol_id, vol_label->vol_id, MAX_VOL_ID_LENGTH);
if (vol_layout->dir_node_size == 0)
@@ -1429,16 +1425,17 @@
/* get some pseudo constants for >> bits */
osb->sect_size_bits = ocfs_get_right_shift_bits(sect_size);
- osb->cluster_size_bits = ocfs_get_right_shift_bits(vol_layout->cluster_size);
+ osb->s_clustersize = vol_layout->cluster_size;
+ osb->s_clustersize_bits = ocfs_get_right_shift_bits(vol_layout->cluster_size);
osb->dir_alloc_bits = ocfs_get_right_shift_bits(vol_layout->dir_node_size);
osb->file_alloc_bits = ocfs_get_right_shift_bits(vol_layout->file_node_size);
osb->inode_alloc_bits = ocfs_get_right_shift_bits(osb->inode_size);
printk("sectbits=%d, clusterbits=%d, dirbits=%d, filebits=%d, inodebits=%d\n",
- osb->sect_size_bits, osb->cluster_size_bits,
+ osb->sect_size_bits, osb->s_clustersize_bits,
osb->dir_alloc_bits, osb->file_alloc_bits, osb->inode_alloc_bits);
OCFS_ASSERT(osb->sect_size_bits);
- OCFS_ASSERT(osb->cluster_size_bits);
+ OCFS_ASSERT(osb->s_clustersize_bits);
OCFS_ASSERT(osb->dir_alloc_bits);
OCFS_ASSERT(osb->file_alloc_bits);
OCFS_ASSERT(osb->inode_alloc_bits);
Modified: branches/format-changes/src/sysfile.c
===================================================================
--- branches/format-changes/src/sysfile.c 2004-06-03 01:22:33 UTC (rev 994)
+++ branches/format-changes/src/sysfile.c 2004-06-03 19:20:44 UTC (rev 995)
@@ -219,8 +219,8 @@
goto leave;
}
- *Length = (__u64) (fe->file_size);
- *AllocSize = (__u64) (fe->alloc_size);
+ *Length = (__u64)fe->i_size;
+ *AllocSize = (__u64)(fe->i_clusters << osb->s_clustersize_bits);
leave:
if (fe) {
@@ -272,7 +272,7 @@
LOG_ERROR_STATUS (status = -EINVAL);
goto leave;
}
- alloc_size = fe->alloc_size;
+ alloc_size = fe->i_clusters << osb->s_clustersize_bits;
OCFS_BH_PUT_DATA(fe_bh);
fe = NULL;
@@ -352,8 +352,8 @@
actualLength = 0;
fe = (ocfs_file_entry *) OCFS_BH_GET_DATA_WRITE(fe_bh); /* write */
- fe->alloc_size += actualLength;
- fe->file_size = FileSize;
+ fe->i_clusters += (actualLength >> osb->s_clustersize_bits);
+ fe->i_size = FileSize;
DISK_LOCK(fe)->curr_master = osb->node_num;
DISK_LOCK(fe)->file_lock = OCFS_DLM_ENABLE_CACHE_LOCK;
@@ -403,21 +403,21 @@
goto leave;
}
- if (fe->granularity < 0)
+ if (fe->i_tree_depth < 0)
{
size = OCFS_MAX_FILE_ENTRY_EXTENTS * sizeof (ocfs_io_runs);
}
else
{
- int pow = fe->granularity + 1;
+ int pow = fe->i_tree_depth + 1;
/* extent tree looks like
* fe[0] fe[1] fe[2]
* hdr[0]...hdr[17] .....
* dat[0]..dat[17]
*
- * granularity of fe is tree height
+ * tree_depth of fe is tree height
* so max runs (total of all leaves) is
- * 3 x 18 ^ (granularity+1)
+ * 3 x 18 ^ (tree_depth+1)
* (OCFS_MAX_DATA_EXTENTS = 18)
*
* g=0: 1296 bytes
@@ -447,7 +447,7 @@
Runoffset = 0;
newOffset = file_off;
- if (fe->granularity < 0) {
+ if (fe->i_tree_depth < 0) {
for (j = 0; j < OCFS_MAX_FILE_ENTRY_EXTENTS; j++) {
if ((fe->extents[j].file_off +
fe->extents[j].num_bytes) > newOffset) {
More information about the Ocfs2-commits
mailing list