diff options
-rw-r--r-- | fs/exofs/ore.c | 10 | ||||
-rw-r--r-- | fs/exofs/ore_raid.c | 13 | ||||
-rw-r--r-- | fs/exofs/ore_raid.h | 18 |
3 files changed, 10 insertions, 31 deletions
diff --git a/fs/exofs/ore.c b/fs/exofs/ore.c index 92157b6971b3..0e2a8353f7cc 100644 --- a/fs/exofs/ore.c +++ b/fs/exofs/ore.c | |||
@@ -545,17 +545,19 @@ void ore_calc_stripe_info(struct ore_layout *layout, u64 file_offset, | |||
545 | 545 | ||
546 | /* "H - (N * U)" is just "H % U" so it's bound to u32 */ | 546 | /* "H - (N * U)" is just "H % U" so it's bound to u32 */ |
547 | u32 C = (u32)(H - (N * U)) / stripe_unit + G * group_width; | 547 | u32 C = (u32)(H - (N * U)) / stripe_unit + G * group_width; |
548 | u32 first_dev = C - C % group_width; | ||
548 | 549 | ||
549 | div_u64_rem(file_offset, stripe_unit, &si->unit_off); | 550 | div_u64_rem(file_offset, stripe_unit, &si->unit_off); |
550 | 551 | ||
551 | si->obj_offset = si->unit_off + (N * stripe_unit) + | 552 | si->obj_offset = si->unit_off + (N * stripe_unit) + |
552 | (M * group_depth * stripe_unit); | 553 | (M * group_depth * stripe_unit); |
554 | si->cur_comp = C - first_dev; | ||
555 | si->cur_pg = si->unit_off / PAGE_SIZE; | ||
553 | 556 | ||
554 | if (parity) { | 557 | if (parity) { |
555 | u32 LCMdP = lcm(group_width, parity) / parity; | 558 | u32 LCMdP = lcm(group_width, parity) / parity; |
556 | /* R = N % LCMdP; */ | 559 | /* R = N % LCMdP; */ |
557 | u32 RxP = (N % LCMdP) * parity; | 560 | u32 RxP = (N % LCMdP) * parity; |
558 | u32 first_dev = C - C % group_width; | ||
559 | 561 | ||
560 | si->par_dev = (group_width + group_width - parity - RxP) % | 562 | si->par_dev = (group_width + group_width - parity - RxP) % |
561 | group_width + first_dev; | 563 | group_width + first_dev; |
@@ -670,9 +672,7 @@ static int _prepare_for_striping(struct ore_io_state *ios) | |||
670 | 672 | ||
671 | BUG_ON(length > si->length); | 673 | BUG_ON(length > si->length); |
672 | 674 | ||
673 | dev_order = _dev_order(devs_in_group, mirrors_p1, si->par_dev, dev); | 675 | dev_order = si->cur_comp; |
674 | si->cur_comp = dev_order; | ||
675 | si->cur_pg = si->unit_off / PAGE_SIZE; | ||
676 | 676 | ||
677 | while (length) { | 677 | while (length) { |
678 | struct ore_per_dev_state *per_dev = | 678 | struct ore_per_dev_state *per_dev = |
@@ -718,6 +718,8 @@ static int _prepare_for_striping(struct ore_io_state *ios) | |||
718 | * stripe. then operate on parity dev. | 718 | * stripe. then operate on parity dev. |
719 | */ | 719 | */ |
720 | dev = si->par_dev; | 720 | dev = si->par_dev; |
721 | /* If last stripe operate on parity comp */ | ||
722 | si->cur_comp = group_width - ios->layout->parity; | ||
721 | } | 723 | } |
722 | per_dev = &ios->per_dev[dev - first_dev]; | 724 | per_dev = &ios->per_dev[dev - first_dev]; |
723 | if (!per_dev->length) { | 725 | if (!per_dev->length) { |
diff --git a/fs/exofs/ore_raid.c b/fs/exofs/ore_raid.c index af417d351535..d58a952e28bc 100644 --- a/fs/exofs/ore_raid.c +++ b/fs/exofs/ore_raid.c | |||
@@ -402,9 +402,8 @@ static int _add_to_r4w_last_page(struct ore_io_state *ios, u64 *offset) | |||
402 | 402 | ||
403 | ore_calc_stripe_info(ios->layout, *offset, 0, &si); | 403 | ore_calc_stripe_info(ios->layout, *offset, 0, &si); |
404 | 404 | ||
405 | p = si.unit_off / PAGE_SIZE; | 405 | p = si.cur_pg; |
406 | c = _dev_order(ios->layout->group_width * ios->layout->mirrors_p1, | 406 | c = si.cur_comp; |
407 | ios->layout->mirrors_p1, si.par_dev, si.dev); | ||
408 | page = ios->sp2d->_1p_stripes[p].pages[c]; | 407 | page = ios->sp2d->_1p_stripes[p].pages[c]; |
409 | 408 | ||
410 | pg_len = PAGE_SIZE - (si.unit_off % PAGE_SIZE); | 409 | pg_len = PAGE_SIZE - (si.unit_off % PAGE_SIZE); |
@@ -532,9 +531,8 @@ static int _read_4_write_last_stripe(struct ore_io_state *ios) | |||
532 | goto read_it; | 531 | goto read_it; |
533 | 532 | ||
534 | ore_calc_stripe_info(ios->layout, offset, 0, &read_si); | 533 | ore_calc_stripe_info(ios->layout, offset, 0, &read_si); |
535 | p = read_si.unit_off / PAGE_SIZE; | 534 | p = read_si.cur_pg; |
536 | c = _dev_order(ios->layout->group_width * ios->layout->mirrors_p1, | 535 | c = read_si.cur_comp; |
537 | ios->layout->mirrors_p1, read_si.par_dev, read_si.dev); | ||
538 | 536 | ||
539 | if (min_p == sp2d->pages_in_unit) { | 537 | if (min_p == sp2d->pages_in_unit) { |
540 | /* Didn't do it yet */ | 538 | /* Didn't do it yet */ |
@@ -638,9 +636,6 @@ int _ore_add_parity_unit(struct ore_io_state *ios, | |||
638 | si->cur_pg = _sp2d_min_pg(sp2d); | 636 | si->cur_pg = _sp2d_min_pg(sp2d); |
639 | num_pages = _sp2d_max_pg(sp2d) + 1 - si->cur_pg; | 637 | num_pages = _sp2d_max_pg(sp2d) + 1 - si->cur_pg; |
640 | 638 | ||
641 | if (!cur_len) /* If last stripe operate on parity comp */ | ||
642 | si->cur_comp = sp2d->data_devs; | ||
643 | |||
644 | if (!per_dev->length) { | 639 | if (!per_dev->length) { |
645 | per_dev->offset += si->cur_pg * PAGE_SIZE; | 640 | per_dev->offset += si->cur_pg * PAGE_SIZE; |
646 | /* If first stripe, Read in all read4write pages | 641 | /* If first stripe, Read in all read4write pages |
diff --git a/fs/exofs/ore_raid.h b/fs/exofs/ore_raid.h index 2ffd2c3c6e46..d365bda6beef 100644 --- a/fs/exofs/ore_raid.h +++ b/fs/exofs/ore_raid.h | |||
@@ -31,24 +31,6 @@ | |||
31 | #define ORE_DBGMSG2(M...) do {} while (0) | 31 | #define ORE_DBGMSG2(M...) do {} while (0) |
32 | /* #define ORE_DBGMSG2 ORE_DBGMSG */ | 32 | /* #define ORE_DBGMSG2 ORE_DBGMSG */ |
33 | 33 | ||
34 | /* Calculate the component order in a stripe. eg the logical data unit | ||
35 | * address within the stripe of @dev given the @par_dev of this stripe. | ||
36 | */ | ||
37 | static inline unsigned _dev_order(unsigned devs_in_group, unsigned mirrors_p1, | ||
38 | unsigned par_dev, unsigned dev) | ||
39 | { | ||
40 | unsigned first_dev = dev - dev % devs_in_group; | ||
41 | |||
42 | dev -= first_dev; | ||
43 | par_dev -= first_dev; | ||
44 | |||
45 | if (devs_in_group == par_dev) /* The raid 0 case */ | ||
46 | return dev / mirrors_p1; | ||
47 | /* raid4/5/6 case */ | ||
48 | return ((devs_in_group + dev - par_dev - mirrors_p1) % devs_in_group) / | ||
49 | mirrors_p1; | ||
50 | } | ||
51 | |||
52 | /* ios_raid.c stuff needed by ios.c */ | 34 | /* ios_raid.c stuff needed by ios.c */ |
53 | int _ore_post_alloc_raid_stuff(struct ore_io_state *ios); | 35 | int _ore_post_alloc_raid_stuff(struct ore_io_state *ios); |
54 | void _ore_free_raid_stuff(struct ore_io_state *ios); | 36 | void _ore_free_raid_stuff(struct ore_io_state *ios); |