Skip to content

Commit 7209049

Browse files
committed
dm kcopyd: return void from dm_kcopyd_copy()
dm_kcopyd_copy() only ever returns 0 so there is no need for callers to account for possible failure. Same goes for dm_kcopyd_zero(). Signed-off-by: Mike Snitzer <snitzer@redhat.com>
1 parent 63c8ecb commit 7209049

File tree

6 files changed

+27
-63
lines changed

6 files changed

+27
-63
lines changed

drivers/md/dm-cache-target.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,9 +1188,8 @@ static void copy_complete(int read_err, unsigned long write_err, void *context)
11881188
queue_continuation(mg->cache->wq, &mg->k);
11891189
}
11901190

1191-
static int copy(struct dm_cache_migration *mg, bool promote)
1191+
static void copy(struct dm_cache_migration *mg, bool promote)
11921192
{
1193-
int r;
11941193
struct dm_io_region o_region, c_region;
11951194
struct cache *cache = mg->cache;
11961195

@@ -1203,11 +1202,9 @@ static int copy(struct dm_cache_migration *mg, bool promote)
12031202
c_region.count = cache->sectors_per_block;
12041203

12051204
if (promote)
1206-
r = dm_kcopyd_copy(cache->copier, &o_region, 1, &c_region, 0, copy_complete, &mg->k);
1205+
dm_kcopyd_copy(cache->copier, &o_region, 1, &c_region, 0, copy_complete, &mg->k);
12071206
else
1208-
r = dm_kcopyd_copy(cache->copier, &c_region, 1, &o_region, 0, copy_complete, &mg->k);
1209-
1210-
return r;
1207+
dm_kcopyd_copy(cache->copier, &c_region, 1, &o_region, 0, copy_complete, &mg->k);
12111208
}
12121209

12131210
static void bio_drop_shared_lock(struct cache *cache, struct bio *bio)
@@ -1449,12 +1446,7 @@ static void mg_full_copy(struct work_struct *ws)
14491446
}
14501447

14511448
init_continuation(&mg->k, mg_upgrade_lock);
1452-
1453-
if (copy(mg, is_policy_promote)) {
1454-
DMERR_LIMIT("%s: migration copy failed", cache_device_name(cache));
1455-
mg->k.input = BLK_STS_IOERR;
1456-
mg_complete(mg, false);
1457-
}
1449+
copy(mg, is_policy_promote);
14581450
}
14591451

14601452
static void mg_copy(struct work_struct *ws)

drivers/md/dm-kcopyd.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -741,9 +741,9 @@ static void split_job(struct kcopyd_job *master_job)
741741
}
742742
}
743743

744-
int dm_kcopyd_copy(struct dm_kcopyd_client *kc, struct dm_io_region *from,
745-
unsigned int num_dests, struct dm_io_region *dests,
746-
unsigned int flags, dm_kcopyd_notify_fn fn, void *context)
744+
void dm_kcopyd_copy(struct dm_kcopyd_client *kc, struct dm_io_region *from,
745+
unsigned int num_dests, struct dm_io_region *dests,
746+
unsigned int flags, dm_kcopyd_notify_fn fn, void *context)
747747
{
748748
struct kcopyd_job *job;
749749
int i;
@@ -818,16 +818,14 @@ int dm_kcopyd_copy(struct dm_kcopyd_client *kc, struct dm_io_region *from,
818818
job->progress = 0;
819819
split_job(job);
820820
}
821-
822-
return 0;
823821
}
824822
EXPORT_SYMBOL(dm_kcopyd_copy);
825823

826-
int dm_kcopyd_zero(struct dm_kcopyd_client *kc,
827-
unsigned num_dests, struct dm_io_region *dests,
828-
unsigned flags, dm_kcopyd_notify_fn fn, void *context)
824+
void dm_kcopyd_zero(struct dm_kcopyd_client *kc,
825+
unsigned num_dests, struct dm_io_region *dests,
826+
unsigned flags, dm_kcopyd_notify_fn fn, void *context)
829827
{
830-
return dm_kcopyd_copy(kc, NULL, num_dests, dests, flags, fn, context);
828+
dm_kcopyd_copy(kc, NULL, num_dests, dests, flags, fn, context);
831829
}
832830
EXPORT_SYMBOL(dm_kcopyd_zero);
833831

drivers/md/dm-raid1.c

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -326,9 +326,8 @@ static void recovery_complete(int read_err, unsigned long write_err,
326326
dm_rh_recovery_end(reg, !(read_err || write_err));
327327
}
328328

329-
static int recover(struct mirror_set *ms, struct dm_region *reg)
329+
static void recover(struct mirror_set *ms, struct dm_region *reg)
330330
{
331-
int r;
332331
unsigned i;
333332
struct dm_io_region from, to[DM_KCOPYD_MAX_REGIONS], *dest;
334333
struct mirror *m;
@@ -367,10 +366,8 @@ static int recover(struct mirror_set *ms, struct dm_region *reg)
367366
if (!errors_handled(ms))
368367
set_bit(DM_KCOPYD_IGNORE_ERROR, &flags);
369368

370-
r = dm_kcopyd_copy(ms->kcopyd_client, &from, ms->nr_mirrors - 1, to,
371-
flags, recovery_complete, reg);
372-
373-
return r;
369+
dm_kcopyd_copy(ms->kcopyd_client, &from, ms->nr_mirrors - 1, to,
370+
flags, recovery_complete, reg);
374371
}
375372

