f2fs/fscrypt-ice: disallow bio merged into request
This fixes wrong bio merge into request which breaks encrypted ICE blocks.
Bug: 71554412
Change-Id: I65b5936add01aa62449d46791a736b734022a48c
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
diff --git a/block/blk-core.c b/block/blk-core.c
index 404629f..ff2e4fd 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1529,6 +1529,7 @@
bio->bi_next = req->bio;
req->bio = bio;
+ WARN_ON(req->__dun || bio->bi_iter.bi_dun);
req->__sector = bio->bi_iter.bi_sector;
req->__data_len += bio->bi_iter.bi_size;
req->ioprio = ioprio_best(req->ioprio, bio_prio(bio));
@@ -1644,6 +1645,7 @@
req->errors = 0;
req->__sector = bio->bi_iter.bi_sector;
+ req->__dun = bio->bi_iter.bi_dun;
req->ioprio = bio_prio(bio);
blk_rq_bio_prep(req->q, req, bio);
}
@@ -2646,8 +2648,11 @@
req->__data_len -= total_bytes;
/* update sector only for requests with clear definition of sector */
- if (req->cmd_type == REQ_TYPE_FS)
+ if (req->cmd_type == REQ_TYPE_FS) {
req->__sector += total_bytes >> 9;
+ if (req->__dun)
+ req->__dun += total_bytes >> 12;
+ }
/* mixed attributes always follow the first bio */
if (req->cmd_flags & REQ_MIXED_MERGE) {
@@ -3048,6 +3053,7 @@
(src->cmd_flags & REQ_CLONE_MASK) | REQ_NOMERGE);
dst->cmd_type = src->cmd_type;
dst->__sector = blk_rq_pos(src);
+ dst->__dun = blk_rq_dun(src);
dst->__data_len = blk_rq_bytes(src);
dst->nr_phys_segments = src->nr_phys_segments;
dst->ioprio = src->ioprio;