Skip to content

Commit 0a2fcd8

Browse files
Younger Liutorvalds
authored andcommitted
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>
1 parent c994c2e commit 0a2fcd8

3 files changed

Lines changed: 14 additions & 87 deletions

File tree

‎fs/ocfs2/move_extents.c‎

Lines changed: 0 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -561,83 +561,6 @@ static void ocfs2_probe_alloc_group(struct inode *inode, struct buffer_head *bh,
561561
mlog(0, "found phys_cpos: %u to fit the wanted moving.\n", *phys_cpos);
562562
}
563563

564-
static 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-
588-
out:
589-
return ret;
590-
}
591-
592-
static 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-
637-
bail:
638-
return status;
639-
}
640-
641564
static int ocfs2_move_extent(struct ocfs2_move_extents_context *context,
642565
u32 cpos, u32 phys_cpos, u32 *new_phys_cpos,
643566
u32 len, int ext_flags)

‎fs/ocfs2/suballoc.c‎

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,6 @@ static int ocfs2_claim_suballoc_bits(struct ocfs2_alloc_context *ac,
113113
struct ocfs2_suballoc_result *res);
114114
static int ocfs2_test_bg_bit_allocatable(struct buffer_head *bg_bh,
115115
int nr);
116-
static 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);
122116
static int ocfs2_relink_block_group(handle_t *handle,
123117
struct inode *alloc_inode,
124118
struct buffer_head *fe_bh,
@@ -1343,7 +1337,7 @@ static int ocfs2_block_group_find_clear_bits(struct ocfs2_super *osb,
13431337
return status;
13441338
}
13451339

1346-
static inline int ocfs2_block_group_set_bits(handle_t *handle,
1340+
int ocfs2_block_group_set_bits(handle_t *handle,
13471341
struct inode *alloc_inode,
13481342
struct ocfs2_group_desc *bg,
13491343
struct buffer_head *group_bh,
@@ -1388,8 +1382,6 @@ static inline int ocfs2_block_group_set_bits(handle_t *handle,
13881382
ocfs2_journal_dirty(handle, group_bh);
13891383

13901384
bail:
1391-
if (status)
1392-
mlog_errno(status);
13931385
return status;
13941386
}
13951387

@@ -1588,7 +1580,7 @@ static int ocfs2_block_group_search(struct inode *inode,
15881580
return ret;
15891581
}
15901582

1591-
static int ocfs2_alloc_dinode_update_counts(struct inode *inode,
1583+
int ocfs2_alloc_dinode_update_counts(struct inode *inode,
15921584
handle_t *handle,
15931585
struct buffer_head *di_bh,
15941586
u32 num_bits,

‎fs/ocfs2/suballoc.h‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,18 @@ int ocfs2_reserve_clusters(struct ocfs2_super *osb,
8686
u32 bits_wanted,
8787
struct ocfs2_alloc_context **ac);
8888

89+
int 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);
94+
int 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+
89101
int ocfs2_claim_metadata(handle_t *handle,
90102
struct ocfs2_alloc_context *ac,
91103
u32 bits_wanted,

0 commit comments

Comments
 (0)