diff options
author | Milan Broz <mbroz@redhat.com> | 2008-10-10 13:37:07 +0100 |
---|---|---|
committer | Alasdair G Kergon <agk@redhat.com> | 2008-10-10 13:37:07 +0100 |
commit | 4e59409891c9cc30cb4d5d73250b0c968af8e39b (patch) | |
tree | c21382942df3b7dd363bca91fe5cd8fef3c64f0b /drivers/md | |
parent | 6c031f41db15b6cb0cd33545cec28ca706cd3c7e (diff) | |
download | linux-4e59409891c9cc30cb4d5d73250b0c968af8e39b.tar.bz2 |
dm crypt: fix async inc_pending
The pending reference count must be incremented *before* the async work is
queued to another thread, not after. Otherwise there's a race if the
work completes and decrements the reference count before it gets incremented.
Signed-off-by: Milan Broz <mbroz@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/dm-crypt.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index d8126ac82960..262ed1816695 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c @@ -719,16 +719,15 @@ static void kcryptd_crypt_write_convert(struct dm_crypt_io *io) remaining -= clone->bi_size; + crypt_inc_pending(io); r = crypt_convert(cc, &io->ctx); if (atomic_dec_and_test(&io->ctx.pending)) { /* processed, no running async crypto */ - crypt_inc_pending(io); kcryptd_crypt_write_io_submit(io, r, 0); if (unlikely(r < 0)) break; - } else - crypt_inc_pending(io); + } /* out of memory -> run queues */ if (unlikely(remaining)) { |