All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] block: only zero page for bio of REQ_OP_READ in bio_truncate
@ 2020-01-09  8:56 Ming Lei
  2020-01-09 14:57 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Ming Lei @ 2020-01-09  8:56 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block, Ming Lei, Christoph Hellwig

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.

Fixes: 85a8ce62c2ea ("block: add bio_truncate to fix guard_bio_eod")
Reported-by: Christoph Hellwig <hch@infradead.org>
Cc: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
 block/bio.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/block/bio.c b/block/bio.c
index 006bcc52a77e..94d697217887 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -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) {
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] block: only zero page for bio of REQ_OP_READ in bio_truncate
  2020-01-09  8:56 [PATCH] block: only zero page for bio of REQ_OP_READ in bio_truncate Ming Lei
@ 2020-01-09 14:57 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2020-01-09 14:57 UTC (permalink / raw)
  To: Ming Lei; +Cc: linux-block, Christoph Hellwig

On 1/9/20 1:56 AM, Ming Lei wrote:
> 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.

I'm going to fold this with the previous. Applied, thanks.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-01-09 14:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-09  8:56 [PATCH] block: only zero page for bio of REQ_OP_READ in bio_truncate Ming Lei
2020-01-09 14:57 ` Jens Axboe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.