[Ocfs2-commits] mfasheh commits r1245 - trunk/src
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Wed Jul 7 17:20:39 CDT 2004
Author: mfasheh
Date: 2004-07-07 16:20:38 -0500 (Wed, 07 Jul 2004)
New Revision: 1245
Modified:
trunk/src/file.c
Log:
* reindent extend_file. yes this is silly but it took me about as long
as typing this commit message.
Modified: trunk/src/file.c
===================================================================
--- trunk/src/file.c 2004-07-07 20:57:50 UTC (rev 1244)
+++ trunk/src/file.c 2004-07-07 21:20:38 UTC (rev 1245)
@@ -1137,7 +1137,7 @@
brelse(bh);
bh = NULL;
-
+
status = ocfs_acquire_lock (osb, OCFS_LKM_EXMODE,
lockFlags, &bh, inode);
if (status < 0) {
@@ -1158,140 +1158,138 @@
fe = (ocfs2_dinode *) bh->b_data;
- if (file_size > (__s64)current_alloc) {
- alloc_size = file_size - current_alloc;
+ if (file_size <= (__s64)current_alloc)
+ goto no_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 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. */
+ alloc_size = file_size - current_alloc;
- if (!system_file) {
- int one_percentish_bits = 7;
- __u64 tempSize = 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 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. */
- if (tempSize > ONE_MEGA_BYTE)
- tempSize = ONE_MEGA_BYTE;
- alloc_size += (tempSize * 2);
-
- 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;
- alloc_size += tempSize;
- }
+ if (!system_file) {
+ int one_percentish_bits = 7;
+ __u64 tempSize = current_alloc;
- }
+ if (tempSize > ONE_MEGA_BYTE)
+ tempSize = ONE_MEGA_BYTE;
+ alloc_size += (tempSize * 2);
- status = ocfs_find_space(osb, alloc_size, &bitmapOffset,
- &numClustersAlloc, system_file, handle);
- LOG_TRACE_ARGS("find_space: alloc_size=%llu, returned off=%u, num=%u\n",
- alloc_size, bitmapOffset, numClustersAlloc);
- if (status < 0) {
- if (status != -ENOSPC && status != -EINTR)
- LOG_ERROR_STATUS (status);
- goto leave;
+ 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;
+ alloc_size += tempSize;
}
+ }
- block_off = ocfs_clusters_to_blocks(osb->sb,
- bitmapOffset);
- num_blocks = ocfs_clusters_to_blocks(osb->sb,
- numClustersAlloc);
+ status = ocfs_find_space(osb, alloc_size, &bitmapOffset,
+ &numClustersAlloc, system_file, handle);
+ LOG_TRACE_ARGS("find_space: alloc_size=%llu, returned off=%u"
+ ", num=%u\n", alloc_size, bitmapOffset,
+ numClustersAlloc);
+ if (status < 0) {
+ if (status != -ENOSPC && status != -EINTR)
+ LOG_ERROR_STATUS (status);
+ goto leave;
+ }
- fe = NULL;
+ block_off = ocfs_clusters_to_blocks(osb->sb,
+ bitmapOffset);
+ num_blocks = ocfs_clusters_to_blocks(osb->sb,
+ numClustersAlloc);
- if (system_file) {
- struct buffer_head **bhs = NULL;
- int i;
-
- bhs = kmalloc(num_blocks *
- sizeof(struct buffer_head *),
- GFP_KERNEL);
- if (!bhs) {
- status = -ENOMEM;
- LOG_ERROR_STATUS(status);
- goto leave;
- }
- memset(bhs, 0, num_blocks *
- sizeof(struct buffer_head *));
-
- status = ocfs_read_bhs(osb,
- block_off << osb->sb->s_blocksize_bits,
- (u64)num_blocks << osb->sb->s_blocksize_bits,
- bhs, 0,
- NULL);
- if (status < 0) {
- kfree(bhs);
- LOG_ERROR_STATUS(status);
- goto leave;
- }
-
- for (i = 0; i < num_blocks; i++) {
- memset(bhs[i]->b_data, 0, osb->sb->s_blocksize);
- }
-
- status = ocfs_write_bhs(osb, bhs, num_blocks, 0,
- NULL);
- for (i = 0; i < num_blocks; i++)
- brelse(bhs[i]);
- kfree(bhs);
- if (status < 0) {
- LOG_ERROR_STATUS(status);
- goto leave;
- }
- } else {
- struct buffer_head *alloc_bh;
- sector_t block;
- struct super_block *sb = osb->sb;
+ fe = NULL;
- for (block = block_off;
- block < (block_off + num_blocks);
- block++) {
- alloc_bh = sb_getblk(sb, block);
- if (!alloc_bh) {
- LOG_ERROR_STATUS(status=-EIO);
- goto leave;
- }
- LOG_TRACE_ARGS("setting block %llu as new!\n",
- (unsigned long long)block);
- alloc_bh->b_state |= (1UL << BH_New);
- brelse(alloc_bh);
- }
+ if (system_file) {
+ struct buffer_head **bhs = NULL;
+ int i;
+
+ bhs = kmalloc(num_blocks * sizeof(struct buffer_head *),
+ GFP_KERNEL);
+ if (!bhs) {
+ status = -ENOMEM;
+ LOG_ERROR_STATUS(status);
+ goto leave;
}
- ext_alloc_inode = ocfs_get_system_file_inode(osb, EXTENT_ALLOC_BITMAP_SYSTEM_INODE, osb->node_num);
- if (!ext_alloc_inode) {
- status = -EFAIL;
+ memset(bhs, 0, num_blocks *
+ sizeof(struct buffer_head *));
+
+ status = ocfs_read_bhs(osb,
+ block_off << osb->sb->s_blocksize_bits,
+ (u64)num_blocks << osb->sb->s_blocksize_bits,
+ bhs, 0,
+ NULL);
+ if (status < 0) {
+ kfree(bhs);
LOG_ERROR_STATUS(status);
goto leave;
}
- ocfs_handle_add_inode(handle, ext_alloc_inode);
- status = ocfs_allocate_extent(osb, bh, handle,
- block_off,
- numClustersAlloc,
- inode);
+ for (i = 0; i < num_blocks; i++)
+ memset(bhs[i]->b_data, 0, osb->sb->s_blocksize);
+
+ status = ocfs_write_bhs(osb, bhs, num_blocks, 0, NULL);
+ for (i = 0; i < num_blocks; i++)
+ brelse(bhs[i]);
+ kfree(bhs);
if (status < 0) {
- LOG_ERROR_STATUS (status);
+ LOG_ERROR_STATUS(status);
goto leave;
}
- fe = (ocfs2_dinode *) bh->b_data;
+ } else {
+ struct buffer_head *alloc_bh;
+ sector_t block;
+ struct super_block *sb = osb->sb;
- /* update the total allocation size here */
- fe->i_clusters += numClustersAlloc;
+ for (block = block_off;
+ block < (block_off + num_blocks);
+ block++) {
+ alloc_bh = sb_getblk(sb, block);
+ if (!alloc_bh) {
+ LOG_ERROR_STATUS(status=-EIO);
+ goto leave;
+ }
+ LOG_TRACE_ARGS("setting block %llu as new!\n",
+ (unsigned long long)block);
+ alloc_bh->b_state |= (1UL << BH_New);
+ brelse(alloc_bh);
+ }
+ }
+ ext_alloc_inode = ocfs_get_system_file_inode(osb, EXTENT_ALLOC_BITMAP_SYSTEM_INODE, osb->node_num);
+ if (!ext_alloc_inode) {
+ status = -EFAIL;
+ LOG_ERROR_STATUS(status);
+ goto leave;
+ }
- down (&(OCFS_I(inode)->ip_sem));
- OCFS_I(inode)->ip_alloc_size =
- (u64)fe->i_clusters << osb->s_clustersize_bits;
- up (&(OCFS_I(inode)->ip_sem));
-
- /* no need to do OCFS_SECTOR_ALIGN once the allocation size is correct. */
- DISK_LOCK(fe)->dl_seq_num = 0;
+ ocfs_handle_add_inode(handle, ext_alloc_inode);
+ status = ocfs_allocate_extent(osb, bh, handle, block_off,
+ numClustersAlloc, inode);
+ if (status < 0) {
+ LOG_ERROR_STATUS (status);
+ goto leave;
}
+ fe = (ocfs2_dinode *) bh->b_data;
+ /* update the total allocation size here */
+ fe->i_clusters += numClustersAlloc;
+
+ down (&(OCFS_I(inode)->ip_sem));
+ OCFS_I(inode)->ip_alloc_size =
+ (u64)fe->i_clusters << osb->s_clustersize_bits;
+ up (&(OCFS_I(inode)->ip_sem));
+
+ /* no need to do OCFS_SECTOR_ALIGN once the allocation size is
+ * correct. */
+ DISK_LOCK(fe)->dl_seq_num = 0;
+
+no_alloc:
/* Update tha file size and add the new one to old one. */
fe->i_size = file_size;
LOG_TRACE_ARGS("fe: i_clusters = %u, i_size=%llu\n",
More information about the Ocfs2-commits
mailing list