aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYounger Liu <liuyiyang@hisense.com>2014-01-21 18:48:33 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2014-01-21 19:19:42 -0500
commit0a2fcd8988ac682f443fd5b0a7c48154a7b42ef2 (patch)
treec9042d7694c14088e6c2d2004c32b3dd835625d9
parentc994c2ebdbbc391a42f177c8eb7882ebf3f142d8 (diff)
ocfs2: remove redundant ocfs2_alloc_dinode_update_counts() and ocfs2_block_group_set_bits()
ocfs2_alloc_dinode_update_counts() and ocfs2_block_group_set_bits() are already provided in suballoc.c. So, the same functions in move_extents.c are not needed any more. Declare the functions in suballoc.h and remove redundant functions in move_extents.c. Signed-off-by: Younger Liu <liuyiyang@hisense.com> Cc: Younger Liu <younger.liucn@gmail.com> Cc: Mark Fasheh <mfasheh@suse.com> Cc: Joel Becker <jlbec@evilplan.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--fs/ocfs2/move_extents.c77
-rw-r--r--fs/ocfs2/suballoc.c12
-rw-r--r--fs/ocfs2/suballoc.h12
3 files changed, 14 insertions, 87 deletions
diff --git a/fs/ocfs2/move_extents.c b/fs/ocfs2/move_extents.c
index 631a98213474..64c304d668f0 100644
--- a/fs/ocfs2/move_extents.c
+++ b/fs/ocfs2/move_extents.c
@@ -561,83 +561,6 @@ static void ocfs2_probe_alloc_group(struct inode *inode, struct buffer_head *bh,
561 mlog(0, "found phys_cpos: %u to fit the wanted moving.\n", *phys_cpos); 561 mlog(0, "found phys_cpos: %u to fit the wanted moving.\n", *phys_cpos);
562} 562}
563 563
564static int ocfs2_alloc_dinode_update_counts(struct inode *inode,
565 handle_t *handle,
566 struct buffer_head *di_bh,
567 u32 num_bits,
568 u16 chain)
569{
570 int ret;
571 u32 tmp_used;
572 struct ocfs2_dinode *di = (struct ocfs2_dinode *) di_bh->b_data;
573 struct ocfs2_chain_list *cl =
574 (struct ocfs2_chain_list *) &di->id2.i_chain;
575
576 ret = ocfs2_journal_access_di(handle, INODE_CACHE(inode), di_bh,
577 OCFS2_JOURNAL_ACCESS_WRITE);
578 if (ret < 0) {
579 mlog_errno(ret);
580 goto out;
581 }
582
583 tmp_used = le32_to_cpu(di->id1.bitmap1.i_used);
584 di->id1.bitmap1.i_used = cpu_to_le32(num_bits + tmp_used);
585 le32_add_cpu(&cl->cl_recs[chain].c_free, -num_bits);
586 ocfs2_journal_dirty(handle, di_bh);
587
588out:
589 return ret;
590}
591
592static inline int ocfs2_block_group_set_bits(handle_t *handle,
593 struct inode *alloc_inode,
594 struct ocfs2_group_desc *bg,
595 struct buffer_head *group_bh,
596 unsigned int bit_off,
597 unsigned int num_bits)
598{
599 int status;
600 void *bitmap = bg->bg_bitmap;
601 int journal_type = OCFS2_JOURNAL_ACCESS_WRITE;
602
603 /* All callers get the descriptor via
604 * ocfs2_read_group_descriptor(). Any corruption is a code bug. */
605 BUG_ON(!OCFS2_IS_VALID_GROUP_DESC(bg));
606 BUG_ON(le16_to_cpu(bg->bg_free_bits_count) < num_bits);
607
608 mlog(0, "block_group_set_bits: off = %u, num = %u\n", bit_off,
609 num_bits);
610
611 if (ocfs2_is_cluster_bitmap(alloc_inode))
612 journal_type = OCFS2_JOURNAL_ACCESS_UNDO;
613
614 status = ocfs2_journal_access_gd(handle,
615 INODE_CACHE(alloc_inode),
616 group_bh,
617 journal_type);
618 if (status < 0) {
619 mlog_errno(status);
620 goto bail;
621 }
622
623 le16_add_cpu(&bg->bg_free_bits_count, -num_bits);
624 if (le16_to_cpu(bg->bg_free_bits_count) > le16_to_cpu(bg->bg_bits)) {
625 ocfs2_error(alloc_inode->i_sb, "Group descriptor # %llu has bit"
626 " count %u but claims %u are freed. num_bits %d",
627 (unsigned long long)le64_to_cpu(bg->bg_blkno),
628 le16_to_cpu(bg->bg_bits),
629 le16_to_cpu(bg->bg_free_bits_count), num_bits);
630 return -EROFS;
631 }
632 while (num_bits--)
633 ocfs2_set_bit(bit_off++, bitmap);
634
635 ocfs2_journal_dirty(handle, group_bh);
636
637bail:
638 return status;
639}
640
641static int ocfs2_move_extent(struct ocfs2_move_extents_context *context, 564static int ocfs2_move_extent(struct ocfs2_move_extents_context *context,
642 u32 cpos, u32 phys_cpos, u32 *new_phys_cpos, 565 u32 cpos, u32 phys_cpos, u32 *new_phys_cpos,
643 u32 len, int ext_flags) 566 u32 len, int ext_flags)
diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
index 2c91452c4047..47ae2663a6f5 100644
--- a/fs/ocfs2/suballoc.c
+++ b/fs/ocfs2/suballoc.c
@@ -113,12 +113,6 @@ static int ocfs2_claim_suballoc_bits(struct ocfs2_alloc_context *ac,
113 struct ocfs2_suballoc_result *res); 113 struct ocfs2_suballoc_result *res);
114static int ocfs2_test_bg_bit_allocatable(struct buffer_head *bg_bh, 114static int ocfs2_test_bg_bit_allocatable(struct buffer_head *bg_bh,
115 int nr); 115 int nr);
116static inline int ocfs2_block_group_set_bits(handle_t *handle,
117 struct inode *alloc_inode,
118 struct ocfs2_group_desc *bg,
119 struct buffer_head *group_bh,
120 unsigned int bit_off,
121 unsigned int num_bits);
122static int ocfs2_relink_block_group(handle_t *handle, 116static int ocfs2_relink_block_group(handle_t *handle,
123 struct inode *alloc_inode, 117 struct inode *alloc_inode,
124 struct buffer_head *fe_bh, 118 struct buffer_head *fe_bh,
@@ -1343,7 +1337,7 @@ static int ocfs2_block_group_find_clear_bits(struct ocfs2_super *osb,
1343 return status; 1337 return status;
1344} 1338}
1345 1339
1346static inline int ocfs2_block_group_set_bits(handle_t *handle, 1340int ocfs2_block_group_set_bits(handle_t *handle,
1347 struct inode *alloc_inode, 1341 struct inode *alloc_inode,
1348 struct ocfs2_group_desc *bg, 1342 struct ocfs2_group_desc *bg,
1349 struct buffer_head *group_bh, 1343 struct buffer_head *group_bh,
@@ -1388,8 +1382,6 @@ static inline int ocfs2_block_group_set_bits(handle_t *handle,
1388 ocfs2_journal_dirty(handle, group_bh); 1382 ocfs2_journal_dirty(handle, group_bh);
1389 1383
1390bail: 1384bail:
1391 if (status)
1392 mlog_errno(status);
1393 return status; 1385 return status;
1394} 1386}
1395 1387
@@ -1588,7 +1580,7 @@ static int ocfs2_block_group_search(struct inode *inode,
1588 return ret; 1580 return ret;
1589} 1581}
1590 1582
1591static int ocfs2_alloc_dinode_update_counts(struct inode *inode, 1583int ocfs2_alloc_dinode_update_counts(struct inode *inode,
1592 handle_t *handle, 1584 handle_t *handle,
1593 struct buffer_head *di_bh, 1585 struct buffer_head *di_bh,
1594 u32 num_bits, 1586 u32 num_bits,
diff --git a/fs/ocfs2/suballoc.h b/fs/ocfs2/suballoc.h
index a36d0aa50911..218d8036b3e7 100644
--- a/fs/ocfs2/suballoc.h
+++ b/fs/ocfs2/suballoc.h
@@ -86,6 +86,18 @@ int ocfs2_reserve_clusters(struct ocfs2_super *osb,
86 u32 bits_wanted, 86 u32 bits_wanted,
87 struct ocfs2_alloc_context **ac); 87 struct ocfs2_alloc_context **ac);
88 88
89int ocfs2_alloc_dinode_update_counts(struct inode *inode,
90 handle_t *handle,
91 struct buffer_head *di_bh,
92 u32 num_bits,
93 u16 chain);
94int ocfs2_block_group_set_bits(handle_t *handle,
95 struct inode *alloc_inode,
96 struct ocfs2_group_desc *bg,
97 struct buffer_head *group_bh,
98 unsigned int bit_off,
99 unsigned int num_bits);
100
89int ocfs2_claim_metadata(handle_t *handle, 101int ocfs2_claim_metadata(handle_t *handle,
90 struct ocfs2_alloc_context *ac, 102 struct ocfs2_alloc_context *ac,
91 u32 bits_wanted, 103 u32 bits_wanted,