aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/localalloc.c
diff options
context:
space:
mode:
authorMark Fasheh <mfasheh@suse.com>2008-07-28 17:55:20 -0400
committerMark Fasheh <mfasheh@suse.com>2008-10-13 16:57:57 -0400
commitebcee4b5c9136096f64ee6f691a013d7c0a4bc34 (patch)
treecb28c9135559a8f5aaf4c61b9d39f9c4ce733b55 /fs/ocfs2/localalloc.c
parent53da4939f349d4edd283b043219221ca5b78e4d4 (diff)
ocfs2: Track local alloc bits internally
Do this instead of tracking absolute local alloc size. This avoids needless re-calculatiion of bits from bytes in localalloc.c. Additionally, the value is now in a more natural unit for internal file system bitmap work. Signed-off-by: Mark Fasheh <mfasheh@suse.com>
Diffstat (limited to 'fs/ocfs2/localalloc.c')
-rw-r--r--fs/ocfs2/localalloc.c34
1 files changed, 12 insertions, 22 deletions
diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
index 28e492e4ec88..b05ce6642919 100644
--- a/fs/ocfs2/localalloc.c
+++ b/fs/ocfs2/localalloc.c
@@ -47,8 +47,6 @@
47 47
48#define OCFS2_LOCAL_ALLOC(dinode) (&((dinode)->id2.i_lab)) 48#define OCFS2_LOCAL_ALLOC(dinode) (&((dinode)->id2.i_lab))
49 49
50static inline int ocfs2_local_alloc_window_bits(struct ocfs2_super *osb);
51
52static u32 ocfs2_local_alloc_count_bits(struct ocfs2_dinode *alloc); 50static u32 ocfs2_local_alloc_count_bits(struct ocfs2_dinode *alloc);
53 51
54static int ocfs2_local_alloc_find_clear_bits(struct ocfs2_super *osb, 52static int ocfs2_local_alloc_find_clear_bits(struct ocfs2_super *osb,
@@ -75,21 +73,13 @@ static int ocfs2_local_alloc_new_window(struct ocfs2_super *osb,
75static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb, 73static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
76 struct inode *local_alloc_inode); 74 struct inode *local_alloc_inode);
77 75
78static inline int ocfs2_local_alloc_window_bits(struct ocfs2_super *osb)
79{
80 BUG_ON(osb->s_clustersize_bits > 20);
81
82 /* Size local alloc windows by the megabyte */
83 return osb->local_alloc_size << (20 - osb->s_clustersize_bits);
84}
85
86/* 76/*
87 * Tell us whether a given allocation should use the local alloc 77 * Tell us whether a given allocation should use the local alloc
88 * file. Otherwise, it has to go to the main bitmap. 78 * file. Otherwise, it has to go to the main bitmap.
89 */ 79 */
90int ocfs2_alloc_should_use_local(struct ocfs2_super *osb, u64 bits) 80int ocfs2_alloc_should_use_local(struct ocfs2_super *osb, u64 bits)
91{ 81{
92 int la_bits = ocfs2_local_alloc_window_bits(osb); 82 int la_bits = osb->local_alloc_bits;
93 int ret = 0; 83 int ret = 0;
94 84
95 if (osb->local_alloc_state != OCFS2_LA_ENABLED) 85 if (osb->local_alloc_state != OCFS2_LA_ENABLED)
@@ -120,14 +110,16 @@ int ocfs2_load_local_alloc(struct ocfs2_super *osb)
120 110
121 mlog_entry_void(); 111 mlog_entry_void();
122 112
123 if (osb->local_alloc_size == 0) 113 if (osb->local_alloc_bits == 0)
124 goto bail; 114 goto bail;
125 115
126 if (ocfs2_local_alloc_window_bits(osb) >= osb->bitmap_cpg) { 116 if (osb->local_alloc_bits >= osb->bitmap_cpg) {
127 mlog(ML_NOTICE, "Requested local alloc window %d is larger " 117 mlog(ML_NOTICE, "Requested local alloc window %d is larger "
128 "than max possible %u. Using defaults.\n", 118 "than max possible %u. Using defaults.\n",
129 ocfs2_local_alloc_window_bits(osb), (osb->bitmap_cpg - 1)); 119 osb->local_alloc_bits, (osb->bitmap_cpg - 1));
130 osb->local_alloc_size = OCFS2_DEFAULT_LOCAL_ALLOC_SIZE; 120 osb->local_alloc_bits =
121 ocfs2_megabytes_to_clusters(osb->sb,
122 OCFS2_DEFAULT_LOCAL_ALLOC_SIZE);
131 } 123 }
132 124
133 /* read the alloc off disk */ 125 /* read the alloc off disk */
@@ -190,8 +182,7 @@ bail:
190 if (inode) 182 if (inode)
191 iput(inode); 183 iput(inode);
192 184
193 mlog(0, "Local alloc window bits = %d\n", 185 mlog(0, "Local alloc window bits = %d\n", osb->local_alloc_bits);
194 ocfs2_local_alloc_window_bits(osb));
195 186
196 mlog_exit(status); 187 mlog_exit(status);
197 return status; 188 return status;
@@ -490,7 +481,7 @@ int ocfs2_reserve_local_alloc_bits(struct ocfs2_super *osb,
490 goto bail; 481 goto bail;
491 } 482 }
492 483
493 if (bits_wanted > ocfs2_local_alloc_window_bits(osb)) { 484 if (bits_wanted > osb->local_alloc_bits) {
494 mlog(0, "Asking for more than my max window size!\n"); 485 mlog(0, "Asking for more than my max window size!\n");
495 status = -ENOSPC; 486 status = -ENOSPC;
496 goto bail; 487 goto bail;
@@ -803,7 +794,7 @@ static int ocfs2_local_alloc_reserve_for_window(struct ocfs2_super *osb,
803 goto bail; 794 goto bail;
804 } 795 }
805 796
806 (*ac)->ac_bits_wanted = ocfs2_local_alloc_window_bits(osb); 797 (*ac)->ac_bits_wanted = osb->local_alloc_bits;
807 798
808 status = ocfs2_reserve_cluster_bitmap_bits(osb, *ac); 799 status = ocfs2_reserve_cluster_bitmap_bits(osb, *ac);
809 if (status < 0) { 800 if (status < 0) {
@@ -849,7 +840,7 @@ static int ocfs2_local_alloc_new_window(struct ocfs2_super *osb,
849 "one\n"); 840 "one\n");
850 841
851 mlog(0, "Allocating %u clusters for a new window.\n", 842 mlog(0, "Allocating %u clusters for a new window.\n",
852 ocfs2_local_alloc_window_bits(osb)); 843 osb->local_alloc_bits);
853 844
854 /* Instruct the allocation code to try the most recently used 845 /* Instruct the allocation code to try the most recently used
855 * cluster group. We'll re-record the group used this pass 846 * cluster group. We'll re-record the group used this pass
@@ -859,8 +850,7 @@ static int ocfs2_local_alloc_new_window(struct ocfs2_super *osb,
859 /* we used the generic suballoc reserve function, but we set 850 /* we used the generic suballoc reserve function, but we set
860 * everything up nicely, so there's no reason why we can't use 851 * everything up nicely, so there's no reason why we can't use
861 * the more specific cluster api to claim bits. */ 852 * the more specific cluster api to claim bits. */
862 status = ocfs2_claim_clusters(osb, handle, ac, 853 status = ocfs2_claim_clusters(osb, handle, ac, osb->local_alloc_bits,
863 ocfs2_local_alloc_window_bits(osb),
864 &cluster_off, &cluster_count); 854 &cluster_off, &cluster_count);
865 if (status < 0) { 855 if (status < 0) {
866 if (status != -ENOSPC) 856 if (status != -ENOSPC)