Linux block layer
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Ming Lei <ming.lei@redhat.com>
Cc: Anuj Gupta <anuj20.g@samsung.com>,
	axboe@kernel.dk, hch@lst.de, martin.petersen@oracle.com,
	joshi.k@samsung.com, linux-block@vger.kernel.org
Subject: Re: [PATCH] block: reuse original bio_vec array for integrity during clone
Date: Wed, 3 Jul 2024 06:46:35 +0200	[thread overview]
Message-ID: <20240703044635.GA24498@lst.de> (raw)
In-Reply-To: <CAFj5m9LcpCbdy4Vim3R+=KOnyM_AwevGM1ye5NSY4HRt1XS06Q@mail.gmail.com>

On Wed, Jul 03, 2024 at 11:08:49AM +0800, Ming Lei wrote:
> > -       bip = bio_integrity_alloc(bio, gfp_mask, bip_src->bip_vcnt);
> > +       bip = bio_integrity_alloc(bio, gfp_mask, 0);
> >         if (IS_ERR(bip))
> >                 return PTR_ERR(bip);
> >
> > -       memcpy(bip->bip_vec, bip_src->bip_vec,
> > -              bip_src->bip_vcnt * sizeof(struct bio_vec));
> > -
> > -       bip->bip_vcnt = bip_src->bip_vcnt;
> > +       bip->bip_vec = bip_src->bip_vec;
> >         bip->bip_iter = bip_src->bip_iter;
> >         bip->bip_flags = bip_src->bip_flags & ~BIP_BLOCK_INTEGRITY;
> 
> I am curious how the patch avoids double free? Given nothing changes
> in bip free code path and source bip_vec is associated with this bip.

bvec_free only frees the bvec array if nr_vecs is > BIO_INLINE_VECS.
bio_integrity_clone now passes 0 as nr_vecs to bio_integrity_alloc
so it won't ever free the bvec array.  This matches what we are
doing for the data bvec array in the bio.

  reply	other threads:[~2024-07-03  4:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20240702101517epcas5p3f651d9307bab6ece4d3e450ed61deb82@epcas5p3.samsung.com>
2024-07-02 10:07 ` [PATCH] block: reuse original bio_vec array for integrity during clone Anuj Gupta
2024-07-02 12:00   ` Christoph Hellwig
2024-07-03  2:13   ` Martin K. Petersen
2024-07-03  3:08   ` Ming Lei
2024-07-03  4:46     ` Christoph Hellwig [this message]
2024-07-03  5:16       ` Ming Lei
2024-07-04  8:08   ` Jens Axboe

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=20240703044635.GA24498@lst.de \
    --to=hch@lst.de \
    --cc=anuj20.g@samsung.com \
    --cc=axboe@kernel.dk \
    --cc=joshi.k@samsung.com \
    --cc=linux-block@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=ming.lei@redhat.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