All of lore.kernel.org
 help / color / mirror / Atom feed
* About `bio->bi_iter.bi_size` at write endio time
@ 2021-06-15  7:22 Qu Wenruo
  2021-06-15  8:37 ` Ming Lei
  0 siblings, 1 reply; 2+ messages in thread
From: Qu Wenruo @ 2021-06-15  7:22 UTC (permalink / raw)
  To: linux-btrfs, linux-block, Linux FS Devel

Hi,

Recently I got a strange case where for write bio, at its endio time, I 
got bio->bi_iter.bi_size == 0, but bio_for_each_segment_all() reports we 
still have some bv_len.

And obviously, when the bio get submitted, its bi_size is not 0.

This is especially common for REQ_OP_ZONE_APPEND bio, but I also get 
rare bi_size == 0 at endio time, for REQ_OP_WRITE too.

So I guess bi_size at endio time is no longer reliable due to bio 
merging/splitting?

Thus the only correct way to get how large a bio really is, is through 
bio_for_each_segment_all()?

Thanks,
Qu

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

* Re: About `bio->bi_iter.bi_size` at write endio time
  2021-06-15  7:22 About `bio->bi_iter.bi_size` at write endio time Qu Wenruo
@ 2021-06-15  8:37 ` Ming Lei
  0 siblings, 0 replies; 2+ messages in thread
From: Ming Lei @ 2021-06-15  8:37 UTC (permalink / raw)
  To: Qu Wenruo; +Cc: linux-btrfs, linux-block, Linux FS Devel

On Tue, Jun 15, 2021 at 03:22:59PM +0800, Qu Wenruo wrote:
> Hi,
> 
> Recently I got a strange case where for write bio, at its endio time, I got
> bio->bi_iter.bi_size == 0, but bio_for_each_segment_all() reports we still
> have some bv_len.

It is normal to observe zero .bi_size in ->bi_end_io(), see req_bio_endio().
Meantime bio_for_each_segment_all() covers all pages added to the bio via
bio_add_page(), which is invariant after the bio is submitted.

> 
> And obviously, when the bio get submitted, its bi_size is not 0.
> 
> This is especially common for REQ_OP_ZONE_APPEND bio, but I also get rare
> bi_size == 0 at endio time, for REQ_OP_WRITE too.

It shouldn't be rare.

> 
> So I guess bi_size at endio time is no longer reliable due to bio
> merging/splitting?

No, ->bi_size should be zero in .bi_end_io() if this bio is completed
successfully no matter if the bio is splitted or not.

> 
> Thus the only correct way to get how large a bio really is, is through
> bio_for_each_segment_all()?

Yeah, if you mean to get the bio's real size in ->bi_end_io().


Thanks,
Ming


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

end of thread, other threads:[~2021-06-15  8:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-15  7:22 About `bio->bi_iter.bi_size` at write endio time Qu Wenruo
2021-06-15  8:37 ` Ming Lei

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.