block: only zero page for bio of REQ_OP_READ in bio_truncate
PATCH 1/1 block: only zero page for bio of REQ_OP_READ in bio_truncate
Commit 85a8ce62c2ea ("block: add bio_truncate to fix guard_bio_eod") adds bio_truncate() which changes to zero the truncated pages for any bio which direction is READ. This way may change the behavior of guard_bio_eod(), so change back to orginal behavior of just zeroing bio of REQ_OP_READ.
Meantime add kerneldoc for bio_truncate() as suggested by Christoph.
--- block/bio.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
block/bio.c +11 -1
@@ -538,6 +538,16 @@ void zero_fill_bio_iter(struct bio *bio, struct bvec_iter start) }EXPORT_SYMBOL (zero_fill_bio_iter); +/** +* bio_truncate - truncate the bio to small size of @new_size +* @bio: the bio to be truncated +* @new_size: new size for truncating the bio +* +* Description: +* Truncate the bio to new size of @new_size. If bio_op(bio) is +* REQ_OP_READ, zero the truncated part. This function should only +* be used for handling corner cases, such as bio eod. +*/ void bio_truncate (struct bio *bio,unsigned new_size) {struct bio_vec bv;
@@ -548,7 +558,7 @@ void bio_truncate(struct bio *bio, unsigned new_size)if (new_size >= bio->bi_iter.bi_size)return ; -if (bio_data_dir (bio) !=READ ) +if (bio_op (bio) !=REQ_OP_READ ) goto exit;bio_for_each_segment (bv, bio, iter) {
Signature · 1 line
2.20.1
Jens Axboe
maintainerQuoted 6 lines · Ming Lei
Commit
85a8ce62c2ea("block: addbio_truncateto fixguard_bio_eod") addsbio_truncate()which changes to zero the truncated pages for any bio which direction is READ. This way may change the behavior ofguard_bio_eod(), so change back to orginal behavior of just zeroing bio ofREQ_OP_READ.Meantime add kerneldoc for
bio_truncate()as suggested by Christoph.
I'm going to fold this with the previous. Applied, thanks.
Signature · 1 line
Jens Axboe