aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilan Broz <mbroz@redhat.com>2008-02-07 21:10:43 -0500
committerAlasdair G Kergon <agk@redhat.com>2008-02-07 21:10:43 -0500
commit5742fd77757894ebb5e441afbdac1fb666e782f7 (patch)
tree6976ec2b920b9df1e2316d4603d81a6082a7d42b
parentfcd369daa36d547607dbedd0b41099d6dfc1d1c7 (diff)
dm crypt: move error setting outside crypt_dec_pending
Move error code setting outside of crypt_dec_pending function. Use -EIO if crypt_convert_scatterlist() fails. Signed-off-by: Milan Broz <mbroz@redhat.com> Signed-off-by: Alasdair G Kergon <agk@redhat.com>
-rw-r--r--drivers/md/dm-crypt.c36
1 files changed, 25 insertions, 11 deletions
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index 862ce9f6faac..cc189a2bc533 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -456,18 +456,14 @@ static void crypt_free_buffer_pages(struct crypt_config *cc, struct bio *clone)
456 * One of the bios was finished. Check for completion of 456 * One of the bios was finished. Check for completion of
457 * the whole request and correctly clean up the buffer. 457 * the whole request and correctly clean up the buffer.
458 */ 458 */
459static void crypt_dec_pending(struct dm_crypt_io *io, int error) 459static void crypt_dec_pending(struct dm_crypt_io *io)
460{ 460{
461 struct crypt_config *cc = (struct crypt_config *) io->target->private; 461 struct crypt_config *cc = io->target->private;
462
463 if (error < 0)
464 io->error = error;
465 462
466 if (!atomic_dec_and_test(&io->pending)) 463 if (!atomic_dec_and_test(&io->pending))
467 return; 464 return;
468 465
469 bio_endio(io->base_bio, io->error); 466 bio_endio(io->base_bio, io->error);
470
471 mempool_free(io, cc->io_pool); 467 mempool_free(io, cc->io_pool);
472} 468}
473 469
@@ -530,7 +526,11 @@ static void crypt_endio(struct bio *clone, int error)
530 526
531out: 527out:
532 bio_put(clone); 528 bio_put(clone);
533 crypt_dec_pending(io, error); 529
530 if (unlikely(error))
531 io->error = error;
532
533 crypt_dec_pending(io);
534} 534}
535 535
536static void clone_init(struct dm_crypt_io *io, struct bio *clone) 536static void clone_init(struct dm_crypt_io *io, struct bio *clone)
@@ -560,7 +560,8 @@ static void process_read(struct dm_crypt_io *io)
560 */ 560 */
561 clone = bio_alloc_bioset(GFP_NOIO, bio_segments(base_bio), cc->bs); 561 clone = bio_alloc_bioset(GFP_NOIO, bio_segments(base_bio), cc->bs);
562 if (unlikely(!clone)) { 562 if (unlikely(!clone)) {
563 crypt_dec_pending(io, -ENOMEM); 563 io->error = -ENOMEM;
564 crypt_dec_pending(io);
564 return; 565 return;
565 } 566 }
566 567
@@ -594,7 +595,8 @@ static void process_write(struct dm_crypt_io *io)
594 while (remaining) { 595 while (remaining) {
595 clone = crypt_alloc_buffer(io, remaining); 596 clone = crypt_alloc_buffer(io, remaining);
596 if (unlikely(!clone)) { 597 if (unlikely(!clone)) {
597 crypt_dec_pending(io, -ENOMEM); 598 io->error = -ENOMEM;
599 crypt_dec_pending(io);
598 return; 600 return;
599 } 601 }
600 602
@@ -604,7 +606,8 @@ static void process_write(struct dm_crypt_io *io)
604 if (unlikely(crypt_convert(cc, &io->ctx) < 0)) { 606 if (unlikely(crypt_convert(cc, &io->ctx) < 0)) {
605 crypt_free_buffer_pages(cc, clone); 607 crypt_free_buffer_pages(cc, clone);
606 bio_put(clone); 608 bio_put(clone);
607 crypt_dec_pending(io, -EIO); 609 io->error = -EIO;
610 crypt_dec_pending(io);
608 return; 611 return;
609 } 612 }
610 613
@@ -631,14 +634,25 @@ static void process_write(struct dm_crypt_io *io)
631 } 634 }
632} 635}
633 636
637static void crypt_read_done(struct dm_crypt_io *io, int error)
638{
639 if (unlikely(error < 0))
640 io->error = -EIO;
641
642 crypt_dec_pending(io);
643}
644
634static void process_read_endio(struct dm_crypt_io *io) 645static void process_read_endio(struct dm_crypt_io *io)
635{ 646{
636 struct crypt_config *cc = io->target->private; 647 struct crypt_config *cc = io->target->private;
648 int r = 0;
637 649
638 crypt_convert_init(cc, &io->ctx, io->base_bio, io->base_bio, 650 crypt_convert_init(cc, &io->ctx, io->base_bio, io->base_bio,
639 io->base_bio->bi_sector - io->target->begin); 651 io->base_bio->bi_sector - io->target->begin);
640 652
641 crypt_dec_pending(io, crypt_convert(cc, &io->ctx)); 653 r = crypt_convert(cc, &io->ctx);
654
655 crypt_read_done(io, r);
642} 656}
643 657
644static void kcryptd_do_work(struct work_struct *work) 658static void kcryptd_do_work(struct work_struct *work)