From patchwork Tue Aug 21 09:09:25 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikulas Patocka X-Patchwork-Id: 1352841 Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by patchwork1.kernel.org (Postfix) with ESMTP id 20C9940210 for ; Tue, 21 Aug 2012 09:13:15 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q7L9BL1N013389; Tue, 21 Aug 2012 05:11:21 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q7L9A5UE025336 for ; Tue, 21 Aug 2012 05:10:05 -0400 Received: from tawny.mazyland.net (ovpn-116-28.ams2.redhat.com [10.36.116.28]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q7L99j8W031291; Tue, 21 Aug 2012 05:10:00 -0400 From: Mikulas Patocka To: dm-devel@redhat.com Date: Tue, 21 Aug 2012 11:09:25 +0200 Message-Id: <08b17304bd93eacf540dd5c2b10e1aa3d38b680d.1345477953.git.mbroz@redhat.com> In-Reply-To: <520994e0c87d38ca6abb8dd60760aef993842a32.1345477953.git.mbroz@redhat.com> References: <520994e0c87d38ca6abb8dd60760aef993842a32.1345477953.git.mbroz@redhat.com> In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-loop: dm-devel@redhat.com Cc: Mikulas Patocka Subject: [dm-devel] [PATCH 14/20] dm-crypt: move error handling to crypt_convert. X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com This patch moves error handling to crypt_convert and makes crypt_convert return void instead of the error number. Signed-off-by: Mikulas Patocka --- drivers/md/dm-crypt.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index bb11a95..6f18838 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c @@ -825,16 +825,16 @@ static void crypt_dec_cc_pending(struct dm_crypt_io *io) /* * Encrypt / decrypt data from one bio to another one (can be the same one) */ -static int crypt_convert(struct crypt_config *cc, - struct dm_crypt_io *io) +static void crypt_convert(struct crypt_config *cc, + struct dm_crypt_io *io) { - int r; LIST_HEAD(batch); unsigned batch_count = 0; atomic_set(&io->cc_pending, 1); while (1) { + int r; struct ablkcipher_request *req = crypt_alloc_req(cc, io, GFP_NOWAIT); if (!req) { /* @@ -849,8 +849,9 @@ static int crypt_convert(struct crypt_config *cc, r = crypt_convert_block(cc, io, req, &batch); if (unlikely(r < 0)) { crypt_flush_batch(cc, &batch); + io->error = -EIO; crypt_dec_cc_pending(io); - goto ret; + return; } io->sector++; @@ -866,12 +867,8 @@ static int crypt_convert(struct crypt_config *cc, } break; } - r = 0; crypt_flush_batch(cc, &batch); -ret: - - return r; } static void dm_crypt_bio_destructor(struct bio *bio) @@ -1134,7 +1131,6 @@ static void kcryptd_crypt_write_convert(struct dm_crypt_io *io) struct bio *clone; unsigned remaining = io->base_bio->bi_size; sector_t sector = io->sector; - int r; /* * Prevent io from disappearing until this function completes. @@ -1155,9 +1151,7 @@ static void kcryptd_crypt_write_convert(struct dm_crypt_io *io) sector += bio_sectors(clone); crypt_inc_pending(io); - r = crypt_convert(cc, io); - if (r) - io->error = -EIO; + crypt_convert(cc, io); dec: crypt_dec_pending(io); } @@ -1165,17 +1159,13 @@ dec: static void kcryptd_crypt_read_convert(struct dm_crypt_io *io) { struct crypt_config *cc = io->cc; - int r = 0; crypt_inc_pending(io); crypt_convert_init(cc, io, io->base_bio, io->base_bio, io->sector); - r = crypt_convert(cc, io); - if (r < 0) - io->error = -EIO; - + crypt_convert(cc, io); crypt_dec_pending(io); }