@@ -47,7 +47,6 @@ static int unstripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
sector_t width, tmp_len;
unsigned long long start;
char dummy;
- int r = -EINVAL;
if (argc != 5) {
ti->error = "Invalid number of arguments";
@@ -86,13 +85,12 @@ static int unstripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
goto err;
}
- r = dm_get_device(ti, argv[3], dm_table_get_mode(ti->table), &uc->dev);
- if (r) {
+ if (dm_get_device(ti, argv[3], dm_table_get_mode(ti->table), &uc->dev)) {
ti->error = "Couldn't get striped device";
goto err;
}
- if (sscanf(argv[1], "%llu%c", &start, &dummy) != 1) {
+ if (sscanf(argv[4], "%llu%c", &start, &dummy) != 1) {
ti->error = "Invalid striped device offset";
goto err;
}
@@ -114,8 +112,7 @@ static int unstripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
goto err;
}
- r = dm_set_target_max_io_len(ti, uc->chunk_size);
- if (r) {
+ if (dm_set_target_max_io_len(ti, uc->chunk_size)) {
ti->error = "Failed to set max io len";
goto err;
}
@@ -124,7 +121,7 @@ static int unstripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
return 0;
err:
cleanup_unstripe(uc, ti);
- return r;
+ return -EINVAL;
}
static void unstripe_dtr(struct dm_target *ti)
@@ -139,11 +136,12 @@ static sector_t map_to_core(struct dm_target *ti, struct bio *bio)
struct unstripe_c *uc = ti->private;
sector_t sector = bio->bi_iter.bi_sector;
+ /* Shift us up to the right "row" on the stripe */
+ sector += uc->unstripe_width * (sector >> uc->chunk_shift);
+
/* Account for what stripe we're operating on */
sector += uc->unstripe_offset;
- /* Shift us up to the right "row" on the stripe */
- sector += uc->unstripe_width * (sector >> uc->chunk_shift);
return sector;
}