376373
static void reset_ms_flags(struct mirror_set *ms)
@@ -388,7 +385,6 @@ static void do_recovery(struct mirror_set *ms)
388385
{
389386
struct dm_region *reg;
390387
struct dm_dirty_log *log = dm_rh_dirty_log(ms->rh);
391-
int r;
392388

393389
/*
394390
* Start quiescing some regions.
@@ -398,11 +394,8 @@ static void do_recovery(struct mirror_set *ms)
398394
/*
399395
* Copy any already quiesced regions.
400396
*/
401-
while ((reg = dm_rh_recovery_start(ms->rh))) {
402-
r = recover(ms, reg);
403-
if (r)
404-
dm_rh_recovery_end(reg, 0);
405-
}
397+
while ((reg = dm_rh_recovery_start(ms->rh)))
398+
recover(ms, reg);
406399

407400
/*
408401
* Update the in sync flag.

drivers/md/dm-thin.c

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,18 +1220,13 @@ static struct dm_thin_new_mapping *get_next_mapping(struct pool *pool)
12201220
static void ll_zero(struct thin_c *tc, struct dm_thin_new_mapping *m,
12211221
sector_t begin, sector_t end)
12221222
{
1223-
int r;
12241223
struct dm_io_region to;
12251224

12261225
to.bdev = tc->pool_dev->bdev;
12271226
to.sector = begin;
12281227
to.count = end - begin;
12291228

1230-
r = dm_kcopyd_zero(tc->pool->copier, 1, &to, 0, copy_complete, m);
1231-
if (r < 0) {
1232-
DMERR_LIMIT("dm_kcopyd_zero() failed");
1233-
copy_complete(1, 1, m);
1234-
}
1229+
dm_kcopyd_zero(tc->pool->copier, 1, &to, 0, copy_complete, m);
12351230
}
12361231

12371232
static void remap_and_issue_overwrite(struct thin_c *tc, struct bio *bio,
@@ -1257,7 +1252,6 @@ static void schedule_copy(struct thin_c *tc, dm_block_t virt_block,
12571252
struct dm_bio_prison_cell *cell, struct bio *bio,
12581253
sector_t len)
12591254
{
1260-
int r;
12611255
struct pool *pool = tc->pool;
12621256
struct dm_thin_new_mapping *m = get_next_mapping(pool);
12631257

@@ -1296,19 +1290,8 @@ static void schedule_copy(struct thin_c *tc, dm_block_t virt_block,
12961290
to.sector = data_dest * pool->sectors_per_block;
12971291
to.count = len;
12981292

1299-
r = dm_kcopyd_copy(pool->copier, &from, 1, &to,
1300-
0, copy_complete, m);
1301-
if (r < 0) {
1302-
DMERR_LIMIT("dm_kcopyd_copy() failed");
1303-
copy_complete(1, 1, m);
1304-
1305-
/*
1306-
* We allow the zero to be issued, to simplify the
1307-
* error path. Otherwise we'd need to start
1308-
* worrying about decrementing the prepare_actions
1309-
* counter.
1310-
*/
1311-
}
1293+
dm_kcopyd_copy(pool->copier, &from, 1, &to,
1294+
0, copy_complete, m);
13121295

13131296
/*
13141297
* Do we need to zero a tail region?

drivers/md/dm-zoned-reclaim.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,8 @@ static int dmz_reclaim_copy(struct dmz_reclaim *zrc,
161161

162162
/* Copy the valid region */
163163
set_bit(DMZ_RECLAIM_KCOPY, &zrc->flags);
164-
ret = dm_kcopyd_copy(zrc->kc, &src, 1, &dst, flags,
165-
dmz_reclaim_kcopy_end, zrc);
166-
if (ret)
167-
return ret;
164+
dm_kcopyd_copy(zrc->kc, &src, 1, &dst, flags,
165+
dmz_reclaim_kcopy_end, zrc);
168166

169167
/* Wait for copy to complete */
170168
wait_on_bit_io(&zrc->flags, DMZ_RECLAIM_KCOPY,

include/linux/dm-kcopyd.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ void dm_kcopyd_client_destroy(struct dm_kcopyd_client *kc);
6262
typedef void (*dm_kcopyd_notify_fn)(int read_err, unsigned long write_err,
6363
void *context);
6464

65-
int dm_kcopyd_copy(struct dm_kcopyd_client *kc, struct dm_io_region *from,
66-
unsigned num_dests, struct dm_io_region *dests,
67-
unsigned flags, dm_kcopyd_notify_fn fn, void *context);
65+
void dm_kcopyd_copy(struct dm_kcopyd_client *kc, struct dm_io_region *from,
66+
unsigned num_dests, struct dm_io_region *dests,
67+
unsigned flags, dm_kcopyd_notify_fn fn, void *context);
6868

6969
/*
7070
* Prepare a callback and submit it via the kcopyd thread.
@@ -81,9 +81,9 @@ void *dm_kcopyd_prepare_callback(struct dm_kcopyd_client *kc,
8181
dm_kcopyd_notify_fn fn, void *context);
8282
void dm_kcopyd_do_callback(void *job, int read_err, unsigned long write_err);
8383

84-
int dm_kcopyd_zero(struct dm_kcopyd_client *kc,
85-
unsigned num_dests, struct dm_io_region *dests,
86-
unsigned flags, dm_kcopyd_notify_fn fn, void *context);
84+
void dm_kcopyd_zero(struct dm_kcopyd_client *kc,
85+
unsigned num_dests, struct dm_io_region *dests,
86+
unsigned flags, dm_kcopyd_notify_fn fn, void *context);
8787

8888
#endif /* __KERNEL__ */
8989
#endif /* _LINUX_DM_KCOPYD_H */

0 commit comments

Comments
 (0)