[Ocfs2-commits] rev 5 - in trunk: . inc
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Fri Nov 21 17:31:23 CST 2003
Author: manish
Date: 2003-11-21 17:31:21 -0600 (Fri, 21 Nov 2003)
New Revision: 5
Removed:
trunk/cluster.c
Modified:
trunk/Makefile
trunk/TODO
trunk/alloc.c
trunk/dlm.c
trunk/file.c
trunk/inc/ocfs.h
trunk/inc/ocfsio.h
trunk/inc/proto.h
trunk/journal.c
trunk/namei.c
trunk/nm.c
trunk/osb.c
trunk/sysfile.c
Log:
More sync
Modified: trunk/Makefile
===================================================================
--- trunk/Makefile 2003-11-21 23:10:37 UTC (rev 4)
+++ trunk/Makefile 2003-11-21 23:31:21 UTC (rev 5)
@@ -147,6 +147,8 @@
DEFINES += -DHAVE_NPTL
endif
+DEFINES += -DDEBUG_LOCK_BUFFER
+
ifeq ($(KVER),vmware)
KERNELINC = /usr/src/linux-2.4/include
endif
Modified: trunk/TODO
===================================================================
--- trunk/TODO 2003-11-21 23:10:37 UTC (rev 4)
+++ trunk/TODO 2003-11-21 23:31:21 UTC (rev 5)
@@ -1,21 +1,31 @@
-* get rid of osb->curr_trans_id as it was never used (always zero)
+* We need to recover previously dead nodes during our startup.
-* get rid of all the:
- changeSeqNum = osb->curr_trans_id;
- DISK_LOCK_SEQNUM(fe) = changeSeqNum;
- code as it is equally useless.
+* Fix all places in locking where we blindly take a lock on timeout without
+ checking whether a node is in recovery. Hearbeat thread needs to monitor
+ recovery processes.
+* fsck must be able to replay the journal
+
* merge and turn on the data alloc file
+* System files should be locked with cache lock, and we need inodes
+ for them so that we can cache our reads to them. This can also count
+ for the main bitmap. Data writes to the bitmap files can be
+ writethrough or journalled (with delayed playback).
+
* Make bitmap reads/writes only read/write those blocks which we care about
* Make bitmap free functions do their job without relocking the bitmaps for
each record.
-* We need to recover previously dead nodes during our startup.
+* Investigate whether we should put dirty cached writes into the
+ inodes dirty_data_buffers list or not. How does this interact with the
+ journalling code?
-* Fix all places in locking where we blindly take a lock on timeout without
- checking whether a node is in recovery. Hearbeat thread needs to monitor
- recovery processes.
+* get rid of osb->curr_trans_id as it was never used (always zero)
-* fsck must be able to replay the journal
+* get rid of all the:
+ changeSeqNum = osb->curr_trans_id;
+ DISK_LOCK_SEQNUM(fe) = changeSeqNum;
+ code as it is equally useless.
+
Modified: trunk/alloc.c
===================================================================
--- trunk/alloc.c 2003-11-21 23:10:37 UTC (rev 4)
+++ trunk/alloc.c 2003-11-21 23:31:21 UTC (rev 5)
@@ -10,6 +10,7 @@
/* Tracing */
#define OCFS_DEBUG_CONTEXT OCFS_DEBUG_CONTEXT_EXTENT
+static int ocfs_find_new_space_from_bitmap(ocfs_super *osb, __u64 file_size, __u64 *PClusterOffset, __u64 *PNumClusterAlloc, ocfs_file_entry *fe);
static int ocfs_allocate_new_data_node (ocfs_super * osb,
ocfs_file_entry * FileEntry,
@@ -18,7 +19,7 @@
__u64 * NewExtentOffset,
ocfs_journal_handle *handle, struct inode *inode);
-static int ocfs_grow_extent_tree (ocfs_super * osb, ocfs_file_entry * fe,
+static int ocfs_grow_extent_tree (ocfs_super * osb, struct buffer_head *fe_bh,
ocfs_journal_handle *handle, __u64 disk_off,
__u64 length, struct inode *inode);
@@ -810,7 +811,7 @@
/* ocfs_grow_extent_tree()
*
*/
-int ocfs_grow_extent_tree (ocfs_super * osb, ocfs_file_entry * fe, ocfs_journal_handle *handle, __u64 disk_off, __u64 length, struct inode *inode)
+int ocfs_grow_extent_tree (ocfs_super * osb, struct buffer_head *fe_bh, ocfs_journal_handle *handle, __u64 disk_off, __u64 length, struct inode *inode)
{
int status = 0;
__s32 k, i;
@@ -825,9 +826,22 @@
struct buffer_head **bhs = NULL;
int numbhs = 0;
void *buf;
+ ocfs_file_entry * fe = NULL, *real_fe = NULL;
LOG_ENTRY_ARGS("(0x%08x, 0x%08x, %u.%u, %u.%u\n", osb, fe, HILO(disk_off), HILO(length));
+ /* too complicated to deal with both reads and writes to the structure */
+ /* just save off a copy and replace the fe_bh with the new data at the end */
+ fe = ocfs_allocate_file_entry();
+ if (fe == NULL) {
+ LOG_ERROR_STATUS (status = -ENOMEM);
+ goto finally;
+ }
+ real_fe = (ocfs_file_entry *)OCFS_BH_GET_DATA(fe_bh);
+ memcpy(fe, real_fe, 512);
+ OCFS_BH_PUT_DATA(fe_bh);
+ real_fe = NULL;
+
AllocSize = ((fe->granularity + 2) * OCFS_SECTOR_SIZE);
numbhs = fe->granularity + 2;
@@ -1078,6 +1092,13 @@
finally:
+ if (fe) {
+ real_fe = (ocfs_file_entry *)OCFS_BH_GET_DATA(fe_bh);
+ memcpy(real_fe, fe, 512);
+ OCFS_BH_PUT_DATA(fe_bh);
+ real_fe = NULL;
+ ocfs_release_file_entry(fe);
+ }
LOG_EXIT_STATUS (status);
return (status);
} /* ocfs_grow_extent_tree */
@@ -1086,7 +1107,7 @@
* ocfs_allocate_extent()
*
*/
-int ocfs_allocate_extent (ocfs_super * osb, ocfs_inode * oin, ocfs_file_entry * FileEntry, ocfs_journal_handle *handle, __u64 actualDiskOffset, __u64 actualLength, struct inode *inode)
+int ocfs_allocate_extent (ocfs_super * osb, ocfs_inode * oin, struct buffer_head *fe_bh, ocfs_journal_handle *handle, __u64 actualDiskOffset, __u64 actualLength, struct inode *inode)
{
int status = 0;
bool IncreaseTreeDepth = false;
@@ -1095,9 +1116,11 @@
struct buffer_head *extent_bh = NULL, *extent_header_bh = NULL;
bool UpdateParent = false;
__u64 newExtentOff, up_ptr;
+ ocfs_file_entry * FileEntry = NULL;
LOG_ENTRY_ARGS("(actualDiskOffset=%u.%u, actualLength=%u.%u)\n", actualDiskOffset, actualLength);
+ FileEntry = (ocfs_file_entry *)OCFS_BH_GET_DATA(fe_bh);
OCFS_ASSERT (FileEntry);
if (!IS_VALID_FILE_ENTRY (FileEntry)) {
@@ -1362,7 +1385,18 @@
increase_depth:
if (IncreaseTreeDepth) {
- status = ocfs_grow_extent_tree(osb, FileEntry, handle, actualDiskOffset, actualLength, inode);
+ OCFS_BH_PUT_DATA(fe_bh);
+ FileEntry = NULL;
+ if (extent_bh && extent) {
+ OCFS_BH_PUT_DATA(extent_bh);
+ extent = NULL;
+ }
+ if (extent_header_bh && extent_header) {
+ OCFS_BH_PUT_DATA(extent_header_bh);
+ extent_header = NULL;
+ }
+
+ status = ocfs_grow_extent_tree(osb, fe_bh, handle, actualDiskOffset, actualLength, inode);
if (status < 0) {
LOG_ERROR_STATUS(status);
goto finally;
@@ -1379,6 +1413,9 @@
* ocfs_add_extent_map_entry merges them into a single
* mapping run.So just adding this entry will be
* fine. */
+ if (FileEntry == NULL)
+ FileEntry = (ocfs_file_entry *)OCFS_BH_GET_DATA(fe_bh);
+
Vbo = FileEntry->alloc_size;
Lbo = actualDiskOffset;
@@ -1402,6 +1439,9 @@
OCFS_BH_PUT_DATA(extent_header_bh);
brelse(extent_header_bh);
}
+ if (FileEntry) {
+ OCFS_BH_PUT_DATA(fe_bh);
+ }
LOG_EXIT_STATUS (status);
return (status);
} /* ocfs_allocate_extent */
@@ -2625,6 +2665,7 @@
__u32 LargeAlloc = 0;
static __u32 LargeAllocOffset = 0;
static __u32 SmallAllocOffset = 0;
+ __u64 startOffset = 0;
bool bLockAcquired = false;
ocfs_lock_res *pLockResource = NULL;
struct buffer_head *bh = NULL;
@@ -2637,131 +2678,143 @@
ocfs_down_sem (&(osb->vol_alloc_lock), true);
- /* Get the allocation lock here */
- status = ocfs_acquire_lock (osb, OCFS_BITMAP_LOCK_OFFSET,
- OCFS_DLM_EXCLUSIVE_LOCK /*OCFS_DLM_ENABLE_CACHE_LOCK*/, 0, &pLockResource,
- &bh, NULL);
- if (status < 0) {
- if (status != -EINTR)
+ /* always use global bitmap for clustersize > 128k, file_size > 2mb */
+#if 0
+ if (osb->vol_layout.cluster_size > (128*1024) || file_size > (2 * 1024 * 1024))
+#endif
+ if (true)
+ {
+ /* Get the allocation lock here */
+ status = ocfs_acquire_lock (osb, OCFS_BITMAP_LOCK_OFFSET,
+ OCFS_DLM_EXCLUSIVE_LOCK /*OCFS_DLM_ENABLE_CACHE_LOCK*/, 0, &pLockResource,
+ &bh, NULL);
+ if (status < 0) {
+ if (status != -EINTR)
+ LOG_ERROR_STATUS (status);
+ goto leave;
+ }
+ bLockAcquired = true;
+ bm_lock = (ocfs_bitmap_lock *)OCFS_BH_GET_DATA(bh);
+
+ ByteCount = file_size;
+
+ /* Round off the byte count to next clustersize (bytes per cluster) */
+ ByteCount += (ByteCount % (osb->vol_layout.cluster_size)) ?
+ (osb->vol_layout.cluster_size -
+ (ByteCount % (osb->vol_layout.cluster_size))) : 0;
+
+ if (ByteCount == 0) {
+ LOG_ERROR_STR ("DISK_FULL?: Bytecount==0");
+ status = 0;
+ goto leave;
+ }
+
+ ClusterCount =
+ (__u32) ((__u64) ByteCount / (__u64) osb->vol_layout.cluster_size);
+
+ if (sysfile ? (ClusterCount > osb->vol_layout.num_clusters) :
+ (ClusterCount > (osb->vol_layout.num_clusters -
+ ((8 * ONE_MEGA_BYTE) / osb->vol_layout.cluster_size)))){
+ LOG_ERROR_STR ("Disk Full");
+ status = -ENOSPC;
+ goto leave;
+ }
+
+ /* This function will check for clear bits in the Bitmap for consecutive */
+ /* clear bits equal to ClusterCount */
+
+ /* If we create a chunk that is larger than 5% of the disksize, then start */
+ /* allocation at 5%, so that small files stay in the beginning as much as possible */
+
+ if (ClusterCount > (osb->vol_layout.num_clusters / 20)) {
+ LargeAlloc = 1;
+ LargeAllocOffset = (osb->vol_layout.num_clusters / 20);
+ }
+
+ bitmapblocks = (OCFS_ALIGN(osb->cluster_bitmap.validbits, OCFS_BITS_IN_CHUNK) / OCFS_BITS_IN_CHUNK);
+
+ /* Ok, somewhat lame, but we submit the whole bitmap for reading here*/
+ if (ocfs_read_bhs(osb, osb->vol_layout.bitmap_off,
+ bitmapblocks * osb->sect_size,
+ osb->cluster_bitmap.chunk, 0, NULL)) {
+ LOG_ERROR_STATUS(-EIO);
+ goto leave;
+ }
+
+ bitoffset = ocfs_find_clear_bits (osb, &osb->cluster_bitmap,
+ ClusterCount,
+ LargeAlloc ? LargeAllocOffset :
+ SmallAllocOffset, sysfile ? 0 :
+ ((8 * ONE_MEGA_BYTE) / osb->vol_layout.cluster_size));
+
+ /* 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 file extention only */
+ /* right now if we run out of diskspace, we still have 8mb free for a systemfile */
+
+ if (bitoffset == -1 && LargeAlloc) {
+ LOG_TRACE_STR("Running low on diskspace.");
+ osb->cluster_bitmap.failed++;
+ bitoffset = ocfs_find_clear_bits (osb, &osb->cluster_bitmap,
+ ClusterCount, 0,
+ sysfile ? 0 :
+ ((8 * ONE_MEGA_BYTE) /
+ osb->vol_layout.cluster_size));
+ }
+
+ /* It returns -1 on failure, otherwise bitoffset points at the */
+ /* location inb bitmap from where there are ClusterCount no of bits */
+ /* are free. */
+
+ if (bitoffset == -1) {
+ if (sysfile)
+ LOG_ERROR_ARGS ("Cannot allocate %u contiguous clusters for system file\n",
+ ClusterCount);
+ status = -ENOSPC;
+ goto leave;
+ }
+
+ LOG_TRACE_ARGS ("byte offset=%u\n", bitoffset);
+
+ ocfs_set_bits (&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) - startbh + 1;
+
+ LOG_TRACE_ARGS("bitoffset = %u, ClusterCount = %u, startbh = %u, numblocks = %u\n", bitoffset, ClusterCount, startbh, numblocks);
+
+ status = ocfs_write_bhs(osb, &osb->cluster_bitmap.chunk[startbh],
+ numblocks, 0, NULL);
+ if (status < 0) {
LOG_ERROR_STATUS (status);
- goto leave;
- }
- bLockAcquired = true;
- bm_lock = (ocfs_bitmap_lock *)OCFS_BH_GET_DATA(bh);
-
- ByteCount = file_size;
-
- /* Round off the byte count to next clustersize (bytes per cluster) */
- ByteCount += (ByteCount % (osb->vol_layout.cluster_size)) ?
- (osb->vol_layout.cluster_size -
- (ByteCount % (osb->vol_layout.cluster_size))) : 0;
-
- if (ByteCount == 0) {
- LOG_ERROR_STR ("DISK_FULL?: Bytecount==0");
- status = 0;
- goto leave;
- }
-
- ClusterCount =
- (__u32) ((__u64) ByteCount / (__u64) osb->vol_layout.cluster_size);
-
- if (sysfile ? (ClusterCount > osb->vol_layout.num_clusters) :
- (ClusterCount > (osb->vol_layout.num_clusters -
- ((8 * ONE_MEGA_BYTE) / osb->vol_layout.cluster_size)))){
- LOG_ERROR_STR ("Disk Full");
- status = -ENOSPC;
- goto leave;
- }
-
- /* This function will check for clear bits in the Bitmap for consecutive */
- /* clear bits equal to ClusterCount */
-
- /* If we create a chunk that is larger than 5% of the disksize, then start */
- /* allocation at 5%, so that small files stay in the beginning as much as possible */
+ goto leave;
+ }
- if (ClusterCount > (osb->vol_layout.num_clusters / 20)) {
- LargeAlloc = 1;
- LargeAllocOffset = (osb->vol_layout.num_clusters / 20);
- }
+ /* write the bitmap size info to the lock sector */
+ /* TODO: optimize by making this part of ocfs_release_lock
+ * for now, it will be back-to-back writes to same sector */
+ bm_lock->used_bits = ocfs_count_bits(&osb->cluster_bitmap);
+ OCFS_BH_PUT_DATA(bh);
+ bm_lock = NULL;
- bitmapblocks = (OCFS_ALIGN(osb->cluster_bitmap.validbits, OCFS_BITS_IN_CHUNK) / OCFS_BITS_IN_CHUNK);
-
- /* Ok, somewhat lame, but we submit the whole bitmap for reading here*/
- if (ocfs_read_bhs(osb, osb->vol_layout.bitmap_off,
- bitmapblocks * osb->sect_size,
- osb->cluster_bitmap.chunk, 0, NULL)) {
- LOG_ERROR_STATUS(-EIO);
- goto leave;
+ status = ocfs_write_bh (osb, bh, 0, NULL);
+ if (status < 0) {
+ LOG_ERROR_STATUS (status);
+ goto leave;
+ }
+
+ *cluster_off = bitoffset;
+ *cluster_count = ClusterCount;
+ status = 0;
}
-
- bitoffset = ocfs_find_clear_bits (osb, &osb->cluster_bitmap,
- ClusterCount,
- LargeAlloc ? LargeAllocOffset :
- SmallAllocOffset, sysfile ? 0 :
- ((8 * ONE_MEGA_BYTE) / osb->vol_layout.cluster_size));
-
- /* 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 file extention only */
- /* right now if we run out of diskspace, we still have 8mb free for a systemfile */
-
- if (bitoffset == -1 && LargeAlloc) {
- LOG_TRACE_STR("Running low on diskspace.");
- osb->cluster_bitmap.failed++;
- bitoffset = ocfs_find_clear_bits (osb, &osb->cluster_bitmap,
- ClusterCount, 0,
- sysfile ? 0 :
- ((8 * ONE_MEGA_BYTE) /
- osb->vol_layout.cluster_size));
+#if 0
+ else {
+ status = ocfs_get_space_from_bitmap(osb, file_size, cluster_off, cluster_count);
}
+#endif
- /* It returns -1 on failure, otherwise bitoffset points at the */
- /* location inb bitmap from where there are ClusterCount no of bits */
- /* are free. */
-
- if (bitoffset == -1) {
- if (sysfile)
- LOG_ERROR_ARGS ("Cannot allocate %u contiguous clusters for system file\n",
- ClusterCount);
- status = -ENOSPC;
- goto leave;
- }
-
- LOG_TRACE_ARGS ("byte offset=%u\n", bitoffset);
-
- ocfs_set_bits (&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) - startbh + 1;
-
- LOG_TRACE_ARGS("bitoffset = %u, ClusterCount = %u, startbh = %u, numblocks = %u\n", bitoffset, ClusterCount, startbh, numblocks);
-
- status = ocfs_write_bhs(osb, &osb->cluster_bitmap.chunk[startbh],
- numblocks, 0, NULL);
- if (status < 0) {
- LOG_ERROR_STATUS (status);
- goto leave;
- }
-
- /* write the bitmap size info to the lock sector */
- /* TODO: optimize by making this part of ocfs_release_lock
- * for now, it will be back-to-back writes to same sector */
- bm_lock->used_bits = ocfs_count_bits(&osb->cluster_bitmap);
- OCFS_BH_PUT_DATA(bh);
- bm_lock = NULL;
-
- status = ocfs_write_bh (osb, bh, 0, NULL);
- if (status < 0) {
- LOG_ERROR_STATUS (status);
- goto leave;
- }
-
- *cluster_off = bitoffset;
- *cluster_count = ClusterCount;
- status = 0;
-
leave:
ocfs_up_sem (&(osb->vol_alloc_lock));
if (bm_lock != NULL)
@@ -3157,3 +3210,179 @@
LOG_EXIT_STATUS (status);
return status;
} /* ocfs_free_file_extents */
+
+
+#if 0
+int ocfs_get_space_from_bitmap(ocfs_super *osb, __u64 file_size, __u64 *PClusterOffset, __u64 *PNumClusterAlloc)
+{
+ int status = 0, ntStatus;
+ ocfs_file_entry * fe;
+ __u64 diskOffset, ByteCount = 0;
+ __u32 size = 0, ByteOffset =0, ClusterCount = 0;
+ __u64 numClusterAlloc = 0, BitmapOffset = 0
+ __u64 actualDiskOffset = 0;
+ __u64 csize = osb->vol_layout.cluster_size;
+ ocfs_lock_res *pLockResource;
+ ocfs_alloc_bm VolBitMap ;
+ void *bitMapBuffer = NULL;
+ __u32 bitMapSize;
+ bool bLockAcquired = false;
+ char *localBuf;
+ int i;
+
+ fe = osb->vol_bitmap_buf;
+
+ if (fe->file_size == 0) {
+ // Read in the file entry corresponding to this nodes volume bitmap file
+ diskOffset = ((OCFS_VOL_BITMAP_FILE + (2 * osb->node_num) ) * 512) + osb->vol_layout.root_int_off;
+ status = ocfs_read_force_disk( osb, fe, 1024, diskOffset);
+ if (status < 0)
+ goto bail;
+ fe->file_size = 1;
+ }
+
+
+ if (fe->AllocationSize != 0) {
+ ocfs_alloc_bm localNodeBitmap;
+ __u32 localBitMapSize;
+
+ ByteCount = file_size;
+ ByteCount += (ByteCount%csize ? csize - (ByteCount%csize) : 0);
+
+ if (ByteCount == 0) {
+ status = -ENOSPC;
+ goto bail;
+ }
+
+ ClusterCount = (__u32)(ByteCount / csize);
+
+ // Look in the local bitmap for the reqd number of bits
+ if(fe->extents[0].disk_off == 0 || fe->extents[0].num_bytes == 0) {
+ printk("something is messed\n");
+ }
+
+ localBitMapSize = (__u32)((fe->extents[0].num_bytes) / csize);
+ ocfs_initialize_bitmap(&localNodeBitmap, (__u32 *)(osb->vol_bitmap_buf + 512), localBitMapSize);
+ ByteOffset = ocfs_find_clear_bits (&localNodeBitmap, ClusterCount, 0);
+ if (ByteOffset != -1) {
+ ocfs_set_bits (&localNodeBitmap, ByteOffset, ClusterCount);
+
+ // For now Flush the bitmap here itself
+ diskOffset = ((OCFS_VOL_BITMAP_FILE + (2 * osb->node_num) ) * 512) +
+ osb->vol_layout.root_int_off;
+ status = ocfs_write_force_disk(osb, fe, (2 * 512), diskOffset);
+ if (status >= 0) {
+ *PClusterOffset = (__u32)(ByteOffset + (__u32)fe->extents[0].file_off);
+ *PNumClusterAlloc = ClusterCount;
+ }
+ goto bail;
+ }
+ }
+
+ // Failed to find anything, Allocate enough bits from the cluster bitmap.
+ ByteCount = (((__u64)(512 * 8))*csize) + file_size;
+ status = ocfs_acquire_lock(osb, OCFS_BITMAP_LOCK_OFFSET, OCFS_DLM_ENABLE_CACHE_LOCK, 0, &pLockResource, NULL);
+ if (status < 0)
+ goto bail;
+
+ bLockAcquired = true;
+ bitMapSize = (__u32)osb->vol_layout.num_clusters;
+ size = (__u32) OCFS_SECTOR_ALIGN((bitMapSize)/8) ;
+
+ // In the start one sector is for Volume header and second sector is for Global sequence Number and Directoy Entry.
+ bitMapBuffer = ocfs_malloc(((bitMapSize + 7) / 8) + 4096);
+ if (bitMapBuffer == NULL)
+ {
+ status = -ENOMEM;
+ goto bail;
+ }
+
+ status = ocfs_read_force_disk( osb, bitMapBuffer, size, osb->vol_layout.bitmap_off);
+ if (status < 0)
+ goto bail;
+
+ ocfs_initialize_bitmap( &VolBitMap, bitMapBuffer, bitMapSize);
+
+ // First clear the bits in the main bitmap which were not used in the local one
+ if (fe->AllocationSize != 0) {
+ __u32 offInMain = 0, freeOffset = 0;
+ ocfs_alloc_bm localBitmap;
+ __u32 localBitMapSize;
+
+ offInMain = (__u32)fe->extents[0].file_off;
+ localBitMapSize = (__u32)(fe->extents[0].num_bytes / csize);
+
+ ocfs_initialize_bitmap(&localBitmap, (__u32 *)(osb->vol_bitmap_buf + 512), localBitMapSize);
+
+ for(i = 0 ; i < (512* 8); i++) {
+ freeOffset = ocfs_find_clear_bits (&localBitmap, 1, 0);
+ if(freeOffset == -1)
+ break;
+ ocfs_set_bits (&localBitmap, freeOffset, 1);
+ freeOffset += offInMain ;
+ ocfs_clear_bits(&VolBitMap, freeOffset, 1);
+ }
+ }
+
+ // Round off the Byte Count to next ClusterSize(Bytes per cluster)
+ ByteCount += (ByteCount % csize ? csize - (ByteCount%csize) : 0);
+
+ if (ByteCount == 0) {
+ status = -ENOSPC;
+ goto bail;
+ }
+
+ ClusterCount = (__u32)(ByteCount/ csize);
+ if (ClusterCount > osb->vol_layout.num_clusters) {
+ status = -ENOSPC;
+ goto bail;
+ }
+
+ ByteOffset = ocfs_find_clear_bits (&VolBitMap, ClusterCount, 0);
+ if (ByteOffset == -1) {
+ status = -ENOSPC;
+ goto bail;
+ }
+
+ ocfs_set_bits (&VolBitMap, ByteOffset, ClusterCount);
+
+ status = ocfs_write_disk(osb, bitMapBuffer, size, osb->vol_layout.bitmap_off);
+ if (status < 0)
+ goto bail;
+
+ BitmapOffset = ByteOffset ;
+ numClusterAlloc = ClusterCount;
+ status = 0;
+
+ actualDiskOffset = (BitmapOffset * csize) + osb->vol_layout.data_start_off;
+
+ // Fill in the File Entry and Zero off the new local bitmap
+ fe->alloc_size = fe->extents[0].num_bytes = (((__u64)(512 * 8)) * csize);
+ fe->extents[0].disk_off = actualDiskOffset;
+ fe->extents[0].file_off = BitmapOffset;
+
+ memset((char *)osb->vol_bitmap_buf + 512, 0, 512);
+
+ diskOffset = ((OCFS_VOL_BITMAP_FILE + (2 * osb->node_num) ) * 512) +
+ osb->vol_layout.root_int_off;
+
+ status = ocfs_write_force_disk(osb, fe, (2 * 512), diskOffset);
+ if (status < 0)
+ goto bail;
+
+ *PClusterOffset = BitmapOffset + (512 * 8);
+ *PNumClusterAlloc = numClusterAlloc - (512 * 8);
+
+ status = 0;
+bail:
+ if( bLockAcquired ) {
+ ntStatus = ocfs_release_lock(osb, OCFS_BITMAP_LOCK_OFFSET, OCFS_DLM_EXCLUSIVE_LOCK, 0, pLockResource);
+ if (ntStatus < 0 && status >= 0)
+ status = ntStatus;
+ }
+
+ ocfs_safefree(bitMapBuffer)
+
+ return status;
+}
+#endif
Deleted: trunk/cluster.c
===================================================================
--- trunk/cluster.c 2003-11-21 23:10:37 UTC (rev 4)
+++ trunk/cluster.c 2003-11-21 23:31:21 UTC (rev 5)
@@ -1,36 +0,0 @@
-#include <ocfs.h>
-
-char *hostname=NULL;
-char *clustername=NULL;
-
-MODULE_LICENSE ("GPL");
-MODULE_AUTHOR("Oracle Corporation");
-MODULE_DESCRIPTION("Cluster");
-
-#ifdef LINUX_2_5
-module_param (hostname, charp, 0);
-module_param (clustername, charp, 0);
-#else /* LINUX_2_5 */
-MODULE_PARM (hostname, "s");
-MODULE_PARM_DESC(hostname, "Hostname of this machine in the cluster");
-MODULE_PARM (clustername, "s");
-MODULE_PARM_DESC(clustername, "Name of cluster");
-#endif
-
-
-static int __init driver_entry (void)
-{
- printk("Registering hostname %s as member of cluster %s\n", hostname, clustername);
- return 0;
-} /* ocfs_driver_entry */
-
-static void __exit driver_exit (void)
-{
- printk("De-registering hostname %s as member of cluster %s\n", hostname, clustername);
- return;
-} /* ocfs_driver_exit */
-
-
-
-module_init (driver_entry);
-module_exit (driver_exit);
Modified: trunk/dlm.c
===================================================================
--- trunk/dlm.c 2003-11-21 23:10:37 UTC (rev 4)
+++ trunk/dlm.c 2003-11-21 23:31:21 UTC (rev 5)
@@ -203,12 +203,13 @@
largestseqno = pubsect->publ_seq_num;
if (pubsect->dirty) {
OCFS_BH_PUT_DATA(bhs[i]);
- up_with_flag (&(osb->publish_lock), publish_flag);
if (!IS_NODE_ALIVE (pubmap, i, numnodes) &&
TEST_NODE_IN_RECOVERY(osb, i)) {
LOG_TRACE_STR("Node is in recovery, trying"
" again.");
} else {
+ up_with_flag (&(osb->publish_lock),
+ publish_flag);
get_random_bytes(&wait, sizeof(wait));
wait %= 200;
wait += OCFS_NM_HEARTBEAT_TIME;
@@ -253,6 +254,8 @@
status = -EAGAIN;
goto finally;
}
+
+ OCFS_BH_PUT_DATA(bhs[i]);
}
/* Increment the largest sequence number by one & */
Modified: trunk/file.c
===================================================================
--- trunk/file.c 2003-11-21 23:10:37 UTC (rev 4)
+++ trunk/file.c 2003-11-21 23:31:21 UTC (rev 5)
@@ -1055,15 +1055,19 @@
actualLength =
(__u64) (numClustersAlloc * osb->vol_layout.cluster_size);
+ OCFS_BH_PUT_DATA(bh);
+ fileEntry = NULL;
+
/* note: ok if oin is null here, not used in
* ocfs_allocate_extent */
- status = ocfs_allocate_extent (osb, oin, fileEntry, handle,
+ status = ocfs_allocate_extent (osb, oin, bh, handle,
actualDiskOffset, actualLength, inode);
if (status < 0) {
OCFS_BH_PUT_DATA(bh);
LOG_ERROR_STATUS (status);
goto leave;
}
+ fileEntry = (ocfs_file_entry *)OCFS_BH_GET_DATA(bh);
/* update the total allocation size here */
fileEntry->alloc_size += actualLength;
Modified: trunk/inc/ocfs.h
===================================================================
--- trunk/inc/ocfs.h 2003-11-21 23:10:37 UTC (rev 4)
+++ trunk/inc/ocfs.h 2003-11-21 23:31:21 UTC (rev 5)
@@ -1227,23 +1227,45 @@
if ((debug_level & OCFS_DEBUG_LEVEL_PRINTK) && \
(ocfs_getpid()!=debug_exclude))
+static inline void eat_value_int(int val)
+{
+ return;
+}
+
+static inline void eat_value_long(long val)
+{
+ return;
+}
+
+static inline void eat_value_ulong(unsigned long val)
+{
+ return;
+}
+
+static inline void eat_value_ptr(void *val)
+{
+ return;
+}
+
/* TRACE disabled. ERROR macros are never disabled. */
#if !defined(TRACE)
# define LOG_ENTRY()
# define LOG_EXIT()
-# define LOG_EXIT_STATUS(val) (val)
-# define LOG_EXIT_LONG(val) (val)
-# define LOG_EXIT_ULONG(val) (val)
-# define LOG_EXIT_PTR(val) (val)
+# define LOG_EXIT_STATUS(val) eat_value_int(val)
+# define LOG_EXIT_LONG(val) eat_value_long(val)
+# define LOG_EXIT_ULONG(val) eat_value_ulong(val)
+# define LOG_EXIT_PTR(val) eat_value_ptr(val)
# define LOG_TRACE_STR(str)
-# define LOG_TRACE_STATUS(val) (val)
+# define LOG_TRACE_STATUS(val) eat_value_int(val)
# define LOG_ENTRY_ARGS(fmt, arg...)
# define LOG_EXIT_ARGS(fmt, arg...)
# define LOG_TRACE_ARGS(fmt, arg...)
# define LOG_PID_PRINTK(fmt, arg...)
# define LOG_PID_STR(str)
-#endif /* !defined(TRACE) */
+#endif /* !defined(TRACE) */
+
+
/* TRACE enabled */
#if defined(TRACE)
Modified: trunk/inc/ocfsio.h
===================================================================
--- trunk/inc/ocfsio.h 2003-11-21 23:10:37 UTC (rev 4)
+++ trunk/inc/ocfsio.h 2003-11-21 23:31:21 UTC (rev 5)
@@ -16,8 +16,29 @@
#define OCFS_NONCACHED(osb,off) ((off) < (osb)->vol_layout.data_start_off)
+#ifdef DEBUG_LOCK_BUFFER
+#define LOCK_BUFFER_STR(bh) if (buffer_locked(bh)) \
+ printk("ocfs: (%d) BUFFER LOCKED! blocknr=%u\n", \
+ current->pid, (bh)->b_blocknr)
+#else
+#define LOCK_BUFFER_STR(bh)
+#endif
+
+#ifdef VERBOSE_DEBUG_LOCK_BUFFER
+#define VERBOSE_LOCK_BUFFER_STR(bh) printk("ocfs: (%d) locking buffer %u\n", \
+ current->pid, (bh)->b_blocknr)
+#define VERBOSE_UNLOCK_BUFFER_STR(bh) printk("ocfs: (%d) unlocking buffer %u\n", \
+ current->pid, (bh)->b_blocknr)
+#else
+#define VERBOSE_LOCK_BUFFER_STR(bh)
+#define VERBOSE_UNLOCK_BUFFER_STR(bh)
+#endif
+
+
#define OCFS_BH_GET_DATA(bh) ({ \
char *kaddr; \
+ LOCK_BUFFER_STR(bh); \
+ VERBOSE_LOCK_BUFFER_STR(bh); \
lock_buffer(bh); \
kaddr = kmap((bh)->b_page); \
if (kaddr) \
@@ -29,6 +50,7 @@
#define OCFS_BH_PUT_DATA(bh) ({ \
kunmap((bh)->b_page); \
+ VERBOSE_UNLOCK_BUFFER_STR(bh); \
unlock_buffer(bh); \
})
@@ -127,6 +149,8 @@
continue;
}
+ LOCK_BUFFER_STR(bh);
+ VERBOSE_LOCK_BUFFER_STR(bh);
lock_buffer(bh);
#ifdef LINUX_2_5
set_buffer_uptodate(bh);
@@ -141,6 +165,7 @@
flags &= ~OCFS_BH_CACHED;
}
unlock_buffer(bh);
+ VERBOSE_UNLOCK_BUFFER_STR(bh);
}
if (!(flags & OCFS_BH_CACHED))
@@ -214,6 +239,8 @@
}
if (!(flags & OCFS_BH_CACHED)) {
+ LOCK_BUFFER_STR(*bh);
+ VERBOSE_LOCK_BUFFER_STR(*bh);
lock_buffer(*bh);
if (!buffer_dirty(*bh))
#ifdef LINUX_2_5
@@ -222,6 +249,7 @@
mark_buffer_uptodate(*bh, false);
#endif
unlock_buffer(*bh);
+ VERBOSE_UNLOCK_BUFFER_STR(*bh);
}
status = 0;
@@ -314,6 +342,8 @@
}
if (!(flags & OCFS_BH_CACHED)) {
+ LOCK_BUFFER_STR(bh);
+ VERBOSE_LOCK_BUFFER_STR(bh);
lock_buffer(bh);
if (!buffer_dirty(bh))
#ifdef LINUX_2_5
@@ -322,6 +352,7 @@
mark_buffer_uptodate(bh, false);
#endif
unlock_buffer(bh);
+ VERBOSE_UNLOCK_BUFFER_STR(bh);
}
}
Modified: trunk/inc/proto.h
===================================================================
--- trunk/inc/proto.h 2003-11-21 23:10:37 UTC (rev 4)
+++ trunk/inc/proto.h 2003-11-21 23:31:21 UTC (rev 5)
@@ -1,4 +1,4 @@
-int ocfs_allocate_extent (ocfs_super * osb, ocfs_inode * oin, ocfs_file_entry * FileEntry, ocfs_journal_handle *handle,__u64 actualDiskOffset, __u64 actualLength, struct inode *inode);
+int ocfs_allocate_extent (ocfs_super * osb, ocfs_inode * oin, struct buffer_head *fe_bh, ocfs_journal_handle *handle,__u64 actualDiskOffset, __u64 actualLength, struct inode *inode);
int ocfs_kill_this_tree(ocfs_super *osb, struct buffer_head *extent_grp_bh, ocfs_bitmap_free_head *free_head, struct inode *inode);
int ocfs_free_extents_for_truncate (ocfs_super * osb, ocfs_file_entry * FileEntry, ocfs_journal_handle *handle, ocfs_bitmap_free_head *free_head, struct inode *inode);
int ocfs_lookup_file_allocation (ocfs_super * osb, ocfs_inode * oin, __s64 Vbo, __s64 * Lbo, __u32 sectors, u32 *sector_count, struct inode *inode);
Modified: trunk/journal.c
===================================================================
--- trunk/journal.c 2003-11-21 23:10:37 UTC (rev 4)
+++ trunk/journal.c 2003-11-21 23:31:21 UTC (rev 5)
@@ -537,7 +537,9 @@
lock = ocfs_malloc(sizeof(ocfs_journal_lock));
if (lock == NULL) {
LOG_ERROR_STR("Out of memory -- cannot add lock to release.");
- goto done;
+ LOG_ERROR_STATUS(-ENOMEM);
+
+ BUG();
}
lock->id = id;
@@ -551,7 +553,7 @@
if (bh)
get_bh(bh);
-done:
+
LOG_EXIT();
return;
}
Modified: trunk/namei.c
===================================================================
--- trunk/namei.c 2003-11-21 23:10:37 UTC (rev 4)
+++ trunk/namei.c 2003-11-21 23:31:21 UTC (rev 5)
@@ -166,22 +166,23 @@
if (status < 0) {
if (status != -EINTR)
LOG_ERROR_STATUS (status);
- goto leave_trans;
+ ocfs_abort_trans(handle);
+ goto leave;
}
+ /* Ok, we got the lock -- we'd better add it to our transaction */
+ ocfs_journal_add_lock(handle, parent_off, OCFS_DLM_EXCLUSIVE_LOCK,
+ FLAG_FILE_CREATE | FLAG_DIR, lock_res, lock_bh);
+
/* do the real work now. */
status = ocfs_mknod_locked(osb, dir, dentry, mode, dev, lock_bh,
&new_fe_bh, handle, inode);
- if (status < 0)
+ if (status < 0) {
if (status != -EINTR)
LOG_ERROR_STATUS(status);
-
-leave_trans:
- ocfs_journal_add_lock(handle, parent_off, OCFS_DLM_EXCLUSIVE_LOCK,
- FLAG_FILE_CREATE | FLAG_DIR, lock_res, lock_bh);
- if (status < 0)
ocfs_abort_trans(handle);
- else if (ocfs_commit_trans(handle) < 0)
+ goto leave;
+ } else if (ocfs_commit_trans(handle) < 0)
LOG_ERROR_STR("Could not complete create!");
status = ocfs_create_new_oin (&oin, 0ULL, osb);
Modified: trunk/nm.c
===================================================================
--- trunk/nm.c 2003-11-21 23:10:37 UTC (rev 4)
+++ trunk/nm.c 2003-11-21 23:31:21 UTC (rev 5)
@@ -943,8 +943,10 @@
}
memset(dir_bhs, 0, dirblks * sizeof(*dir_bhs));
- status = ocfs_read_bhs(osb, lock_id, dirblks,
- dir_bhs, OCFS_BH_CACHED, inode);
+ status = ocfs_read_bhs(osb, lock_id,
+ dirblks * osb->sect_size,
+ dir_bhs, OCFS_BH_CACHED,
+ inode);
if (status >= 0)
ocfs_release_dir_cache_lock(osb, dir_bhs, inode);
Modified: trunk/osb.c
===================================================================
--- trunk/osb.c 2003-11-21 23:10:37 UTC (rev 4)
+++ trunk/osb.c 2003-11-21 23:31:21 UTC (rev 5)
@@ -393,8 +393,8 @@
if (!mounted)
ocfs_journal_wipe(&osb->journal, 0);
else
- LOG_ERROR_STR("Dirty publish file system found, recovering" \
- " volume.");
+ printk(KERN_NOTICE "ocfs: File system was not unmounted "
+ "cleanly, recovering volume.\n");
/* will play back anything left in the journal. */
ocfs_journal_load(&osb->journal);
Modified: trunk/sysfile.c
===================================================================
--- trunk/sysfile.c 2003-11-21 23:10:37 UTC (rev 4)
+++ trunk/sysfile.c 2003-11-21 23:31:21 UTC (rev 5)
@@ -482,13 +482,17 @@
}
#endif
- status = ocfs_allocate_extent (osb, NULL, fe, handle,
+ OCFS_BH_PUT_DATA(fe_bh);
+ fe = NULL;
+
+ status = ocfs_allocate_extent (osb, NULL, fe_bh, handle,
actualDiskOffset, actualLength, NULL);
if (status < 0) {
LOG_ERROR_STATUS (status);
goto leave;
}
-
+
+ fe = (ocfs_file_entry *) OCFS_BH_GET_DATA(fe_bh);
fe->alloc_size += actualLength;
fe->file_size = FileSize;
}
More information about the Ocfs2-commits
mailing list