Skip to content

Commit fc5a5e9

Browse files
Milan Brozkergon
authored andcommitted
dm crypt: tidy write loop pending
Move kcryptd_crypt_write_convert_loop inside kcryptd_crypt_write_convert. This change is needed for a later patch. No functional change. Signed-off-by: Milan Broz <[email protected]> Signed-off-by: Alasdair G Kergon <[email protected]>
1 parent dc440d1 commit fc5a5e9

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

drivers/md/dm-crypt.c

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -691,13 +691,19 @@ static void kcryptd_crypt_write_io_submit(struct dm_crypt_io *io,
691691
}
692692
}
693693

694-
static void kcryptd_crypt_write_convert_loop(struct dm_crypt_io *io)
694+
static void kcryptd_crypt_write_convert(struct dm_crypt_io *io)
695695
{
696696
struct crypt_config *cc = io->target->private;
697697
struct bio *clone;
698698
unsigned remaining = io->base_bio->bi_size;
699699
int r;
700700

701+
/*
702+
* Prevent io from disappearing until this function completes.
703+
*/
704+
crypt_inc_pending(io);
705+
crypt_convert_init(cc, &io->ctx, NULL, io->base_bio, io->sector);
706+
701707
/*
702708
* The allocated buffers can be smaller than the whole bio,
703709
* so repeat the whole process until all the data can be handled.
@@ -706,7 +712,7 @@ static void kcryptd_crypt_write_convert_loop(struct dm_crypt_io *io)
706712
clone = crypt_alloc_buffer(io, remaining);
707713
if (unlikely(!clone)) {
708714
io->error = -ENOMEM;
709-
return;
715+
break;
710716
}
711717

712718
io->ctx.bio_out = clone;
@@ -720,7 +726,7 @@ static void kcryptd_crypt_write_convert_loop(struct dm_crypt_io *io)
720726
/* processed, no running async crypto */
721727
kcryptd_crypt_write_io_submit(io, r, 0);
722728
if (unlikely(r < 0))
723-
return;
729+
break;
724730
} else
725731
crypt_inc_pending(io);
726732

@@ -732,19 +738,6 @@ static void kcryptd_crypt_write_convert_loop(struct dm_crypt_io *io)
732738
congestion_wait(WRITE, HZ/100);
733739
}
734740
}
735-
}
736-
737-
static void kcryptd_crypt_write_convert(struct dm_crypt_io *io)
738-
{
739-
struct crypt_config *cc = io->target->private;
740-
741-
/*
742-
* Prevent io from disappearing until this function completes.
743-
*/
744-
crypt_inc_pending(io);
745-
746-
crypt_convert_init(cc, &io->ctx, NULL, io->base_bio, io->sector);
747-
kcryptd_crypt_write_convert_loop(io);
748741

749742
crypt_dec_pending(io);
750743
}

0 commit comments

Comments
 (0)