Skip to content

Commit 9826075

Browse files
author
Boaz Harrosh
committed
ore: cleanup: Embed an ore_striping_info inside ore_io_state
Now that each ore_io_state covers only a single raid group. A single striping_info math is needed. Embed one inside ore_io_state to cache the calculation results and eliminate an extra call. Also the outer _prepare_for_striping is removed since it does nothing. Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
1 parent b916c5c commit 9826075

2 files changed

Lines changed: 25 additions & 37 deletions

File tree

‎fs/exofs/ore.c‎

Lines changed: 24 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,9 @@ int ore_get_rw_state(struct ore_layout *layout, struct ore_components *oc,
121121
ios->offset = offset;
122122

123123
if (length) {
124-
struct ore_striping_info si;
125-
126-
ore_calc_stripe_info(layout, offset, &si);
127-
ios->length = (length <= si.group_length) ? length :
128-
si.group_length;
124+
ore_calc_stripe_info(layout, offset, &ios->si);
125+
ios->length = (length <= ios->si.group_length) ? length :
126+
ios->si.group_length;
129127
ios->nr_pages = (ios->length + PAGE_SIZE - 1) / PAGE_SIZE;
130128
}
131129

@@ -416,17 +414,36 @@ static int _add_stripe_unit(struct ore_io_state *ios, unsigned *cur_pg,
416414
return 0;
417415
}
418416

419-
static int _prepare_one_group(struct ore_io_state *ios, u64 length,
420-
struct ore_striping_info *si)
417+
static int _prepare_for_striping(struct ore_io_state *ios)
421418
{
419+
struct ore_striping_info *si = &ios->si;
422420
unsigned stripe_unit = ios->layout->stripe_unit;
423421
unsigned mirrors_p1 = ios->layout->mirrors_p1;
424422
unsigned devs_in_group = ios->layout->group_width * mirrors_p1;
425423
unsigned dev = si->dev;
426424
unsigned first_dev = dev - (dev % devs_in_group);
427425
unsigned cur_pg = ios->pages_consumed;
426+
u64 length = ios->length;
428427
int ret = 0;
429428

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+
430447
while (length) {
431448
unsigned comp = dev - first_dev;
432449
struct ore_per_dev_state *per_dev = &ios->per_dev[comp];
@@ -469,36 +486,6 @@ static int _prepare_one_group(struct ore_io_state *ios, u64 length,
469486
return ret;
470487
}
471488

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-
502489
int ore_create(struct ore_io_state *ios)
503490
{
504491
int i, ret;

‎include/scsi/osd_ore.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ typedef void (*ore_io_done_fn)(struct ore_io_state *ios, void *private);
9393

9494
struct ore_io_state {
9595
struct kref kref;
96+
struct ore_striping_info si;
9697

9798
void *private;
9899
ore_io_done_fn done;

0 commit comments

Comments
 (0)