Skip to content

Commit e5524e1

Browse files
committed
dm crypt: use dm_submit_bio_remap
Care was taken to support kcryptd_io_read being called from crypt_map or workqueue. Use of an intermediate CRYPT_MAP_READ_GFP gfp_t (defined as GFP_NOWAIT) should protect from maintenance burden if that flag were to change for some reason. Reviewed-by: Mikulas Patocka <[email protected]> Signed-off-by: Mike Snitzer <[email protected]>
1 parent 0fbb4d9 commit e5524e1

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

drivers/md/dm-crypt.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1828,6 +1828,8 @@ static void crypt_endio(struct bio *clone)
18281828
crypt_dec_pending(io);
18291829
}
18301830

1831+
#define CRYPT_MAP_READ_GFP GFP_NOWAIT
1832+
18311833
static int kcryptd_io_read(struct dm_crypt_io *io, gfp_t gfp)
18321834
{
18331835
struct crypt_config *cc = io->cc;
@@ -1855,7 +1857,7 @@ static int kcryptd_io_read(struct dm_crypt_io *io, gfp_t gfp)
18551857
return 1;
18561858
}
18571859

1858-
submit_bio_noacct(clone);
1860+
dm_submit_bio_remap(io->base_bio, clone, (gfp != CRYPT_MAP_READ_GFP));
18591861
return 0;
18601862
}
18611863

@@ -1881,7 +1883,7 @@ static void kcryptd_io_write(struct dm_crypt_io *io)
18811883
{
18821884
struct bio *clone = io->ctx.bio_out;
18831885

1884-
submit_bio_noacct(clone);
1886+
dm_submit_bio_remap(io->base_bio, clone, true);
18851887
}
18861888

18871889
#define crypt_io_from_node(node) rb_entry((node), struct dm_crypt_io, rb_node)
@@ -1960,7 +1962,7 @@ static void kcryptd_crypt_write_io_submit(struct dm_crypt_io *io, int async)
19601962

19611963
if ((likely(!async) && test_bit(DM_CRYPT_NO_OFFLOAD, &cc->flags)) ||
19621964
test_bit(DM_CRYPT_NO_WRITE_WORKQUEUE, &cc->flags)) {
1963-
submit_bio_noacct(clone);
1965+
dm_submit_bio_remap(io->base_bio, clone, true);
19641966
return;
19651967
}
19661968

@@ -3363,6 +3365,7 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
33633365

33643366
ti->num_flush_bios = 1;
33653367
ti->limit_swap_bios = true;
3368+
ti->accounts_remapped_io = true;
33663369

33673370
dm_audit_log_ctr(DM_MSG_PREFIX, ti, 1);
33683371
return 0;
@@ -3431,7 +3434,7 @@ static int crypt_map(struct dm_target *ti, struct bio *bio)
34313434
io->ctx.r.req = (struct skcipher_request *)(io + 1);
34323435

34333436
if (bio_data_dir(io->base_bio) == READ) {
3434-
if (kcryptd_io_read(io, GFP_NOWAIT))
3437+
if (kcryptd_io_read(io, CRYPT_MAP_READ_GFP))
34353438
kcryptd_queue_read(io);
34363439
} else
34373440
kcryptd_queue_crypt(io);
@@ -3626,7 +3629,7 @@ static void crypt_io_hints(struct dm_target *ti, struct queue_limits *limits)
36263629

36273630
static struct target_type crypt_target = {
36283631
.name = "crypt",
3629-
.version = {1, 23, 0},
3632+
.version = {1, 24, 0},
36303633
.module = THIS_MODULE,
36313634
.ctr = crypt_ctr,
36323635
.dtr = crypt_dtr,

0 commit comments

Comments
 (0)