diff options
Diffstat (limited to 'fs/exofs')
-rw-r--r-- | fs/exofs/ore.c | 61 |
1 files changed, 24 insertions, 37 deletions
diff --git a/fs/exofs/ore.c b/fs/exofs/ore.c index c1c2cc607adf..7e02d33b5e5c 100644 --- a/fs/exofs/ore.c +++ b/fs/exofs/ore.c | |||
@@ -121,11 +121,9 @@ int ore_get_rw_state(struct ore_layout *layout, struct ore_components *oc, | |||
121 | ios->offset = offset; | 121 | ios->offset = offset; |
122 | 122 | ||
123 | if (length) { | 123 | if (length) { |
124 | struct ore_striping_info si; | 124 | ore_calc_stripe_info(layout, offset, &ios->si); |
125 | 125 | ios->length = (length <= ios->si.group_length) ? length : | |
126 | ore_calc_stripe_info(layout, offset, &si); | 126 | ios->si.group_length; |
127 | ios->length = (length <= si.group_length) ? length : | ||
128 | si.group_length; | ||
129 | ios->nr_pages = (ios->length + PAGE_SIZE - 1) / PAGE_SIZE; | 127 | ios->nr_pages = (ios->length + PAGE_SIZE - 1) / PAGE_SIZE; |
130 | } | 128 | } |
131 | 129 | ||
@@ -416,17 +414,36 @@ static int _add_stripe_unit(struct ore_io_state *ios, unsigned *cur_pg, | |||
416 | return 0; | 414 | return 0; |
417 | } | 415 | } |
418 | 416 | ||
419 | static int _prepare_one_group(struct ore_io_state *ios, u64 length, | 417 | static int _prepare_for_striping(struct ore_io_state *ios) |
420 | struct ore_striping_info *si) | ||
421 | { | 418 | { |
419 | struct ore_striping_info *si = &ios->si; | ||
422 | unsigned stripe_unit = ios->layout->stripe_unit; | 420 | unsigned stripe_unit = ios->layout->stripe_unit; |
423 | unsigned mirrors_p1 = ios->layout->mirrors_p1; | 421 | unsigned mirrors_p1 = ios->layout->mirrors_p1; |
424 | unsigned devs_in_group = ios->layout->group_width * mirrors_p1; | 422 | unsigned devs_in_group = ios->layout->group_width * mirrors_p1; |
425 | unsigned dev = si->dev; | 423 | unsigned dev = si->dev; |
426 | unsigned first_dev = dev - (dev % devs_in_group); | 424 | unsigned first_dev = dev - (dev % devs_in_group); |
427 | unsigned cur_pg = ios->pages_consumed; | 425 | unsigned cur_pg = ios->pages_consumed; |
426 | u64 length = ios->length; | ||
428 | int ret = 0; | 427 | int ret = 0; |
429 | 428 | ||
429 | if (!ios->pages) { | ||
430 | if (ios->kern_buff) { | ||
431 | struct ore_per_dev_state *per_dev = &ios->per_dev[0]; | ||
432 | |||
433 | per_dev->offset = si->obj_offset; | ||
434 | per_dev->dev = si->dev; | ||
435 | |||
436 | /* no cross device without page array */ | ||
437 | BUG_ON((ios->layout->group_width > 1) && | ||
438 | (si->unit_off + ios->length > | ||
439 | ios->layout->stripe_unit)); | ||
440 | } | ||
441 | ios->numdevs = ios->layout->mirrors_p1; | ||
442 | return 0; | ||
443 | } | ||
444 | |||
445 | BUG_ON(length > si->group_length); | ||
446 | |||
430 | while (length) { | 447 | while (length) { |
431 | unsigned comp = dev - first_dev; | 448 | unsigned comp = dev - first_dev; |
432 | struct ore_per_dev_state *per_dev = &ios->per_dev[comp]; | 449 | struct ore_per_dev_state *per_dev = &ios->per_dev[comp]; |
@@ -469,36 +486,6 @@ out: | |||
469 | return ret; | 486 | return ret; |
470 | } | 487 | } |
471 | 488 | ||
472 | static int _prepare_for_striping(struct ore_io_state *ios) | ||
473 | { | ||
474 | struct ore_striping_info si; | ||
475 | int ret; | ||
476 | |||
477 | if (!ios->pages) { | ||
478 | if (ios->kern_buff) { | ||
479 | struct ore_per_dev_state *per_dev = &ios->per_dev[0]; | ||
480 | |||
481 | ore_calc_stripe_info(ios->layout, ios->offset, &si); | ||
482 | per_dev->offset = si.obj_offset; | ||
483 | per_dev->dev = si.dev; | ||
484 | |||
485 | /* no cross device without page array */ | ||
486 | BUG_ON((ios->layout->group_width > 1) && | ||
487 | (si.unit_off + ios->length > | ||
488 | ios->layout->stripe_unit)); | ||
489 | } | ||
490 | ios->numdevs = ios->layout->mirrors_p1; | ||
491 | return 0; | ||
492 | } | ||
493 | |||
494 | ore_calc_stripe_info(ios->layout, ios->offset, &si); | ||
495 | |||
496 | BUG_ON(ios->length > si.group_length); | ||
497 | ret = _prepare_one_group(ios, ios->length, &si); | ||
498 | |||
499 | return ret; | ||
500 | } | ||
501 | |||
502 | int ore_create(struct ore_io_state *ios) | 489 | int ore_create(struct ore_io_state *ios) |
503 | { | 490 | { |
504 | int i, ret; | 491 | int i, ret; |