[Ocfs2-commits] mfasheh commits r1531 - branches/dlm-changes/src
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Thu Sep 30 20:33:30 CDT 2004
Author: mfasheh
Date: 2004-09-30 20:33:29 -0500 (Thu, 30 Sep 2004)
New Revision: 1531
Modified:
branches/dlm-changes/src/alloc.c
Log:
* local alloc for 32k was only getting half of what everyone else did
* ocfs_sync_local_to_main wasn't updating the main bitmap # used bits
properly.
* ocfs_local_alloc_full_window_change is now roll-forward only
Modified: branches/dlm-changes/src/alloc.c
===================================================================
--- branches/dlm-changes/src/alloc.c 2004-10-01 00:55:13 UTC (rev 1530)
+++ branches/dlm-changes/src/alloc.c 2004-10-01 01:33:29 UTC (rev 1531)
@@ -3481,7 +3481,7 @@
* into account in the following manner:
*
* 4k -> 1024 bits, 8k -> 512 bits, 16k -> 256 bits,
- * 32/64/128k -> 64 bits
+ * 32k -> 128 bits, 64k -> 64 bits
*/
static inline int ocfs_local_alloc_window_bits(ocfs_super *osb)
{
@@ -3500,6 +3500,10 @@
numbits = 256;
break;
+ case (32*1024):
+ numbits = 128;
+ break;
+
default:
numbits = 64;
break;
@@ -3568,12 +3572,14 @@
static int ocfs_sync_local_to_main(ocfs_super *osb,
ocfs_journal_handle *handle,
ocfs2_dinode *alloc,
- struct inode *main_bm_inode)
+ struct inode *main_bm_inode,
+ struct buffer_head *main_bm_bh)
{
int status = 0;
int bit_off, left;
void *bitmap;
unsigned int start, numblocks, bitmapblocks;
+ ocfs2_dinode *bm_fe;
LOG_ENTRY_ARGS("alloc->la_bm_bits = %u, COUNT = %u, la_bits_set = %u\n",
LOCAL_ALLOC(alloc)->la_bm_bits,
@@ -3609,6 +3615,14 @@
BUG();
}
+ bm_fe = (ocfs2_dinode *) main_bm_bh->b_data;
+ status = ocfs_journal_access(handle, main_bm_bh,
+ OCFS_JOURNAL_ACCESS_WRITE);
+ if (status < 0) {
+ LOG_ERROR_STATUS(status);
+ goto bail;
+ }
+
LOG_TRACE_ARGS("start=%u, alloc->la_bm_off = %u, numblocks=%u\n", start,
LOCAL_ALLOC(alloc)->la_bm_off, numblocks);
status = ocfs_read_bhs(osb,
@@ -3637,9 +3651,16 @@
ocfs_clear_bits(osb->sb, handle, &osb->cluster_bitmap,
bit_off + LOCAL_ALLOC(alloc)->la_bm_off,
1);
+ bm_fe->id1.bitmap1.i_used--;
bit_off++;
}
+ status = ocfs_journal_dirty(handle, main_bm_bh);
+ if (status < 0) {
+ LOG_ERROR_STATUS (status);
+ goto bail;
+ }
+
bail:
LOG_EXIT_STATUS(status);
@@ -3849,6 +3870,7 @@
struct inode *main_bm_inode = NULL;
ocfs_journal_handle *handle = NULL;
ocfs2_dinode *alloc;
+ ocfs2_dinode *alloc_copy = NULL;
LOG_ENTRY();
@@ -3887,24 +3909,39 @@
LOG_ERROR_STATUS (status);
goto bail;
}
+ ocfs_handle_set_always_commits(handle, 1);
+ alloc = (ocfs2_dinode *) osb->local_alloc_bh->b_data;
+
+ /* We want to clear the local alloc before doing anything
+ * else, so that if we error later during this operation,
+ * local alloc shutdown won't try to double free main bitmap
+ * bits. Make a copy so the sync function knows which bits to
+ * free. */
+ alloc_copy = kmalloc(osb->local_alloc_bh->b_size, GFP_KERNEL);
+ if (!alloc_copy) {
+ status = -ENOMEM;
+ goto bail;
+ }
+ memcpy(alloc_copy, alloc, osb->local_alloc_bh->b_size);
+
status = ocfs_journal_access(handle, osb->local_alloc_bh,
OCFS_JOURNAL_ACCESS_WRITE);
if (status < 0) {
LOG_ERROR_STATUS(status);
goto bail;
}
- alloc = (ocfs2_dinode *) osb->local_alloc_bh->b_data;
- status = ocfs_sync_local_to_main(osb, handle, alloc, main_bm_inode);
+ ocfs_clear_local_alloc(alloc);
+
+ status = ocfs_journal_dirty(handle, osb->local_alloc_bh);
if (status < 0) {
LOG_ERROR_STATUS(status);
goto bail;
}
- ocfs_clear_local_alloc(alloc);
-
- status = ocfs_journal_dirty(handle, osb->local_alloc_bh);
+ status = ocfs_sync_local_to_main(osb, handle, alloc_copy,
+ main_bm_inode, main_bm_bh);
if (status < 0) {
LOG_ERROR_STATUS(status);
goto bail;
@@ -3919,12 +3956,20 @@
atomic_inc(&osb->alloc_stats.moves);
- ocfs_commit_trans(handle);
status = 0;
bail:
- if ((status < 0) && handle)
- ocfs_abort_trans(handle);
+ if (handle)
+ ocfs_commit_trans(handle);
+ if (main_bm_bh)
+ brelse(main_bm_bh);
+
+ if (main_bm_inode)
+ iput(main_bm_inode);
+
+ if (alloc_copy)
+ kfree(alloc_copy);
+
LOG_EXIT_STATUS(status);
return(status);
}
More information about the Ocfs2-commits
mailing list