[Ocfs2-commits] jlbec commits r1508 - branches/dlm-changes/src
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Wed Sep 29 13:44:08 CDT 2004
Author: jlbec
Date: 2004-09-29 13:44:07 -0500 (Wed, 29 Sep 2004)
New Revision: 1508
Modified:
branches/dlm-changes/src/ocfs.h
branches/dlm-changes/src/suballoc.c
Log:
o Add OCFS_ASSERT_RO() to notice places where we really should be
remounting RO.
o Fix suballoc.c to use OCFS_ASSERT_RO()
Modified: branches/dlm-changes/src/ocfs.h
===================================================================
--- branches/dlm-changes/src/ocfs.h 2004-09-29 02:43:09 UTC (rev 1507)
+++ branches/dlm-changes/src/ocfs.h 2004-09-29 18:44:07 UTC (rev 1508)
@@ -98,6 +98,13 @@
/* convenience macro */
#define OCFS_ASSERT(x) do { if (!(x)) BUG(); } while (0)
+#define OCFS_ASSERT_RO(x) \
+ do { \
+ if (!(x)) { \
+ printk(KERN_ERR "This should make the filesystem remount RO\n"); \
+ BUG(); \
+ } \
+ } while (0)
#define BITCOUNT(x) (((BX_(x)+(BX_(x)>>4)) & 0x0F0F0F0F) % 255)
Modified: branches/dlm-changes/src/suballoc.c
===================================================================
--- branches/dlm-changes/src/suballoc.c 2004-09-29 02:43:09 UTC (rev 1507)
+++ branches/dlm-changes/src/suballoc.c 2004-09-29 18:44:07 UTC (rev 1508)
@@ -383,8 +383,8 @@
ocfs_handle_add_inode(handle, alloc_inode);
fe = (ocfs2_dinode *) bh->b_data;
- OCFS_ASSERT(IS_VALID_FILE_ENTRY(fe));
- OCFS_ASSERT(fe->i_flags & OCFS2_CHAIN_FL);
+ OCFS_ASSERT_RO(IS_VALID_FILE_ENTRY(fe));
+ OCFS_ASSERT_RO(fe->i_flags & OCFS2_CHAIN_FL);
if (bits_wanted > (le32_to_cpu(fe->id1.bitmap1.i_total) -
le32_to_cpu(fe->id1.bitmap1.i_used))) {
@@ -521,7 +521,7 @@
u16 best_offset, best_size;
int offset, start, found, status = 0;
- OCFS_ASSERT(IS_VALID_GROUP_DESC(bg));
+ OCFS_ASSERT_RO(IS_VALID_GROUP_DESC(bg));
found = start = best_offset = best_size = 0;
bitmap = bg->bg_bitmap;
@@ -577,7 +577,7 @@
LOG_ENTRY();
- OCFS_ASSERT(IS_VALID_GROUP_DESC(bg));
+ OCFS_ASSERT_RO(IS_VALID_GROUP_DESC(bg));
OCFS_ASSERT(bg->bg_free_bits_count >= num_bits);
LOG_TRACE_ARGS("block_group_set_bits: off = %u, num = %u\n", bit_off,
@@ -640,9 +640,9 @@
ocfs2_group_desc *bg = (ocfs2_group_desc *) bg_bh->b_data;
ocfs2_group_desc *prev_bg = (ocfs2_group_desc *) prev_bg_bh->b_data;
- OCFS_ASSERT(IS_VALID_FILE_ENTRY(fe));
- OCFS_ASSERT(IS_VALID_GROUP_DESC(bg));
- OCFS_ASSERT(IS_VALID_GROUP_DESC(prev_bg));
+ OCFS_ASSERT_RO(IS_VALID_FILE_ENTRY(fe));
+ OCFS_ASSERT_RO(IS_VALID_GROUP_DESC(bg));
+ OCFS_ASSERT_RO(IS_VALID_GROUP_DESC(prev_bg));
printk("In suballoc %llu, chain %u, move group %llu to top, "
"prev = %llu\n", fe->i_blkno, chain, bg->bg_blkno,
@@ -739,8 +739,8 @@
OCFS_ASSERT(ac->ac_bh);
fe = (ocfs2_dinode *) ac->ac_bh->b_data;
- OCFS_ASSERT(IS_VALID_FILE_ENTRY(fe));
- OCFS_ASSERT(fe->id1.bitmap1.i_used < fe->id1.bitmap1.i_total);
+ OCFS_ASSERT_RO(IS_VALID_FILE_ENTRY(fe));
+ OCFS_ASSERT_RO(fe->id1.bitmap1.i_used < fe->id1.bitmap1.i_total);
cl = (ocfs2_chain_list *) &fe->id2.i_chain;
@@ -760,27 +760,19 @@
}
bg = (ocfs2_group_desc *) group_bh->b_data;
- OCFS_ASSERT(IS_VALID_GROUP_DESC(bg));
+ OCFS_ASSERT_RO(IS_VALID_GROUP_DESC(bg));
/* for now, the chain search is a bit simplistic. We just use
* the 1st group with any empty bits. */
groups_read = 1;
while (!bg->bg_free_bits_count) {
- /* TODO: Self optimizing block groups. Here's how:
- * Keep track of previous block descriptor read. When
- * we find a target, if we have read more than X
- * number of descriptors, and the target is reasonably
- * empty, relink him to top of his chain.
- *
- * prev_bg->bg_next_group = bg->bg_next_group;
- * bg->bg_next_group = fe->id2.i_chain.cl_recs[chain].c_blkno;
- * fe->id2.i_chain.cl_recs[chain].c_blkno = bg->bg_blkno;
- *
- * We've read 0 extra blocks and only send one more to
- * the transaction, yet the next guy to search has a
- * much easier time.
+ /*
+ * This means we've walked off the end of a chain that
+ * we thought had bits, but didn't. While this
+ * _could_ be a code error, it is more likely to be
+ * corruption on disk.
*/
- OCFS_ASSERT(bg->bg_next_group);
+ OCFS_ASSERT_RO(bg->bg_next_group);
if (prev_group_bh) {
brelse(prev_group_bh);
@@ -800,10 +792,24 @@
}
groups_read++;
bg = (ocfs2_group_desc *) group_bh->b_data;
- OCFS_ASSERT(IS_VALID_GROUP_DESC(bg));
+ OCFS_ASSERT_RO(IS_VALID_GROUP_DESC(bg));
}
#define OCFS2_BG_RELINK_TRIGGER 1
+ /*
+ * Keep track of previous block descriptor read. When
+ * we find a target, if we have read more than X
+ * number of descriptors, and the target is reasonably
+ * empty, relink him to top of his chain.
+ *
+ * prev_bg->bg_next_group = bg->bg_next_group;
+ * bg->bg_next_group = fe->id2.i_chain.cl_recs[chain].c_blkno;
+ * fe->id2.i_chain.cl_recs[chain].c_blkno = bg->bg_blkno;
+ *
+ * We've read 0 extra blocks and only send one more to
+ * the transaction, yet the next guy to search has a
+ * much easier time.
+ */
if ((prev_group_bh)
&& (groups_read > OCFS2_BG_RELINK_TRIGGER)
&& (ocfs_block_group_reasonably_empty(bg))) {
@@ -977,7 +983,7 @@
LOG_ENTRY();
- OCFS_ASSERT(IS_VALID_FILE_ENTRY(fe));
+ OCFS_ASSERT_RO(IS_VALID_FILE_ENTRY(fe));
OCFS_ASSERT((count + start_bit)
<= ((u32) cl->cl_cpg * (u32) cl->cl_bpc));
@@ -998,7 +1004,7 @@
}
group = (ocfs2_group_desc *) group_bh->b_data;
- OCFS_ASSERT(IS_VALID_GROUP_DESC(group));
+ OCFS_ASSERT_RO(IS_VALID_GROUP_DESC(group));
status = ocfs_journal_access(handle, group_bh,
OCFS_JOURNAL_ACCESS_WRITE);
More information about the Ocfs2-commits
mailing list