[PATCH 022 of 35] Teach dm-crypt to honour bi_offset and bi_size

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Signed-off-by: Neil Brown <[email protected]>

### Diffstat output
 ./drivers/md/dm-crypt.c |   16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff .prev/drivers/md/dm-crypt.c ./drivers/md/dm-crypt.c
--- .prev/drivers/md/dm-crypt.c	2007-07-31 11:21:03.000000000 +1000
+++ ./drivers/md/dm-crypt.c	2007-07-31 11:21:12.000000000 +1000
@@ -49,6 +49,8 @@ struct convert_context {
 	unsigned int offset_out;
 	unsigned int idx_in;
 	unsigned int idx_out;
+	int len_in;
+	int len_out;
 	sector_t sector;
 	int write;
 };
@@ -326,8 +328,10 @@ crypt_convert_init(struct crypt_config *
 {
 	ctx->bio_in = bio_in;
 	ctx->bio_out = bio_out;
-	ctx->offset_in = 0;
-	ctx->offset_out = 0;
+	ctx->offset_in = bio_in->bi_offset;
+	ctx->offset_out = bio_out->bi_offset;
+	ctx->len_in = bio_in->bi_size;
+	ctx->len_out = bio_out->bi_size;
 	ctx->idx_in = 0;
 	ctx->idx_out = 0;
 	ctx->sector = sector + cc->iv_offset;
@@ -362,12 +366,18 @@ static int crypt_convert(struct crypt_co
 			ctx->offset_in = 0;
 			ctx->idx_in++;
 		}
+		ctx->len_in -= sg_in.length;
+		if (ctx->len_in <= 0)
+			ctx->idx_in = ctx->bio_in->bi_vcnt;
 
 		ctx->offset_out += sg_out.length;
 		if (ctx->offset_out >= bv_out->bv_len) {
 			ctx->offset_out = 0;
 			ctx->idx_out++;
 		}
+		ctx->len_out -= sg_in.length;
+		if (ctx->len_out <= 0)
+			ctx->idx_out = ctx->bio_out->bi_vcnt;
 
 		r = crypt_convert_scatterlist(cc, &sg_out, &sg_in, sg_in.length,
 		                              ctx->write, ctx->sector);
@@ -605,6 +615,8 @@ static void process_write(struct dm_cryp
 
 		ctx.bio_out = clone;
 		ctx.idx_out = 0;
+		ctx.offset_out = clone->bi_offset;
+		ctx.len_out = clone->bi_size;
 
 		if (unlikely(crypt_convert(cc, &ctx) < 0)) {
 			crypt_free_buffer_pages(cc, clone, clone->bi_size);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux