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 <bharrosh@panasas.com>
diff --git a/fs/exofs/ios.c b/fs/exofs/ios.c
index 4337cad..5bb4737 100644
--- a/fs/exofs/ios.c
+++ b/fs/exofs/ios.c
@@ -392,20 +392,19 @@
}
static int _prepare_one_group(struct exofs_io_state *ios, u64 length,
- struct _striping_info *si, unsigned first_comp)
+ struct _striping_info *si)
{
unsigned stripe_unit = ios->layout->stripe_unit;
unsigned mirrors_p1 = ios->layout->mirrors_p1;
unsigned devs_in_group = ios->layout->group_width * mirrors_p1;
unsigned dev = si->dev;
unsigned first_dev = dev - (dev % devs_in_group);
- unsigned comp = first_comp + (dev - first_dev);
unsigned max_comp = ios->numdevs ? ios->numdevs - mirrors_p1 : 0;
unsigned cur_pg = ios->pages_consumed;
int ret = 0;
while (length) {
- struct exofs_per_dev_state *per_dev = &ios->per_dev[comp];
+ struct exofs_per_dev_state *per_dev = &ios->per_dev[dev];
unsigned cur_len, page_off = 0;
if (!per_dev->length) {
@@ -424,11 +423,8 @@
cur_len = stripe_unit;
}
- if (max_comp < comp)
- max_comp = comp;
-
- dev += mirrors_p1;
- dev = (dev % devs_in_group) + first_dev;
+ if (max_comp < dev)
+ max_comp = dev;
} else {
cur_len = stripe_unit;
}
@@ -440,8 +436,8 @@
if (unlikely(ret))
goto out;
- comp += mirrors_p1;
- comp = (comp % devs_in_group) + first_comp;
+ dev += mirrors_p1;
+ dev = (dev % devs_in_group) + first_dev;
length -= cur_len;
}
@@ -457,7 +453,6 @@
struct _striping_info si;
unsigned devs_in_group = ios->layout->group_width *
ios->layout->mirrors_p1;
- unsigned first_comp = 0;
int ret = 0;
_calc_stripe_info(ios, ios->offset, &si);
@@ -482,7 +477,7 @@
if (length < si.group_length)
si.group_length = length;
- ret = _prepare_one_group(ios, si.group_length, &si, first_comp);
+ ret = _prepare_one_group(ios, si.group_length, &si);
if (unlikely(ret))
goto out;
@@ -496,9 +491,6 @@
si.dev = (si.dev - (si.dev % devs_in_group)) + devs_in_group;
si.dev %= ios->layout->s_numdevs;
-
- first_comp += devs_in_group;
- first_comp %= ios->layout->s_numdevs;
}
out: