aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/alloc.c
diff options
context:
space:
mode:
authorTao Ma <tao.ma@oracle.com>2010-03-22 02:20:18 -0400
committerTao Ma <tao.ma@oracle.com>2010-03-22 02:20:18 -0400
commit74380c479ad83addeff8a172ab95f59557b5b0c3 (patch)
tree49b94f3ff48cd2ca6b53977a5e3070380ccecd6b /fs/ocfs2/alloc.c
parentaf2bf0d86019e0b0306965321096f8380b7ca830 (diff)
ocfs2: Free block to the right block group.
In case the block we are going to free is allocated from a discontiguous block group, we have to use suballoc_loc to be the right group. Signed-off-by: Tao Ma <tao.ma@oracle.com>
Diffstat (limited to 'fs/ocfs2/alloc.c')
-rw-r--r--fs/ocfs2/alloc.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
index 479d2ecae340..af2d1bd00d0a 100644
--- a/fs/ocfs2/alloc.c
+++ b/fs/ocfs2/alloc.c
@@ -6203,6 +6203,7 @@ int ocfs2_truncate_log_init(struct ocfs2_super *osb)
6203 */ 6203 */
6204struct ocfs2_cached_block_free { 6204struct ocfs2_cached_block_free {
6205 struct ocfs2_cached_block_free *free_next; 6205 struct ocfs2_cached_block_free *free_next;
6206 u64 free_bg;
6206 u64 free_blk; 6207 u64 free_blk;
6207 unsigned int free_bit; 6208 unsigned int free_bit;
6208}; 6209};
@@ -6249,8 +6250,11 @@ static int ocfs2_free_cached_blocks(struct ocfs2_super *osb,
6249 } 6250 }
6250 6251
6251 while (head) { 6252 while (head) {
6252 bg_blkno = ocfs2_which_suballoc_group(head->free_blk, 6253 if (head->free_bg)
6253 head->free_bit); 6254 bg_blkno = head->free_bg;
6255 else
6256 bg_blkno = ocfs2_which_suballoc_group(head->free_blk,
6257 head->free_bit);
6254 mlog(0, "Free bit: (bit %u, blkno %llu)\n", 6258 mlog(0, "Free bit: (bit %u, blkno %llu)\n",
6255 head->free_bit, (unsigned long long)head->free_blk); 6259 head->free_bit, (unsigned long long)head->free_blk);
6256 6260
@@ -6298,7 +6302,7 @@ int ocfs2_cache_cluster_dealloc(struct ocfs2_cached_dealloc_ctxt *ctxt,
6298 int ret = 0; 6302 int ret = 0;
6299 struct ocfs2_cached_block_free *item; 6303 struct ocfs2_cached_block_free *item;
6300 6304
6301 item = kmalloc(sizeof(*item), GFP_NOFS); 6305 item = kzalloc(sizeof(*item), GFP_NOFS);
6302 if (item == NULL) { 6306 if (item == NULL) {
6303 ret = -ENOMEM; 6307 ret = -ENOMEM;
6304 mlog_errno(ret); 6308 mlog_errno(ret);
@@ -6438,8 +6442,8 @@ ocfs2_find_per_slot_free_list(int type,
6438} 6442}
6439 6443
6440int ocfs2_cache_block_dealloc(struct ocfs2_cached_dealloc_ctxt *ctxt, 6444int ocfs2_cache_block_dealloc(struct ocfs2_cached_dealloc_ctxt *ctxt,
6441 int type, int slot, u64 blkno, 6445 int type, int slot, u64 suballoc,
6442 unsigned int bit) 6446 u64 blkno, unsigned int bit)
6443{ 6447{
6444 int ret; 6448 int ret;
6445 struct ocfs2_per_slot_free_list *fl; 6449 struct ocfs2_per_slot_free_list *fl;
@@ -6452,7 +6456,7 @@ int ocfs2_cache_block_dealloc(struct ocfs2_cached_dealloc_ctxt *ctxt,
6452 goto out; 6456 goto out;
6453 } 6457 }
6454 6458
6455 item = kmalloc(sizeof(*item), GFP_NOFS); 6459 item = kzalloc(sizeof(*item), GFP_NOFS);
6456 if (item == NULL) { 6460 if (item == NULL) {
6457 ret = -ENOMEM; 6461 ret = -ENOMEM;
6458 mlog_errno(ret); 6462 mlog_errno(ret);
@@ -6462,6 +6466,7 @@ int ocfs2_cache_block_dealloc(struct ocfs2_cached_dealloc_ctxt *ctxt,
6462 mlog(0, "Insert: (type %d, slot %u, bit %u, blk %llu)\n", 6466 mlog(0, "Insert: (type %d, slot %u, bit %u, blk %llu)\n",
6463 type, slot, bit, (unsigned long long)blkno); 6467 type, slot, bit, (unsigned long long)blkno);
6464 6468
6469 item->free_bg = suballoc;
6465 item->free_blk = blkno; 6470 item->free_blk = blkno;
6466 item->free_bit = bit; 6471 item->free_bit = bit;
6467 item->free_next = fl->f_first; 6472 item->free_next = fl->f_first;
@@ -6478,6 +6483,7 @@ static int ocfs2_cache_extent_block_free(struct ocfs2_cached_dealloc_ctxt *ctxt,
6478{ 6483{
6479 return ocfs2_cache_block_dealloc(ctxt, EXTENT_ALLOC_SYSTEM_INODE, 6484 return ocfs2_cache_block_dealloc(ctxt, EXTENT_ALLOC_SYSTEM_INODE,
6480 le16_to_cpu(eb->h_suballoc_slot), 6485 le16_to_cpu(eb->h_suballoc_slot),
6486 le64_to_cpu(eb->h_suballoc_loc),
6481 le64_to_cpu(eb->h_blkno), 6487 le64_to_cpu(eb->h_blkno),
6482 le16_to_cpu(eb->h_suballoc_bit)); 6488 le16_to_cpu(eb->h_suballoc_bit));
6483} 6489}