Skip to content

Commit c4cc18c

Browse files
Hou Taogregkh
authored andcommitted
dm-crypt: don't update io->sector after kcryptd_crypt_write_io_submit()
commit 9fdbbdb upstream. The updates of io->sector are the leftovers when dm-crypt allocated pages for partial write request. However, since commit cf2f1ab ("dm crypt: don't allocate pages for a partial request"), there is no partial request anymore. After the introduction of write request rb-tree, the updates of io->sectors may interfere the insertion procedure, because ->sectors of these write requests which have already been added in the rb-tree may be changed during the insertion of new write request. Fix it by removing these buggy updates of io->sectors. Considering these updates only effect the write request rb-tree, the commit which introduces the write request rb-tree is used as the fix tag. Fixes: b3c5fd3 ("dm crypt: sort writes") Cc: stable@vger.kernel.org Signed-off-by: Hou Tao <houtao1@huawei.com> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 41ccbff commit c4cc18c

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

drivers/md/dm-crypt.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2092,7 +2092,6 @@ static void kcryptd_crypt_write_continue(struct work_struct *work)
20922092
struct crypt_config *cc = io->cc;
20932093
struct convert_context *ctx = &io->ctx;
20942094
int crypt_finished;
2095-
sector_t sector = io->sector;
20962095
blk_status_t r;
20972096

20982097
wait_for_completion(&ctx->restart);
@@ -2109,10 +2108,8 @@ static void kcryptd_crypt_write_continue(struct work_struct *work)
21092108
}
21102109

21112110
/* Encryption was already finished, submit io now */
2112-
if (crypt_finished) {
2111+
if (crypt_finished)
21132112
kcryptd_crypt_write_io_submit(io, 0);
2114-
io->sector = sector;
2115-
}
21162113

21172114
crypt_dec_pending(io);
21182115
}
@@ -2123,14 +2120,13 @@ static void kcryptd_crypt_write_convert(struct dm_crypt_io *io)
21232120
struct convert_context *ctx = &io->ctx;
21242121
struct bio *clone;
21252122
int crypt_finished;
2126-
sector_t sector = io->sector;
21272123
blk_status_t r;
21282124

21292125
/*
21302126
* Prevent io from disappearing until this function completes.
21312127
*/
21322128
crypt_inc_pending(io);
2133-
crypt_convert_init(cc, ctx, NULL, io->base_bio, sector);
2129+
crypt_convert_init(cc, ctx, NULL, io->base_bio, io->sector);
21342130

21352131
clone = crypt_alloc_buffer(io, io->base_bio->bi_iter.bi_size);
21362132
if (unlikely(!clone)) {
@@ -2147,8 +2143,6 @@ static void kcryptd_crypt_write_convert(struct dm_crypt_io *io)
21472143
io->ctx.iter_in = clone->bi_iter;
21482144
}
21492145

2150-
sector += bio_sectors(clone);
2151-
21522146
crypt_inc_pending(io);
21532147
r = crypt_convert(cc, ctx,
21542148
test_bit(DM_CRYPT_NO_WRITE_WORKQUEUE, &cc->flags), true);
@@ -2172,10 +2166,8 @@ static void kcryptd_crypt_write_convert(struct dm_crypt_io *io)
21722166
}
21732167

21742168
/* Encryption was already finished, submit io now */
2175-
if (crypt_finished) {
2169+
if (crypt_finished)
21762170
kcryptd_crypt_write_io_submit(io, 0);
2177-
io->sector = sector;
2178-
}
21792171

21802172
dec:
21812173
crypt_dec_pending(io);

0 commit comments

Comments
 (0)