diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2016-06-20 11:25:44 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2016-06-20 11:25:44 -0400 |
commit | af52739b922f656eb1f39016fabaabe4baeda2e2 (patch) | |
tree | 79a7aa810d0493cd0cf4adebac26d37f12e8b545 /fs/btrfs/tests/inode-tests.c | |
parent | 25ed6a5e97809129a1bc852b6b5c7d03baa112c4 (diff) | |
parent | 33688abb2802ff3a230bd2441f765477b94cc89e (diff) |
Merge 4.7-rc4 into staging-next
We want the fixes in here, and we can resolve a merge issue in
drivers/iio/industrialio-trigger.c
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/btrfs/tests/inode-tests.c')
-rw-r--r-- | fs/btrfs/tests/inode-tests.c | 344 |
1 files changed, 188 insertions, 156 deletions
diff --git a/fs/btrfs/tests/inode-tests.c b/fs/btrfs/tests/inode-tests.c index 8a25fe8b7c45..29648c0a39f1 100644 --- a/fs/btrfs/tests/inode-tests.c +++ b/fs/btrfs/tests/inode-tests.c | |||
@@ -16,6 +16,7 @@ | |||
16 | * Boston, MA 021110-1307, USA. | 16 | * Boston, MA 021110-1307, USA. |
17 | */ | 17 | */ |
18 | 18 | ||
19 | #include <linux/types.h> | ||
19 | #include "btrfs-tests.h" | 20 | #include "btrfs-tests.h" |
20 | #include "../ctree.h" | 21 | #include "../ctree.h" |
21 | #include "../btrfs_inode.h" | 22 | #include "../btrfs_inode.h" |
@@ -86,19 +87,19 @@ static void insert_inode_item_key(struct btrfs_root *root) | |||
86 | * diagram of how the extents will look though this may not be possible we still | 87 | * diagram of how the extents will look though this may not be possible we still |
87 | * want to make sure everything acts normally (the last number is not inclusive) | 88 | * want to make sure everything acts normally (the last number is not inclusive) |
88 | * | 89 | * |
89 | * [0 - 5][5 - 6][6 - 10][10 - 4096][ 4096 - 8192 ][8192 - 12288] | 90 | * [0 - 5][5 - 6][ 6 - 4096 ][ 4096 - 4100][4100 - 8195][8195 - 12291] |
90 | * [hole ][inline][ hole ][ regular ][regular1 split][ hole ] | 91 | * [hole ][inline][hole but no extent][ hole ][ regular ][regular1 split] |
91 | * | 92 | * |
92 | * [ 12288 - 20480][20480 - 24576][ 24576 - 28672 ][28672 - 36864][36864 - 45056] | 93 | * [12291 - 16387][16387 - 24579][24579 - 28675][ 28675 - 32771][32771 - 36867 ] |
93 | * [regular1 split][ prealloc1 ][prealloc1 written][ prealloc1 ][ compressed ] | 94 | * [ hole ][regular1 split][ prealloc ][ prealloc1 ][prealloc1 written] |
94 | * | 95 | * |
95 | * [45056 - 49152][49152-53248][53248-61440][61440-65536][ 65536+81920 ] | 96 | * [36867 - 45059][45059 - 53251][53251 - 57347][57347 - 61443][61443- 69635] |
96 | * [ compressed1 ][ regular ][compressed1][ regular ][ hole but no extent] | 97 | * [ prealloc1 ][ compressed ][ compressed1 ][ regular ][ compressed1] |
97 | * | 98 | * |
98 | * [81920-86016] | 99 | * [69635-73731][ 73731 - 86019 ][86019-90115] |
99 | * [ regular ] | 100 | * [ regular ][ hole but no extent][ regular ] |
100 | */ | 101 | */ |
101 | static void setup_file_extents(struct btrfs_root *root) | 102 | static void setup_file_extents(struct btrfs_root *root, u32 sectorsize) |
102 | { | 103 | { |
103 | int slot = 0; | 104 | int slot = 0; |
104 | u64 disk_bytenr = SZ_1M; | 105 | u64 disk_bytenr = SZ_1M; |
@@ -119,7 +120,7 @@ static void setup_file_extents(struct btrfs_root *root) | |||
119 | insert_extent(root, offset, 1, 1, 0, 0, 0, BTRFS_FILE_EXTENT_INLINE, 0, | 120 | insert_extent(root, offset, 1, 1, 0, 0, 0, BTRFS_FILE_EXTENT_INLINE, 0, |
120 | slot); | 121 | slot); |
121 | slot++; | 122 | slot++; |
122 | offset = 4096; | 123 | offset = sectorsize; |
123 | 124 | ||
124 | /* Now another hole */ | 125 | /* Now another hole */ |
125 | insert_extent(root, offset, 4, 4, 0, 0, 0, BTRFS_FILE_EXTENT_REG, 0, | 126 | insert_extent(root, offset, 4, 4, 0, 0, 0, BTRFS_FILE_EXTENT_REG, 0, |
@@ -128,99 +129,106 @@ static void setup_file_extents(struct btrfs_root *root) | |||
128 | offset += 4; | 129 | offset += 4; |
129 | 130 | ||
130 | /* Now for a regular extent */ | 131 | /* Now for a regular extent */ |
131 | insert_extent(root, offset, 4095, 4095, 0, disk_bytenr, 4096, | 132 | insert_extent(root, offset, sectorsize - 1, sectorsize - 1, 0, |
132 | BTRFS_FILE_EXTENT_REG, 0, slot); | 133 | disk_bytenr, sectorsize, BTRFS_FILE_EXTENT_REG, 0, slot); |
133 | slot++; | 134 | slot++; |
134 | disk_bytenr += 4096; | 135 | disk_bytenr += sectorsize; |
135 | offset += 4095; | 136 | offset += sectorsize - 1; |
136 | 137 | ||
137 | /* | 138 | /* |
138 | * Now for 3 extents that were split from a hole punch so we test | 139 | * Now for 3 extents that were split from a hole punch so we test |
139 | * offsets properly. | 140 | * offsets properly. |
140 | */ | 141 | */ |
141 | insert_extent(root, offset, 4096, 16384, 0, disk_bytenr, 16384, | 142 | insert_extent(root, offset, sectorsize, 4 * sectorsize, 0, disk_bytenr, |
142 | BTRFS_FILE_EXTENT_REG, 0, slot); | 143 | 4 * sectorsize, BTRFS_FILE_EXTENT_REG, 0, slot); |
143 | slot++; | 144 | slot++; |
144 | offset += 4096; | 145 | offset += sectorsize; |
145 | insert_extent(root, offset, 4096, 4096, 0, 0, 0, BTRFS_FILE_EXTENT_REG, | 146 | insert_extent(root, offset, sectorsize, sectorsize, 0, 0, 0, |
146 | 0, slot); | 147 | BTRFS_FILE_EXTENT_REG, 0, slot); |
147 | slot++; | 148 | slot++; |
148 | offset += 4096; | 149 | offset += sectorsize; |
149 | insert_extent(root, offset, 8192, 16384, 8192, disk_bytenr, 16384, | 150 | insert_extent(root, offset, 2 * sectorsize, 4 * sectorsize, |
151 | 2 * sectorsize, disk_bytenr, 4 * sectorsize, | ||
150 | BTRFS_FILE_EXTENT_REG, 0, slot); | 152 | BTRFS_FILE_EXTENT_REG, 0, slot); |
151 | slot++; | 153 | slot++; |
152 | offset += 8192; | 154 | offset += 2 * sectorsize; |
153 | disk_bytenr += 16384; | 155 | disk_bytenr += 4 * sectorsize; |
154 | 156 | ||
155 | /* Now for a unwritten prealloc extent */ | 157 | /* Now for a unwritten prealloc extent */ |
156 | insert_extent(root, offset, 4096, 4096, 0, disk_bytenr, 4096, | 158 | insert_extent(root, offset, sectorsize, sectorsize, 0, disk_bytenr, |
157 | BTRFS_FILE_EXTENT_PREALLOC, 0, slot); | 159 | sectorsize, BTRFS_FILE_EXTENT_PREALLOC, 0, slot); |
158 | slot++; | 160 | slot++; |
159 | offset += 4096; | 161 | offset += sectorsize; |
160 | 162 | ||
161 | /* | 163 | /* |
162 | * We want to jack up disk_bytenr a little more so the em stuff doesn't | 164 | * We want to jack up disk_bytenr a little more so the em stuff doesn't |
163 | * merge our records. | 165 | * merge our records. |
164 | */ | 166 | */ |
165 | disk_bytenr += 8192; | 167 | disk_bytenr += 2 * sectorsize; |
166 | 168 | ||
167 | /* | 169 | /* |
168 | * Now for a partially written prealloc extent, basically the same as | 170 | * Now for a partially written prealloc extent, basically the same as |
169 | * the hole punch example above. Ram_bytes never changes when you mark | 171 | * the hole punch example above. Ram_bytes never changes when you mark |
170 | * extents written btw. | 172 | * extents written btw. |
171 | */ | 173 | */ |
172 | insert_extent(root, offset, 4096, 16384, 0, disk_bytenr, 16384, | 174 | insert_extent(root, offset, sectorsize, 4 * sectorsize, 0, disk_bytenr, |
173 | BTRFS_FILE_EXTENT_PREALLOC, 0, slot); | 175 | 4 * sectorsize, BTRFS_FILE_EXTENT_PREALLOC, 0, slot); |
174 | slot++; | 176 | slot++; |
175 | offset += 4096; | 177 | offset += sectorsize; |
176 | insert_extent(root, offset, 4096, 16384, 4096, disk_bytenr, 16384, | 178 | insert_extent(root, offset, sectorsize, 4 * sectorsize, sectorsize, |
177 | BTRFS_FILE_EXTENT_REG, 0, slot); | 179 | disk_bytenr, 4 * sectorsize, BTRFS_FILE_EXTENT_REG, 0, |
180 | slot); | ||
178 | slot++; | 181 | slot++; |
179 | offset += 4096; | 182 | offset += sectorsize; |
180 | insert_extent(root, offset, 8192, 16384, 8192, disk_bytenr, 16384, | 183 | insert_extent(root, offset, 2 * sectorsize, 4 * sectorsize, |
184 | 2 * sectorsize, disk_bytenr, 4 * sectorsize, | ||
181 | BTRFS_FILE_EXTENT_PREALLOC, 0, slot); | 185 | BTRFS_FILE_EXTENT_PREALLOC, 0, slot); |
182 | slot++; | 186 | slot++; |
183 | offset += 8192; | 187 | offset += 2 * sectorsize; |
184 | disk_bytenr += 16384; | 188 | disk_bytenr += 4 * sectorsize; |
185 | 189 | ||
186 | /* Now a normal compressed extent */ | 190 | /* Now a normal compressed extent */ |
187 | insert_extent(root, offset, 8192, 8192, 0, disk_bytenr, 4096, | 191 | insert_extent(root, offset, 2 * sectorsize, 2 * sectorsize, 0, |
188 | BTRFS_FILE_EXTENT_REG, BTRFS_COMPRESS_ZLIB, slot); | 192 | disk_bytenr, sectorsize, BTRFS_FILE_EXTENT_REG, |
193 | BTRFS_COMPRESS_ZLIB, slot); | ||
189 | slot++; | 194 | slot++; |
190 | offset += 8192; | 195 | offset += 2 * sectorsize; |
191 | /* No merges */ | 196 | /* No merges */ |
192 | disk_bytenr += 8192; | 197 | disk_bytenr += 2 * sectorsize; |
193 | 198 | ||
194 | /* Now a split compressed extent */ | 199 | /* Now a split compressed extent */ |
195 | insert_extent(root, offset, 4096, 16384, 0, disk_bytenr, 4096, | 200 | insert_extent(root, offset, sectorsize, 4 * sectorsize, 0, disk_bytenr, |
196 | BTRFS_FILE_EXTENT_REG, BTRFS_COMPRESS_ZLIB, slot); | 201 | sectorsize, BTRFS_FILE_EXTENT_REG, |
202 | BTRFS_COMPRESS_ZLIB, slot); | ||
197 | slot++; | 203 | slot++; |
198 | offset += 4096; | 204 | offset += sectorsize; |
199 | insert_extent(root, offset, 4096, 4096, 0, disk_bytenr + 4096, 4096, | 205 | insert_extent(root, offset, sectorsize, sectorsize, 0, |
206 | disk_bytenr + sectorsize, sectorsize, | ||
200 | BTRFS_FILE_EXTENT_REG, 0, slot); | 207 | BTRFS_FILE_EXTENT_REG, 0, slot); |
201 | slot++; | 208 | slot++; |
202 | offset += 4096; | 209 | offset += sectorsize; |
203 | insert_extent(root, offset, 8192, 16384, 8192, disk_bytenr, 4096, | 210 | insert_extent(root, offset, 2 * sectorsize, 4 * sectorsize, |
211 | 2 * sectorsize, disk_bytenr, sectorsize, | ||
204 | BTRFS_FILE_EXTENT_REG, BTRFS_COMPRESS_ZLIB, slot); | 212 | BTRFS_FILE_EXTENT_REG, BTRFS_COMPRESS_ZLIB, slot); |
205 | slot++; | 213 | slot++; |
206 | offset += 8192; | 214 | offset += 2 * sectorsize; |
207 | disk_bytenr += 8192; | 215 | disk_bytenr += 2 * sectorsize; |
208 | 216 | ||
209 | /* Now extents that have a hole but no hole extent */ | 217 | /* Now extents that have a hole but no hole extent */ |
210 | insert_extent(root, offset, 4096, 4096, 0, disk_bytenr, 4096, | 218 | insert_extent(root, offset, sectorsize, sectorsize, 0, disk_bytenr, |
211 | BTRFS_FILE_EXTENT_REG, 0, slot); | 219 | sectorsize, BTRFS_FILE_EXTENT_REG, 0, slot); |
212 | slot++; | 220 | slot++; |
213 | offset += 16384; | 221 | offset += 4 * sectorsize; |
214 | disk_bytenr += 4096; | 222 | disk_bytenr += sectorsize; |
215 | insert_extent(root, offset, 4096, 4096, 0, disk_bytenr, 4096, | 223 | insert_extent(root, offset, sectorsize, sectorsize, 0, disk_bytenr, |
216 | BTRFS_FILE_EXTENT_REG, 0, slot); | 224 | sectorsize, BTRFS_FILE_EXTENT_REG, 0, slot); |
217 | } | 225 | } |
218 | 226 | ||
219 | static unsigned long prealloc_only = 0; | 227 | static unsigned long prealloc_only = 0; |
220 | static unsigned long compressed_only = 0; | 228 | static unsigned long compressed_only = 0; |
221 | static unsigned long vacancy_only = 0; | 229 | static unsigned long vacancy_only = 0; |
222 | 230 | ||
223 | static noinline int test_btrfs_get_extent(void) | 231 | static noinline int test_btrfs_get_extent(u32 sectorsize, u32 nodesize) |
224 | { | 232 | { |
225 | struct inode *inode = NULL; | 233 | struct inode *inode = NULL; |
226 | struct btrfs_root *root = NULL; | 234 | struct btrfs_root *root = NULL; |
@@ -240,7 +248,7 @@ static noinline int test_btrfs_get_extent(void) | |||
240 | BTRFS_I(inode)->location.objectid = BTRFS_FIRST_FREE_OBJECTID; | 248 | BTRFS_I(inode)->location.objectid = BTRFS_FIRST_FREE_OBJECTID; |
241 | BTRFS_I(inode)->location.offset = 0; | 249 | BTRFS_I(inode)->location.offset = 0; |
242 | 250 | ||
243 | root = btrfs_alloc_dummy_root(); | 251 | root = btrfs_alloc_dummy_root(sectorsize, nodesize); |
244 | if (IS_ERR(root)) { | 252 | if (IS_ERR(root)) { |
245 | test_msg("Couldn't allocate root\n"); | 253 | test_msg("Couldn't allocate root\n"); |
246 | goto out; | 254 | goto out; |
@@ -256,7 +264,7 @@ static noinline int test_btrfs_get_extent(void) | |||
256 | goto out; | 264 | goto out; |
257 | } | 265 | } |
258 | 266 | ||
259 | root->node = alloc_dummy_extent_buffer(NULL, 4096); | 267 | root->node = alloc_dummy_extent_buffer(NULL, nodesize, nodesize); |
260 | if (!root->node) { | 268 | if (!root->node) { |
261 | test_msg("Couldn't allocate dummy buffer\n"); | 269 | test_msg("Couldn't allocate dummy buffer\n"); |
262 | goto out; | 270 | goto out; |
@@ -273,7 +281,7 @@ static noinline int test_btrfs_get_extent(void) | |||
273 | 281 | ||
274 | /* First with no extents */ | 282 | /* First with no extents */ |
275 | BTRFS_I(inode)->root = root; | 283 | BTRFS_I(inode)->root = root; |
276 | em = btrfs_get_extent(inode, NULL, 0, 0, 4096, 0); | 284 | em = btrfs_get_extent(inode, NULL, 0, 0, sectorsize, 0); |
277 | if (IS_ERR(em)) { | 285 | if (IS_ERR(em)) { |
278 | em = NULL; | 286 | em = NULL; |
279 | test_msg("Got an error when we shouldn't have\n"); | 287 | test_msg("Got an error when we shouldn't have\n"); |
@@ -295,7 +303,7 @@ static noinline int test_btrfs_get_extent(void) | |||
295 | * setup_file_extents, so if you change anything there you need to | 303 | * setup_file_extents, so if you change anything there you need to |
296 | * update the comment and update the expected values below. | 304 | * update the comment and update the expected values below. |
297 | */ | 305 | */ |
298 | setup_file_extents(root); | 306 | setup_file_extents(root, sectorsize); |
299 | 307 | ||
300 | em = btrfs_get_extent(inode, NULL, 0, 0, (u64)-1, 0); | 308 | em = btrfs_get_extent(inode, NULL, 0, 0, (u64)-1, 0); |
301 | if (IS_ERR(em)) { | 309 | if (IS_ERR(em)) { |
@@ -318,7 +326,7 @@ static noinline int test_btrfs_get_extent(void) | |||
318 | offset = em->start + em->len; | 326 | offset = em->start + em->len; |
319 | free_extent_map(em); | 327 | free_extent_map(em); |
320 | 328 | ||
321 | em = btrfs_get_extent(inode, NULL, 0, offset, 4096, 0); | 329 | em = btrfs_get_extent(inode, NULL, 0, offset, sectorsize, 0); |
322 | if (IS_ERR(em)) { | 330 | if (IS_ERR(em)) { |
323 | test_msg("Got an error when we shouldn't have\n"); | 331 | test_msg("Got an error when we shouldn't have\n"); |
324 | goto out; | 332 | goto out; |
@@ -327,7 +335,8 @@ static noinline int test_btrfs_get_extent(void) | |||
327 | test_msg("Expected an inline, got %llu\n", em->block_start); | 335 | test_msg("Expected an inline, got %llu\n", em->block_start); |
328 | goto out; | 336 | goto out; |
329 | } | 337 | } |
330 | if (em->start != offset || em->len != 4091) { | 338 | |
339 | if (em->start != offset || em->len != (sectorsize - 5)) { | ||
331 | test_msg("Unexpected extent wanted start %llu len 1, got start " | 340 | test_msg("Unexpected extent wanted start %llu len 1, got start " |
332 | "%llu len %llu\n", offset, em->start, em->len); | 341 | "%llu len %llu\n", offset, em->start, em->len); |
333 | goto out; | 342 | goto out; |
@@ -344,7 +353,7 @@ static noinline int test_btrfs_get_extent(void) | |||
344 | offset = em->start + em->len; | 353 | offset = em->start + em->len; |
345 | free_extent_map(em); | 354 | free_extent_map(em); |
346 | 355 | ||
347 | em = btrfs_get_extent(inode, NULL, 0, offset, 4096, 0); | 356 | em = btrfs_get_extent(inode, NULL, 0, offset, sectorsize, 0); |
348 | if (IS_ERR(em)) { | 357 | if (IS_ERR(em)) { |
349 | test_msg("Got an error when we shouldn't have\n"); | 358 | test_msg("Got an error when we shouldn't have\n"); |
350 | goto out; | 359 | goto out; |
@@ -366,7 +375,7 @@ static noinline int test_btrfs_get_extent(void) | |||
366 | free_extent_map(em); | 375 | free_extent_map(em); |
367 | 376 | ||
368 | /* Regular extent */ | 377 | /* Regular extent */ |
369 | em = btrfs_get_extent(inode, NULL, 0, offset, 4096, 0); | 378 | em = btrfs_get_extent(inode, NULL, 0, offset, sectorsize, 0); |
370 | if (IS_ERR(em)) { | 379 | if (IS_ERR(em)) { |
371 | test_msg("Got an error when we shouldn't have\n"); | 380 | test_msg("Got an error when we shouldn't have\n"); |
372 | goto out; | 381 | goto out; |
@@ -375,7 +384,7 @@ static noinline int test_btrfs_get_extent(void) | |||
375 | test_msg("Expected a real extent, got %llu\n", em->block_start); | 384 | test_msg("Expected a real extent, got %llu\n", em->block_start); |
376 | goto out; | 385 | goto out; |
377 | } | 386 | } |
378 | if (em->start != offset || em->len != 4095) { | 387 | if (em->start != offset || em->len != sectorsize - 1) { |
379 | test_msg("Unexpected extent wanted start %llu len 4095, got " | 388 | test_msg("Unexpected extent wanted start %llu len 4095, got " |
380 | "start %llu len %llu\n", offset, em->start, em->len); | 389 | "start %llu len %llu\n", offset, em->start, em->len); |
381 | goto out; | 390 | goto out; |
@@ -393,7 +402,7 @@ static noinline int test_btrfs_get_extent(void) | |||
393 | free_extent_map(em); | 402 | free_extent_map(em); |
394 | 403 | ||
395 | /* The next 3 are split extents */ | 404 | /* The next 3 are split extents */ |
396 | em = btrfs_get_extent(inode, NULL, 0, offset, 4096, 0); | 405 | em = btrfs_get_extent(inode, NULL, 0, offset, sectorsize, 0); |
397 | if (IS_ERR(em)) { | 406 | if (IS_ERR(em)) { |
398 | test_msg("Got an error when we shouldn't have\n"); | 407 | test_msg("Got an error when we shouldn't have\n"); |
399 | goto out; | 408 | goto out; |
@@ -402,9 +411,10 @@ static noinline int test_btrfs_get_extent(void) | |||
402 | test_msg("Expected a real extent, got %llu\n", em->block_start); | 411 | test_msg("Expected a real extent, got %llu\n", em->block_start); |
403 | goto out; | 412 | goto out; |
404 | } | 413 | } |
405 | if (em->start != offset || em->len != 4096) { | 414 | if (em->start != offset || em->len != sectorsize) { |
406 | test_msg("Unexpected extent wanted start %llu len 4096, got " | 415 | test_msg("Unexpected extent start %llu len %u, " |
407 | "start %llu len %llu\n", offset, em->start, em->len); | 416 | "got start %llu len %llu\n", |
417 | offset, sectorsize, em->start, em->len); | ||
408 | goto out; | 418 | goto out; |
409 | } | 419 | } |
410 | if (em->flags != 0) { | 420 | if (em->flags != 0) { |
@@ -421,7 +431,7 @@ static noinline int test_btrfs_get_extent(void) | |||
421 | offset = em->start + em->len; | 431 | offset = em->start + em->len; |
422 | free_extent_map(em); | 432 | free_extent_map(em); |
423 | 433 | ||
424 | em = btrfs_get_extent(inode, NULL, 0, offset, 4096, 0); | 434 | em = btrfs_get_extent(inode, NULL, 0, offset, sectorsize, 0); |
425 | if (IS_ERR(em)) { | 435 | if (IS_ERR(em)) { |
426 | test_msg("Got an error when we shouldn't have\n"); | 436 | test_msg("Got an error when we shouldn't have\n"); |
427 | goto out; | 437 | goto out; |
@@ -430,9 +440,10 @@ static noinline int test_btrfs_get_extent(void) | |||
430 | test_msg("Expected a hole, got %llu\n", em->block_start); | 440 | test_msg("Expected a hole, got %llu\n", em->block_start); |
431 | goto out; | 441 | goto out; |
432 | } | 442 | } |
433 | if (em->start != offset || em->len != 4096) { | 443 | if (em->start != offset || em->len != sectorsize) { |
434 | test_msg("Unexpected extent wanted start %llu len 4096, got " | 444 | test_msg("Unexpected extent wanted start %llu len %u, " |
435 | "start %llu len %llu\n", offset, em->start, em->len); | 445 | "got start %llu len %llu\n", |
446 | offset, sectorsize, em->start, em->len); | ||
436 | goto out; | 447 | goto out; |
437 | } | 448 | } |
438 | if (em->flags != 0) { | 449 | if (em->flags != 0) { |
@@ -442,7 +453,7 @@ static noinline int test_btrfs_get_extent(void) | |||
442 | offset = em->start + em->len; | 453 | offset = em->start + em->len; |
443 | free_extent_map(em); | 454 | free_extent_map(em); |
444 | 455 | ||
445 | em = btrfs_get_extent(inode, NULL, 0, offset, 4096, 0); | 456 | em = btrfs_get_extent(inode, NULL, 0, offset, sectorsize, 0); |
446 | if (IS_ERR(em)) { | 457 | if (IS_ERR(em)) { |
447 | test_msg("Got an error when we shouldn't have\n"); | 458 | test_msg("Got an error when we shouldn't have\n"); |
448 | goto out; | 459 | goto out; |
@@ -451,9 +462,10 @@ static noinline int test_btrfs_get_extent(void) | |||
451 | test_msg("Expected a real extent, got %llu\n", em->block_start); | 462 | test_msg("Expected a real extent, got %llu\n", em->block_start); |
452 | goto out; | 463 | goto out; |
453 | } | 464 | } |
454 | if (em->start != offset || em->len != 8192) { | 465 | if (em->start != offset || em->len != 2 * sectorsize) { |
455 | test_msg("Unexpected extent wanted start %llu len 8192, got " | 466 | test_msg("Unexpected extent wanted start %llu len %u, " |
456 | "start %llu len %llu\n", offset, em->start, em->len); | 467 | "got start %llu len %llu\n", |
468 | offset, 2 * sectorsize, em->start, em->len); | ||
457 | goto out; | 469 | goto out; |
458 | } | 470 | } |
459 | if (em->flags != 0) { | 471 | if (em->flags != 0) { |
@@ -475,7 +487,7 @@ static noinline int test_btrfs_get_extent(void) | |||
475 | free_extent_map(em); | 487 | free_extent_map(em); |
476 | 488 | ||
477 | /* Prealloc extent */ | 489 | /* Prealloc extent */ |
478 | em = btrfs_get_extent(inode, NULL, 0, offset, 4096, 0); | 490 | em = btrfs_get_extent(inode, NULL, 0, offset, sectorsize, 0); |
479 | if (IS_ERR(em)) { | 491 | if (IS_ERR(em)) { |
480 | test_msg("Got an error when we shouldn't have\n"); | 492 | test_msg("Got an error when we shouldn't have\n"); |
481 | goto out; | 493 | goto out; |
@@ -484,9 +496,10 @@ static noinline int test_btrfs_get_extent(void) | |||
484 | test_msg("Expected a real extent, got %llu\n", em->block_start); | 496 | test_msg("Expected a real extent, got %llu\n", em->block_start); |
485 | goto out; | 497 | goto out; |
486 | } | 498 | } |
487 | if (em->start != offset || em->len != 4096) { | 499 | if (em->start != offset || em->len != sectorsize) { |
488 | test_msg("Unexpected extent wanted start %llu len 4096, got " | 500 | test_msg("Unexpected extent wanted start %llu len %u, " |
489 | "start %llu len %llu\n", offset, em->start, em->len); | 501 | "got start %llu len %llu\n", |
502 | offset, sectorsize, em->start, em->len); | ||
490 | goto out; | 503 | goto out; |
491 | } | 504 | } |
492 | if (em->flags != prealloc_only) { | 505 | if (em->flags != prealloc_only) { |
@@ -503,7 +516,7 @@ static noinline int test_btrfs_get_extent(void) | |||
503 | free_extent_map(em); | 516 | free_extent_map(em); |
504 | 517 | ||
505 | /* The next 3 are a half written prealloc extent */ | 518 | /* The next 3 are a half written prealloc extent */ |
506 | em = btrfs_get_extent(inode, NULL, 0, offset, 4096, 0); | 519 | em = btrfs_get_extent(inode, NULL, 0, offset, sectorsize, 0); |
507 | if (IS_ERR(em)) { | 520 | if (IS_ERR(em)) { |
508 | test_msg("Got an error when we shouldn't have\n"); | 521 | test_msg("Got an error when we shouldn't have\n"); |
509 | goto out; | 522 | goto out; |
@@ -512,9 +525,10 @@ static noinline int test_btrfs_get_extent(void) | |||
512 | test_msg("Expected a real extent, got %llu\n", em->block_start); | 525 | test_msg("Expected a real extent, got %llu\n", em->block_start); |
513 | goto out; | 526 | goto out; |
514 | } | 527 | } |
515 | if (em->start != offset || em->len != 4096) { | 528 | if (em->start != offset || em->len != sectorsize) { |
516 | test_msg("Unexpected extent wanted start %llu len 4096, got " | 529 | test_msg("Unexpected extent wanted start %llu len %u, " |
517 | "start %llu len %llu\n", offset, em->start, em->len); | 530 | "got start %llu len %llu\n", |
531 | offset, sectorsize, em->start, em->len); | ||
518 | goto out; | 532 | goto out; |
519 | } | 533 | } |
520 | if (em->flags != prealloc_only) { | 534 | if (em->flags != prealloc_only) { |
@@ -532,7 +546,7 @@ static noinline int test_btrfs_get_extent(void) | |||
532 | offset = em->start + em->len; | 546 | offset = em->start + em->len; |
533 | free_extent_map(em); | 547 | free_extent_map(em); |
534 | 548 | ||
535 | em = btrfs_get_extent(inode, NULL, 0, offset, 4096, 0); | 549 | em = btrfs_get_extent(inode, NULL, 0, offset, sectorsize, 0); |
536 | if (IS_ERR(em)) { | 550 | if (IS_ERR(em)) { |
537 | test_msg("Got an error when we shouldn't have\n"); | 551 | test_msg("Got an error when we shouldn't have\n"); |
538 | goto out; | 552 | goto out; |
@@ -541,9 +555,10 @@ static noinline int test_btrfs_get_extent(void) | |||
541 | test_msg("Expected a real extent, got %llu\n", em->block_start); | 555 | test_msg("Expected a real extent, got %llu\n", em->block_start); |
542 | goto out; | 556 | goto out; |
543 | } | 557 | } |
544 | if (em->start != offset || em->len != 4096) { | 558 | if (em->start != offset || em->len != sectorsize) { |
545 | test_msg("Unexpected extent wanted start %llu len 4096, got " | 559 | test_msg("Unexpected extent wanted start %llu len %u, " |
546 | "start %llu len %llu\n", offset, em->start, em->len); | 560 | "got start %llu len %llu\n", |
561 | offset, sectorsize, em->start, em->len); | ||
547 | goto out; | 562 | goto out; |
548 | } | 563 | } |
549 | if (em->flags != 0) { | 564 | if (em->flags != 0) { |
@@ -564,7 +579,7 @@ static noinline int test_btrfs_get_extent(void) | |||
564 | offset = em->start + em->len; | 579 | offset = em->start + em->len; |
565 | free_extent_map(em); | 580 | free_extent_map(em); |
566 | 581 | ||
567 | em = btrfs_get_extent(inode, NULL, 0, offset, 4096, 0); | 582 | em = btrfs_get_extent(inode, NULL, 0, offset, sectorsize, 0); |
568 | if (IS_ERR(em)) { | 583 | if (IS_ERR(em)) { |
569 | test_msg("Got an error when we shouldn't have\n"); | 584 | test_msg("Got an error when we shouldn't have\n"); |
570 | goto out; | 585 | goto out; |
@@ -573,9 +588,10 @@ static noinline int test_btrfs_get_extent(void) | |||
573 | test_msg("Expected a real extent, got %llu\n", em->block_start); | 588 | test_msg("Expected a real extent, got %llu\n", em->block_start); |
574 | goto out; | 589 | goto out; |
575 | } | 590 | } |
576 | if (em->start != offset || em->len != 8192) { | 591 | if (em->start != offset || em->len != 2 * sectorsize) { |
577 | test_msg("Unexpected extent wanted start %llu len 8192, got " | 592 | test_msg("Unexpected extent wanted start %llu len %u, " |
578 | "start %llu len %llu\n", offset, em->start, em->len); | 593 | "got start %llu len %llu\n", |
594 | offset, 2 * sectorsize, em->start, em->len); | ||
579 | goto out; | 595 | goto out; |
580 | } | 596 | } |
581 | if (em->flags != prealloc_only) { | 597 | if (em->flags != prealloc_only) { |
@@ -598,7 +614,7 @@ static noinline int test_btrfs_get_extent(void) | |||
598 | free_extent_map(em); | 614 | free_extent_map(em); |
599 | 615 | ||
600 | /* Now for the compressed extent */ | 616 | /* Now for the compressed extent */ |
601 | em = btrfs_get_extent(inode, NULL, 0, offset, 4096, 0); | 617 | em = btrfs_get_extent(inode, NULL, 0, offset, sectorsize, 0); |
602 | if (IS_ERR(em)) { | 618 | if (IS_ERR(em)) { |
603 | test_msg("Got an error when we shouldn't have\n"); | 619 | test_msg("Got an error when we shouldn't have\n"); |
604 | goto out; | 620 | goto out; |
@@ -607,9 +623,10 @@ static noinline int test_btrfs_get_extent(void) | |||
607 | test_msg("Expected a real extent, got %llu\n", em->block_start); | 623 | test_msg("Expected a real extent, got %llu\n", em->block_start); |
608 | goto out; | 624 | goto out; |
609 | } | 625 | } |
610 | if (em->start != offset || em->len != 8192) { | 626 | if (em->start != offset || em->len != 2 * sectorsize) { |
611 | test_msg("Unexpected extent wanted start %llu len 8192, got " | 627 | test_msg("Unexpected extent wanted start %llu len %u," |
612 | "start %llu len %llu\n", offset, em->start, em->len); | 628 | "got start %llu len %llu\n", |
629 | offset, 2 * sectorsize, em->start, em->len); | ||
613 | goto out; | 630 | goto out; |
614 | } | 631 | } |
615 | if (em->flags != compressed_only) { | 632 | if (em->flags != compressed_only) { |
@@ -631,7 +648,7 @@ static noinline int test_btrfs_get_extent(void) | |||
631 | free_extent_map(em); | 648 | free_extent_map(em); |
632 | 649 | ||
633 | /* Split compressed extent */ | 650 | /* Split compressed extent */ |
634 | em = btrfs_get_extent(inode, NULL, 0, offset, 4096, 0); | 651 | em = btrfs_get_extent(inode, NULL, 0, offset, sectorsize, 0); |
635 | if (IS_ERR(em)) { | 652 | if (IS_ERR(em)) { |
636 | test_msg("Got an error when we shouldn't have\n"); | 653 | test_msg("Got an error when we shouldn't have\n"); |
637 | goto out; | 654 | goto out; |
@@ -640,9 +657,10 @@ static noinline int test_btrfs_get_extent(void) | |||
640 | test_msg("Expected a real extent, got %llu\n", em->block_start); | 657 | test_msg("Expected a real extent, got %llu\n", em->block_start); |
641 | goto out; | 658 | goto out; |
642 | } | 659 | } |
643 | if (em->start != offset || em->len != 4096) { | 660 | if (em->start != offset || em->len != sectorsize) { |
644 | test_msg("Unexpected extent wanted start %llu len 4096, got " | 661 | test_msg("Unexpected extent wanted start %llu len %u," |
645 | "start %llu len %llu\n", offset, em->start, em->len); | 662 | "got start %llu len %llu\n", |
663 | offset, sectorsize, em->start, em->len); | ||
646 | goto out; | 664 | goto out; |
647 | } | 665 | } |
648 | if (em->flags != compressed_only) { | 666 | if (em->flags != compressed_only) { |
@@ -665,7 +683,7 @@ static noinline int test_btrfs_get_extent(void) | |||
665 | offset = em->start + em->len; | 683 | offset = em->start + em->len; |
666 | free_extent_map(em); | 684 | free_extent_map(em); |
667 | 685 | ||
668 | em = btrfs_get_extent(inode, NULL, 0, offset, 4096, 0); | 686 | em = btrfs_get_extent(inode, NULL, 0, offset, sectorsize, 0); |
669 | if (IS_ERR(em)) { | 687 | if (IS_ERR(em)) { |
670 | test_msg("Got an error when we shouldn't have\n"); | 688 | test_msg("Got an error when we shouldn't have\n"); |
671 | goto out; | 689 | goto out; |
@@ -674,9 +692,10 @@ static noinline int test_btrfs_get_extent(void) | |||
674 | test_msg("Expected a real extent, got %llu\n", em->block_start); | 692 | test_msg("Expected a real extent, got %llu\n", em->block_start); |
675 | goto out; | 693 | goto out; |
676 | } | 694 | } |
677 | if (em->start != offset || em->len != 4096) { | 695 | if (em->start != offset || em->len != sectorsize) { |
678 | test_msg("Unexpected extent wanted start %llu len 4096, got " | 696 | test_msg("Unexpected extent wanted start %llu len %u, " |
679 | "start %llu len %llu\n", offset, em->start, em->len); | 697 | "got start %llu len %llu\n", |
698 | offset, sectorsize, em->start, em->len); | ||
680 | goto out; | 699 | goto out; |
681 | } | 700 | } |
682 | if (em->flags != 0) { | 701 | if (em->flags != 0) { |
@@ -691,7 +710,7 @@ static noinline int test_btrfs_get_extent(void) | |||
691 | offset = em->start + em->len; | 710 | offset = em->start + em->len; |
692 | free_extent_map(em); | 711 | free_extent_map(em); |
693 | 712 | ||
694 | em = btrfs_get_extent(inode, NULL, 0, offset, 4096, 0); | 713 | em = btrfs_get_extent(inode, NULL, 0, offset, sectorsize, 0); |
695 | if (IS_ERR(em)) { | 714 | if (IS_ERR(em)) { |
696 | test_msg("Got an error when we shouldn't have\n"); | 715 | test_msg("Got an error when we shouldn't have\n"); |
697 | goto out; | 716 | goto out; |
@@ -701,9 +720,10 @@ static noinline int test_btrfs_get_extent(void) | |||
701 | disk_bytenr, em->block_start); | 720 | disk_bytenr, em->block_start); |
702 | goto out; | 721 | goto out; |
703 | } | 722 | } |
704 | if (em->start != offset || em->len != 8192) { | 723 | if (em->start != offset || em->len != 2 * sectorsize) { |
705 | test_msg("Unexpected extent wanted start %llu len 8192, got " | 724 | test_msg("Unexpected extent wanted start %llu len %u, " |
706 | "start %llu len %llu\n", offset, em->start, em->len); | 725 | "got start %llu len %llu\n", |
726 | offset, 2 * sectorsize, em->start, em->len); | ||
707 | goto out; | 727 | goto out; |
708 | } | 728 | } |
709 | if (em->flags != compressed_only) { | 729 | if (em->flags != compressed_only) { |
@@ -725,7 +745,7 @@ static noinline int test_btrfs_get_extent(void) | |||
725 | free_extent_map(em); | 745 | free_extent_map(em); |
726 | 746 | ||
727 | /* A hole between regular extents but no hole extent */ | 747 | /* A hole between regular extents but no hole extent */ |
728 | em = btrfs_get_extent(inode, NULL, 0, offset + 6, 4096, 0); | 748 | em = btrfs_get_extent(inode, NULL, 0, offset + 6, sectorsize, 0); |
729 | if (IS_ERR(em)) { | 749 | if (IS_ERR(em)) { |
730 | test_msg("Got an error when we shouldn't have\n"); | 750 | test_msg("Got an error when we shouldn't have\n"); |
731 | goto out; | 751 | goto out; |
@@ -734,9 +754,10 @@ static noinline int test_btrfs_get_extent(void) | |||
734 | test_msg("Expected a real extent, got %llu\n", em->block_start); | 754 | test_msg("Expected a real extent, got %llu\n", em->block_start); |
735 | goto out; | 755 | goto out; |
736 | } | 756 | } |
737 | if (em->start != offset || em->len != 4096) { | 757 | if (em->start != offset || em->len != sectorsize) { |
738 | test_msg("Unexpected extent wanted start %llu len 4096, got " | 758 | test_msg("Unexpected extent wanted start %llu len %u, " |
739 | "start %llu len %llu\n", offset, em->start, em->len); | 759 | "got start %llu len %llu\n", |
760 | offset, sectorsize, em->start, em->len); | ||
740 | goto out; | 761 | goto out; |
741 | } | 762 | } |
742 | if (em->flags != 0) { | 763 | if (em->flags != 0) { |
@@ -765,9 +786,10 @@ static noinline int test_btrfs_get_extent(void) | |||
765 | * length of the actual hole, if this changes we'll have to change this | 786 | * length of the actual hole, if this changes we'll have to change this |
766 | * test. | 787 | * test. |
767 | */ | 788 | */ |
768 | if (em->start != offset || em->len != 12288) { | 789 | if (em->start != offset || em->len != 3 * sectorsize) { |
769 | test_msg("Unexpected extent wanted start %llu len 12288, got " | 790 | test_msg("Unexpected extent wanted start %llu len %u, " |
770 | "start %llu len %llu\n", offset, em->start, em->len); | 791 | "got start %llu len %llu\n", |
792 | offset, 3 * sectorsize, em->start, em->len); | ||
771 | goto out; | 793 | goto out; |
772 | } | 794 | } |
773 | if (em->flags != vacancy_only) { | 795 | if (em->flags != vacancy_only) { |
@@ -783,7 +805,7 @@ static noinline int test_btrfs_get_extent(void) | |||
783 | offset = em->start + em->len; | 805 | offset = em->start + em->len; |
784 | free_extent_map(em); | 806 | free_extent_map(em); |
785 | 807 | ||
786 | em = btrfs_get_extent(inode, NULL, 0, offset, 4096, 0); | 808 | em = btrfs_get_extent(inode, NULL, 0, offset, sectorsize, 0); |
787 | if (IS_ERR(em)) { | 809 | if (IS_ERR(em)) { |
788 | test_msg("Got an error when we shouldn't have\n"); | 810 | test_msg("Got an error when we shouldn't have\n"); |
789 | goto out; | 811 | goto out; |
@@ -792,9 +814,10 @@ static noinline int test_btrfs_get_extent(void) | |||
792 | test_msg("Expected a real extent, got %llu\n", em->block_start); | 814 | test_msg("Expected a real extent, got %llu\n", em->block_start); |
793 | goto out; | 815 | goto out; |
794 | } | 816 | } |
795 | if (em->start != offset || em->len != 4096) { | 817 | if (em->start != offset || em->len != sectorsize) { |
796 | test_msg("Unexpected extent wanted start %llu len 4096, got " | 818 | test_msg("Unexpected extent wanted start %llu len %u," |
797 | "start %llu len %llu\n", offset, em->start, em->len); | 819 | "got start %llu len %llu\n", |
820 | offset, sectorsize, em->start, em->len); | ||
798 | goto out; | 821 | goto out; |
799 | } | 822 | } |
800 | if (em->flags != 0) { | 823 | if (em->flags != 0) { |
@@ -815,7 +838,7 @@ out: | |||
815 | return ret; | 838 | return ret; |
816 | } | 839 | } |
817 | 840 | ||
818 | static int test_hole_first(void) | 841 | static int test_hole_first(u32 sectorsize, u32 nodesize) |
819 | { | 842 | { |
820 | struct inode *inode = NULL; | 843 | struct inode *inode = NULL; |
821 | struct btrfs_root *root = NULL; | 844 | struct btrfs_root *root = NULL; |
@@ -832,7 +855,7 @@ static int test_hole_first(void) | |||
832 | BTRFS_I(inode)->location.objectid = BTRFS_FIRST_FREE_OBJECTID; | 855 | BTRFS_I(inode)->location.objectid = BTRFS_FIRST_FREE_OBJECTID; |
833 | BTRFS_I(inode)->location.offset = 0; | 856 | BTRFS_I(inode)->location.offset = 0; |
834 | 857 | ||
835 | root = btrfs_alloc_dummy_root(); | 858 | root = btrfs_alloc_dummy_root(sectorsize, nodesize); |
836 | if (IS_ERR(root)) { | 859 | if (IS_ERR(root)) { |
837 | test_msg("Couldn't allocate root\n"); | 860 | test_msg("Couldn't allocate root\n"); |
838 | goto out; | 861 | goto out; |
@@ -844,7 +867,7 @@ static int test_hole_first(void) | |||
844 | goto out; | 867 | goto out; |
845 | } | 868 | } |
846 | 869 | ||
847 | root->node = alloc_dummy_extent_buffer(NULL, 4096); | 870 | root->node = alloc_dummy_extent_buffer(NULL, nodesize, nodesize); |
848 | if (!root->node) { | 871 | if (!root->node) { |
849 | test_msg("Couldn't allocate dummy buffer\n"); | 872 | test_msg("Couldn't allocate dummy buffer\n"); |
850 | goto out; | 873 | goto out; |
@@ -861,9 +884,9 @@ static int test_hole_first(void) | |||
861 | * btrfs_get_extent. | 884 | * btrfs_get_extent. |
862 | */ | 885 | */ |
863 | insert_inode_item_key(root); | 886 | insert_inode_item_key(root); |
864 | insert_extent(root, 4096, 4096, 4096, 0, 4096, 4096, | 887 | insert_extent(root, sectorsize, sectorsize, sectorsize, 0, sectorsize, |
865 | BTRFS_FILE_EXTENT_REG, 0, 1); | 888 | sectorsize, BTRFS_FILE_EXTENT_REG, 0, 1); |
866 | em = btrfs_get_extent(inode, NULL, 0, 0, 8192, 0); | 889 | em = btrfs_get_extent(inode, NULL, 0, 0, 2 * sectorsize, 0); |
867 | if (IS_ERR(em)) { | 890 | if (IS_ERR(em)) { |
868 | test_msg("Got an error when we shouldn't have\n"); | 891 | test_msg("Got an error when we shouldn't have\n"); |
869 | goto out; | 892 | goto out; |
@@ -872,9 +895,10 @@ static int test_hole_first(void) | |||
872 | test_msg("Expected a hole, got %llu\n", em->block_start); | 895 | test_msg("Expected a hole, got %llu\n", em->block_start); |
873 | goto out; | 896 | goto out; |
874 | } | 897 | } |
875 | if (em->start != 0 || em->len != 4096) { | 898 | if (em->start != 0 || em->len != sectorsize) { |
876 | test_msg("Unexpected extent wanted start 0 len 4096, got start " | 899 | test_msg("Unexpected extent wanted start 0 len %u, " |
877 | "%llu len %llu\n", em->start, em->len); | 900 | "got start %llu len %llu\n", |
901 | sectorsize, em->start, em->len); | ||
878 | goto out; | 902 | goto out; |
879 | } | 903 | } |
880 | if (em->flags != vacancy_only) { | 904 | if (em->flags != vacancy_only) { |
@@ -884,18 +908,19 @@ static int test_hole_first(void) | |||
884 | } | 908 | } |
885 | free_extent_map(em); | 909 | free_extent_map(em); |
886 | 910 | ||
887 | em = btrfs_get_extent(inode, NULL, 0, 4096, 8192, 0); | 911 | em = btrfs_get_extent(inode, NULL, 0, sectorsize, 2 * sectorsize, 0); |
888 | if (IS_ERR(em)) { | 912 | if (IS_ERR(em)) { |
889 | test_msg("Got an error when we shouldn't have\n"); | 913 | test_msg("Got an error when we shouldn't have\n"); |
890 | goto out; | 914 | goto out; |
891 | } | 915 | } |
892 | if (em->block_start != 4096) { | 916 | if (em->block_start != sectorsize) { |
893 | test_msg("Expected a real extent, got %llu\n", em->block_start); | 917 | test_msg("Expected a real extent, got %llu\n", em->block_start); |
894 | goto out; | 918 | goto out; |
895 | } | 919 | } |
896 | if (em->start != 4096 || em->len != 4096) { | 920 | if (em->start != sectorsize || em->len != sectorsize) { |
897 | test_msg("Unexpected extent wanted start 4096 len 4096, got " | 921 | test_msg("Unexpected extent wanted start %u len %u, " |
898 | "start %llu len %llu\n", em->start, em->len); | 922 | "got start %llu len %llu\n", |
923 | sectorsize, sectorsize, em->start, em->len); | ||
899 | goto out; | 924 | goto out; |
900 | } | 925 | } |
901 | if (em->flags != 0) { | 926 | if (em->flags != 0) { |
@@ -912,7 +937,7 @@ out: | |||
912 | return ret; | 937 | return ret; |
913 | } | 938 | } |
914 | 939 | ||
915 | static int test_extent_accounting(void) | 940 | static int test_extent_accounting(u32 sectorsize, u32 nodesize) |
916 | { | 941 | { |
917 | struct inode *inode = NULL; | 942 | struct inode *inode = NULL; |
918 | struct btrfs_root *root = NULL; | 943 | struct btrfs_root *root = NULL; |
@@ -924,7 +949,7 @@ static int test_extent_accounting(void) | |||
924 | return ret; | 949 | return ret; |
925 | } | 950 | } |
926 | 951 | ||
927 | root = btrfs_alloc_dummy_root(); | 952 | root = btrfs_alloc_dummy_root(sectorsize, nodesize); |
928 | if (IS_ERR(root)) { | 953 | if (IS_ERR(root)) { |
929 | test_msg("Couldn't allocate root\n"); | 954 | test_msg("Couldn't allocate root\n"); |
930 | goto out; | 955 | goto out; |
@@ -954,10 +979,11 @@ static int test_extent_accounting(void) | |||
954 | goto out; | 979 | goto out; |
955 | } | 980 | } |
956 | 981 | ||
957 | /* [BTRFS_MAX_EXTENT_SIZE][4k] */ | 982 | /* [BTRFS_MAX_EXTENT_SIZE][sectorsize] */ |
958 | BTRFS_I(inode)->outstanding_extents++; | 983 | BTRFS_I(inode)->outstanding_extents++; |
959 | ret = btrfs_set_extent_delalloc(inode, BTRFS_MAX_EXTENT_SIZE, | 984 | ret = btrfs_set_extent_delalloc(inode, BTRFS_MAX_EXTENT_SIZE, |
960 | BTRFS_MAX_EXTENT_SIZE + 4095, NULL); | 985 | BTRFS_MAX_EXTENT_SIZE + sectorsize - 1, |
986 | NULL); | ||
961 | if (ret) { | 987 | if (ret) { |
962 | test_msg("btrfs_set_extent_delalloc returned %d\n", ret); | 988 | test_msg("btrfs_set_extent_delalloc returned %d\n", ret); |
963 | goto out; | 989 | goto out; |
@@ -969,10 +995,10 @@ static int test_extent_accounting(void) | |||
969 | goto out; | 995 | goto out; |
970 | } | 996 | } |
971 | 997 | ||
972 | /* [BTRFS_MAX_EXTENT_SIZE/2][4K HOLE][the rest] */ | 998 | /* [BTRFS_MAX_EXTENT_SIZE/2][sectorsize HOLE][the rest] */ |
973 | ret = clear_extent_bit(&BTRFS_I(inode)->io_tree, | 999 | ret = clear_extent_bit(&BTRFS_I(inode)->io_tree, |
974 | BTRFS_MAX_EXTENT_SIZE >> 1, | 1000 | BTRFS_MAX_EXTENT_SIZE >> 1, |
975 | (BTRFS_MAX_EXTENT_SIZE >> 1) + 4095, | 1001 | (BTRFS_MAX_EXTENT_SIZE >> 1) + sectorsize - 1, |
976 | EXTENT_DELALLOC | EXTENT_DIRTY | | 1002 | EXTENT_DELALLOC | EXTENT_DIRTY | |
977 | EXTENT_UPTODATE | EXTENT_DO_ACCOUNTING, 0, 0, | 1003 | EXTENT_UPTODATE | EXTENT_DO_ACCOUNTING, 0, 0, |
978 | NULL, GFP_KERNEL); | 1004 | NULL, GFP_KERNEL); |
@@ -987,10 +1013,11 @@ static int test_extent_accounting(void) | |||
987 | goto out; | 1013 | goto out; |
988 | } | 1014 | } |
989 | 1015 | ||
990 | /* [BTRFS_MAX_EXTENT_SIZE][4K] */ | 1016 | /* [BTRFS_MAX_EXTENT_SIZE][sectorsize] */ |
991 | BTRFS_I(inode)->outstanding_extents++; | 1017 | BTRFS_I(inode)->outstanding_extents++; |
992 | ret = btrfs_set_extent_delalloc(inode, BTRFS_MAX_EXTENT_SIZE >> 1, | 1018 | ret = btrfs_set_extent_delalloc(inode, BTRFS_MAX_EXTENT_SIZE >> 1, |
993 | (BTRFS_MAX_EXTENT_SIZE >> 1) + 4095, | 1019 | (BTRFS_MAX_EXTENT_SIZE >> 1) |
1020 | + sectorsize - 1, | ||
994 | NULL); | 1021 | NULL); |
995 | if (ret) { | 1022 | if (ret) { |
996 | test_msg("btrfs_set_extent_delalloc returned %d\n", ret); | 1023 | test_msg("btrfs_set_extent_delalloc returned %d\n", ret); |
@@ -1004,16 +1031,17 @@ static int test_extent_accounting(void) | |||
1004 | } | 1031 | } |
1005 | 1032 | ||
1006 | /* | 1033 | /* |
1007 | * [BTRFS_MAX_EXTENT_SIZE+4K][4K HOLE][BTRFS_MAX_EXTENT_SIZE+4K] | 1034 | * [BTRFS_MAX_EXTENT_SIZE+sectorsize][sectorsize HOLE][BTRFS_MAX_EXTENT_SIZE+sectorsize] |
1008 | * | 1035 | * |
1009 | * I'm artificially adding 2 to outstanding_extents because in the | 1036 | * I'm artificially adding 2 to outstanding_extents because in the |
1010 | * buffered IO case we'd add things up as we go, but I don't feel like | 1037 | * buffered IO case we'd add things up as we go, but I don't feel like |
1011 | * doing that here, this isn't the interesting case we want to test. | 1038 | * doing that here, this isn't the interesting case we want to test. |
1012 | */ | 1039 | */ |
1013 | BTRFS_I(inode)->outstanding_extents += 2; | 1040 | BTRFS_I(inode)->outstanding_extents += 2; |
1014 | ret = btrfs_set_extent_delalloc(inode, BTRFS_MAX_EXTENT_SIZE + 8192, | 1041 | ret = btrfs_set_extent_delalloc(inode, |
1015 | (BTRFS_MAX_EXTENT_SIZE << 1) + 12287, | 1042 | BTRFS_MAX_EXTENT_SIZE + 2 * sectorsize, |
1016 | NULL); | 1043 | (BTRFS_MAX_EXTENT_SIZE << 1) + 3 * sectorsize - 1, |
1044 | NULL); | ||
1017 | if (ret) { | 1045 | if (ret) { |
1018 | test_msg("btrfs_set_extent_delalloc returned %d\n", ret); | 1046 | test_msg("btrfs_set_extent_delalloc returned %d\n", ret); |
1019 | goto out; | 1047 | goto out; |
@@ -1025,10 +1053,13 @@ static int test_extent_accounting(void) | |||
1025 | goto out; | 1053 | goto out; |
1026 | } | 1054 | } |
1027 | 1055 | ||
1028 | /* [BTRFS_MAX_EXTENT_SIZE+4k][4k][BTRFS_MAX_EXTENT_SIZE+4k] */ | 1056 | /* |
1057 | * [BTRFS_MAX_EXTENT_SIZE+sectorsize][sectorsize][BTRFS_MAX_EXTENT_SIZE+sectorsize] | ||
1058 | */ | ||
1029 | BTRFS_I(inode)->outstanding_extents++; | 1059 | BTRFS_I(inode)->outstanding_extents++; |
1030 | ret = btrfs_set_extent_delalloc(inode, BTRFS_MAX_EXTENT_SIZE+4096, | 1060 | ret = btrfs_set_extent_delalloc(inode, |
1031 | BTRFS_MAX_EXTENT_SIZE+8191, NULL); | 1061 | BTRFS_MAX_EXTENT_SIZE + sectorsize, |
1062 | BTRFS_MAX_EXTENT_SIZE + 2 * sectorsize - 1, NULL); | ||
1032 | if (ret) { | 1063 | if (ret) { |
1033 | test_msg("btrfs_set_extent_delalloc returned %d\n", ret); | 1064 | test_msg("btrfs_set_extent_delalloc returned %d\n", ret); |
1034 | goto out; | 1065 | goto out; |
@@ -1042,8 +1073,8 @@ static int test_extent_accounting(void) | |||
1042 | 1073 | ||
1043 | /* [BTRFS_MAX_EXTENT_SIZE+4k][4K HOLE][BTRFS_MAX_EXTENT_SIZE+4k] */ | 1074 | /* [BTRFS_MAX_EXTENT_SIZE+4k][4K HOLE][BTRFS_MAX_EXTENT_SIZE+4k] */ |
1044 | ret = clear_extent_bit(&BTRFS_I(inode)->io_tree, | 1075 | ret = clear_extent_bit(&BTRFS_I(inode)->io_tree, |
1045 | BTRFS_MAX_EXTENT_SIZE+4096, | 1076 | BTRFS_MAX_EXTENT_SIZE + sectorsize, |
1046 | BTRFS_MAX_EXTENT_SIZE+8191, | 1077 | BTRFS_MAX_EXTENT_SIZE + 2 * sectorsize - 1, |
1047 | EXTENT_DIRTY | EXTENT_DELALLOC | | 1078 | EXTENT_DIRTY | EXTENT_DELALLOC | |
1048 | EXTENT_DO_ACCOUNTING | EXTENT_UPTODATE, 0, 0, | 1079 | EXTENT_DO_ACCOUNTING | EXTENT_UPTODATE, 0, 0, |
1049 | NULL, GFP_KERNEL); | 1080 | NULL, GFP_KERNEL); |
@@ -1063,8 +1094,9 @@ static int test_extent_accounting(void) | |||
1063 | * might fail and I'd rather satisfy my paranoia at this point. | 1094 | * might fail and I'd rather satisfy my paranoia at this point. |
1064 | */ | 1095 | */ |
1065 | BTRFS_I(inode)->outstanding_extents++; | 1096 | BTRFS_I(inode)->outstanding_extents++; |
1066 | ret = btrfs_set_extent_delalloc(inode, BTRFS_MAX_EXTENT_SIZE+4096, | 1097 | ret = btrfs_set_extent_delalloc(inode, |
1067 | BTRFS_MAX_EXTENT_SIZE+8191, NULL); | 1098 | BTRFS_MAX_EXTENT_SIZE + sectorsize, |
1099 | BTRFS_MAX_EXTENT_SIZE + 2 * sectorsize - 1, NULL); | ||
1068 | if (ret) { | 1100 | if (ret) { |
1069 | test_msg("btrfs_set_extent_delalloc returned %d\n", ret); | 1101 | test_msg("btrfs_set_extent_delalloc returned %d\n", ret); |
1070 | goto out; | 1102 | goto out; |
@@ -1103,7 +1135,7 @@ out: | |||
1103 | return ret; | 1135 | return ret; |
1104 | } | 1136 | } |
1105 | 1137 | ||
1106 | int btrfs_test_inodes(void) | 1138 | int btrfs_test_inodes(u32 sectorsize, u32 nodesize) |
1107 | { | 1139 | { |
1108 | int ret; | 1140 | int ret; |
1109 | 1141 | ||
@@ -1112,13 +1144,13 @@ int btrfs_test_inodes(void) | |||
1112 | set_bit(EXTENT_FLAG_PREALLOC, &prealloc_only); | 1144 | set_bit(EXTENT_FLAG_PREALLOC, &prealloc_only); |
1113 | 1145 | ||
1114 | test_msg("Running btrfs_get_extent tests\n"); | 1146 | test_msg("Running btrfs_get_extent tests\n"); |
1115 | ret = test_btrfs_get_extent(); | 1147 | ret = test_btrfs_get_extent(sectorsize, nodesize); |
1116 | if (ret) | 1148 | if (ret) |
1117 | return ret; | 1149 | return ret; |
1118 | test_msg("Running hole first btrfs_get_extent test\n"); | 1150 | test_msg("Running hole first btrfs_get_extent test\n"); |
1119 | ret = test_hole_first(); | 1151 | ret = test_hole_first(sectorsize, nodesize); |
1120 | if (ret) | 1152 | if (ret) |
1121 | return ret; | 1153 | return ret; |
1122 | test_msg("Running outstanding_extents tests\n"); | 1154 | test_msg("Running outstanding_extents tests\n"); |
1123 | return test_extent_accounting(); | 1155 | return test_extent_accounting(sectorsize, nodesize); |
1124 | } | 1156 | } |