[dm-devel] [PATCH 5.20 1/4] block: add bio_rewind() API

Kent Overstreet kent.overstreet at gmail.com
Thu Jun 30 00:58:40 UTC 2022


On Thu, Jun 30, 2022 at 08:47:13AM +0800, Ming Lei wrote:
> What is the difference between bio_set_pos and bio_rewind()? Both have
> to restore bio->bi_iter(the sector part and the bvec part).
> 
> Also how to update ->bi_done which 'counts bytes advanced'? You meant doing it in
> very bio_advance()? then no, why do we have to pay the cost for very unusual
> bio_rewind()?

Yeah, we'll have to add a u32 to bvec_iter, and increment it in bio_advance().

This would us everything we want - you'll be able to restore a bio to an initial
state and you just have to save 8 bytes, not a whole bvec_iter, and unlike
bio_rewind it'll be safe to use after calling submit_bio(), _and_ it solves the
problem that stashing a copy of bvec_iter doesn't save state in integrity or
crypt context.

> Or if I misunderstood your point, please cook a patch and I am happy to
> take a close look, and posting one very raw idea with random data
> structure looks not helpful much for this discussion technically.

I can do that...



More information about the dm-devel mailing list