Skip to content

Commit 5002dd1

Browse files
author
Boaz Harrosh
committed
exofs: Fix groups code when num_devices is not divisible by group_width
There is a bug when num_devices is not divisible by group_width * mirrors. We would not return to the proper device and offset when looping on to the next group. The fix makes code simpler actually. Signed-off-by: Boaz Harrosh <[email protected]>
1 parent 6e31609 commit 5002dd1

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

fs/exofs/ios.c

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,6 @@ int exofs_check_io(struct exofs_io_state *ios, u64 *resid)
305305
struct _striping_info {
306306
u64 obj_offset;
307307
u64 group_length;
308-
u64 total_group_length;
309-
u64 Major;
310308
unsigned dev;
311309
unsigned unit_off;
312310
};
@@ -343,8 +341,6 @@ static void _calc_stripe_info(struct exofs_io_state *ios, u64 file_offset,
343341
(M * group_depth * stripe_unit);
344342

345343
si->group_length = T - H;
346-
si->total_group_length = T;
347-
si->Major = M;
348344
}
349345

350346
static int _add_stripe_unit(struct exofs_io_state *ios, unsigned *cur_pg,
@@ -450,17 +446,15 @@ static int _prepare_one_group(struct exofs_io_state *ios, u64 length,
450446
static int _prepare_for_striping(struct exofs_io_state *ios)
451447
{
452448
u64 length = ios->length;
449+
u64 offset = ios->offset;
453450
struct _striping_info si;
454-
unsigned devs_in_group = ios->layout->group_width *
455-
ios->layout->mirrors_p1;
456451
int ret = 0;
457452

458-
_calc_stripe_info(ios, ios->offset, &si);
459-
460453
if (!ios->pages) {
461454
if (ios->kern_buff) {
462455
struct exofs_per_dev_state *per_dev = &ios->per_dev[0];
463456

457+
_calc_stripe_info(ios, ios->offset, &si);
464458
per_dev->offset = si.obj_offset;
465459
per_dev->dev = si.dev;
466460

@@ -474,23 +468,17 @@ static int _prepare_for_striping(struct exofs_io_state *ios)
474468
}
475469

476470
while (length) {
471+
_calc_stripe_info(ios, offset, &si);
472+
477473
if (length < si.group_length)
478474
si.group_length = length;
479475

480476
ret = _prepare_one_group(ios, si.group_length, &si);
481477
if (unlikely(ret))
482478
goto out;
483479

480+
offset += si.group_length;
484481
length -= si.group_length;
485-
486-
si.group_length = si.total_group_length;
487-
si.unit_off = 0;
488-
++si.Major;
489-
si.obj_offset = si.Major * ios->layout->stripe_unit *
490-
ios->layout->group_depth;
491-
492-
si.dev = (si.dev - (si.dev % devs_in_group)) + devs_in_group;
493-
si.dev %= ios->layout->s_numdevs;
494482
}
495483

496484
out:

0 commit comments

Comments
 (0)