From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C0314331A68 for ; Thu, 18 Dec 2025 09:40:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766050821; cv=none; b=oCnT2JWdwz7Oe6fky+IdBd4n5GyDiAbwWMrUy7at3nNXxv09AdVx7g0GoZPsIaG7USCHmLXzWYBvB2dEfqRJctSRDT8GNYiO7ugT7bDezC/mBnp9OXVXe5PSzf5EOK8hlXSW+ZiIGWfdjjMq0TTIS4Q+ge9V+tGsB9Rm2w3DyQY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766050821; c=relaxed/simple; bh=ky5Q1T+ezas+6lHUJs5lgO7Nb5r4ocP/kZLPfuMxAbI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Oz3Yp2JpNhsZRuDR55a1M743KCRkARmhbhcNukS805sKx12GR6oJC1EuzF/CgwzLpgHk/97MzImYiv8fodcFDk1JBVw9MfvevuFGRNjXawGenrrYU1UZFSjL7MKVSNqk2YNjhbS5jzKRcAZsYuEyenDYYUxolXA4x5gUnxcFp7o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=E5VwaKwI; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="E5VwaKwI" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1766050817; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=gdoVLXx4c8oXv89VmjV0/oZ5aqeNJYRBkgDgvRg7VFw=; b=E5VwaKwIhvbg1Vaf6PhYcGdYZZPBxArrpBx43ICmWrFNGx3wpgI467CdN9vHvd/7xjhpuV rQAp5czt01PBggbIejHWM9bJOeTpXOcMtBAUpZ6hWEFguVzDZulUvWGhwXY0M36Hei0j9N OBgO07m659j2TZAXpXXUEntSAWA+YWE= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-422-XjyHrbePM0O-UgWrDE71Gg-1; Thu, 18 Dec 2025 04:40:12 -0500 X-MC-Unique: XjyHrbePM0O-UgWrDE71Gg-1 X-Mimecast-MFC-AGG-ID: XjyHrbePM0O-UgWrDE71Gg_1766050811 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 936C318011FB; Thu, 18 Dec 2025 09:40:11 +0000 (UTC) Received: from fedora (unknown [10.72.116.190]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A5E6B19560B4; Thu, 18 Dec 2025 09:40:06 +0000 (UTC) Date: Thu, 18 Dec 2025 17:40:00 +0800 From: Ming Lei To: Christoph Hellwig Cc: Jens Axboe , Carlos Maiolino , Damien Le Moal , Hans Holmberg , linux-block@vger.kernel.org, linux-xfs@vger.kernel.org Subject: Re: [PATCH 1/3] block: add a bio_reuse helper Message-ID: References: <20251218063234.1539374-1-hch@lst.de> <20251218063234.1539374-2-hch@lst.de> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20251218063234.1539374-2-hch@lst.de> X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 On Thu, Dec 18, 2025 at 07:31:45AM +0100, Christoph Hellwig wrote: > Add a helper to allow an existing bio to be resubmitted withtout > having to re-add the payload. > > Signed-off-by: Christoph Hellwig > --- > block/bio.c | 25 +++++++++++++++++++++++++ > include/linux/bio.h | 1 + > 2 files changed, 26 insertions(+) > > diff --git a/block/bio.c b/block/bio.c > index e726c0e280a8..1b68ae877468 100644 > --- a/block/bio.c > +++ b/block/bio.c > @@ -311,6 +311,31 @@ void bio_reset(struct bio *bio, struct block_device *bdev, blk_opf_t opf) > } > EXPORT_SYMBOL(bio_reset); > > +/** > + * bio_reuse - reuse a bio with the payload left intact > + * @bio bio to reuse > + * > + * Allow reusing an existing bio for another operation with all set up > + * fields including the payload, device and end_io handler left intact. > + * > + * Typically used for bios first used to read data which is then written > + * to another location without modification. > + */ > +void bio_reuse(struct bio *bio) > +{ > + unsigned short vcnt = bio->bi_vcnt, i; > + bio_end_io_t *end_io = bio->bi_end_io; > + void *private = bio->bi_private; The incoming bio can't be a cloned bio, so WARN_ON_ONCE(bio_flagged(bio, BIO_CLONED)); should be added. Otherwise, it looks fine. Thanks, Ming