[Ocfs2-commits] mfasheh commits r1537 - branches/dlm-changes/src
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Fri Oct 1 16:12:53 CDT 2004
Author: mfasheh
Date: 2004-10-01 16:12:52 -0500 (Fri, 01 Oct 2004)
New Revision: 1537
Modified:
branches/dlm-changes/src/alloc.c
branches/dlm-changes/src/alloc.h
branches/dlm-changes/src/ocfs.h
branches/dlm-changes/src/ocfs_journal.h
Log:
* fix up delete for header blocks
* clean up the free_disk_bitmap stuff a little more, but not to much as
it'll be going away after we fix truncate anyway.
Modified: branches/dlm-changes/src/alloc.c
===================================================================
--- branches/dlm-changes/src/alloc.c 2004-10-01 21:09:48 UTC (rev 1536)
+++ branches/dlm-changes/src/alloc.c 2004-10-01 21:12:52 UTC (rev 1537)
@@ -102,9 +102,6 @@
static int ocfs_update_last_eb_blk(ocfs_super *osb, ocfs2_dinode *fe,
struct inode *inode);
-static int ocfs_free_vol_block (ocfs_super * osb, ocfs_journal_handle *handle,
- ocfs_free_rec * FreeLog, __u32 NodeNum);
-
static int ocfs_free_disk_bitmap (ocfs_super * osb, ocfs_free_rec *free_log);
static inline int ocfs_free_main_bitmap(ocfs_super *osb,
@@ -198,29 +195,32 @@
int ocfs_add_to_bitmap_free_head(ocfs_super *osb,
ocfs_bitmap_free_head *f,
- __u32 len, __u32 fileoff,
- __u32 nodenum, __u32 type)
+ u32 len, u32 fileoff,
+ u32 nodenum, u64 blkno, u32 type)
{
int status = 0, n;
ocfs_free_rec *log;
ocfs_bitmap_update *fb;
- LOG_ENTRY_ARGS("(len = %u, fileoff = %u, nodenum = %u, "
- "type=%d (\"%s\")\n", len, fileoff, nodenum, type,
+ LOG_ENTRY_ARGS("(len = %u, fileoff = %u, nodenum = %u, blk = %llu"
+ "type=%d (\"%s\")\n", len, fileoff, nodenum,
+ blkno, type,
(type == DISK_ALLOC_VOLUME) ? "DISK_ALLOC_VOLUME" :
- ( (type == DISK_ALLOC_EXTENT_NODE) ?
- "DISK_ALLOC_EXTENT_NODE" : "DISK_ALLOC_INODE" ));
+ "DISK_ALLOC_EXTENT_NODE");
if (len == 0) {
printk("ocfs2: Zero length delete!\n");
printk("(len = %u, fileoff = %u, nodenum = %u, "
"type=%d (\"%s\")\n", len, fileoff, nodenum, type,
(type == DISK_ALLOC_VOLUME) ? "DISK_ALLOC_VOLUME" :
- ( (type == DISK_ALLOC_EXTENT_NODE) ?
- "DISK_ALLOC_EXTENT_NODE" : "DISK_ALLOC_INODE" ));
+ "DISK_ALLOC_EXTENT_NODE");
BUG();
}
+ /* right now we don't support this. */
+ if ((type == DISK_ALLOC_EXTENT_NODE) && (nodenum != 0))
+ BUG();
+
log = f->tail;
/* need a new one? */
@@ -246,6 +246,7 @@
fb->file_off = fileoff;
fb->type = type;
fb->node_num = nodenum;
+ fb->blkno = blkno;
log->num_updates++;
done:
@@ -253,6 +254,21 @@
return(status);
}
+static inline void ocfs_copy_update(ocfs_free_rec *rec,
+ ocfs_bitmap_update *fb2)
+{
+ int idx = rec->num_updates;
+ ocfs_bitmap_update *fb1 = &(rec->update[idx]);
+
+ fb1->length = fb2->length;
+ fb1->file_off = fb2->file_off;
+ fb1->type = fb2->type;
+ fb1->node_num = fb2->node_num;
+ fb1->blkno = fb2->blkno;
+ rec->num_updates++;
+ return;
+}
+
/*
* ocfs_free_disk_bitmap()
*
@@ -260,101 +276,67 @@
static int ocfs_free_disk_bitmap (ocfs_super * osb, ocfs_free_rec *free_log)
{
int status = 0;
- __u32 num_upd;
- __u32 i;
-// __u32 node_num;
- ocfs_free_rec **ext_alloc_free = NULL;
- ocfs_free_rec *free_vol_bits = NULL;
- ocfs_free_rec *tmp_log = NULL;
- struct inode **ext_alloc_inode = NULL;
+ int i;
+ ocfs_free_rec *ext_alloc_free = NULL;
+ ocfs_free_rec *vol_alloc_free = NULL;
+ struct inode *ext_alloc_inode = NULL;
struct inode *vol_inode = NULL;
- __u32 tmp_indx;
- struct buffer_head *globalbh = NULL;
- struct buffer_head *tmpbh = NULL;
+ struct buffer_head *vol_alloc_bh = NULL;
+ struct buffer_head *ext_alloc_bh = NULL;
ocfs_journal_handle *handle = NULL;
- int credits = 33; /* one for each potential sysfile fe. This
- * goes away when ocfs_ugly_hack goes
- * away. */
+ int credits = 0; /* sysfile fe's. */
+ ocfs_bitmap_update *tmp;
LOG_ENTRY_ARGS ("(0x%p, 0x%p)\n", osb, free_log);
-#define ALLOC_BLOCK(ptr, len, err) \
- do { \
- (ptr) = ocfs_malloc (len); \
- if (!(ptr)) { \
- LOG_ERROR_STATUS ((err) = -ENOMEM); \
- goto finally; \
- } \
- } while (0)
+ for (i = 0; i < free_log->num_updates; i++) {
+// OCFS_ASSERT(
+// (free_log->update[i].type == DISK_ALLOC_EXTENT_NODE)
+// || (free_log->update[i].type == DISK_ALLOC_VOLUME));
+ if ((free_log->update[i].type != DISK_ALLOC_EXTENT_NODE)
+ && (free_log->update[i].type != DISK_ALLOC_VOLUME)) {
+ printk("num_updates = %u, i=%d\n",
+ free_log->num_updates, i);
+ printk("length: %llu\n", free_log->update[i].length);
+ printk("file_off: %llu\n",
+ free_log->update[i].file_off);
+ printk("type: %u\n", free_log->update[i].type);
+ printk("node_num: %d\n", free_log->update[i].node_num);
+ printk("blkno: %llu\n", free_log->update[i].blkno);
+ BUG();
+ }
- ALLOC_BLOCK(ext_alloc_free,
- osb->max_nodes * sizeof (ocfs_free_rec *), status);
- ALLOC_BLOCK(ext_alloc_inode,
- osb->max_nodes * sizeof (struct inode *), status);
- /* init */
- for (i = 0; i < osb->max_nodes; i++) {
- ext_alloc_free[i] = NULL;
- ext_alloc_inode[i] = NULL;
- }
-
- num_upd = free_log->num_updates;
- for (i = 0; i < num_upd; i++) {
- switch (free_log->update[i].type) {
- case DISK_ALLOC_EXTENT_NODE:
-#if 0
- node_num = free_log->update[i].node_num;
- if (ext_alloc_free[node_num] == NULL) {
- ext_alloc_free[node_num] =
+ if (free_log->update[i].type == DISK_ALLOC_EXTENT_NODE) {
+ if (!ext_alloc_free) {
+ ext_alloc_free =
+ ocfs_malloc(sizeof(ocfs_free_rec));
+ if (!ext_alloc_free) {
+ LOG_ERROR_STATUS(status = -ENOMEM);
+ goto finally;
+ }
+ ext_alloc_free->num_updates = 0;
+ credits++; /* for the fe updates */
+ }
+ credits++;
+ ocfs_copy_update(ext_alloc_free,
+ &(free_log->update[i]));
+ } else {
+ if (vol_alloc_free == NULL) {
+ vol_alloc_free =
ocfs_malloc (sizeof (ocfs_free_rec));
- if (ext_alloc_free[node_num] == NULL) {
- LOG_ERROR_STATUS (status = -ENOMEM);
- goto finally;
- }
- ext_alloc_free[node_num]->num_updates = 0;
- }
- tmp_log = ext_alloc_free[node_num];
-
- credits++;
-#endif
- break;
-
- case DISK_ALLOC_VOLUME:
- if (free_vol_bits == NULL) {
- free_vol_bits =
- ocfs_malloc (sizeof (ocfs_free_rec));
- if (free_vol_bits == NULL) {
- LOG_ERROR_STATUS (status = -ENOMEM);
- goto finally;
- }
- free_vol_bits->num_updates = 0;
- }
- tmp_log = free_vol_bits;
-
- credits += ocfs_blocks_for_bits(osb->sb,
- free_log->update[i].length);
- break;
-
- default:
- tmp_log = NULL;
- break;
+ if (vol_alloc_free == NULL) {
+ LOG_ERROR_STATUS (status = -ENOMEM);
+ goto finally;
+ }
+ vol_alloc_free->num_updates = 0;
+ credits++; /* for the fe updates */
+ }
+ credits += ocfs_blocks_for_bits(osb->sb,
+ free_log->update[i].length);
+ ocfs_copy_update(vol_alloc_free,
+ &(free_log->update[i]));
}
-
- if (tmp_log) {
- ocfs_bitmap_update *fb1, *fb2;
-
- tmp_indx = tmp_log->num_updates;
-
- fb1 = &(tmp_log->update[tmp_indx]);
- fb2 = &(free_log->update[i]);
-
- fb1->length = fb2->length;
- fb1->file_off = fb2->file_off;
- fb1->type = fb2->type;
- fb1->node_num = fb2->node_num;
-
- tmp_log->num_updates++;
- }
}
handle = ocfs_alloc_handle(osb);
@@ -364,50 +346,42 @@
goto finally;
}
- for (i = 0; i < osb->max_nodes; i++) {
- if (ext_alloc_free[i] != NULL) {
- ext_alloc_inode[i] =
- ocfs_get_system_file_inode(osb, EXTENT_ALLOC_SYSTEM_INODE, i);
- if (!ext_alloc_inode[i]) {
- status = -EINVAL;
- LOG_ERROR_STATUS (status);
- goto finally;
- }
+ if (ext_alloc_free) {
+ ext_alloc_inode =
+ ocfs_get_system_file_inode(osb,
+ EXTENT_ALLOC_SYSTEM_INODE,
+ 0);
+ if (!ext_alloc_inode) {
+ status = -EINVAL;
+ LOG_ERROR_STATUS (status);
+ goto finally;
+ }
- status = ocfs_acquire_lock (osb,
- OCFS_LKM_EXMODE,
- 0,
- &tmpbh,
- ext_alloc_inode[i]);
- if (tmpbh) {
- brelse(tmpbh);
- tmpbh = NULL;
- }
- if (status < 0) {
- iput(ext_alloc_inode[i]);
- ext_alloc_inode[i] = NULL;
- if (status != -EINTR)
- LOG_ERROR_STATUS (status);
- goto finally;
- }
- ocfs_handle_add_lock(handle, OCFS_LKM_EXMODE,
- 0,
- ext_alloc_inode[i]);
- ocfs_handle_add_inode(handle, ext_alloc_inode[i]);
+ status = ocfs_acquire_lock (osb, OCFS_LKM_EXMODE, 0,
+ &ext_alloc_bh, ext_alloc_inode);
+ if (status < 0) {
+ if (status != -EINTR)
+ LOG_ERROR_STATUS (status);
+ goto finally;
}
+ ocfs_handle_add_lock(handle, OCFS_LKM_EXMODE, 0,
+ ext_alloc_inode);
+ ocfs_handle_add_inode(handle, ext_alloc_inode);
}
- if (free_vol_bits != NULL) {
- vol_inode = ocfs_get_system_file_inode(osb, GLOBAL_BITMAP_SYSTEM_INODE, -1);
+ if (vol_alloc_free) {
+ vol_inode =
+ ocfs_get_system_file_inode(osb,
+ GLOBAL_BITMAP_SYSTEM_INODE,
+ -1);
if (!vol_inode) {
status = -EINVAL;
LOG_ERROR_STATUS (status);
goto finally;
}
- status = ocfs_acquire_lock(osb, OCFS_LKM_EXMODE,
- 0,
- &globalbh, vol_inode);
+ status = ocfs_acquire_lock(osb, OCFS_LKM_EXMODE, 0,
+ &vol_alloc_bh, vol_inode);
if (status < 0) {
iput(vol_inode);
vol_inode = NULL;
@@ -429,45 +403,46 @@
}
ocfs_handle_set_always_commits(handle, 1);
- if (free_vol_bits)
+ if (vol_alloc_free)
ocfs_free_main_bitmap(osb, handle, vol_inode,
- globalbh, free_vol_bits);
+ vol_alloc_bh, vol_alloc_free);
- for (i = 0; i < osb->max_nodes; i++) {
- if (ext_alloc_free[i] != NULL)
- ocfs_free_vol_block(osb, handle,
- ext_alloc_free[i], i);
- }
+ if (ext_alloc_free)
+ for (i = 0; i < ext_alloc_free->num_updates; i++) {
+ tmp = &(ext_alloc_free->update[i]);
+ status = ocfs_free_suballoc_bits(osb,
+ handle,
+ ext_alloc_inode,
+ ext_alloc_bh,
+ (unsigned int)
+ tmp->file_off,
+ tmp->blkno,
+ 1);
+ if (status < 0) {
+ LOG_ERROR_STATUS (status);
+ goto finally;
+ }
+ }
finally:
if (handle)
ocfs_commit_trans(handle);
- if (ext_alloc_inode) {
- for (i = 0; i < osb->max_nodes; i++) {
- if (ext_alloc_inode[i])
- iput(ext_alloc_inode[i]);
- }
- kfree(ext_alloc_inode);
- }
-
+ if (ext_alloc_inode)
+ iput(ext_alloc_inode);
if (vol_inode)
iput(vol_inode);
- if (globalbh)
- brelse(globalbh);
+ if (vol_alloc_bh)
+ brelse(vol_alloc_bh);
+ if (ext_alloc_bh)
+ brelse(ext_alloc_bh);
- if (ext_alloc_free) {
- for (i = 0; i < osb->max_nodes; i++) {
- if (ext_alloc_free[i])
- kfree(ext_alloc_free[i]);
- }
+ if (ext_alloc_free)
kfree(ext_alloc_free);
- }
+ if (vol_alloc_free)
+ kfree(vol_alloc_free);
- if (free_vol_bits)
- kfree(free_vol_bits);
-
LOG_EXIT_STATUS (status);
return status;
} /* ocfs_free_disk_bitmap */
@@ -526,86 +501,6 @@
}
/*
- * ocfs_free_vol_block()
- *
- */
-static int ocfs_free_vol_block(ocfs_super *osb,
- ocfs_journal_handle *handle,
- ocfs_free_rec *FreeLog, __u32 NodeNum)
-{
- int status = 0;
- __u64 fileSize = 0;
- __u64 allocSize = 0;
- __u32 foundBit = -1;
- __u32 blockSize = 0, blockSizeBits = 0;
- int file_type;
- __u32 bitmapblocks = 0;
- ocfs_alloc_bm AllocBitmap;
- ocfs_alloc_bm *tmpbitmap = NULL;
- __u32 i;
- struct inode *inode = NULL;
-
- LOG_ENTRY ();
-
- LOG_TRACE_ARGS("Free Log Details\n");
- LOG_TRACE_ARGS("num_updates = %u\n", FreeLog->num_updates);
- for(i = 0; i < FreeLog->num_updates; i++)
- LOG_TRACE_ARGS("(upd=%u, length=%llu, file_off=%llu, type=%d, node_num=%d)\n",
- i, FreeLog->update[i].length, FreeLog->update[i].file_off,
- FreeLog->update[i].type, FreeLog->update[i].node_num);
-
- file_type = EXTENT_ALLOC_SYSTEM_INODE;
- blockSize = osb->sb->s_blocksize;
- blockSizeBits = osb->sb->s_blocksize_bits;
-
- if (NodeNum >= osb->max_nodes) {
- LOG_ERROR_STATUS(status = -EINVAL);
- goto leave;
- }
-
- inode = ocfs_get_system_file_inode(osb, file_type, NodeNum);
- if (!inode) {
- LOG_ERROR_STATUS (status = -EINVAL);
- goto leave;
- }
- fileSize = inode->i_size;
- allocSize = OCFS_I(inode)->ip_alloc_size;
-
- ocfs_initialize_bitmap(osb->sb, &AllocBitmap, fileSize * 8,
- allocSize * 8);
-
- tmpbitmap = &AllocBitmap;
- 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);
- if (status < 0) {
- LOG_ERROR_STATUS (status);
- goto leave;
- }
-
- for (i = 0; i < FreeLog->num_updates; i++) {
- if (FreeLog->update[i].file_off == 0) {
- LOG_ERROR_ARGS ("offset=0, blksz=%d", blockSize);
- }
-
- foundBit = (__u32) (FreeLog->update[i].file_off >> blockSizeBits);
- ocfs_clear_bits(osb->sb, handle, tmpbitmap, foundBit,
- (__u32) FreeLog->update[i].length);
- }
-
-leave:
- if (tmpbitmap)
- ocfs_uninitialize_bitmap(tmpbitmap);
- if (inode)
- iput(inode);
- LOG_EXIT_STATUS (status);
- return status;
-} /* ocfs_free_vol_block */
-
-/*
* How many free extents have we got before we need more meta data?
*/
int ocfs_num_free_extents(ocfs_super *osb,
@@ -1585,7 +1480,7 @@
}
status = ocfs_handle_add_commit_bits(handle,
numBitsAllocated,
- bitmapOffset, -1,
+ bitmapOffset, -1, 0,
DISK_ALLOC_VOLUME);
if (status < 0) {
LOG_ERROR_STATUS (status);
@@ -1660,7 +1555,7 @@
num_clusters = ext->e_clusters;
bitmap_offset =
(u32)((ext->e_blkno << osb->sb->s_blocksize_bits) >> osb->s_clustersize_bits);
- status = ocfs_handle_add_commit_bits(handle, num_clusters, bitmap_offset, -1, DISK_ALLOC_VOLUME);
+ status = ocfs_handle_add_commit_bits(handle, num_clusters, bitmap_offset, -1, 0, DISK_ALLOC_VOLUME);
if (status < 0) {
LOG_ERROR_STATUS (status);
goto bail;
@@ -1718,6 +1613,7 @@
status = ocfs_handle_add_commit_bits(handle, 1,
cur_eb->h_suballoc_bit,
cur_eb->h_suballoc_node,
+ cur_eb->h_blkno,
DISK_ALLOC_EXTENT_NODE);
if (status < 0) {
LOG_ERROR_STATUS (status);
@@ -2081,7 +1977,7 @@
done = 1;
goto skip_bitmap_add;
}
- status = ocfs_handle_add_commit_bits(handle, num_clusters, bitmap_offset, -1, DISK_ALLOC_VOLUME);
+ status = ocfs_handle_add_commit_bits(handle, num_clusters, bitmap_offset, -1, 0, DISK_ALLOC_VOLUME);
if (status < 0) {
LOG_ERROR_STATUS (status);
goto bail;
@@ -2156,7 +2052,7 @@
LOG_TRACE_ARGS("Popping this header (%llu)\n",
alloc_eb->h_blkno);
- status = ocfs_handle_add_commit_bits(handle, 1, alloc_eb->h_suballoc_bit, alloc_eb->h_suballoc_node, DISK_ALLOC_EXTENT_NODE);
+ status = ocfs_handle_add_commit_bits(handle, 1, alloc_eb->h_suballoc_bit, alloc_eb->h_suballoc_node, alloc_eb->h_blkno, DISK_ALLOC_EXTENT_NODE);
if (status < 0) {
LOG_ERROR_STATUS (status);
goto bail;
@@ -3429,7 +3325,7 @@
osb->s_clustersize_bits);
ocfs_handle_add_commit_bits(handle, numBitsAllocated,
- bitmapOffset, -1,
+ bitmapOffset, -1, 0,
DISK_ALLOC_VOLUME);
}
} else {
@@ -3722,7 +3618,7 @@
status = ocfs_add_to_bitmap_free_head(osb,
*f, 1,
bit_off + LOCAL_ALLOC(alloc)->la_bm_off,
- -1, DISK_ALLOC_VOLUME);
+ -1, 0, DISK_ALLOC_VOLUME);
if (status < 0) {
ocfs_free_bitmap_free_head(*f);
*f = NULL;
Modified: branches/dlm-changes/src/alloc.h
===================================================================
--- branches/dlm-changes/src/alloc.h 2004-10-01 21:09:48 UTC (rev 1536)
+++ branches/dlm-changes/src/alloc.h 2004-10-01 21:12:52 UTC (rev 1537)
@@ -30,9 +30,9 @@
#define OCFS2_ALLOC_H
int ocfs_add_to_bitmap_free_head(ocfs_super *osb,
- ocfs_bitmap_free_head *f,
- __u32 len, __u32 fileoff,
- __u32 nodenum, __u32 type);
+ ocfs_bitmap_free_head *f,
+ u32 len, u32 fileoff,
+ u32 nodenum, u64 blkno, u32 type);
struct _ocfs2_alloc_context;
int ocfs_allocate_extent(ocfs_super *osb, struct buffer_head *fe_bh,
ocfs_journal_handle *handle,
Modified: branches/dlm-changes/src/ocfs.h
===================================================================
--- branches/dlm-changes/src/ocfs.h 2004-10-01 21:09:48 UTC (rev 1536)
+++ branches/dlm-changes/src/ocfs.h 2004-10-01 21:12:52 UTC (rev 1537)
@@ -827,10 +827,11 @@
/* a bitmap update, currently used for freeing bits */
typedef struct ocfs_bitmap_update
{
- __u64 length;
- __u64 file_off;
- __u32 type;
- __s16 node_num;
+ u64 length;
+ u64 file_off;
+ u32 type;
+ s16 node_num;
+ u64 blkno;
}
ocfs_bitmap_update;
Modified: branches/dlm-changes/src/ocfs_journal.h
===================================================================
--- branches/dlm-changes/src/ocfs_journal.h 2004-10-01 21:09:48 UTC (rev 1536)
+++ branches/dlm-changes/src/ocfs_journal.h 2004-10-01 21:12:52 UTC (rev 1537)
@@ -252,8 +252,9 @@
}
static inline int ocfs_handle_add_commit_bits(ocfs_journal_handle *handle,
- __u32 len, __u32 fileoff,
- __u32 nodenum, __u32 type)
+ u32 len, u32 fileoff,
+ u32 nodenum, u64 blkno,
+ u32 type)
{
int ret = 0;
if (!handle->commit_bits)
@@ -265,7 +266,7 @@
ret = ocfs_add_to_bitmap_free_head(handle->osb,
handle->commit_bits,
len, fileoff,
- nodenum, type);
+ nodenum, blkno, type);
return ret;
}
More information about the Ocfs2-commits
mailing list