diff options
author | Tao Ma <tao.ma@oracle.com> | 2009-02-24 11:53:24 -0500 |
---|---|---|
committer | Mark Fasheh <mfasheh@suse.com> | 2009-04-03 14:39:17 -0400 |
commit | 60ca81e82dae4aa2e8ae84cf96b4d08535931669 (patch) | |
tree | da9b5d2a002ae886ec5e82b7c49429437b1b772d /fs/ocfs2 | |
parent | 138211515c102807a16c02fdc15feef1f6ef8124 (diff) |
ocfs2: Allocate inode groups from global_bitmap.
Inode groups used to be allocated from local alloc file,
but since we want all inodes to be contiguous enough, we
will try to allocate them directly from global_bitmap.
Signed-off-by: Tao Ma <tao.ma@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
Diffstat (limited to 'fs/ocfs2')
-rw-r--r-- | fs/ocfs2/suballoc.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c index 487f00c45f84..b7a065e87cb0 100644 --- a/fs/ocfs2/suballoc.c +++ b/fs/ocfs2/suballoc.c | |||
@@ -48,7 +48,8 @@ | |||
48 | #include "buffer_head_io.h" | 48 | #include "buffer_head_io.h" |
49 | 49 | ||
50 | #define NOT_ALLOC_NEW_GROUP 0 | 50 | #define NOT_ALLOC_NEW_GROUP 0 |
51 | #define ALLOC_NEW_GROUP 1 | 51 | #define ALLOC_NEW_GROUP 0x1 |
52 | #define ALLOC_GROUPS_FROM_GLOBAL 0x2 | ||
52 | 53 | ||
53 | #define OCFS2_MAX_INODES_TO_STEAL 1024 | 54 | #define OCFS2_MAX_INODES_TO_STEAL 1024 |
54 | 55 | ||
@@ -64,7 +65,8 @@ static int ocfs2_block_group_fill(handle_t *handle, | |||
64 | static int ocfs2_block_group_alloc(struct ocfs2_super *osb, | 65 | static int ocfs2_block_group_alloc(struct ocfs2_super *osb, |
65 | struct inode *alloc_inode, | 66 | struct inode *alloc_inode, |
66 | struct buffer_head *bh, | 67 | struct buffer_head *bh, |
67 | u64 max_block); | 68 | u64 max_block, |
69 | int flags); | ||
68 | 70 | ||
69 | static int ocfs2_cluster_group_search(struct inode *inode, | 71 | static int ocfs2_cluster_group_search(struct inode *inode, |
70 | struct buffer_head *group_bh, | 72 | struct buffer_head *group_bh, |
@@ -116,6 +118,7 @@ static inline void ocfs2_block_to_cluster_group(struct inode *inode, | |||
116 | u16 *bg_bit_off); | 118 | u16 *bg_bit_off); |
117 | static int ocfs2_reserve_clusters_with_limit(struct ocfs2_super *osb, | 119 | static int ocfs2_reserve_clusters_with_limit(struct ocfs2_super *osb, |
118 | u32 bits_wanted, u64 max_block, | 120 | u32 bits_wanted, u64 max_block, |
121 | int flags, | ||
119 | struct ocfs2_alloc_context **ac); | 122 | struct ocfs2_alloc_context **ac); |
120 | 123 | ||
121 | void ocfs2_free_ac_resource(struct ocfs2_alloc_context *ac) | 124 | void ocfs2_free_ac_resource(struct ocfs2_alloc_context *ac) |
@@ -403,7 +406,8 @@ static inline u16 ocfs2_find_smallest_chain(struct ocfs2_chain_list *cl) | |||
403 | static int ocfs2_block_group_alloc(struct ocfs2_super *osb, | 406 | static int ocfs2_block_group_alloc(struct ocfs2_super *osb, |
404 | struct inode *alloc_inode, | 407 | struct inode *alloc_inode, |
405 | struct buffer_head *bh, | 408 | struct buffer_head *bh, |
406 | u64 max_block) | 409 | u64 max_block, |
410 | int flags) | ||
407 | { | 411 | { |
408 | int status, credits; | 412 | int status, credits; |
409 | struct ocfs2_dinode *fe = (struct ocfs2_dinode *) bh->b_data; | 413 | struct ocfs2_dinode *fe = (struct ocfs2_dinode *) bh->b_data; |
@@ -423,7 +427,7 @@ static int ocfs2_block_group_alloc(struct ocfs2_super *osb, | |||
423 | cl = &fe->id2.i_chain; | 427 | cl = &fe->id2.i_chain; |
424 | status = ocfs2_reserve_clusters_with_limit(osb, | 428 | status = ocfs2_reserve_clusters_with_limit(osb, |
425 | le16_to_cpu(cl->cl_cpg), | 429 | le16_to_cpu(cl->cl_cpg), |
426 | max_block, &ac); | 430 | max_block, flags, &ac); |
427 | if (status < 0) { | 431 | if (status < 0) { |
428 | if (status != -ENOSPC) | 432 | if (status != -ENOSPC) |
429 | mlog_errno(status); | 433 | mlog_errno(status); |
@@ -531,7 +535,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb, | |||
531 | struct ocfs2_alloc_context *ac, | 535 | struct ocfs2_alloc_context *ac, |
532 | int type, | 536 | int type, |
533 | u32 slot, | 537 | u32 slot, |
534 | int alloc_new_group) | 538 | int flags) |
535 | { | 539 | { |
536 | int status; | 540 | int status; |
537 | u32 bits_wanted = ac->ac_bits_wanted; | 541 | u32 bits_wanted = ac->ac_bits_wanted; |
@@ -587,7 +591,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb, | |||
587 | goto bail; | 591 | goto bail; |
588 | } | 592 | } |
589 | 593 | ||
590 | if (alloc_new_group != ALLOC_NEW_GROUP) { | 594 | if (!(flags & ALLOC_NEW_GROUP)) { |
591 | mlog(0, "Alloc File %u Full: wanted=%u, free_bits=%u, " | 595 | mlog(0, "Alloc File %u Full: wanted=%u, free_bits=%u, " |
592 | "and we don't alloc a new group for it.\n", | 596 | "and we don't alloc a new group for it.\n", |
593 | slot, bits_wanted, free_bits); | 597 | slot, bits_wanted, free_bits); |
@@ -596,7 +600,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb, | |||
596 | } | 600 | } |
597 | 601 | ||
598 | status = ocfs2_block_group_alloc(osb, alloc_inode, bh, | 602 | status = ocfs2_block_group_alloc(osb, alloc_inode, bh, |
599 | ac->ac_max_block); | 603 | ac->ac_max_block, flags); |
600 | if (status < 0) { | 604 | if (status < 0) { |
601 | if (status != -ENOSPC) | 605 | if (status != -ENOSPC) |
602 | mlog_errno(status); | 606 | mlog_errno(status); |
@@ -740,7 +744,9 @@ int ocfs2_reserve_new_inode(struct ocfs2_super *osb, | |||
740 | atomic_set(&osb->s_num_inodes_stolen, 0); | 744 | atomic_set(&osb->s_num_inodes_stolen, 0); |
741 | status = ocfs2_reserve_suballoc_bits(osb, *ac, | 745 | status = ocfs2_reserve_suballoc_bits(osb, *ac, |
742 | INODE_ALLOC_SYSTEM_INODE, | 746 | INODE_ALLOC_SYSTEM_INODE, |
743 | osb->slot_num, ALLOC_NEW_GROUP); | 747 | osb->slot_num, |
748 | ALLOC_NEW_GROUP | | ||
749 | ALLOC_GROUPS_FROM_GLOBAL); | ||
744 | if (status >= 0) { | 750 | if (status >= 0) { |
745 | status = 0; | 751 | status = 0; |
746 | 752 | ||
@@ -806,6 +812,7 @@ bail: | |||
806 | * things a bit. */ | 812 | * things a bit. */ |
807 | static int ocfs2_reserve_clusters_with_limit(struct ocfs2_super *osb, | 813 | static int ocfs2_reserve_clusters_with_limit(struct ocfs2_super *osb, |
808 | u32 bits_wanted, u64 max_block, | 814 | u32 bits_wanted, u64 max_block, |
815 | int flags, | ||
809 | struct ocfs2_alloc_context **ac) | 816 | struct ocfs2_alloc_context **ac) |
810 | { | 817 | { |
811 | int status; | 818 | int status; |
@@ -823,7 +830,8 @@ static int ocfs2_reserve_clusters_with_limit(struct ocfs2_super *osb, | |||
823 | (*ac)->ac_max_block = max_block; | 830 | (*ac)->ac_max_block = max_block; |
824 | 831 | ||
825 | status = -ENOSPC; | 832 | status = -ENOSPC; |
826 | if (ocfs2_alloc_should_use_local(osb, bits_wanted)) { | 833 | if (!(flags & ALLOC_GROUPS_FROM_GLOBAL) && |
834 | ocfs2_alloc_should_use_local(osb, bits_wanted)) { | ||
827 | status = ocfs2_reserve_local_alloc_bits(osb, | 835 | status = ocfs2_reserve_local_alloc_bits(osb, |
828 | bits_wanted, | 836 | bits_wanted, |
829 | *ac); | 837 | *ac); |
@@ -861,7 +869,8 @@ int ocfs2_reserve_clusters(struct ocfs2_super *osb, | |||
861 | u32 bits_wanted, | 869 | u32 bits_wanted, |
862 | struct ocfs2_alloc_context **ac) | 870 | struct ocfs2_alloc_context **ac) |
863 | { | 871 | { |
864 | return ocfs2_reserve_clusters_with_limit(osb, bits_wanted, 0, ac); | 872 | return ocfs2_reserve_clusters_with_limit(osb, bits_wanted, 0, |
873 | ALLOC_NEW_GROUP, ac); | ||
865 | } | 874 | } |
866 | 875 | ||
867 | /* | 876 | /* |