Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 110637
b: refs/heads/master
c: c808161
h: refs/heads/master
i:
  110635: 3a2d4bd
v: v3
  • Loading branch information
Milan Broz authored and Alasdair G Kergon committed Oct 10, 2008
1 parent b48f9de commit d495536
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 4e59409891c9cc30cb4d5d73250b0c968af8e39b
refs/heads/master: c8081618a9f832fdf7ca81eb087f9f61f2bf07d5
16 changes: 11 additions & 5 deletions trunk/drivers/md/dm-crypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,6 @@ static void crypt_convert_init(struct crypt_config *cc,
ctx->idx_out = bio_out ? bio_out->bi_idx : 0;
ctx->sector = sector + cc->iv_offset;
init_completion(&ctx->restart);
atomic_set(&ctx->pending, 1);
}

static int crypt_convert_block(struct crypt_config *cc,
Expand Down Expand Up @@ -408,6 +407,8 @@ static int crypt_convert(struct crypt_config *cc,
{
int r;

atomic_set(&ctx->pending, 1);

while(ctx->idx_in < ctx->bio_in->bi_vcnt &&
ctx->idx_out < ctx->bio_out->bi_vcnt) {

Expand Down Expand Up @@ -694,6 +695,7 @@ static void kcryptd_crypt_write_convert(struct dm_crypt_io *io)
{
struct crypt_config *cc = io->target->private;
struct bio *clone;
int crypt_finished;
unsigned remaining = io->base_bio->bi_size;
int r;

Expand Down Expand Up @@ -721,19 +723,23 @@ static void kcryptd_crypt_write_convert(struct dm_crypt_io *io)

crypt_inc_pending(io);
r = crypt_convert(cc, &io->ctx);
crypt_finished = atomic_dec_and_test(&io->ctx.pending);

if (atomic_dec_and_test(&io->ctx.pending)) {
/* processed, no running async crypto */
/* Encryption was already finished, submit io now */
if (crypt_finished) {
kcryptd_crypt_write_io_submit(io, r, 0);

/*
* If there was an error, do not try next fragments.
* For async, error is processed in async handler.
*/
if (unlikely(r < 0))
break;
}

/* out of memory -> run queues */
if (unlikely(remaining)) {
/* wait for async crypto then reinitialize pending */
wait_event(cc->writeq, !atomic_read(&io->ctx.pending));
atomic_set(&io->ctx.pending, 1);
congestion_wait(WRITE, HZ/100);
}
}
Expand Down

0 comments on commit d495536

Please sign in to comment.