Skip to content

Commit 6e31609

Browse files
author
Boaz Harrosh
committed
exofs: Remove useless optimization
We used to compact all used devices in an IO to the beginning of the device array in an io_state. And keep a last device used so in later loops we don't iterate on all device slots. This does not prevent us from checking if slots are empty since in reads we only read from a single mirror and jump to the next mirror-set. This optimization is marginal, and needlessly complicates the code. Specially when we will later want to support raid/456 with same abstract code. So remove the distinction between "dev" and "comp". Only "dev" is used both as the device used and as the index (component) in the device array. [Note that now the io_state->dev member is redundant but I keep it because I might want to optimize by only IOing a single group, though keeping a group_width*mirrors devices in io_state, we now keep num-devices in each io_state] Signed-off-by: Boaz Harrosh <[email protected]>
1 parent b284834 commit 6e31609

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

fs/exofs/ios.c

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -392,20 +392,19 @@ static int _add_stripe_unit(struct exofs_io_state *ios, unsigned *cur_pg,
392392
}
393393

394394
static int _prepare_one_group(struct exofs_io_state *ios, u64 length,
395-
struct _striping_info *si, unsigned first_comp)
395+
struct _striping_info *si)
396396
{
397397
unsigned stripe_unit = ios->layout->stripe_unit;
398398
unsigned mirrors_p1 = ios->layout->mirrors_p1;
399399
unsigned devs_in_group = ios->layout->group_width * mirrors_p1;
400400
unsigned dev = si->dev;
401401
unsigned first_dev = dev - (dev % devs_in_group);
402-
unsigned comp = first_comp + (dev - first_dev);
403402
unsigned max_comp = ios->numdevs ? ios->numdevs - mirrors_p1 : 0;
404403
unsigned cur_pg = ios->pages_consumed;
405404
int ret = 0;
406405

407406
while (length) {
408-
struct exofs_per_dev_state *per_dev = &ios->per_dev[comp];
407+
struct exofs_per_dev_state *per_dev = &ios->per_dev[dev];
409408
unsigned cur_len, page_off = 0;
410409

411410
if (!per_dev->length) {
@@ -424,11 +423,8 @@ static int _prepare_one_group(struct exofs_io_state *ios, u64 length,
424423
cur_len = stripe_unit;
425424
}
426425

427-
if (max_comp < comp)
428-
max_comp = comp;
429-
430-
dev += mirrors_p1;
431-
dev = (dev % devs_in_group) + first_dev;
426+
if (max_comp < dev)
427+
max_comp = dev;
432428
} else {
433429
cur_len = stripe_unit;
434430
}
@@ -440,8 +436,8 @@ static int _prepare_one_group(struct exofs_io_state *ios, u64 length,
440436
if (unlikely(ret))
441437
goto out;
442438

443-
comp += mirrors_p1;
444-
comp = (comp % devs_in_group) + first_comp;
439+
dev += mirrors_p1;
440+
dev = (dev % devs_in_group) + first_dev;
445441

446442
length -= cur_len;
447443
}
@@ -457,7 +453,6 @@ static int _prepare_for_striping(struct exofs_io_state *ios)
457453
struct _striping_info si;
458454
unsigned devs_in_group = ios->layout->group_width *
459455
ios->layout->mirrors_p1;
460-
unsigned first_comp = 0;
461456
int ret = 0;
462457

463458
_calc_stripe_info(ios, ios->offset, &si);
@@ -482,7 +477,7 @@ static int _prepare_for_striping(struct exofs_io_state *ios)
482477
if (length < si.group_length)
483478
si.group_length = length;
484479

485-
ret = _prepare_one_group(ios, si.group_length, &si, first_comp);
480+
ret = _prepare_one_group(ios, si.group_length, &si);
486481
if (unlikely(ret))
487482
goto out;
488483

@@ -496,9 +491,6 @@ static int _prepare_for_striping(struct exofs_io_state *ios)
496491

497492
si.dev = (si.dev - (si.dev % devs_in_group)) + devs_in_group;
498493
si.dev %= ios->layout->s_numdevs;
499-
500-
first_comp += devs_in_group;
501-
first_comp %= ios->layout->s_numdevs;
502494
}
503495

504496
out:

0 commit comments

Comments
 (0)