[Ocfs2-commits] jlbec commits r1090 - branches/format-changes/src
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Mon Jun 14 04:17:15 CDT 2004
Author: jlbec
Date: 2004-06-14 03:17:13 -0500 (Mon, 14 Jun 2004)
New Revision: 1090
Modified:
branches/format-changes/src/alloc.c
branches/format-changes/src/bitmap.c
branches/format-changes/src/bitmap.h
branches/format-changes/src/file.c
branches/format-changes/src/ocfs.h
branches/format-changes/src/ocfs_journal.h
branches/format-changes/src/super.c
Log:
o Add in the OCFS_BITS_IN_CHUNK() stuff from the s_blocksize branch.
This removes a number of OCFS_ALIGN() calls.
Modified: branches/format-changes/src/alloc.c
===================================================================
--- branches/format-changes/src/alloc.c 2004-06-14 07:18:58 UTC (rev 1089)
+++ branches/format-changes/src/alloc.c 2004-06-14 08:17:13 UTC (rev 1090)
@@ -311,8 +311,8 @@
}
tmp_log = free_vol_bits;
- credits += 1 + free_log->update[i].length /
- OCFS_BITS_IN_CHUNK;
+ credits += ocfs_blocks_for_bits(osb->sb,
+ free_log->update[i].length);
break;
default:
@@ -432,7 +432,7 @@
bm_lock = OCFS_BH_GET_DATA_WRITE(globalbh);
bm_lock->id1.bitmap1.i_used =
- ocfs_count_bits(&osb->cluster_bitmap);
+ ocfs_count_bits(osb->sb, &osb->cluster_bitmap);
OCFS_BH_PUT_DATA(globalbh);
status = ocfs_journal_dirty(handle, globalbh);
@@ -522,7 +522,7 @@
bitmap = &osb->cluster_bitmap;
- bitmapblocks = (OCFS_ALIGN(bitmap->validbits, OCFS_BITS_IN_CHUNK) / OCFS_BITS_IN_CHUNK);
+ bitmapblocks = ocfs_blocks_for_bits(osb->sb, bitmap->validbits);
status = ocfs_read_bhs(osb, osb->bitmap_blkno << osb->sb->s_blocksize_bits,
bitmapblocks << osb->sb->s_blocksize_bits,
@@ -533,7 +533,9 @@
}
for (i = 0; i < freelog->num_updates; i++)
- ocfs_clear_bits(handle, bitmap, freelog->update[i].file_off, freelog->update[i].length);
+ ocfs_clear_bits(osb->sb, handle, bitmap,
+ freelog->update[i].file_off,
+ freelog->update[i].length);
status = 0;
bail:
@@ -603,9 +605,11 @@
fileSize = inode->i_size;
allocSize = OCFS_I(inode)->alloc_size;
- ocfs_initialize_bitmap(&AllocBitmap, fileSize * 8, allocSize * 8);
+ ocfs_initialize_bitmap(osb->sb, &AllocBitmap, fileSize * 8,
+ allocSize * 8);
tmpbitmap = &AllocBitmap;
- bitmapblocks = (OCFS_ALIGN(tmpbitmap->validbits, OCFS_BITS_IN_CHUNK) / OCFS_BITS_IN_CHUNK);
+ bitmapblocks = ocfs_blocks_for_bits(osb->sb,
+ tmpbitmap->validbits);
status = ocfs_read_system_file(osb, file_type, NodeNum, AllocBitmap.chunk,
bitmapblocks << osb->sb->s_blocksize_bits);
@@ -621,7 +625,7 @@
}
foundBit = (__u32) (FreeLog->update[i].file_off >> blockSizeBits);
- ocfs_clear_bits(handle, tmpbitmap, foundBit,
+ ocfs_clear_bits(osb->sb, handle, tmpbitmap, foundBit,
(__u32) FreeLog->update[i].length);
}
@@ -2877,7 +2881,14 @@
* Pass in 'lock_bh' and bitmap_inode only if you've already taken the
* vol_alloc semaphore, and you've done the acquire_lock on the bitmap.
*/
-int ocfs_find_contiguous_space_from_bitmap (ocfs_super * osb, ocfs_journal_handle *handle, __u64 file_size, __u64 * cluster_off, __u64 * cluster_count, int sysfile, struct buffer_head *lock_bh, struct inode *bitmap_inode)
+int ocfs_find_contiguous_space_from_bitmap(ocfs_super *osb,
+ ocfs_journal_handle *handle,
+ __u64 file_size,
+ __u64 *cluster_off,
+ __u64 *cluster_count,
+ int sysfile,
+ struct buffer_head *lock_bh,
+ struct inode *bitmap_inode)
{
int status = 0, startbh, numblocks;
__u32 bitoffset = 0, ClusterCount = 0;
@@ -2975,8 +2986,9 @@
LargeAllocOffset = five_percent;
}
- bitmapblocks = (OCFS_ALIGN(osb->cluster_bitmap.validbits,
- OCFS_BITS_IN_CHUNK) / OCFS_BITS_IN_CHUNK);
+ bitmapblocks =
+ ocfs_blocks_for_bits(osb->sb,
+ osb->cluster_bitmap.validbits);
/* Ok, somewhat lame, but we submit the whole bitmap for reading here*/
if (ocfs_read_bhs(osb, osb->bitmap_blkno << osb->sb->s_blocksize_bits,
@@ -3023,19 +3035,20 @@
LOG_TRACE_ARGS ("setting at bit offset=%u\n", bitoffset);
- ocfs_set_bits (handle, &osb->cluster_bitmap, bitoffset, ClusterCount);
+ ocfs_set_bits(osb->sb, handle, &osb->cluster_bitmap, bitoffset,
+ ClusterCount);
/* Ok, write out the bitmap now. We optimize only by writing
* out the bitmap blocks which have changed, and not all of
* them like before. */
- startbh = OCFS_GLOBAL_OFF_TO_CHUNK(bitoffset);
- numblocks = OCFS_GLOBAL_OFF_TO_CHUNK(bitoffset + ClusterCount - 1) - startbh + 1;
+ startbh = OCFS_GLOBAL_OFF_TO_CHUNK(osb->sb, bitoffset);
+ numblocks = OCFS_GLOBAL_OFF_TO_CHUNK(osb->sb, bitoffset + ClusterCount - 1) - startbh + 1;
LOG_TRACE_ARGS("bitoffset = %u, ClusterCount = %u, startbh = %u, numblocks = %u\n", bitoffset, ClusterCount, startbh, numblocks);
/* write the bitmap size info to the lock sector */
bm_lock->id1.bitmap1.i_used =
- ocfs_count_bits(&osb->cluster_bitmap);
+ ocfs_count_bits(osb->sb, &osb->cluster_bitmap);
OCFS_BH_PUT_DATA(bh);
bm_lock = NULL;
@@ -3164,11 +3177,13 @@
if ((fileSize != 0) && (allocSize != 0)) {
/* Round this off to dirnodesize */
- ocfs_initialize_bitmap (&bitmap, (__u32) fileSize * 8, (__u32) allocSize * 8);
+ ocfs_initialize_bitmap(osb->sb, &bitmap,
+ (__u32)fileSize * 8,
+ (__u32)allocSize * 8);
needs_uninit = 1;
- status = ocfs_read_system_file (osb, bm_file, NodeNum,
- bitmap.chunk, allocSize);
+ status = ocfs_read_system_file(osb, bm_file, NodeNum,
+ bitmap.chunk, allocSize);
if (status < 0) {
LOG_ERROR_STATUS (status);
goto leave;
@@ -3178,7 +3193,8 @@
/* This function will check for clear bits in the Bitmap for */
/* consective clear bits equal to ClusterCount */
- foundBit = ocfs_find_clear_bits (osb, &bitmap, numBits, 0, 0);
+ foundBit = ocfs_find_clear_bits(osb, &bitmap, numBits,
+ 0, 0);
}
/* It returns -1 on failure , otherwise ByteOffset points at the */
@@ -3226,15 +3242,17 @@
OCFS_BH_PUT_DATA(bh);
if (needs_uninit)
- ocfs_reinitialize_bitmap(&bitmap, fileSize * 8,
+ ocfs_reinitialize_bitmap(osb->sb, &bitmap,
+ fileSize * 8,
allocSize * 8);
else
- ocfs_initialize_bitmap(&bitmap, fileSize * 8,
+ ocfs_initialize_bitmap(osb->sb, &bitmap,
+ fileSize * 8,
allocSize * 8);
needs_uninit = 1;
- status = ocfs_read_system_file (osb, bm_file, NodeNum,
- bitmap.chunk, allocSize);
+ status = ocfs_read_system_file(osb, bm_file, NodeNum,
+ bitmap.chunk, allocSize);
if (status < 0) {
LOG_ERROR_STATUS (status);
goto leave;
@@ -3249,11 +3267,11 @@
LOG_TRACE_ARGS ("byte offset=%d\n", foundBit);
- ocfs_set_bits (handle, &bitmap, foundBit, numBits);
+ ocfs_set_bits(osb->sb, handle, &bitmap, foundBit, numBits);
/* only write out what has changed... */
- startbh = OCFS_GLOBAL_OFF_TO_CHUNK(foundBit);
- numblocks = OCFS_GLOBAL_OFF_TO_CHUNK(foundBit + numBits - 1) - startbh + 1;
+ startbh = OCFS_GLOBAL_OFF_TO_CHUNK(osb->sb, foundBit);
+ numblocks = OCFS_GLOBAL_OFF_TO_CHUNK(osb->sb, foundBit + numBits - 1) - startbh + 1;
LOG_TRACE_ARGS ("offset=%u, type=%x, blksz=%u, foundbit=%u, fileid=%u\n",
foundBit * blockSize, Type, blockSize, foundBit, alloc_file);
Modified: branches/format-changes/src/bitmap.c
===================================================================
--- branches/format-changes/src/bitmap.c 2004-06-14 07:18:58 UTC (rev 1089)
+++ branches/format-changes/src/bitmap.c 2004-06-14 08:17:13 UTC (rev 1090)
@@ -51,19 +51,19 @@
* ocfs_initialize_bitmap()
*
*/
-void ocfs_initialize_bitmap (ocfs_alloc_bm * bitmap, __u32 validbits, __u32 allocbits)
+void ocfs_initialize_bitmap(struct super_block *sb,
+ ocfs_alloc_bm *bitmap, __u32 validbits,
+ __u32 allocbits)
{
- __u32 tmp;
+ LOG_ENTRY_ARGS ("(0x%p, 0x%p, %u, %u)\n", sb, bitmap, validbits,
+ allocbits);
- LOG_ENTRY_ARGS ("(0x%p, %u, %u)\n", bitmap, validbits, allocbits);
-
bitmap->validbits = validbits;
bitmap->allocbits = allocbits;
bitmap->failed = 0;
bitmap->ok_retries = 0;
- tmp = OCFS_ALIGN(allocbits, OCFS_BITS_IN_CHUNK);
- bitmap->numbh = (tmp / OCFS_BITS_IN_CHUNK);
+ bitmap->numbh = ocfs_blocks_for_bits(sb, bitmap->allocbits);
bitmap->chunk = ocfs_malloc(bitmap->numbh * sizeof(struct buffer_head *));
if (!bitmap->chunk)
BUG();
@@ -97,9 +97,10 @@
}
/* we only handle if the bitmap has grown, not shrunk. */
-void ocfs_reinitialize_bitmap(ocfs_alloc_bm *bitmap, __u32 validbits, __u32 allocbits)
+void ocfs_reinitialize_bitmap(struct super_block *sb,
+ ocfs_alloc_bm *bitmap, __u32 validbits,
+ __u32 allocbits)
{
- __u32 tmp;
__u32 newnumbh;
struct buffer_head **newchunk;
@@ -114,8 +115,7 @@
if (allocbits == bitmap->allocbits)
goto skipbhs;
- tmp = OCFS_ALIGN(allocbits, OCFS_BITS_IN_CHUNK);
- newnumbh = (tmp / OCFS_BITS_IN_CHUNK);
+ newnumbh = ocfs_blocks_for_bits(sb, allocbits);
newchunk = ocfs_malloc(bitmap->numbh * sizeof(struct buffer_head *));
if (!newchunk)
@@ -170,9 +170,12 @@
* in case we have a disk full.
*
*/
-int ocfs_find_clear_bits (ocfs_super *osb, ocfs_alloc_bm * bitmap, __u32 numBits, __u32 offset, __u32 sysonly)
+int ocfs_find_clear_bits(ocfs_super *osb, ocfs_alloc_bm * bitmap,
+ __u32 numBits, __u32 offset, __u32 sysonly)
{
- __u32 globalsize, globaloff, localstart, lastbh, size, bitoff, count;
+ __u32 globalsize, globaloff, localstart, lastbh;
+ __u32 size = OCFS_BITS_IN_CHUNK(osb->sb);
+ __u32 bitoff = 0, count = 0;
void *buffer;
int c;
struct buffer_head *currbh = NULL;
@@ -181,19 +184,15 @@
offset, sysonly);
globalsize = bitmap->validbits - sysonly;
- bitoff = count = 0;
- lastbh = (OCFS_ALIGN(globalsize, OCFS_BITS_IN_CHUNK) /
- OCFS_BITS_IN_CHUNK) - 1;
+ lastbh = ocfs_blocks_for_bits(osb->sb, globalsize) - 1;
globaloff = offset;
- localstart = OCFS_GLOBAL_OFF_TO_LOCAL(globaloff);
+ c = OCFS_GLOBAL_OFF_TO_CHUNK(osb->sb, globaloff);
+ localstart = OCFS_GLOBAL_OFF_TO_LOCAL(osb->sb, globaloff);
if (lastbh == 0)
size = globalsize;
- else
- size = OCFS_BITS_IN_CHUNK;
- c = OCFS_GLOBAL_OFF_TO_CHUNK(localstart);
currbh = bitmap->chunk[c];
/*LOG_TRACE_ARGS("globalsize=%u, bitmap->validbits=%u, sysonly=%u\n",
@@ -202,7 +201,8 @@
"localstart=%u\n", c, lastbh, size, localstart);*/
buffer = OCFS_BH_GET_DATA_READ(currbh);
- while ((bitoff = find_next_zero_bit(buffer, OCFS_BITS_IN_CHUNK,
+ while ((bitoff = find_next_zero_bit(buffer,
+ OCFS_BITS_IN_CHUNK(osb->sb),
localstart)) != -1) {
/*LOG_TRACE_ARGS("c=%u, globaloff=%u, bitoff=%u, "
"localstart=%u\n", c, globaloff, bitoff,
@@ -232,8 +232,10 @@
currbh = bitmap->chunk[c];
buffer = OCFS_BH_GET_DATA_READ(currbh);
if (c == lastbh)
- size = globalsize-(OCFS_BITS_IN_CHUNK*lastbh);
- globaloff = c * OCFS_BITS_IN_CHUNK;
+ size = globalsize -
+ (OCFS_BITS_IN_CHUNK(osb->sb)
+ * lastbh);
+ globaloff = c * OCFS_BITS_IN_CHUNK(osb->sb);
continue;
}
@@ -246,7 +248,8 @@
if (localstart >= size)
goto nextbh;
- globaloff = OCFS_CHUNK_TO_GLOBAL_OFF(c, bitoff) + 1;
+ globaloff = OCFS_CHUNK_TO_GLOBAL_OFF(osb->sb, c,
+ bitoff) + 1;
} else if (bitoff == localstart) {
/*LOG_TRACE_ARGS("bitoff == localstart (%u)\n",
bitoff);*/
@@ -259,7 +262,8 @@
bitoff, localstart);*/
/* we had to skip over some ones */
count = 1;
- globaloff = OCFS_CHUNK_TO_GLOBAL_OFF(c, bitoff) + 1;
+ globaloff = OCFS_CHUNK_TO_GLOBAL_OFF(osb->sb, c,
+ bitoff) + 1;
localstart = bitoff + 1;
}
@@ -285,7 +289,7 @@
* ocfs_count_bits()
*
*/
-int ocfs_count_bits (ocfs_alloc_bm * bitmap)
+int ocfs_count_bits(struct super_block *sb, ocfs_alloc_bm *bitmap)
{
__u32 count = 0, i, j;
struct buffer_head *currbh;
@@ -296,14 +300,17 @@
LOG_ENTRY ();
size = (bitmap->validbits >> 3);
+ validbytes = size;
+ if (validbytes > sb->s_blocksize)
+ validbytes = sb->s_blocksize;
- for (i = 0, validbytes = (size >= OCFS_BITMAP_CHUNK ? OCFS_BITMAP_CHUNK : size);
- size > 0; size -= validbytes, i++) {
+ for (i = 0; size > 0; size -= validbytes, i++) {
currbh = bitmap->chunk[i];
buffer = OCFS_BH_GET_DATA_READ(currbh);
for (j = 0; j < validbytes; j++) {
- memcpy (&tmp, buffer, 1);
- count += BITCOUNT (tmp);
+ /* U-U-U-GLY */
+ memcpy(&tmp, buffer, 1);
+ count += BITCOUNT(tmp);
buffer++;
}
OCFS_BH_PUT_DATA(currbh);
@@ -321,15 +328,16 @@
* ocfs_set_bits()
*
*/
-void ocfs_set_bits (ocfs_journal_handle *handle, ocfs_alloc_bm * bitmap,
- __u32 start, __u32 num)
+void ocfs_set_bits(struct super_block *sb, ocfs_journal_handle *handle,
+ ocfs_alloc_bm * bitmap, __u32 start, __u32 num)
{
struct buffer_head *currbh = NULL;
void *buff;
int i, local;
int status;
- LOG_ENTRY_ARGS ("(0x%p, %u, %u)\n", bitmap, start, num);
+ LOG_ENTRY_ARGS ("(0x%p, 0x%p, 0x%p, %u, %u)\n", sb, handle,
+ bitmap, start, num);
if ((start + num) > bitmap->validbits) {
LOG_ERROR_ARGS("bitmap->validbits = %u but start = %u and " \
@@ -337,8 +345,8 @@
goto bail;
}
- i = OCFS_GLOBAL_OFF_TO_CHUNK(start);
- local = OCFS_GLOBAL_OFF_TO_LOCAL(start);
+ i = OCFS_GLOBAL_OFF_TO_CHUNK(sb, start);
+ local = OCFS_GLOBAL_OFF_TO_LOCAL(sb, start);
currbh = bitmap->chunk[i];
status = ocfs_journal_access(handle, currbh, OCFS_JOURNAL_ACCESS_UNDO);
@@ -351,7 +359,7 @@
while (num--) {
set_bit (local++, buff);
- if (local >= OCFS_BITS_IN_CHUNK && num != 0) {
+ if ((local >= OCFS_BITS_IN_CHUNK(sb)) && (num != 0)) {
local = 0;
OCFS_BH_PUT_DATA(currbh);
status = ocfs_journal_dirty(handle, currbh);
@@ -390,7 +398,8 @@
* ocfs_clear_bits()
*
*/
-void ocfs_clear_bits (ocfs_journal_handle *handle, ocfs_alloc_bm * bitmap,
+void ocfs_clear_bits(struct super_block *sb,
+ ocfs_journal_handle *handle, ocfs_alloc_bm *bitmap,
__u32 start, __u32 num)
{
struct buffer_head *currbh = NULL;
@@ -398,7 +407,8 @@
int i, local;
int status;
- LOG_ENTRY_ARGS ("(0x%p, %u, %u)\n", bitmap, start, num);
+ LOG_ENTRY_ARGS ("(0x%p, 0x%p, 0x%p, %u, %u)\n", sb, handle,
+ bitmap, start, num);
if ((start + num) > bitmap->validbits) {
LOG_ERROR_ARGS("bitmap->validbits = %u but start = %u and " \
@@ -406,8 +416,8 @@
goto bail;
}
- i = OCFS_GLOBAL_OFF_TO_CHUNK(start);
- local = OCFS_GLOBAL_OFF_TO_LOCAL(start);
+ i = OCFS_GLOBAL_OFF_TO_CHUNK(sb, start);
+ local = OCFS_GLOBAL_OFF_TO_LOCAL(sb, start);
currbh = bitmap->chunk[i];
status = ocfs_journal_access(handle, currbh, OCFS_JOURNAL_ACCESS_UNDO);
@@ -424,7 +434,7 @@
(unsigned long *)bh2jh(currbh)->b_committed_data);
local++;
- if (local >= OCFS_BITS_IN_CHUNK && num != 0) {
+ if ((local >= OCFS_BITS_IN_CHUNK(sb)) && (num != 0)) {
local = 0;
OCFS_BH_PUT_DATA(currbh);
Modified: branches/format-changes/src/bitmap.h
===================================================================
--- branches/format-changes/src/bitmap.h 2004-06-14 07:18:58 UTC (rev 1089)
+++ branches/format-changes/src/bitmap.h 2004-06-14 08:17:13 UTC (rev 1090)
@@ -29,18 +29,20 @@
#ifndef OCFS2_BITMAP_H
#define OCFS2_BITMAP_H
-int ocfs_count_bits(ocfs_alloc_bm *bitmap);
-void ocfs_clear_bits(ocfs_journal_handle *handle,
- ocfs_alloc_bm *bitmap,
+int ocfs_count_bits(struct super_block *sb, ocfs_alloc_bm *bitmap);
+void ocfs_clear_bits(struct super_block *sb,
+ ocfs_journal_handle *handle, ocfs_alloc_bm *bitmap,
__u32 start, __u32 num);
int ocfs_find_clear_bits(ocfs_super *osb, ocfs_alloc_bm *bitmap,
__u32 numBits, __u32 offset, __u32 sysonly);
-void ocfs_initialize_bitmap(ocfs_alloc_bm *bitmap, __u32 validbits,
+void ocfs_initialize_bitmap(struct super_block *sb,
+ ocfs_alloc_bm *bitmap, __u32 validbits,
__u32 allocbits);
-void ocfs_reinitialize_bitmap(ocfs_alloc_bm *bitmap, __u32 validbits,
+void ocfs_reinitialize_bitmap(struct super_block *sb,
+ ocfs_alloc_bm *bitmap, __u32 validbits,
__u32 allocbits);
-void ocfs_set_bits(ocfs_journal_handle *handle, ocfs_alloc_bm *bitmap,
- __u32 start, __u32 num);
+void ocfs_set_bits(struct super_block *sb, ocfs_journal_handle *handle,
+ ocfs_alloc_bm *bitmap, __u32 start, __u32 num);
void ocfs_uninitialize_bitmap(ocfs_alloc_bm *bitmap);
#endif /* OCFS2_BITMAP_H */
Modified: branches/format-changes/src/file.c
===================================================================
--- branches/format-changes/src/file.c 2004-06-14 07:18:58 UTC (rev 1089)
+++ branches/format-changes/src/file.c 2004-06-14 08:17:13 UTC (rev 1090)
@@ -1132,8 +1132,8 @@
fe = NULL;
if (passed_handle == NULL) {
- credits = ocfs_calc_extend_credits(((__u32) alloc_size),
- osb->s_clustersize);
+ credits = ocfs_calc_extend_credits(osb->sb,
+ (__u32) alloc_size);
/* cannot call start_trans with a locked buffer head. */
handle = ocfs_start_trans(osb, OCFS_FILE_EXTEND_CREDITS);
Modified: branches/format-changes/src/ocfs.h
===================================================================
--- branches/format-changes/src/ocfs.h 2004-06-14 07:18:58 UTC (rev 1089)
+++ branches/format-changes/src/ocfs.h 2004-06-14 08:17:13 UTC (rev 1090)
@@ -45,20 +45,16 @@
#endif
-#define OCFS_BITMAP_CHUNK (512) /* size of a chunk, in bytes */
-#define OCFS_BITS_IN_CHUNK (OCFS_BITMAP_CHUNK * 8)
-/* Lovely convenience macros. If we move to a scheme where
- * OCFS_BITS_IN_CHUNK is not constant, this'll
- * be nice. */
-#define OCFS_CHUNK_TO_GLOBAL_OFF(index, localoffset) \
- ((index) * OCFS_BITS_IN_CHUNK + (localoffset))
-#define OCFS_GLOBAL_OFF_TO_CHUNK(globaloffset) \
- ((globaloffset) / OCFS_BITS_IN_CHUNK)
-#define OCFS_GLOBAL_OFF_TO_LOCAL(globaloffset) \
- ((globaloffset) % OCFS_BITS_IN_CHUNK)
-#define OCFS_BITMAP_RANGE_BITS(startbh, startoff, endbh, endoff) \
- (OCFS_CHUNK_TO_GLOBAL_OFF((endbh), (endoff)) - \
- OCFS_CHUNK_TO_GLOBAL_OFF((startbh), (startoff)))
+#define OCFS_BITS_IN_CHUNK(sb) ((sb)->s_blocksize * 8)
+#define OCFS_CHUNK_TO_GLOBAL_OFF(sb, index, localoffset) \
+ ((index) * OCFS_BITS_IN_CHUNK(sb) + (localoffset))
+#define OCFS_GLOBAL_OFF_TO_CHUNK(sb, globaloffset) \
+ ((globaloffset) / OCFS_BITS_IN_CHUNK(sb))
+#define OCFS_GLOBAL_OFF_TO_LOCAL(sb, globaloffset) \
+ ((globaloffset) % OCFS_BITS_IN_CHUNK(sb))
+#define OCFS_BITMAP_RANGE_BITS(sb, startbh, startoff, endbh, endoff) \
+ (OCFS_CHUNK_TO_GLOBAL_OFF((sb), (endbh), (endoff)) - \
+ OCFS_CHUNK_TO_GLOBAL_OFF((sb), (startbh), (startoff)))
typedef struct _ocfs_alloc_bm
{
@@ -356,10 +352,6 @@
#define OCFS_SET_FLAG(flag, value) ((flag) |= (value))
#define OCFS_CLEAR_FLAG(flag, value) ((flag) &= ~(value))
-#define OCFS_SECTOR_ALIGN(buf) \
- ((__u64)buf + \
- (((__u64)buf % OCFS_SECTOR_SIZE) ? \
- (OCFS_SECTOR_SIZE - ((__u64)buf % OCFS_SECTOR_SIZE)):0))
/*
** Structures...
@@ -1452,6 +1444,14 @@
return (u32)(blocks >> b_to_c_bits);
}
+static inline int ocfs_blocks_for_bits(struct super_block *sb,
+ unsigned int num_bits)
+{
+ int bits_per_chunk = OCFS_BITS_IN_CHUNK(sb);
+
+ return (num_bits + (bits_per_chunk - 1)) / bits_per_chunk;
+}
+
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-14 07:18:58 UTC (rev 1089)
+++ branches/format-changes/src/ocfs_journal.h 2004-06-14 08:17:13 UTC (rev 1090)
@@ -339,19 +339,17 @@
* needed for an extend. Unfortunately, we're in bytes because the
* rest of the file system is.
*/
-static inline int ocfs_calc_extend_credits(__u32 bytes_wanted,
- __u32 cluster_size)
+static inline int ocfs_calc_extend_credits(struct super_block *sb,
+ __u32 bytes_wanted)
{
int bitmap_blocks;
unsigned int bits_wanted;
- bits_wanted = (__u32)OCFS_ALIGN(bytes_wanted, cluster_size) /
- cluster_size;
+ bits_wanted = ocfs_clusters_for_bytes(sb, bytes_wanted);
/* take advantage of the fact that we always allocate in one
* large chunk. */
- bitmap_blocks = 1 + OCFS_ALIGN(bits_wanted, OCFS_BITS_IN_CHUNK) /
- OCFS_BITS_IN_CHUNK;
+ bitmap_blocks = ocfs_blocks_for_bits(sb, bits_wanted) + 1;
- return(bitmap_blocks + OCFS_FILE_EXTEND_CREDITS);
+ return (bitmap_blocks + OCFS_FILE_EXTEND_CREDITS);
}
/* fe, anything along new 'edge' of tree + fuzz*/
Modified: branches/format-changes/src/super.c
===================================================================
--- branches/format-changes/src/super.c 2004-06-14 07:18:58 UTC (rev 1089)
+++ branches/format-changes/src/super.c 2004-06-14 08:17:13 UTC (rev 1090)
@@ -1652,7 +1652,9 @@
printk("bitmap_blkno=%llu, bitmap_blocks=%llu, num_clusters=%llu\n",
osb->bitmap_blkno, osb->bitmap_blocks, osb->num_clusters);
- ocfs_initialize_bitmap (&osb->cluster_bitmap, osb->num_clusters, OCFS_I(inode)->alloc_size << 3);
+ ocfs_initialize_bitmap(osb->sb, &osb->cluster_bitmap,
+ osb->num_clusters,
+ OCFS_I(inode)->alloc_size << 3);
/* read the whole cluster bitmap off disk, even though we only
* need the beginning of it. */
status = ocfs_read_bhs(osb, ret, OCFS_I(inode)->alloc_size,
More information about the Ocfs2-commits
mailing list