diff options
Diffstat (limited to 'fs/exofs/ios.c')
-rw-r--r-- | fs/exofs/ios.c | 129 |
1 files changed, 106 insertions, 23 deletions
diff --git a/fs/exofs/ios.c b/fs/exofs/ios.c index d28febdf54ab..5293bc411d17 100644 --- a/fs/exofs/ios.c +++ b/fs/exofs/ios.c | |||
@@ -262,25 +262,50 @@ int exofs_check_io(struct exofs_io_state *ios, u64 *resid) | |||
262 | /* | 262 | /* |
263 | * L - logical offset into the file | 263 | * L - logical offset into the file |
264 | * | 264 | * |
265 | * U - The number of bytes in a full stripe | 265 | * U - The number of bytes in a stripe within a group |
266 | * | 266 | * |
267 | * U = stripe_unit * group_width | 267 | * U = stripe_unit * group_width |
268 | * | 268 | * |
269 | * N - The stripe number | 269 | * T - The number of bytes striped within a group of component objects |
270 | * (before advancing to the next group) | ||
270 | * | 271 | * |
271 | * N = L / U | 272 | * T = stripe_unit * group_width * group_depth |
273 | * | ||
274 | * S - The number of bytes striped across all component objects | ||
275 | * before the pattern repeats | ||
276 | * | ||
277 | * S = stripe_unit * group_width * group_depth * group_count | ||
278 | * | ||
279 | * M - The "major" (i.e., across all components) stripe number | ||
280 | * | ||
281 | * M = L / S | ||
282 | * | ||
283 | * G - Counts the groups from the beginning of the major stripe | ||
284 | * | ||
285 | * G = (L - (M * S)) / T [or (L % S) / T] | ||
286 | * | ||
287 | * H - The byte offset within the group | ||
288 | * | ||
289 | * H = (L - (M * S)) % T [or (L % S) % T] | ||
290 | * | ||
291 | * N - The "minor" (i.e., across the group) stripe number | ||
292 | * | ||
293 | * N = H / U | ||
272 | * | 294 | * |
273 | * C - The component index coresponding to L | 295 | * C - The component index coresponding to L |
274 | * | 296 | * |
275 | * C = (L - (N*U)) / stripe_unit | 297 | * C = (H - (N * U)) / stripe_unit + G * group_width |
298 | * [or (L % U) / stripe_unit + G * group_width] | ||
276 | * | 299 | * |
277 | * O - The component offset coresponding to L | 300 | * O - The component offset coresponding to L |
278 | * | 301 | * |
279 | * (N*stripe_unit)+(L%stripe_unit) | 302 | * O = L % stripe_unit + N * stripe_unit + M * group_depth * stripe_unit |
280 | */ | 303 | */ |
281 | |||
282 | struct _striping_info { | 304 | struct _striping_info { |
283 | u64 obj_offset; | 305 | u64 obj_offset; |
306 | u64 group_length; | ||
307 | u64 total_group_length; | ||
308 | u64 Major; | ||
284 | unsigned dev; | 309 | unsigned dev; |
285 | unsigned unit_off; | 310 | unsigned unit_off; |
286 | }; | 311 | }; |
@@ -290,15 +315,35 @@ static void _calc_stripe_info(struct exofs_io_state *ios, u64 file_offset, | |||
290 | { | 315 | { |
291 | u32 stripe_unit = ios->layout->stripe_unit; | 316 | u32 stripe_unit = ios->layout->stripe_unit; |
292 | u32 group_width = ios->layout->group_width; | 317 | u32 group_width = ios->layout->group_width; |
318 | u64 group_depth = ios->layout->group_depth; | ||
319 | |||
293 | u32 U = stripe_unit * group_width; | 320 | u32 U = stripe_unit * group_width; |
321 | u64 T = U * group_depth; | ||
322 | u64 S = T * ios->layout->group_count; | ||
323 | u64 M = div64_u64(file_offset, S); | ||
324 | |||
325 | /* | ||
326 | G = (L - (M * S)) / T | ||
327 | H = (L - (M * S)) % T | ||
328 | */ | ||
329 | u64 LmodS = file_offset - M * S; | ||
330 | u32 G = div64_u64(LmodS, T); | ||
331 | u64 H = LmodS - G * T; | ||
332 | |||
333 | u32 N = div_u64(H, U); | ||
334 | |||
335 | /* "H - (N * U)" is just "H % U" so it's bound to u32 */ | ||
336 | si->dev = (u32)(H - (N * U)) / stripe_unit + G * group_width; | ||
337 | si->dev *= ios->layout->mirrors_p1; | ||
294 | 338 | ||
295 | u32 LmodU; | 339 | div_u64_rem(file_offset, stripe_unit, &si->unit_off); |
296 | u64 N = div_u64_rem(file_offset, U, &LmodU); | ||
297 | 340 | ||
298 | si->unit_off = LmodU % stripe_unit; | 341 | si->obj_offset = si->unit_off + (N * stripe_unit) + |
299 | si->obj_offset = N * stripe_unit + si->unit_off; | 342 | (M * group_depth * stripe_unit); |
300 | si->dev = LmodU / stripe_unit; | 343 | |
301 | si->dev *= ios->layout->mirrors_p1; | 344 | si->group_length = T - H; |
345 | si->total_group_length = T; | ||
346 | si->Major = M; | ||
302 | } | 347 | } |
303 | 348 | ||
304 | static int _add_stripe_unit(struct exofs_io_state *ios, unsigned *cur_pg, | 349 | static int _add_stripe_unit(struct exofs_io_state *ios, unsigned *cur_pg, |
@@ -345,16 +390,17 @@ static int _add_stripe_unit(struct exofs_io_state *ios, unsigned *cur_pg, | |||
345 | return 0; | 390 | return 0; |
346 | } | 391 | } |
347 | 392 | ||
348 | static int _prepare_pages(struct exofs_io_state *ios, | 393 | static int _prepare_one_group(struct exofs_io_state *ios, u64 length, |
349 | struct _striping_info *si) | 394 | struct _striping_info *si, unsigned first_comp) |
350 | { | 395 | { |
351 | u64 length = ios->length; | ||
352 | unsigned stripe_unit = ios->layout->stripe_unit; | 396 | unsigned stripe_unit = ios->layout->stripe_unit; |
353 | unsigned mirrors_p1 = ios->layout->mirrors_p1; | 397 | unsigned mirrors_p1 = ios->layout->mirrors_p1; |
398 | unsigned devs_in_group = ios->layout->group_width * mirrors_p1; | ||
354 | unsigned dev = si->dev; | 399 | unsigned dev = si->dev; |
355 | unsigned comp = 0; | 400 | unsigned first_dev = dev - (dev % devs_in_group); |
356 | unsigned stripes = 0; | 401 | unsigned comp = first_comp + (dev - first_dev); |
357 | unsigned cur_pg = 0; | 402 | unsigned max_comp = ios->numdevs ? ios->numdevs - mirrors_p1 : 0; |
403 | unsigned cur_pg = ios->pages_consumed; | ||
358 | int ret = 0; | 404 | int ret = 0; |
359 | 405 | ||
360 | while (length) { | 406 | while (length) { |
@@ -377,10 +423,11 @@ static int _prepare_pages(struct exofs_io_state *ios, | |||
377 | cur_len = stripe_unit; | 423 | cur_len = stripe_unit; |
378 | } | 424 | } |
379 | 425 | ||
380 | stripes++; | 426 | if (max_comp < comp) |
427 | max_comp = comp; | ||
381 | 428 | ||
382 | dev += mirrors_p1; | 429 | dev += mirrors_p1; |
383 | dev %= ios->layout->s_numdevs; | 430 | dev = (dev % devs_in_group) + first_dev; |
384 | } else { | 431 | } else { |
385 | cur_len = stripe_unit; | 432 | cur_len = stripe_unit; |
386 | } | 433 | } |
@@ -393,18 +440,24 @@ static int _prepare_pages(struct exofs_io_state *ios, | |||
393 | goto out; | 440 | goto out; |
394 | 441 | ||
395 | comp += mirrors_p1; | 442 | comp += mirrors_p1; |
396 | comp %= ios->layout->s_numdevs; | 443 | comp = (comp % devs_in_group) + first_comp; |
397 | 444 | ||
398 | length -= cur_len; | 445 | length -= cur_len; |
399 | } | 446 | } |
400 | out: | 447 | out: |
401 | ios->numdevs = stripes * mirrors_p1; | 448 | ios->numdevs = max_comp + mirrors_p1; |
449 | ios->pages_consumed = cur_pg; | ||
402 | return ret; | 450 | return ret; |
403 | } | 451 | } |
404 | 452 | ||
405 | static int _prepare_for_striping(struct exofs_io_state *ios) | 453 | static int _prepare_for_striping(struct exofs_io_state *ios) |
406 | { | 454 | { |
455 | u64 length = ios->length; | ||
407 | struct _striping_info si; | 456 | struct _striping_info si; |
457 | unsigned devs_in_group = ios->layout->group_width * | ||
458 | ios->layout->mirrors_p1; | ||
459 | unsigned first_comp = 0; | ||
460 | int ret = 0; | ||
408 | 461 | ||
409 | _calc_stripe_info(ios, ios->offset, &si); | 462 | _calc_stripe_info(ios, ios->offset, &si); |
410 | 463 | ||
@@ -424,7 +477,31 @@ static int _prepare_for_striping(struct exofs_io_state *ios) | |||
424 | return 0; | 477 | return 0; |
425 | } | 478 | } |
426 | 479 | ||
427 | return _prepare_pages(ios, &si); | 480 | while (length) { |
481 | if (length < si.group_length) | ||
482 | si.group_length = length; | ||
483 | |||
484 | ret = _prepare_one_group(ios, si.group_length, &si, first_comp); | ||
485 | if (unlikely(ret)) | ||
486 | goto out; | ||
487 | |||
488 | length -= si.group_length; | ||
489 | |||
490 | si.group_length = si.total_group_length; | ||
491 | si.unit_off = 0; | ||
492 | ++si.Major; | ||
493 | si.obj_offset = si.Major * ios->layout->stripe_unit * | ||
494 | ios->layout->group_depth; | ||
495 | |||
496 | si.dev = (si.dev - (si.dev % devs_in_group)) + devs_in_group; | ||
497 | si.dev %= ios->layout->s_numdevs; | ||
498 | |||
499 | first_comp += devs_in_group; | ||
500 | first_comp %= ios->layout->s_numdevs; | ||
501 | } | ||
502 | |||
503 | out: | ||
504 | return ret; | ||
428 | } | 505 | } |
429 | 506 | ||
430 | int exofs_sbi_create(struct exofs_io_state *ios) | 507 | int exofs_sbi_create(struct exofs_io_state *ios) |
@@ -482,6 +559,9 @@ static int _sbi_write_mirror(struct exofs_io_state *ios, int cur_comp) | |||
482 | unsigned last_comp = cur_comp + ios->layout->mirrors_p1; | 559 | unsigned last_comp = cur_comp + ios->layout->mirrors_p1; |
483 | int ret = 0; | 560 | int ret = 0; |
484 | 561 | ||
562 | if (ios->pages && !master_dev->length) | ||
563 | return 0; /* Just an empty slot */ | ||
564 | |||
485 | for (; cur_comp < last_comp; ++cur_comp, ++dev) { | 565 | for (; cur_comp < last_comp; ++cur_comp, ++dev) { |
486 | struct exofs_per_dev_state *per_dev = &ios->per_dev[cur_comp]; | 566 | struct exofs_per_dev_state *per_dev = &ios->per_dev[cur_comp]; |
487 | struct osd_request *or; | 567 | struct osd_request *or; |
@@ -580,6 +660,9 @@ static int _sbi_read_mirror(struct exofs_io_state *ios, unsigned cur_comp) | |||
580 | struct exofs_per_dev_state *per_dev = &ios->per_dev[cur_comp]; | 660 | struct exofs_per_dev_state *per_dev = &ios->per_dev[cur_comp]; |
581 | unsigned first_dev = (unsigned)ios->obj.id; | 661 | unsigned first_dev = (unsigned)ios->obj.id; |
582 | 662 | ||
663 | if (ios->pages && !per_dev->length) | ||
664 | return 0; /* Just an empty slot */ | ||
665 | |||
583 | first_dev = per_dev->dev + first_dev % ios->layout->mirrors_p1; | 666 | first_dev = per_dev->dev + first_dev % ios->layout->mirrors_p1; |
584 | or = osd_start_request(exofs_ios_od(ios, first_dev), GFP_KERNEL); | 667 | or = osd_start_request(exofs_ios_od(ios, first_dev), GFP_KERNEL); |
585 | if (unlikely(!or)) { | 668 | if (unlikely(!or)) { |