]>
Commit | Line | Data |
---|---|---|
2cb7cef9 BS |
1 | From: Mark Fasheh <mfasheh@suse.com> |
2 | Subject: ocfs2: Track local alloc bits internally | |
3 | Patch-mainline: 2.6.28 | |
4 | ||
5 | Do this instead of tracking absolute local alloc size. This avoids | |
6 | needless re-calculatiion of bits from bytes in localalloc.c. Additionally, | |
7 | the value is now in a more natural unit for internal file system bitmap | |
8 | work. | |
9 | ||
10 | Signed-off-by: Mark Fasheh <mfasheh@suse.com> | |
11 | --- | |
12 | fs/ocfs2/localalloc.c | 34 ++++++++++++---------------------- | |
13 | fs/ocfs2/ocfs2.h | 10 +++++++++- | |
14 | fs/ocfs2/super.c | 8 +++++--- | |
15 | 3 files changed, 26 insertions(+), 26 deletions(-) | |
16 | ||
17 | Index: linux-2.6.27/fs/ocfs2/localalloc.c | |
18 | =================================================================== | |
19 | --- linux-2.6.27.orig/fs/ocfs2/localalloc.c | |
20 | +++ linux-2.6.27/fs/ocfs2/localalloc.c | |
21 | @@ -47,8 +47,6 @@ | |
22 | ||
23 | #define OCFS2_LOCAL_ALLOC(dinode) (&((dinode)->id2.i_lab)) | |
24 | ||
25 | -static inline int ocfs2_local_alloc_window_bits(struct ocfs2_super *osb); | |
26 | - | |
27 | static u32 ocfs2_local_alloc_count_bits(struct ocfs2_dinode *alloc); | |
28 | ||
29 | static int ocfs2_local_alloc_find_clear_bits(struct ocfs2_super *osb, | |
30 | @@ -75,21 +73,13 @@ static int ocfs2_local_alloc_new_window( | |
31 | static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb, | |
32 | struct inode *local_alloc_inode); | |
33 | ||
34 | -static inline int ocfs2_local_alloc_window_bits(struct ocfs2_super *osb) | |
35 | -{ | |
36 | - BUG_ON(osb->s_clustersize_bits > 20); | |
37 | - | |
38 | - /* Size local alloc windows by the megabyte */ | |
39 | - return osb->local_alloc_size << (20 - osb->s_clustersize_bits); | |
40 | -} | |
41 | - | |
42 | /* | |
43 | * Tell us whether a given allocation should use the local alloc | |
44 | * file. Otherwise, it has to go to the main bitmap. | |
45 | */ | |
46 | int ocfs2_alloc_should_use_local(struct ocfs2_super *osb, u64 bits) | |
47 | { | |
48 | - int la_bits = ocfs2_local_alloc_window_bits(osb); | |
49 | + int la_bits = osb->local_alloc_bits; | |
50 | int ret = 0; | |
51 | ||
52 | if (osb->local_alloc_state != OCFS2_LA_ENABLED) | |
53 | @@ -120,14 +110,16 @@ int ocfs2_load_local_alloc(struct ocfs2_ | |
54 | ||
55 | mlog_entry_void(); | |
56 | ||
57 | - if (osb->local_alloc_size == 0) | |
58 | + if (osb->local_alloc_bits == 0) | |
59 | goto bail; | |
60 | ||
61 | - if (ocfs2_local_alloc_window_bits(osb) >= osb->bitmap_cpg) { | |
62 | + if (osb->local_alloc_bits >= osb->bitmap_cpg) { | |
63 | mlog(ML_NOTICE, "Requested local alloc window %d is larger " | |
64 | "than max possible %u. Using defaults.\n", | |
65 | - ocfs2_local_alloc_window_bits(osb), (osb->bitmap_cpg - 1)); | |
66 | - osb->local_alloc_size = OCFS2_DEFAULT_LOCAL_ALLOC_SIZE; | |
67 | + osb->local_alloc_bits, (osb->bitmap_cpg - 1)); | |
68 | + osb->local_alloc_bits = | |
69 | + ocfs2_megabytes_to_clusters(osb->sb, | |
70 | + OCFS2_DEFAULT_LOCAL_ALLOC_SIZE); | |
71 | } | |
72 | ||
73 | /* read the alloc off disk */ | |
74 | @@ -190,8 +182,7 @@ bail: | |
75 | if (inode) | |
76 | iput(inode); | |
77 | ||
78 | - mlog(0, "Local alloc window bits = %d\n", | |
79 | - ocfs2_local_alloc_window_bits(osb)); | |
80 | + mlog(0, "Local alloc window bits = %d\n", osb->local_alloc_bits); | |
81 | ||
82 | mlog_exit(status); | |
83 | return status; | |
84 | @@ -530,7 +521,7 @@ int ocfs2_reserve_local_alloc_bits(struc | |
85 | goto bail; | |
86 | } | |
87 | ||
88 | - if (bits_wanted > ocfs2_local_alloc_window_bits(osb)) { | |
89 | + if (bits_wanted > osb->local_alloc_bits) { | |
90 | mlog(0, "Asking for more than my max window size!\n"); | |
91 | status = -ENOSPC; | |
92 | goto bail; | |
93 | @@ -858,7 +849,7 @@ static int ocfs2_local_alloc_reserve_for | |
94 | goto bail; | |
95 | } | |
96 | ||
97 | - (*ac)->ac_bits_wanted = ocfs2_local_alloc_window_bits(osb); | |
98 | + (*ac)->ac_bits_wanted = osb->local_alloc_bits; | |
99 | ||
100 | status = ocfs2_reserve_cluster_bitmap_bits(osb, *ac); | |
101 | if (status < 0) { | |
102 | @@ -904,7 +895,7 @@ static int ocfs2_local_alloc_new_window( | |
103 | "one\n"); | |
104 | ||
105 | mlog(0, "Allocating %u clusters for a new window.\n", | |
106 | - ocfs2_local_alloc_window_bits(osb)); | |
107 | + osb->local_alloc_bits); | |
108 | ||
109 | /* Instruct the allocation code to try the most recently used | |
110 | * cluster group. We'll re-record the group used this pass | |
111 | @@ -914,8 +905,7 @@ static int ocfs2_local_alloc_new_window( | |
112 | /* we used the generic suballoc reserve function, but we set | |
113 | * everything up nicely, so there's no reason why we can't use | |
114 | * the more specific cluster api to claim bits. */ | |
115 | - status = ocfs2_claim_clusters(osb, handle, ac, | |
116 | - ocfs2_local_alloc_window_bits(osb), | |
117 | + status = ocfs2_claim_clusters(osb, handle, ac, osb->local_alloc_bits, | |
118 | &cluster_off, &cluster_count); | |
119 | if (status < 0) { | |
120 | if (status != -ENOSPC) | |
121 | Index: linux-2.6.27/fs/ocfs2/ocfs2.h | |
122 | =================================================================== | |
123 | --- linux-2.6.27.orig/fs/ocfs2/ocfs2.h | |
124 | +++ linux-2.6.27/fs/ocfs2/ocfs2.h | |
125 | @@ -261,7 +261,7 @@ struct ocfs2_super | |
126 | struct ocfs2_journal *journal; | |
127 | unsigned long osb_commit_interval; | |
128 | ||
129 | - int local_alloc_size; | |
130 | + unsigned int local_alloc_bits; | |
131 | enum ocfs2_local_alloc_state local_alloc_state; | |
132 | struct buffer_head *local_alloc_bh; | |
133 | u64 la_last_gd; | |
134 | @@ -570,6 +570,14 @@ static inline unsigned int ocfs2_pages_p | |
135 | return pages_per_cluster; | |
136 | } | |
137 | ||
138 | +static inline unsigned int ocfs2_megabytes_to_clusters(struct super_block *sb, | |
139 | + unsigned int megs) | |
140 | +{ | |
141 | + BUILD_BUG_ON(OCFS2_MAX_CLUSTERSIZE > 1048576); | |
142 | + | |
143 | + return megs << (20 - OCFS2_SB(sb)->s_clustersize_bits); | |
144 | +} | |
145 | + | |
146 | static inline void ocfs2_init_inode_steal_slot(struct ocfs2_super *osb) | |
147 | { | |
148 | spin_lock(&osb->osb_lock); | |
149 | Index: linux-2.6.27/fs/ocfs2/super.c | |
150 | =================================================================== | |
151 | --- linux-2.6.27.orig/fs/ocfs2/super.c | |
152 | +++ linux-2.6.27/fs/ocfs2/super.c | |
153 | @@ -655,7 +655,7 @@ static int ocfs2_fill_super(struct super | |
154 | osb->s_atime_quantum = parsed_options.atime_quantum; | |
155 | osb->preferred_slot = parsed_options.slot; | |
156 | osb->osb_commit_interval = parsed_options.commit_interval; | |
157 | - osb->local_alloc_size = parsed_options.localalloc_opt; | |
158 | + osb->local_alloc_bits = ocfs2_megabytes_to_clusters(sb, parsed_options.localalloc_opt); | |
159 | ||
160 | status = ocfs2_verify_userspace_stack(osb, &parsed_options); | |
161 | if (status) | |
162 | @@ -965,6 +965,7 @@ static int ocfs2_show_options(struct seq | |
163 | { | |
164 | struct ocfs2_super *osb = OCFS2_SB(mnt->mnt_sb); | |
165 | unsigned long opts = osb->s_mount_opt; | |
166 | + unsigned int local_alloc_megs; | |
167 | ||
168 | if (opts & OCFS2_MOUNT_HB_LOCAL) | |
169 | seq_printf(s, ",_netdev,heartbeat=local"); | |
170 | @@ -997,8 +998,9 @@ static int ocfs2_show_options(struct seq | |
171 | seq_printf(s, ",commit=%u", | |
172 | (unsigned) (osb->osb_commit_interval / HZ)); | |
173 | ||
174 | - if (osb->local_alloc_size != OCFS2_DEFAULT_LOCAL_ALLOC_SIZE) | |
175 | - seq_printf(s, ",localalloc=%d", osb->local_alloc_size); | |
176 | + local_alloc_megs = osb->local_alloc_bits >> (20 - osb->s_clustersize_bits); | |
177 | + if (local_alloc_megs != OCFS2_DEFAULT_LOCAL_ALLOC_SIZE) | |
178 | + seq_printf(s, ",localalloc=%d", local_alloc_megs); | |
179 | ||
180 | if (opts & OCFS2_MOUNT_LOCALFLOCKS) | |
181 | seq_printf(s, ",localflocks,"); |