[Ocfs2-commits] jlbec commits r1047 - branches/format-changes/src
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Thu Jun 10 18:41:39 CDT 2004
Author: jlbec
Date: 2004-06-10 17:41:37 -0500 (Thu, 10 Jun 2004)
New Revision: 1047
Modified:
branches/format-changes/src/alloc.c
branches/format-changes/src/extmap.c
branches/format-changes/src/namei.c
branches/format-changes/src/ocfs.h
branches/format-changes/src/ocfs_journal.h
branches/format-changes/src/sysfile.c
Log:
o Delete OCFS_MAX_{FILE_ENTRY,DATA}_EXTENTS. It's now based on
blocksize.
Modified: branches/format-changes/src/alloc.c
===================================================================
--- branches/format-changes/src/alloc.c 2004-06-10 20:40:58 UTC (rev 1046)
+++ branches/format-changes/src/alloc.c 2004-06-10 22:41:37 UTC (rev 1047)
@@ -97,8 +97,8 @@
struct inode *inode);
static int ocfs_fix_extent_header(ocfs_super *osb,
- struct buffer_head *eh_bh,
- struct inode *inode);
+ struct buffer_head *eh_bh,
+ struct inode *inode);
static int ocfs_split_this_tree(ocfs_super * osb,
struct buffer_head *extent_grp_bh,
@@ -133,15 +133,15 @@
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, ocfs2_extent_rec *ext,
- u64 blkno);
+ u64 blkno);
static int ocfs_extent_contig(struct inode *inode, ocfs2_extent_rec *ext,
- u64 blkno)
+ u64 blkno)
{
u64 start_blkno = ext->e_blkno;
start_blkno += ocfs_clusters_to_blocks(inode->i_sb,
- ext->e_clusters);
+ ext->e_clusters);
return (start_blkno == blkno);
}
@@ -687,7 +687,7 @@
parent_blk = fe->i_blkno;
}
- numSectorsAlloc = NUM_SECTORS_IN_LEAF_NODE + depth;
+ numSectorsAlloc = depth + 1;
allocSize = (numSectorsAlloc * osb->sect_size);
/* allocate contiguous blocks on disk */
@@ -760,6 +760,7 @@
ext->h_blkno =
(physicalOffset >> osb->sb->s_blocksize_bits) + i;
ext->h_tree_depth = (depth - 1 - i);
+ ext->h_records = ocfs_extent_recs_per_eh(osb->sb);
if (i != depth) {
/* fill in each header */
@@ -952,7 +953,7 @@
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++) {
+ for (k = 0; k < fe->i_records; k++) {
eh1->extents[k].e_cpos = fe->extents[k].e_cpos;
eh1->extents[k].e_clusters =
fe->extents[k].e_clusters;
@@ -982,15 +983,16 @@
eh2 = OCFS_BH_GET_DATA_WRITE(bhs[i]);
eh2->h_tree_depth = (fe->i_tree_depth - 1) - i;
+ eh2->h_records = ocfs_extent_recs_per_eh(osb->sb);
strcpy(eh2->signature, OCFS_EXTENT_HEADER_SIGNATURE);
if (i == 0) {
- 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;
+ eh2->extents[fe->i_records].e_blkno = phys_blkno + 1;
+ eh2->extents[fe->i_records].e_cpos = fe->i_clusters;
+ eh2->extents[fe->i_records].e_clusters = new_clusters;
- eh2->h_next_free_rec = OCFS_MAX_FILE_ENTRY_EXTENTS + 1;
+ eh2->h_next_free_rec = fe->i_records + 1;
eh2->h_blkno =
physicalOffset >> osb->sb->s_blocksize_bits;
eh2->h_parent_blk = parent_blk;
@@ -1018,7 +1020,7 @@
/* Update the Data Segment, which is the last one in our array */
eh1 = OCFS_BH_GET_DATA_WRITE(bhs[fe->i_tree_depth]);
- i = (fe->i_tree_depth) ? 0 : OCFS_MAX_FILE_ENTRY_EXTENTS;
+ i = (fe->i_tree_depth) ? 0 : fe->i_records;
LOG_TRACE_ARGS ("EntryAvailable is: %d\n", eh1->h_next_free_rec);
@@ -1026,7 +1028,8 @@
/* will have one more entry to accomodate the latest allocation */
strcpy (eh1->signature, OCFS_EXTENT_DATA_SIGNATURE);
- eh1->h_tree_depth = -1;
+ eh1->h_tree_depth = -1;
+ eh1->h_records = ocfs_extent_recs_per_eh(osb->sb);
eh1->extents[i].e_cpos = fe->i_clusters;
eh1->extents[i].e_clusters = new_clusters;
@@ -1075,7 +1078,7 @@
eh3 = OCFS_BH_GET_DATA_WRITE(bh);
if (!IS_VALID_EXTENT_HEADER(eh3) ||
- (eh3->h_tree_depth != -1)) {
+ (eh3->h_tree_depth != -1)) {
OCFS_BH_PUT_DATA(bh);
brelse(bh);
LOG_ERROR_STATUS (status = -EINVAL);
@@ -1099,7 +1102,7 @@
struct buffer_head *bh = NULL;
status = 0;
- for (i = 0; i < OCFS_MAX_FILE_ENTRY_EXTENTS; ++i) {
+ for (i = 0; i < fe->i_records; ++i) {
status = ocfs_read_bh(osb,
fe->extents[i].e_blkno << osb->sb->s_blocksize_bits,
&bh, OCFS_BH_COND_CACHED,
@@ -1130,7 +1133,7 @@
}
/* Clear all the extent information from File Entry */
- for (i = 0; i < OCFS_MAX_FILE_ENTRY_EXTENTS; i++) {
+ for (i = 0; i < fe->i_records; i++) {
fe->extents[i].e_cpos = 0;
fe->extents[i].e_clusters = 0;
fe->extents[i].e_blkno = 0;
@@ -1190,7 +1193,7 @@
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_rec > OCFS_MAX_FILE_ENTRY_EXTENTS) {
+ if (fe->i_next_free_rec > fe->i_records) {
LOG_ERROR_STATUS(status = -EINVAL);
goto finally;
}
@@ -1206,7 +1209,7 @@
/* We cannot merge try to give him the next extent */
k = fe->i_next_free_rec;
- if (k != OCFS_MAX_FILE_ENTRY_EXTENTS) {
+ if (k != fe->i_records) {
/* file_off for the new extent will be equal
* to the previous allocation size of file */
fe->extents[k].e_cpos =
@@ -1239,7 +1242,7 @@
}
eh1 = OCFS_BH_GET_DATA_WRITE(eh1_bh);
if (!IS_VALID_EXTENT_HEADER(eh1) ||
- (eh1->h_tree_depth != -1)) {
+ (eh1->h_tree_depth != -1)) {
LOG_ERROR_STATUS (status = -EINVAL);
goto finally;
}
@@ -1273,7 +1276,7 @@
/* We cannot merge, give him the next extent */
k = eh1->h_next_free_rec;
- if (k != OCFS_MAX_DATA_EXTENTS) {
+ if (k != eh1->h_records) {
/* we can just add next extent */
OCFS_BH_PUT_DATA(eh1_bh);
@@ -1320,18 +1323,18 @@
}
eh2 = OCFS_BH_GET_DATA_READ(eh2_bh);
if (!IS_VALID_EXTENT_HEADER(eh2) ||
- (eh2->h_tree_depth < 0)) {
+ (eh2->h_tree_depth < 0)) {
LOG_ERROR_STATUS (status = -EINVAL);
goto finally;
}
- if (eh2->h_tree_depth != i ||
- eh2->h_next_free_rec > OCFS_MAX_DATA_EXTENTS) {
+ if ((eh2->h_tree_depth != i) ||
+ (eh2->h_next_free_rec > eh2->h_records)) {
LOG_ERROR_STATUS(status = -EINVAL);
goto finally;
}
- if (eh2->h_next_free_rec != OCFS_MAX_DATA_EXTENTS)
+ if (eh2->h_next_free_rec != eh2->h_records)
break;
parent_blk = eh2->h_parent_blk;
@@ -1347,8 +1350,7 @@
* if the FE is full -- if so, then we need to
* increase the tree_depth. */
if ((i == fe->i_tree_depth) &&
- (fe->i_next_free_rec ==
- OCFS_MAX_FILE_ENTRY_EXTENTS)) {
+ (fe->i_next_free_rec == fe->i_records)) {
IncreaseTreeDepth = 1;
goto increase_depth;
}
@@ -1425,7 +1427,7 @@
eh2 = OCFS_BH_GET_DATA_WRITE(eh2_bh);
if (!IS_VALID_EXTENT_HEADER(eh2) ||
- (eh2->h_tree_depth < 0)) {
+ (eh2->h_tree_depth < 0)) {
LOG_ERROR_STATUS (status = -EINVAL);
goto finally;
}
@@ -1758,8 +1760,8 @@
#ifndef USERSPACE_TOOL
static int ocfs_fix_extent_header(ocfs_super *osb,
- struct buffer_head *eh_bh,
- struct inode *inode)
+ struct buffer_head *eh_bh,
+ struct inode *inode)
{
ocfs2_extent_rec *ext;
ocfs2_extent_header *eh = NULL;
@@ -1782,7 +1784,7 @@
ext = eh->extents;
- for(i = eh->h_next_free_rec; i < OCFS_MAX_DATA_EXTENTS; i++) {
+ for(i = eh->h_next_free_rec; i < eh->h_records; i++) {
ext[i].e_clusters = 0;
ext[i].e_blkno = 0;
ext[i].e_cpos = 0;
@@ -2355,11 +2357,11 @@
goto bail;
}
- /* Can't be called with local extents */
- if (fe->i_tree_depth < 0)
- BUG();
+ /* Can't be called with local extents */
+ if (fe->i_tree_depth < 0)
+ BUG();
- /* Ugly magic -1 */
+ /* Ugly magic -1 */
victim = fe->i_next_free_rec - 1;
status = ocfs_read_bh(osb,
fe->extents[victim].e_blkno << osb->sb->s_blocksize_bits,
Modified: branches/format-changes/src/extmap.c
===================================================================
--- branches/format-changes/src/extmap.c 2004-06-10 20:40:58 UTC (rev 1046)
+++ branches/format-changes/src/extmap.c 2004-06-10 22:41:37 UTC (rev 1047)
@@ -647,7 +647,7 @@
}
}
- if ((ext->h_next_free_rec != OCFS_MAX_DATA_EXTENTS) &&
+ if ((ext->h_next_free_rec != ext->h_records) &&
(*remainingLength)) {
LOG_ERROR_ARGS ("h_next_free_rec=%d, rem_len=%llu",
ext->h_next_free_rec, *remainingLength);
Modified: branches/format-changes/src/namei.c
===================================================================
--- branches/format-changes/src/namei.c 2004-06-10 20:40:58 UTC (rev 1046)
+++ branches/format-changes/src/namei.c 2004-06-10 22:41:37 UTC (rev 1047)
@@ -218,7 +218,7 @@
file_off = fe->i_blkno << osb->sb->s_blocksize_bits;
handle->new_file_lockid =
- fe->i_blkno << osb->sb->s_blocksize_bits;
+ fe->i_blkno << osb->sb->s_blocksize_bits;
OCFS_BH_PUT_DATA(new_fe_bh);
fe = NULL;
@@ -363,7 +363,7 @@
}
status = ocfs_read_bh(osb, disk_off, new_fe_bh,
- OCFS_BH_CACHED, inode);
+ OCFS_BH_CACHED, inode);
status = ocfs_journal_access(handle, *new_fe_bh, OCFS_JOURNAL_ACCESS_CREATE);
if (status < 0) {
@@ -372,14 +372,14 @@
}
fe = OCFS_BH_GET_DATA_WRITE(*new_fe_bh);
- memset (fe, 0, osb->sect_size);
+ memset(fe, 0, osb->sb->s_blocksize);
inode->i_ino = ino_from_off(osb->sb, disk_off);
- /*
- * FIXME This needs to be
- * (node_num << 24) | (nodeconf->gen_counter++ & 0x00FFFFFF)
- */
- inode->i_generation = 0;
- fe->i_generation = cpu_to_le32(inode->i_generation);
+ /*
+ * FIXME This needs to be
+ * (node_num << 24) | (nodeconf->gen_counter++ & 0x00FFFFFF)
+ */
+ inode->i_generation = 0;
+ fe->i_generation = cpu_to_le32(inode->i_generation);
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;
@@ -401,6 +401,7 @@
fe->i_next_free_rec = 0;
fe->i_last_eh_blk = 0;
strcpy (fe->i_signature, OCFS_FILE_ENTRY_SIGNATURE);
+ fe->i_records = ocfs_extent_recs_per_inode(osb->sb);
fe->i_flags |= OCFS2_VALID_FL;
fe->i_flags &= ~(OCFS2_CHANGE_FL);
DISK_LOCK(fe)->dlock_seq_num = 0;
@@ -408,7 +409,7 @@
DISK_LOCK(fe)->file_lock = OCFS_DLM_ENABLE_CACHE_LOCK;
ocfs_set_disk_lock_open_map(osb, DISK_LOCK(fe), &just_me);
fe->i_atime = fe->i_ctime = fe->i_mtime = OCFS_CURRENT_TIME;
- fe->i_dtime = 0;
+ fe->i_dtime = 0;
OCFS_BH_PUT_DATA(*new_fe_bh);
fe = NULL;
@@ -423,7 +424,7 @@
inode->i_mode = mode;
status = ocfs_add_entry(handle, dentry, inode, disk_off,
- parent_fe_bh);
+ parent_fe_bh);
if (status < 0) {
LOG_ERROR_STATUS (status);
goto leave;
Modified: branches/format-changes/src/ocfs.h
===================================================================
--- branches/format-changes/src/ocfs.h 2004-06-10 20:40:58 UTC (rev 1046)
+++ branches/format-changes/src/ocfs.h 2004-06-10 22:41:37 UTC (rev 1047)
@@ -256,10 +256,6 @@
NONLOCAL_EXT = 2
} ocfs_ext_flag;
-#define OCFS_MAX_FILE_ENTRY_EXTENTS 3
-#define OCFS_MAX_DATA_EXTENTS 18
-#define NUM_SECTORS_IN_LEAF_NODE 1
-
/*
** Structure signatures
*/
@@ -396,15 +392,6 @@
(((node) >= 0) && ((node) < OCFS_MAXIMUM_NODES))
-#define CHECK_FOR_LAST_EXTENT(fileentry, k) \
- do { \
- for((k) = 0; (k) < OCFS_MAX_FILE_ENTRY_EXTENTS; (k)++) { \
- if((fileentry)->extents[(k)].disk_off == 0) \
- break; \
- } \
- (k) = ((k) >= 1) ? ((k) - 1) : (k); \
- } while(0)
-
#define down_with_flag(_sem, _flg) \
do { \
if (!_flg) { \
@@ -1239,9 +1226,10 @@
-1 means data extents hang
directly off of the
inode. */
+ __u16 i_records; /* Number of extent records */
__u16 i_next_free_rec; /* Next unused extent slot */
- __u32 i_reserved3;
-/*A8*/ ocfs2_extent_rec extents[OCFS_MAX_FILE_ENTRY_EXTENTS]; // EXTENT[OCFS_MAX_FILE_ENTRY_EXTENTS]
+ __u16 i_reserved3;
+/*A8*/ ocfs2_extent_rec extents[0]; /* Extent records */
} ocfs2_dinode;
/*
@@ -1267,9 +1255,10 @@
point. -1 means data extents
hang directly off this
header (a leaf) */
+ __u16 h_records; /* Number of extent records */
__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]
+ __u16 h_reserved3;
+/*38*/ ocfs2_extent_rec extents[0]; /* Extent records */
} ocfs2_extent_header;
typedef struct _ocfs_dlm_msg_hdr
@@ -1754,7 +1743,7 @@
u32 cluster;
u64 byte_off;
- for (k = 0; k < OCFS_MAX_DATA_EXTENTS; k++) {
+ for (k = 0; k < eh->h_records; k++) {
ext = &eh->extents[k];
cluster = ext->e_cpos + ext->e_clusters;
@@ -1785,6 +1774,27 @@
return (u32)(blocks >> b_to_c_bits);
}
+static inline int ocfs_extent_recs_per_inode(struct super_block *sb)
+{
+ int size;
+
+ size = sb->s_blocksize -
+ offsetof(struct _ocfs2_dinode, extents);
+
+ return size / sizeof(struct _ocfs2_extent_rec);
+}
+
+static inline int ocfs_extent_recs_per_eh(struct super_block *sb)
+{
+ int size;
+
+ size = sb->s_blocksize -
+ offsetof(struct _ocfs2_extent_header, extents);
+
+ return size / sizeof(struct _ocfs2_extent_rec);
+}
+
+
typedef struct _ocfs_journal_handle ocfs_journal_handle;
#endif /* !OCFS_H */
Modified: branches/format-changes/src/ocfs_journal.h
===================================================================
--- branches/format-changes/src/ocfs_journal.h 2004-06-10 20:40:58 UTC (rev 1046)
+++ branches/format-changes/src/ocfs_journal.h 2004-06-10 22:41:37 UTC (rev 1047)
@@ -366,10 +366,8 @@
+ 1 - OCFS_JOURNAL_FUZZ_CREDITS)
/* fe change, locknode change, dirnode head, times two plus a possible
- * delete, three to fix the up_node_hdr_ptr values of any extents
- * below the moved fe, plus a possible dirnode addition in insert_file, and fuzz */
+ * delete, plus a possible dirnode addition in insert_file, and fuzz */
#define OCFS_FILE_RENAME_CREDITS (2 * (1 + 1 + 1) + OCFS_FILE_DELETE_CREDITS \
- + OCFS_MAX_FILE_ENTRY_EXTENTS \
+ OCFS_JOURNAL_FUZZ_CREDITS + \
OCFS_DEFAULT_DIR_NODE_SECTS)
Modified: branches/format-changes/src/sysfile.c
===================================================================
--- branches/format-changes/src/sysfile.c 2004-06-10 20:40:58 UTC (rev 1046)
+++ branches/format-changes/src/sysfile.c 2004-06-10 22:41:37 UTC (rev 1047)
@@ -491,29 +491,26 @@
if (fe->i_tree_depth < 0)
{
- size = OCFS_MAX_FILE_ENTRY_EXTENTS * sizeof (ocfs_io_runs);
+ size = fe->i_records * sizeof (ocfs_io_runs);
}
else
{
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]
+ * hdr[0]...hdr[n] .....
+ * leaf[0]..leaf[n]
*
* tree_depth of fe is tree height
* so max runs (total of all leaves) is
- * 3 x 18 ^ (tree_depth+1)
- * (OCFS_MAX_DATA_EXTENTS = 18)
+ * 3 x h_records ^ (tree_depth+1)
*
- * g=0: 1296 bytes
- * g=1: 23328 bytes
* g=2: 419904 bytes!
*/
size = 3;
while (pow)
{
- size *= OCFS_MAX_DATA_EXTENTS;
+ size *= ocfs_extent_recs_per_eh(osb->sb);
pow--;
}
size *= sizeof (ocfs_io_runs);
@@ -534,7 +531,7 @@
newOffset = file_off;
if (fe->i_tree_depth < 0) {
- for (j = 0; j < OCFS_MAX_FILE_ENTRY_EXTENTS; j++) {
+ for (j = 0; j < fe->i_records; j++) {
if (((u64)(fe->extents[j].e_cpos + fe->extents[j].e_clusters) << osb->s_clustersize_bits) > newOffset) {
IoRuns[Runoffset].disk_off =
(fe->extents[j].e_blkno << osb->sb->s_blocksize_bits) +
@@ -567,13 +564,13 @@
while (1) {
/* Keep going downwards looking for the Entry, till
* we hit the last Data entry */
- for (k = 0; k < OCFS_MAX_FILE_ENTRY_EXTENTS; k++) {
+ for (k = 0; k < fe->i_records; k++) {
if ((__s64)((u64)(fe->extents[k].e_cpos + fe->extents[k].e_clusters) << osb->s_clustersize_bits) > newOffset) {
break;
}
}
- if (k == OCFS_MAX_FILE_ENTRY_EXTENTS) {
+ if (k == fe->i_records) {
LOG_ERROR_STR ("data extents maxed");
}
@@ -603,7 +600,7 @@
k = ocfs_extent_for_offset(osb->sb,
extent,
newOffset);
- if (k == OCFS_MAX_DATA_EXTENTS) {
+ if (k == extent->h_records) {
LOG_ERROR_STR ("data extents maxed");
}
@@ -636,7 +633,7 @@
goto leave;
}
- for (j = 0; j < OCFS_MAX_DATA_EXTENTS; j++) {
+ for (j = 0; j < extent->h_records; j++) {
if (((u64)(extent->extents[j].e_cpos + extent->extents[j].e_clusters) << osb->s_clustersize_bits) > newOffset) {
IoRuns[Runoffset].disk_off =
(extent->extents[j].e_blkno << osb->sb->s_blocksize_bits) +
@@ -663,7 +660,7 @@
Runs++;
Runoffset++;
if (Runs >=
- OCFS_MAX_DATA_EXTENTS)
+ extent->h_records)
{
LOG_ERROR_ARGS ("Runs=%d", Runs);
}
@@ -671,7 +668,7 @@
}
}
- if (j == OCFS_MAX_DATA_EXTENTS) {
+ if (j == extent->h_records) {
OCFS_BH_PUT_DATA(extent_bh);
brelse(extent_bh);
extent = NULL; extent_bh = NULL;
More information about the Ocfs2-commits
mailing list