From 704fa4112f214e7eceeb3ffbdbeb8a0b5b3d60e1 Mon Sep 17 00:00:00 2001 From: Milan Broz Date: Fri, 8 Feb 2008 02:11:02 +0000 Subject: [PATCH] --- yaml --- r: 84583 b: refs/heads/master c: 899c95d36c896f9fb7bc5f4f03b4abd86bda292c h: refs/heads/master i: 84581: 3cd5f73682b399b432864cb4c6a86a3e756b5a5f 84579: d43041ff27c770dc70202f7f2f41d7b1b4547a95 84575: 9b22f19618adeac76a03896fc87b41abd38a250e v: v3 --- [refs] | 2 +- trunk/drivers/md/dm-crypt.c | 20 ++++++++------------ 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/[refs] b/[refs] index 77b634359939..ef93429302ad 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 84131db689ab86409315c15a3ea5daf732cb04e1 +refs/heads/master: 899c95d36c896f9fb7bc5f4f03b4abd86bda292c diff --git a/trunk/drivers/md/dm-crypt.c b/trunk/drivers/md/dm-crypt.c index 986283c5332f..44e1aa30e3f6 100644 --- a/trunk/drivers/md/dm-crypt.c +++ b/trunk/drivers/md/dm-crypt.c @@ -584,7 +584,6 @@ static void kcryptd_crypt_write_io_submit(struct dm_crypt_io *io, int error) crypt_free_buffer_pages(cc, clone); bio_put(clone); io->error = -EIO; - crypt_dec_pending(io); return; } @@ -593,6 +592,9 @@ static void kcryptd_crypt_write_io_submit(struct dm_crypt_io *io, int error) clone->bi_sector = cc->start + io->sector; io->sector += bio_sectors(clone); + + atomic_inc(&io->pending); + generic_make_request(clone); } static void kcryptd_crypt_write_convert_loop(struct dm_crypt_io *io) @@ -610,7 +612,6 @@ static void kcryptd_crypt_write_convert_loop(struct dm_crypt_io *io) clone = crypt_alloc_buffer(io, remaining); if (unlikely(!clone)) { io->error = -ENOMEM; - crypt_dec_pending(io); return; } @@ -625,16 +626,6 @@ static void kcryptd_crypt_write_convert_loop(struct dm_crypt_io *io) if (unlikely(r < 0)) return; - /* Grab another reference to the io struct - * before we kick off the request */ - if (remaining) - atomic_inc(&io->pending); - - generic_make_request(clone); - - /* Do not reference clone after this - it - * may be gone already. */ - /* out of memory -> run queues */ if (unlikely(remaining)) congestion_wait(WRITE, HZ/100); @@ -645,10 +636,15 @@ static void kcryptd_crypt_write_convert(struct dm_crypt_io *io) { struct crypt_config *cc = io->target->private; + /* + * Prevent io from disappearing until this function completes. + */ atomic_inc(&io->pending); crypt_convert_init(cc, &io->ctx, NULL, io->base_bio, io->sector); kcryptd_crypt_write_convert_loop(io); + + crypt_dec_pending(io); } static void kcryptd_crypt_read_done(struct dm_crypt_io *io, int error)