[Ocfs2-commits] mfasheh commits r1641 - trunk/src
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Thu Nov 11 15:38:23 CST 2004
Author: mfasheh
Date: 2004-11-11 15:38:21 -0600 (Thu, 11 Nov 2004)
New Revision: 1641
Modified:
trunk/src/inode.c
trunk/src/localalloc.c
trunk/src/ocfs.h
trunk/src/ocfs2_fs.h
trunk/src/suballoc.c
Log:
* update local alloc stuff to use the i_used and i_total fields on dinode
instead of la_bm_bits and la_bits_free.
* get rid of the inode private union containing ip_bitinfo. It wasn't
used in any meaningfull way.
Modified: trunk/src/inode.c
===================================================================
--- trunk/src/inode.c 2004-11-10 23:49:27 UTC (rev 1640)
+++ trunk/src/inode.c 2004-11-11 21:38:21 UTC (rev 1641)
@@ -385,7 +385,6 @@
OCFS_I(inode)->ip_clusters = fe->i_clusters;
OCFS_I(inode)->ip_inode = inode;
- OCFS_I(inode)->u.fe_private = fe->id1.i_pad1;
if (create_ino)
inode->i_ino = ino_from_blkno(inode->i_sb, fe->i_blkno);
@@ -398,14 +397,6 @@
if (le32_to_cpu(fe->i_flags) & OCFS2_LOCAL_ALLOC_FL) {
LOG_TRACE_ARGS("local alloc inode: i_ino=%lu\n", inode->i_ino);
- } else if (le32_to_cpu(fe->i_flags) & OCFS2_BITMAP_FL) {
- OCFS_I(inode)->u.ip_bitinfo.used_bits =
- le32_to_cpu(fe->id1.bitmap1.i_used);
- OCFS_I(inode)->u.ip_bitinfo.total_bits =
- le32_to_cpu(fe->id1.bitmap1.i_total);
- LOG_TRACE_ARGS("bitmap inode: i_ino=%lu, used=%u, total=%u\n",
- inode->i_ino, OCFS_I(inode)->u.ip_bitinfo.used_bits,
- OCFS_I(inode)->u.ip_bitinfo.total_bits);
} else if (le32_to_cpu(fe->i_flags) & OCFS2_SUPER_BLOCK_FL) {
LOG_TRACE_ARGS("superblock inode: i_ino=%lu\n", inode->i_ino);
// we can't actually hit this as read_inode can't handle
@@ -982,13 +973,6 @@
}
spin_lock(&OCFS_I(inode)->ip_lock);
- if (le32_to_cpu(fe->i_flags) & OCFS2_BITMAP_FL) {
- fe->id1.bitmap1.i_used =
- cpu_to_le32(OCFS_I(inode)->u.ip_bitinfo.used_bits);
- fe->id1.bitmap1.i_total =
- cpu_to_le32(OCFS_I(inode)->u.ip_bitinfo.total_bits);
- }
-
fe->i_clusters = OCFS_I(inode)->ip_clusters;
spin_unlock(&OCFS_I(inode)->ip_lock);
@@ -1077,16 +1061,6 @@
drop_map = 1; /* Because we have the lock here */
}
- if (le32_to_cpu(fe->i_flags) & OCFS2_BITMAP_FL) {
- OCFS_I(inode)->u.ip_bitinfo.used_bits =
- le32_to_cpu(fe->id1.bitmap1.i_used);
- OCFS_I(inode)->u.ip_bitinfo.total_bits =
- le32_to_cpu(fe->id1.bitmap1.i_total);
- LOG_TRACE_ARGS("updated bitmap inode: i_ino=%lu, used=%u, total=%u\n",
- inode->i_ino, OCFS_I(inode)->u.ip_bitinfo.used_bits,
- OCFS_I(inode)->u.ip_bitinfo.total_bits);
- }
-
LOG_TRACE_STR("Allocsize, filesize or seq no did not match");
OCFS_I(inode)->ip_clusters = fe->i_clusters;
inode->i_size = fe->i_size;
Modified: trunk/src/localalloc.c
===================================================================
--- trunk/src/localalloc.c 2004-11-10 23:49:27 UTC (rev 1640)
+++ trunk/src/localalloc.c 2004-11-11 21:38:21 UTC (rev 1641)
@@ -161,6 +161,13 @@
alloc = (ocfs2_dinode *) alloc_bh->b_data;
+ if (!(alloc->i_flags & (OCFS2_LOCAL_ALLOC_FL|OCFS2_BITMAP_FL))) {
+ LOG_ERROR_ARGS("Invalid local alloc inode, %llu\n",
+ OCFS_I(inode)->ip_blkno);
+ status = -EINVAL;
+ goto bail;
+ }
+
/* do a little verification. */
num_used = ocfs_local_alloc_count_bits(alloc);
@@ -168,14 +175,14 @@
* we load it so there should be no bits used from the main
* bitmap. */
if (num_used
- || LOCAL_ALLOC(alloc)->la_bits_set
- || LOCAL_ALLOC(alloc)->la_bm_bits
+ || alloc->id1.bitmap1.i_used
+ || alloc->id1.bitmap1.i_total
|| LOCAL_ALLOC(alloc)->la_bm_off) {
LOG_ERROR_ARGS("Local alloc hasn't been recovered!\n"
"found = %u, set = %u, taken = %u, off = %u\n",
num_used,
- LOCAL_ALLOC(alloc)->la_bits_set,
- LOCAL_ALLOC(alloc)->la_bm_bits,
+ alloc->id1.bitmap1.i_used,
+ alloc->id1.bitmap1.i_total,
LOCAL_ALLOC(alloc)->la_bm_off);
status = -EBUSY;
goto bail;
@@ -480,10 +487,6 @@
*
* We will add ourselves to the transaction passed in, but may start
* our own in order to shift windows.
- *
- * When we stop being lame and support multiple chunks of
- * discontiguous space, we this turns into a really simple check of
- * ->la_bits_set
*/
int ocfs_reserve_local_alloc_bits(ocfs_super *osb,
ocfs_journal_handle *passed_handle,
@@ -493,7 +496,7 @@
int status;
ocfs2_dinode *alloc;
struct inode *local_alloc_inode;
- int free_bits;
+ unsigned int free_bits;
LOG_ENTRY();
@@ -532,11 +535,11 @@
alloc = (ocfs2_dinode *) osb->local_alloc_bh->b_data;
- OCFS_ASSERT(LOCAL_ALLOC(alloc)->la_bits_set ==
+ OCFS_ASSERT(alloc->id1.bitmap1.i_used ==
ocfs_local_alloc_count_bits(alloc));
- free_bits = le16_to_cpu(LOCAL_ALLOC(alloc)->la_bm_bits) -
- le16_to_cpu(LOCAL_ALLOC(alloc)->la_bits_set);
+ free_bits = le32_to_cpu(alloc->id1.bitmap1.i_total) -
+ le32_to_cpu(alloc->id1.bitmap1.i_used);
if (bits_wanted > free_bits) {
/* uhoh, window change time. */
status =
@@ -606,7 +609,7 @@
while(bits_wanted--)
ocfs2_set_bit(start++, bitmap);
- LOCAL_ALLOC(alloc)->la_bits_set += *num_bits;
+ alloc->id1.bitmap1.i_used += *num_bits;
status = ocfs_journal_dirty(handle, osb->local_alloc_bh);
if (status < 0) {
@@ -655,7 +658,7 @@
LOG_ENTRY_ARGS("(numbits wanted = %u)\n", numbits);
- if (LOCAL_ALLOC(alloc)->la_bm_bits == 0) {
+ if (!alloc->id1.bitmap1.i_total) {
LOG_TRACE_STR("No bits in my window!");
bitoff = -1;
goto bail;
@@ -665,7 +668,7 @@
numfound = bitoff = startoff = 0;
lastzero = -1;
- left = LOCAL_ALLOC(alloc)->la_bm_bits;
+ left = alloc->id1.bitmap1.i_total;
while ((bitoff = ocfs2_find_next_zero_bit(bitmap, left, startoff)) != -1) {
if (bitoff == left) {
/* LOG_TRACE_ARGS("bitoff (%d) == left", bitoff); */
@@ -713,8 +716,8 @@
int i;
LOG_ENTRY();
- LOCAL_ALLOC(alloc)->la_bm_bits = 0;
- LOCAL_ALLOC(alloc)->la_bits_set = 0;
+ alloc->id1.bitmap1.i_total = 0;
+ alloc->id1.bitmap1.i_used = 0;
LOCAL_ALLOC(alloc)->la_bm_off = 0;
for(i = 0; i < LOCAL_ALLOC(alloc)->la_size; i++)
LOCAL_ALLOC(alloc)->la_bitmap[i] = 0;
@@ -762,18 +765,17 @@
u64 blkno;
void *bitmap;
- LOG_ENTRY_ARGS("alloc->la_bm_bits = %u, COUNT = %u, "
- "la_bits_set = %u\n", LOCAL_ALLOC(alloc)->la_bm_bits,
+ LOG_ENTRY_ARGS("total = %u, COUNT = %u, used = %u\n",
+ alloc->id1.bitmap1.i_total,
ocfs_local_alloc_count_bits(alloc),
- LOCAL_ALLOC(alloc)->la_bits_set);
+ alloc->id1.bitmap1.i_used);
- if (LOCAL_ALLOC(alloc)->la_bm_bits == 0) {
+ if (!alloc->id1.bitmap1.i_total) {
LOG_TRACE_STR("nothing to sync!");
goto bail;
}
- if (LOCAL_ALLOC(alloc)->la_bits_set ==
- LOCAL_ALLOC(alloc)->la_bm_bits) {
+ if (alloc->id1.bitmap1.i_used == alloc->id1.bitmap1.i_total) {
LOG_TRACE_STR("all bits were taken!");
goto bail;
}
@@ -782,7 +784,7 @@
LOCAL_ALLOC(alloc)->la_bm_off);
bitmap = LOCAL_ALLOC(alloc)->la_bitmap;
start = count = bit_off = 0;
- left = LOCAL_ALLOC(alloc)->la_bm_bits;
+ left = alloc->id1.bitmap1.i_total;
while ((bit_off = ocfs2_find_next_zero_bit(bitmap, left, start))
!= -1) {
@@ -876,7 +878,7 @@
LOG_ENTRY();
alloc = (ocfs2_dinode *) osb->local_alloc_bh->b_data;
- if (LOCAL_ALLOC(alloc)->la_bm_bits != 0)
+ if (alloc->id1.bitmap1.i_total)
LOG_TRACE_STR("asking me to alloc a new window over a"
" non-empty one");
@@ -898,20 +900,19 @@
alloc = (ocfs2_dinode *) osb->local_alloc_bh->b_data;
LOCAL_ALLOC(alloc)->la_bm_off = cluster_off;
- LOCAL_ALLOC(alloc)->la_bm_bits = cluster_count;
+ alloc->id1.bitmap1.i_total = cpu_to_le32(cluster_count);
/* just in case... In the future when we find space ourselves,
* we don't have to get all contiguous -- but we'll have to
* set all previously used bits in bitmap and update
* la_bits_set before setting the bits in the main bitmap. */
- LOCAL_ALLOC(alloc)->la_bits_set = 0;
+ alloc->id1.bitmap1.i_used = 0;
memset(LOCAL_ALLOC(alloc)->la_bitmap, 0,
LOCAL_ALLOC(alloc)->la_size);
LOG_TRACE_STR("New window allocated:");
LOG_TRACE_ARGS("window la_bm_off = %u\n",
LOCAL_ALLOC(alloc)->la_bm_off);
- LOG_TRACE_ARGS("window la_bm_bits = %u\n",
- LOCAL_ALLOC(alloc)->la_bm_bits);
+ LOG_TRACE_ARGS("window bits = %u\n", alloc->id1.bitmap1.i_total);
bail:
LOG_EXIT_STATUS(status);
Modified: trunk/src/ocfs.h
===================================================================
--- trunk/src/ocfs.h 2004-11-10 23:49:27 UTC (rev 1640)
+++ trunk/src/ocfs.h 2004-11-11 21:38:21 UTC (rev 1641)
@@ -395,15 +395,6 @@
atomic_t ip_clean_buffer_seq;
__u32 ip_flags; /* see below */
- /* stolen right off of ocfs2_dinode */
- union {
- __u64 fe_private;
- struct _ip_bitinfo {
- __u32 used_bits;
- __u32 total_bits;
- } ip_bitinfo;
- } u;
-
/* protected by recovery_lock. */
struct inode *ip_next_orphan;
Modified: trunk/src/ocfs2_fs.h
===================================================================
--- trunk/src/ocfs2_fs.h 2004-11-10 23:49:27 UTC (rev 1640)
+++ trunk/src/ocfs2_fs.h 2004-11-11 21:38:21 UTC (rev 1641)
@@ -332,12 +332,9 @@
typedef struct _ocfs2_local_alloc
{
/*00*/ __u32 la_bm_off; /* Starting bit offset in main bitmap */
- /* Do we want to use id1.bitmap1? */
- __u16 la_bm_bits; /* Number of bits from main bitmap */
- __u16 la_bits_set; /* Number of set bits */
__u16 la_size; /* Size of included bitmap, in bytes */
__u16 la_reserved1;
- __u32 la_reserved2;
+ __u64 la_reserved2;
/*10*/ __u8 la_bitmap[0];
} ocfs2_local_alloc;
Modified: trunk/src/suballoc.c
===================================================================
--- trunk/src/suballoc.c 2004-11-10 23:49:27 UTC (rev 1640)
+++ trunk/src/suballoc.c 2004-11-11 21:38:21 UTC (rev 1641)
@@ -386,8 +386,6 @@
OCFS_I(alloc_inode)->ip_clusters = fe->i_clusters;
fe->i_size = ocfs2_clusters_to_bytes(alloc_inode->i_sb,
fe->i_clusters);
- OCFS_I(alloc_inode)->u.ip_bitinfo.used_bits = fe->id1.bitmap1.i_used;
- OCFS_I(alloc_inode)->u.ip_bitinfo.total_bits = fe->id1.bitmap1.i_total;
spin_unlock(&OCFS_I(alloc_inode)->ip_lock);
alloc_inode->i_size = fe->i_size;
alloc_inode->i_blocks = (alloc_inode->i_size + osb->sb->s_blocksize - 1) >> osb->sb->s_blocksize_bits;
@@ -1097,10 +1095,6 @@
LOG_TRACE_ARGS("Allocated %u bits from suballocator %llu\n",
*num_bits, fe->i_blkno);
- spin_lock(&OCFS_I(alloc_inode)->ip_lock);
- OCFS_I(alloc_inode)->u.ip_bitinfo.used_bits = fe->id1.bitmap1.i_used;
- spin_unlock(&OCFS_I(alloc_inode)->ip_lock);
-
*bg_blkno = bg->bg_blkno;
bail:
if (group_bh)
@@ -1445,9 +1439,6 @@
goto bail;
}
- spin_lock(&OCFS_I(alloc_inode)->ip_lock);
- OCFS_I(alloc_inode)->u.ip_bitinfo.used_bits = fe->id1.bitmap1.i_used;
- spin_unlock(&OCFS_I(alloc_inode)->ip_lock);
bail:
if (group_bh)
brelse(group_bh);
More information about the Ocfs2-commits
mailing list