Skip to content

Commit 9fdbbdb

Browse files
Hou TaoMikulas Patocka
authored andcommitted
dm-crypt: don't update io->sector after kcryptd_crypt_write_io_submit()
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: [email protected] Signed-off-by: Hou Tao <[email protected]> Signed-off-by: Mikulas Patocka <[email protected]>
1 parent 2f8c28d commit 9fdbbdb

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
@@ -2090,7 +2090,6 @@ static void kcryptd_crypt_write_continue(struct work_struct *work)
20902090
struct crypt_config *cc = io->cc;
20912091
struct convert_context *ctx = &io->ctx;
20922092
int crypt_finished;
2093-
sector_t sector = io->sector;
20942093
blk_status_t r;
20952094

20962095
wait_for_completion(&ctx->restart);
@@ -2107,10 +2106,8 @@ static void kcryptd_crypt_write_continue(struct work_struct *work)
21072106
}
21082107

21092108
/* Encryption was already finished, submit io now */
2110-
if (crypt_finished) {
2109+
if (crypt_finished)
21112110
kcryptd_crypt_write_io_submit(io, 0);
2112-
io->sector = sector;
2113-
}
21142111

21152112
crypt_dec_pending(io);
21162113
}
@@ -2121,14 +2118,13 @@ static void kcryptd_crypt_write_convert(struct dm_crypt_io *io)
21212118
struct convert_context *ctx = &io->ctx;
21222119
struct bio *clone;
21232120
int crypt_finished;
2124-
sector_t sector = io->sector;
21252121
blk_status_t r;
21262122

21272123
/*
21282124
* Prevent io from disappearing until this function completes.
21292125
*/
21302126
crypt_inc_pending(io);
2131-
crypt_convert_init(cc, ctx, NULL, io->base_bio, sector);
2127+
crypt_convert_init(cc, ctx, NULL, io->base_bio, io->sector);
21322128

21332129
clone = crypt_alloc_buffer(io, io->base_bio->bi_iter.bi_size);
21342130
if (unlikely(!clone)) {
@@ -2145,8 +2141,6 @@ static void kcryptd_crypt_write_convert(struct dm_crypt_io *io)
21452141
io->ctx.iter_in = clone->bi_iter;
21462142
}
21472143

2148-
sector += bio_sectors(clone);
2149-
21502144
crypt_inc_pending(io);
21512145
r = crypt_convert(cc, ctx,
21522146
test_bit(DM_CRYPT_NO_WRITE_WORKQUEUE, &cc->flags), true);
@@ -2170,10 +2164,8 @@ static void kcryptd_crypt_write_convert(struct dm_crypt_io *io)
21702164
}
21712165

21722166
/* Encryption was already finished, submit io now */
2173-
if (crypt_finished) {
2167+
if (crypt_finished)
21742168
kcryptd_crypt_write_io_submit(io, 0);
2175-
io->sector = sector;
2176-
}
21772169

21782170
dec:
21792171
crypt_dec_pending(io);

0 commit comments

Comments
 (0)