linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Qu Wenruo <quwenruo.btrfs@gmx.com>
Cc: Linux FS Devel <linux-fsdevel@vger.kernel.org>,
	dm-devel@redhat.com,
	"linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>
Subject: Re: Any bio_clone_slow() implementation which doesn't share bi_io_vec?
Date: Mon, 22 Nov 2021 23:43:58 -0800	[thread overview]
Message-ID: <YZybvlheyLGAadFF@infradead.org> (raw)
In-Reply-To: <5d8351f1-1b09-bff0-02f2-a417c1669607@gmx.com>

On Tue, Nov 23, 2021 at 02:44:32PM +0800, Qu Wenruo wrote:
> Hi,
> 
> Although there are some out-of-date comments mentions other
> bio_clone_*() variants, but there isn't really any other bio clone
> variants other than __bio_clone_fast(), which shares bi_io_vec with the
> source bio.
> 
> This limits means we can't free the source bio before the cloned one.
> 
> Is there any bio_clone variant which do a deep clone, including bi_io_vec?

There is no use case for that, unless the actual data changes like in
the bounce buffering code.

> That's why the bio_clone thing is involved, there is still some corner
> cases that we don't want to fail the whole large bio if there is only
> one stripe failed (mostly for read bio, that we want to salvage as much
> data as possible)
> 
> Thus regular bio_split() + bio_chain() solution is not that good here.
> 
> Any idea why no such bio_clone_slow() or bio_split_slow() provided in
> block layer?
> 
> Or really bio_split() + bio_chain() is the only recommended solution?

You can use bio_split witout bio_chain.  You just need your own
bi_end_io handler that first performs the action you want and then
contains code equivalent to __bio_chain_endio.  As a bonus you can
pint bi_private to whatever you want, it does not have to be the parent
bio, just something that allows you to find it.

  reply	other threads:[~2021-11-23  7:44 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-23  6:44 Any bio_clone_slow() implementation which doesn't share bi_io_vec? Qu Wenruo
2021-11-23  7:43 ` Christoph Hellwig [this message]
2021-11-23  8:10   ` Qu Wenruo
2021-11-23  8:13     ` Christoph Hellwig
2021-11-23 11:09       ` Qu Wenruo
2021-11-23 11:39         ` Johannes Thumshirn
2021-11-23 14:28           ` hch
2021-11-23 23:07             ` Qu Wenruo
2021-11-24  6:09               ` hch
2021-11-24  6:18                 ` Qu Wenruo
2021-11-24  7:02                   ` hch
2021-11-24  7:22                     ` hch
2021-11-24  7:25               ` Naohiro Aota
2021-11-24  7:39                 ` Qu Wenruo
2021-11-26 12:33       ` Qu Wenruo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YZybvlheyLGAadFF@infradead.org \
    --to=hch@infradead.org \
    --cc=dm-devel@redhat.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=quwenruo.btrfs@gmx.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).