From nobody Sun Feb 8 13:52:58 2026 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 6DC6417A2F6 for ; Sun, 21 Dec 2025 02:52:49 +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=1766285571; cv=none; b=QWwteOritokS8hS5yiEFYrXb3hM4K6HJpo0/ijDtHVWsIHPYov4zH7ld7ZYBrT+qtMhlzpA6prDAOiXB/UbZKvC4jrS2IRXUUAIMk/hljabPpRlvDpT56tFXv5UM+IWJ/AXN2MhuEwBLuJsh+4wax20KSmRz+iSNkjIZZjEhMoM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766285571; c=relaxed/simple; bh=4ZBa892y1M1TfmSx5/Ar1yUahL1O7FrFkXQfkieSWPI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HPgws+xgST7qQC2x/g0mUWffGastPugM/THe396LltZtoFPJj2bK26EBqN1HsOw12yboZW3iyWqySHjDrvIMjJ1r8Pjf1st/uaTDhcxgzngndfkHYaLJiEaRYgTpAq7/3slc1KyXnC6YbEvJMmySkgoFs4aVi2hdMHDeldPRChk= 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=TKphHjCQ; 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="TKphHjCQ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1766285568; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0rFNrTbz3ZImqikct+7ijcbg6dOqTPdKeJOJQAT9nGU=; b=TKphHjCQSUPOscWPiGm92sAs30KrLXXE+ptjWSGrrKe9KdMJGRTLztu36l1zOTNeOUJcHR WujJv8rwblbXMw5u8XvLs7AgAjDNge2GsNqlW9SdigHVNw9YlIkCIHhoznoGJBBNt7tvqi GLVrNz8BAFZQJzBiYFxeqpJ1TUjnl0c= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-624-4BAqgF_mO_m3d2XQMIrwtg-1; Sat, 20 Dec 2025 21:52:44 -0500 X-MC-Unique: 4BAqgF_mO_m3d2XQMIrwtg-1 X-Mimecast-MFC-AGG-ID: 4BAqgF_mO_m3d2XQMIrwtg_1766285563 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1CE4D1956080; Sun, 21 Dec 2025 02:52:43 +0000 (UTC) Received: from pasta.fast.eng.rdu2.dc.redhat.com (unknown [10.44.32.8]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1EF1B180045B; Sun, 21 Dec 2025 02:52:39 +0000 (UTC) From: Andreas Gruenbacher To: Christoph Hellwig , Jens Axboe , Chris Mason , David Sterba , Satya Tangirala Cc: Andreas Gruenbacher , linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-raid@vger.kernel.org, dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [RFC v2 01/17] xfs: don't clobber bi_status in xfs_zone_alloc_and_submit Date: Sun, 21 Dec 2025 03:52:16 +0100 Message-ID: <20251221025233.87087-2-agruenba@redhat.com> In-Reply-To: <20251221025233.87087-1-agruenba@redhat.com> References: <20251221025233.87087-1-agruenba@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Content-Type: text/plain; charset="utf-8" Function xfs_zone_alloc_and_submit() sets bio->bi_status and then it calls bio_io_error(), which overwrites that value again. Fix that by completing the bio separately after setting bio->bi_status. Signed-off-by: Andreas Gruenbacher --- fs/xfs/xfs_zone_alloc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/xfs/xfs_zone_alloc.c b/fs/xfs/xfs_zone_alloc.c index ef7a931ebde5..bd6f3ef095cb 100644 --- a/fs/xfs/xfs_zone_alloc.c +++ b/fs/xfs/xfs_zone_alloc.c @@ -897,6 +897,9 @@ xfs_zone_alloc_and_submit( =20 out_split_error: ioend->io_bio.bi_status =3D errno_to_blk_status(PTR_ERR(split)); + bio_endio(&ioend->io_bio); + return; + out_error: bio_io_error(&ioend->io_bio); } --=20 2.52.0 From nobody Sun Feb 8 13:52:58 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 DACF621883E for ; Sun, 21 Dec 2025 02:52:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766285575; cv=none; b=iaiSPcn/5iA4FcroRKVft6KJovdHWvzBeElqLmQ+zxdI2M5CdTIbv4mtLm/uoGAEA5Mz5UDUzUizY/t4r6Zf38nIxKwKQ7U8cmfi2ZvNgiwmxh4C/NlN2R2zwfYocPR7W3VguS+ea56e0ELfiMb06fZWBhP54MGde8deD/ih6ao= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766285575; c=relaxed/simple; bh=s2FKoMxZd739dCzhmdB8JVLEUJx/RdFLnNDGdbuTA+s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HK9YCwUueX4s0oqkjCVulL0vTdrSnmmUAZyaS5JJr/qc1nc0YMETYOkuvunnuVsyEBWhXyCFBygss2cMWURtcdyU9LQW/2jP27ciZR9RVgqqWcV2HqToRZZjh0DHVOU9MtxA/V4nmt5VvoisHTFWHGZ5PV1Vdo5KyScVsa6ZhuI= 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=BRHHYYbY; arc=none smtp.client-ip=170.10.129.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="BRHHYYbY" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1766285572; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=z84twE+0dmUFQawUihISJPCYSTL4dhggfdILlETnyIY=; b=BRHHYYbYLQPXf7bJc892Ym5lyY4B+/U9fq3V6YFJdSbX6yWbh4fXuOY8eiM080uRWLyLqX YycSduvjQhsAaRr9QVAuhwzAk1EZiGHYAlbhcRx6RKxr5ShNwLqMGC7h/Atezy2zVhQOCZ Bb08ohsVOMBGH1HrnaZvZcl7KL7dF+M= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-639-iB9QqN7SOFaqUEEFzmQTgg-1; Sat, 20 Dec 2025 21:52:49 -0500 X-MC-Unique: iB9QqN7SOFaqUEEFzmQTgg-1 X-Mimecast-MFC-AGG-ID: iB9QqN7SOFaqUEEFzmQTgg_1766285567 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 341301956088; Sun, 21 Dec 2025 02:52:47 +0000 (UTC) Received: from pasta.fast.eng.rdu2.dc.redhat.com (unknown [10.44.32.8]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 863B8180049F; Sun, 21 Dec 2025 02:52:43 +0000 (UTC) From: Andreas Gruenbacher To: Christoph Hellwig , Jens Axboe , Chris Mason , David Sterba , Satya Tangirala Cc: Andreas Gruenbacher , linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-raid@vger.kernel.org, dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org, Christoph Hellwig Subject: [RFC v2 02/17] bio: rename bio_chain arguments Date: Sun, 21 Dec 2025 03:52:17 +0100 Message-ID: <20251221025233.87087-3-agruenba@redhat.com> In-Reply-To: <20251221025233.87087-1-agruenba@redhat.com> References: <20251221025233.87087-1-agruenba@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Content-Type: text/plain; charset="utf-8" Use the same argument names in bio_chain() as in bio_chain_and_submit() to be consistent. Slightly improve the function description. Signed-off-by: Andreas Gruenbacher Reviewed-by: Christoph Hellwig --- block/bio.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/block/bio.c b/block/bio.c index b3a79285c278..3f408e1ba13f 100644 --- a/block/bio.c +++ b/block/bio.c @@ -327,22 +327,22 @@ static void bio_chain_endio(struct bio *bio) =20 /** * bio_chain - chain bio completions - * @bio: the target bio - * @parent: the parent bio of @bio + * @prev: the bio to chain + * @new: the bio to chain to * - * The caller won't have a bi_end_io called when @bio completes - instead, - * @parent's bi_end_io won't be called until both @parent and @bio have - * completed; the chained bio will also be freed when it completes. + * The caller won't have a bi_end_io called when @prev completes. Instead, + * @new's bi_end_io will be called once both @new and @prev have completed. + * Like an unchained bio, @prev will be put when it completes. * - * The caller must not set bi_private or bi_end_io in @bio. + * The caller must not set bi_private or bi_end_io in @prev. */ -void bio_chain(struct bio *bio, struct bio *parent) +void bio_chain(struct bio *prev, struct bio *new) { - BUG_ON(bio->bi_private || bio->bi_end_io); + BUG_ON(prev->bi_private || prev->bi_end_io); =20 - bio->bi_private =3D parent; - bio->bi_end_io =3D bio_chain_endio; - bio_inc_remaining(parent); + prev->bi_private =3D new; + prev->bi_end_io =3D bio_chain_endio; + bio_inc_remaining(new); } EXPORT_SYMBOL(bio_chain); =20 --=20 2.52.0 From nobody Sun Feb 8 13:52:58 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 8820B2153E7 for ; Sun, 21 Dec 2025 02:52:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766285579; cv=none; b=VRJPbF3Np/73dLbfy9kepXnj8pR6Qbk61h4BpdPdkhyF1hl/aAC3owGSIXEpJZvC9LwyAeEew4B07oEew5CHvs9FSm9Xrxu9kCl2L+ECBHJUXSPVdyvkWNt22D80wIExSJR2hzg069iyf0VBTtwo7/jOcYi5jvRYCPBbLyhW9ic= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766285579; c=relaxed/simple; bh=ytmSqvCI1NK1Y6W/9zah+OycgBNTaOsJHj7jzvMklgI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FtDamMdn1MqAZRS94VEpHuN3NtaKVHC+raB6znV4ShU31t2BlAdl9IWkOtJZeIcwylgXSTSvPA0KgAu1bLM+Z/C6VFrHbwSzkA14poiIJ6ySTB8GZWg4yftHD6yoLGIMHG0tI50mNGe0NgV8MIHYPKSNzTAdEnGoVevQa63+CTE= 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=aNZ0elEv; arc=none smtp.client-ip=170.10.129.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="aNZ0elEv" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1766285576; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=98J2ESppVbFgezylqxcV+tZ8H9YPLvgyX4ksKvm5FJY=; b=aNZ0elEvH73wvBVabDbkh6DnBEe7lNsGJ/TsK0UlW6g4yyS51NJW++nL1j8sOzAZFfa+Sa rfx/D4gdYxj/yevyWq/rPqswX9Y96P065Lm5hvK5frOomaIzgq13pmJ/U8IBRLiE+tb8Od Qj1/Fa+P2bgOmhBMt2dDjgdZMBA53pA= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-347-NOr3FQneOXevrgcNFltEzw-1; Sat, 20 Dec 2025 21:52:53 -0500 X-MC-Unique: NOr3FQneOXevrgcNFltEzw-1 X-Mimecast-MFC-AGG-ID: NOr3FQneOXevrgcNFltEzw_1766285571 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E8C551956088; Sun, 21 Dec 2025 02:52:50 +0000 (UTC) Received: from pasta.fast.eng.rdu2.dc.redhat.com (unknown [10.44.32.8]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 851A21800352; Sun, 21 Dec 2025 02:52:47 +0000 (UTC) From: Andreas Gruenbacher To: Christoph Hellwig , Jens Axboe , Chris Mason , David Sterba , Satya Tangirala Cc: Andreas Gruenbacher , linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-raid@vger.kernel.org, dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org, Christoph Hellwig Subject: [RFC v2 03/17] bio: use bio_io_error more often Date: Sun, 21 Dec 2025 03:52:18 +0100 Message-ID: <20251221025233.87087-4-agruenba@redhat.com> In-Reply-To: <20251221025233.87087-1-agruenba@redhat.com> References: <20251221025233.87087-1-agruenba@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Content-Type: text/plain; charset="utf-8" Instead of setting bio->bi_status to BLK_STS_IOERR and calling bio_endio(bio), use the shorthand bio_io_error(bio). Created with Coccinelle using the following semantic patch: @@ struct bio *bio; @@ - bio->bi_status =3D BLK_STS_IOERR; - bio_endio(bio); + bio_io_error(bio); Signed-off-by: Andreas Gruenbacher Reviewed-by: Christoph Hellwig --- block/fops.c | 3 +-- drivers/block/drbd/drbd_int.h | 3 +-- drivers/md/bcache/bcache.h | 3 +-- drivers/md/bcache/request.c | 6 ++---- drivers/md/dm-mpath.c | 3 +-- drivers/md/dm-writecache.c | 3 +-- fs/f2fs/segment.c | 3 +-- 7 files changed, 8 insertions(+), 16 deletions(-) diff --git a/block/fops.c b/block/fops.c index 5e3db9fead77..b4f911273289 100644 --- a/block/fops.c +++ b/block/fops.c @@ -221,8 +221,7 @@ static ssize_t __blkdev_direct_IO(struct kiocb *iocb, s= truct iov_iter *iter, =20 ret =3D blkdev_iov_iter_get_pages(bio, iter, bdev); if (unlikely(ret)) { - bio->bi_status =3D BLK_STS_IOERR; - bio_endio(bio); + bio_io_error(bio); break; } if (iocb->ki_flags & IOCB_NOWAIT) { diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h index f6d6276974ee..32639e8ea72a 100644 --- a/drivers/block/drbd/drbd_int.h +++ b/drivers/block/drbd/drbd_int.h @@ -1491,8 +1491,7 @@ static inline void drbd_submit_bio_noacct(struct drbd= _device *device, __release(local); if (!bio->bi_bdev) { drbd_err(device, "drbd_submit_bio_noacct: bio->bi_bdev =3D=3D NULL\n"); - bio->bi_status =3D BLK_STS_IOERR; - bio_endio(bio); + bio_io_error(bio); return; } =20 diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h index 1d33e40d26ea..7ad7c778d8ff 100644 --- a/drivers/md/bcache/bcache.h +++ b/drivers/md/bcache/bcache.h @@ -940,8 +940,7 @@ static inline void closure_bio_submit(struct cache_set = *c, { closure_get(cl); if (unlikely(test_bit(CACHE_SET_IO_DISABLE, &c->flags))) { - bio->bi_status =3D BLK_STS_IOERR; - bio_endio(bio); + bio_io_error(bio); return; } submit_bio_noacct(bio); diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c index af345dc6fde1..acccecd061ea 100644 --- a/drivers/md/bcache/request.c +++ b/drivers/md/bcache/request.c @@ -1192,8 +1192,7 @@ void cached_dev_submit_bio(struct bio *bio) =20 if (unlikely((d->c && test_bit(CACHE_SET_IO_DISABLE, &d->c->flags)) || dc->io_disable)) { - bio->bi_status =3D BLK_STS_IOERR; - bio_endio(bio); + bio_io_error(bio); return; } =20 @@ -1296,8 +1295,7 @@ void flash_dev_submit_bio(struct bio *bio) struct bcache_device *d =3D bio->bi_bdev->bd_disk->private_data; =20 if (unlikely(d->c && test_bit(CACHE_SET_IO_DISABLE, &d->c->flags))) { - bio->bi_status =3D BLK_STS_IOERR; - bio_endio(bio); + bio_io_error(bio); return; } =20 diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c index aaf4a0a4b0eb..1424ef75d088 100644 --- a/drivers/md/dm-mpath.c +++ b/drivers/md/dm-mpath.c @@ -719,8 +719,7 @@ static void process_queued_bios(struct work_struct *wor= k) r =3D __multipath_map_bio(m, bio, mpio); switch (r) { case DM_MAPIO_KILL: - bio->bi_status =3D BLK_STS_IOERR; - bio_endio(bio); + bio_io_error(bio); break; case DM_MAPIO_REQUEUE: bio->bi_status =3D BLK_STS_DM_REQUEUE; diff --git a/drivers/md/dm-writecache.c b/drivers/md/dm-writecache.c index d8de4a3076a1..4f70e2673e4b 100644 --- a/drivers/md/dm-writecache.c +++ b/drivers/md/dm-writecache.c @@ -1877,8 +1877,7 @@ static void __writecache_writeback_pmem(struct dm_wri= tecache *wc, struct writeba if (WC_MODE_FUA(wc)) bio->bi_opf |=3D REQ_FUA; if (writecache_has_error(wc)) { - bio->bi_status =3D BLK_STS_IOERR; - bio_endio(bio); + bio_io_error(bio); } else if (unlikely(!bio_sectors(bio))) { bio->bi_status =3D BLK_STS_OK; bio_endio(bio); diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index b45eace879d7..6444d572f0c7 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -4090,8 +4090,7 @@ int f2fs_inplace_write_data(struct f2fs_io_info *fio) if (fio->bio && *(fio->bio)) { struct bio *bio =3D *(fio->bio); =20 - bio->bi_status =3D BLK_STS_IOERR; - bio_endio(bio); + bio_io_error(bio); *(fio->bio) =3D NULL; } return err; --=20 2.52.0 From nobody Sun Feb 8 13:52:58 2026 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 801CE21E087 for ; Sun, 21 Dec 2025 02:53:00 +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=1766285582; cv=none; b=jX/j2KFBBseYFv5p4w2K0aQv211i0DnHYs0y5yiKcVF5UTe0A3tAuJnhNIo0C7raB39neXBAIcmh8M9GYkKTVBcxNNEqqTnk6zQ1ttXbz/gm5P45+QxgNRRY5RJlG48Sl2S/KxgGecTLktQ6YhHotSWjSJpIxZqbbeq+Pq7GuAg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766285582; c=relaxed/simple; bh=wa/cLGBGStMHa4wiaPJkp2x8IVdNQku/BtZQXKI/1k0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GodBtwS0K4eUv//ZHzySM/CB12oIztM9JZAS6bYLdmV0j1C7ejJwk7xIOXjBZVFi/grwQ0GfA5wu5+piMZC755olot7jkr8+JkjZpr9/JYujqAHxYrG/vhccX0oae/INrFfJZIfbXpEfh59nFunC4eMM+w23LZAyZSDySV5Cs2E= 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=SaeXiDmx; 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="SaeXiDmx" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1766285579; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UHW4SPD9tBLodJmH7Rf3AmmAfw6AhO5IJSG7uhaTc7A=; b=SaeXiDmxIj97VlRiHIX53SWpy92iseSLsYEzMyv/Q4CxcbWC40CorDlflJQqk7jl7yPNLK g6Own8rELDMrSl2iwVvqXDkJ/+PA6rELMtHEkWVZNZOKk6X+jMyr11ulwfzW2qbb8UW67/ wfiTJMo90W2GPSexZLMpzJRKPoAuyT8= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-114-i3vt7UEBN_-QSuoCQY2xvA-1; Sat, 20 Dec 2025 21:52:56 -0500 X-MC-Unique: i3vt7UEBN_-QSuoCQY2xvA-1 X-Mimecast-MFC-AGG-ID: i3vt7UEBN_-QSuoCQY2xvA_1766285574 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5474719560A5; Sun, 21 Dec 2025 02:52:54 +0000 (UTC) Received: from pasta.fast.eng.rdu2.dc.redhat.com (unknown [10.44.32.8]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5F42A180035F; Sun, 21 Dec 2025 02:52:51 +0000 (UTC) From: Andreas Gruenbacher To: Christoph Hellwig , Jens Axboe , Chris Mason , David Sterba , Satya Tangirala Cc: Andreas Gruenbacher , linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-raid@vger.kernel.org, dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [RFC v2 04/17] bio: add bio_set_status Date: Sun, 21 Dec 2025 03:52:19 +0100 Message-ID: <20251221025233.87087-5-agruenba@redhat.com> In-Reply-To: <20251221025233.87087-1-agruenba@redhat.com> References: <20251221025233.87087-1-agruenba@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Content-Type: text/plain; charset="utf-8" Add a bio_set_status(bio, status) helper that sets bio->bi_status to status if status !=3D BLK_STS_OK. Replace instances of this pattern in the code with a call to the new helper. The WRITE_ONCE() in bio_set_status() ensures that the compiler won't reorder things in a weird way, but tearing is not an issue because bi_status is a single-byte field. Created with Coccinelle using the following semantic patch and option '--disable-iso unlikely'. (Coccinelle occasionally likes to add unnecessary curly braces in if statements; those were removed by hand.) @@ expression status; struct bio *bio; @@ - if (status) - bio->bi_status =3D status; + bio_set_status(bio, status); @@ expression status; struct bio *bio; @@ - if (unlikely(status)) - bio->bi_status =3D status; + if (unlikely(status)) + bio_set_status(bio, status); @@ expression status; struct bio *bio; @@ if (status) { <... - bio->bi_status =3D status; + bio_set_status(bio, status); ...> } @@ expression status; struct bio *bio; @@ if (status !=3D BLK_STS_OK) { <... - bio->bi_status =3D status; + bio_set_status(bio, status); ...> } @@ expression status; struct bio *bio; statement S; @@ if (status) - bio->bi_status =3D status; + bio_set_status(bio, status); else S Signed-off-by: Andreas Gruenbacher --- block/blk-crypto-fallback.c | 4 ++-- block/blk-mq.c | 4 ++-- block/t10-pi.c | 2 +- drivers/md/dm-cache-target.c | 3 ++- drivers/md/dm.c | 3 +-- drivers/nvdimm/pmem.c | 2 +- include/linux/bio.h | 16 ++++++++++++++++ 7 files changed, 25 insertions(+), 9 deletions(-) diff --git a/block/blk-crypto-fallback.c b/block/blk-crypto-fallback.c index 86b27f96051a..a9cb5647879c 100644 --- a/block/blk-crypto-fallback.c +++ b/block/blk-crypto-fallback.c @@ -292,7 +292,7 @@ static bool blk_crypto_fallback_encrypt_bio(struct bio = **bio_ptr) blk_st =3D blk_crypto_get_keyslot(blk_crypto_fallback_profile, bc->bc_key, &slot); if (blk_st !=3D BLK_STS_OK) { - src_bio->bi_status =3D blk_st; + bio_set_status(src_bio, blk_st); goto out_put_enc_bio; } =20 @@ -395,7 +395,7 @@ static void blk_crypto_fallback_decrypt_bio(struct work= _struct *work) blk_st =3D blk_crypto_get_keyslot(blk_crypto_fallback_profile, bc->bc_key, &slot); if (blk_st !=3D BLK_STS_OK) { - bio->bi_status =3D blk_st; + bio_set_status(bio, blk_st); goto out_no_keyslot; } =20 diff --git a/block/blk-mq.c b/block/blk-mq.c index d626d32f6e57..9d1883d653c4 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -970,7 +970,7 @@ bool blk_update_request(struct request *req, blk_status= _t error, unsigned bio_bytes =3D min(bio->bi_iter.bi_size, nr_bytes); =20 if (unlikely(error)) - bio->bi_status =3D error; + bio_set_status(bio, error); =20 if (bio_bytes =3D=3D bio->bi_iter.bi_size) { req->bio =3D bio->bi_next; @@ -3206,7 +3206,7 @@ void blk_mq_submit_bio(struct bio *bio) =20 ret =3D blk_crypto_rq_get_keyslot(rq); if (ret !=3D BLK_STS_OK) { - bio->bi_status =3D ret; + bio_set_status(bio, ret); bio_endio(bio); blk_mq_free_request(rq); return; diff --git a/block/t10-pi.c b/block/t10-pi.c index 0c4ed9702146..968cf1fe45f0 100644 --- a/block/t10-pi.c +++ b/block/t10-pi.c @@ -440,7 +440,7 @@ void blk_integrity_verify_iter(struct bio *bio, struct = bvec_iter *saved_iter) kunmap_local(kaddr); =20 if (ret) { - bio->bi_status =3D ret; + bio_set_status(bio, ret); return; } } diff --git a/drivers/md/dm-cache-target.c b/drivers/md/dm-cache-target.c index a10d75a562db..03816f0dcb58 100644 --- a/drivers/md/dm-cache-target.c +++ b/drivers/md/dm-cache-target.c @@ -1190,7 +1190,8 @@ static void mg_complete(struct dm_cache_migration *mg= , bool success) if (success) force_set_dirty(cache, cblock); else if (mg->k.input) - mg->overwrite_bio->bi_status =3D mg->k.input; + bio_set_status(mg->overwrite_bio, + mg->k.input); else mg->overwrite_bio->bi_status =3D BLK_STS_IOERR; bio_endio(mg->overwrite_bio); diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 6c83ab940af7..cbc64377fa96 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -983,8 +983,7 @@ static void __dm_io_complete(struct dm_io *io, bool fir= st_stage) queue_io(md, bio); } else { /* done with normal IO or empty flush */ - if (io_error) - bio->bi_status =3D io_error; + bio_set_status(bio, io_error); bio_endio(bio); } } diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index 05785ff21a8b..4fdcbe56a3bc 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -222,7 +222,7 @@ static void pmem_submit_bio(struct bio *bio) rc =3D pmem_do_read(pmem, bvec.bv_page, bvec.bv_offset, iter.bi_sector, bvec.bv_len); if (rc) { - bio->bi_status =3D rc; + bio_set_status(bio, rc); break; } } diff --git a/include/linux/bio.h b/include/linux/bio.h index 16c1c85613b7..a1324ce61ebd 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -376,6 +376,22 @@ void submit_bio(struct bio *bio); =20 extern void bio_endio(struct bio *); =20 +/** + * bio_set_status - set the status of bio + * @bio: bio + * @status: a BLK_STS_* status code + * + * Set the status of @bio to @status unless @status is BLK_STS_OK (0). In= bio + * chains, this function may be called repeatedly on the same bio. In that + * case, it can override a previous error, but it will never revert from an + * error back to BLK_STS_OK. + */ +static inline void bio_set_status(struct bio *bio, blk_status_t status) +{ + if (status !=3D BLK_STS_OK) + WRITE_ONCE(bio->bi_status, status); +} + static inline void bio_io_error(struct bio *bio) { bio->bi_status =3D BLK_STS_IOERR; --=20 2.52.0 From nobody Sun Feb 8 13:52:58 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 1E83A20E00B for ; Sun, 21 Dec 2025 02:53:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766285587; cv=none; b=MIL41KUFfS2M+hR3JZMJMMEN/7yfr/yN0hBpmca/8yQw0yf7yIZeT312zTWms7zCxgv4GS26iKoRjmvEJ7sW7n+BvTmMIHbcdoDcJzIaO7fiPeXunGBmkt88ZChomxckHJv5Cv4W1Rz8bEQyjuIS8kvvzJlXulMNLVVOvKLZDxY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766285587; c=relaxed/simple; bh=VIUI/WhlV6S7EgK1pDq/ANaELNqd+0QD2YI6LfB3Vas=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XgAY0vp7v/fkh4A5EWfpvD9D9XFU09ITPPagBSsKo0N64GH3RsYx5jMjpFwtae4dgDa1qn89BG0SDVncbv4HhXtuB5XTB41ynh2WuCztwLPc02i3tmKsmau3QikUfSJZz75/d92DgRMMA4oz0yLYNBaO7kNno7B9yEgtnPtzffg= 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=MAG8R3du; arc=none smtp.client-ip=170.10.129.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="MAG8R3du" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1766285584; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zeUG0nQz5ZqoTaK3HHgCqQApK+6+pEbI86lHLhPE+m0=; b=MAG8R3du1lF9MwJYaq9wAbCGsONAMG6aRkGP5fisZY6taIT2wbBWpJldMq3khPnPQLEoOW 5Tdkn53d0kTlcUm4AifC9Z+8gJ4yGqOQ+RjHcebNtMRiN4L34q0xYofMw9mxnP0j7A9YCd SsLj0DBr2J5LsxUiix07b3AfwvOgq5Q= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-567-q0g61KcqPCiCTt8Dl6VEAA-1; Sat, 20 Dec 2025 21:52:59 -0500 X-MC-Unique: q0g61KcqPCiCTt8Dl6VEAA-1 X-Mimecast-MFC-AGG-ID: q0g61KcqPCiCTt8Dl6VEAA_1766285578 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id ED066195608E; Sun, 21 Dec 2025 02:52:57 +0000 (UTC) Received: from pasta.fast.eng.rdu2.dc.redhat.com (unknown [10.44.32.8]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BE1EC180049F; Sun, 21 Dec 2025 02:52:54 +0000 (UTC) From: Andreas Gruenbacher To: Christoph Hellwig , Jens Axboe , Chris Mason , David Sterba , Satya Tangirala Cc: Andreas Gruenbacher , linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-raid@vger.kernel.org, dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [RFC v2 05/17] bio: use bio_set_status for BLK_STS_* status codes Date: Sun, 21 Dec 2025 03:52:20 +0100 Message-ID: <20251221025233.87087-6-agruenba@redhat.com> In-Reply-To: <20251221025233.87087-1-agruenba@redhat.com> References: <20251221025233.87087-1-agruenba@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Content-Type: text/plain; charset="utf-8" Use bio_set_status(bio, status) in cases where status is a blk_status_t constant other than BLK_STS_OK. In these cases, the compiler knows that status !=3D BLK_STS_OK, so it can optimize out the check in bio_set_status() and effectively end up with identical code. Created with Coccinelle using the following semantic patch: @@ struct bio *bio; constant C !=3D 0 && !=3D BLK_STS_OK; @@ - bio->bi_status =3D C; + bio_set_status(bio, C); @@ struct bio bio; constant C !=3D 0 && !=3D BLK_STS_OK; @@ - bio.bi_status =3D C; + bio_set_status(&bio, C); Signed-off-by: Andreas Gruenbacher --- block/bio-integrity-auto.c | 2 +- block/blk-core.c | 2 +- block/blk-crypto-fallback.c | 16 ++++++++-------- block/blk-crypto-internal.h | 2 +- block/blk-crypto.c | 4 ++-- block/blk-mq.c | 4 ++-- drivers/block/aoe/aoecmd.c | 8 ++++---- drivers/block/aoe/aoedev.c | 2 +- drivers/block/drbd/drbd_req.c | 4 ++-- drivers/block/zram/zram_drv.c | 4 ++-- drivers/md/bcache/request.c | 2 +- drivers/md/dm-cache-target.c | 5 +++-- drivers/md/dm-integrity.c | 12 ++++++------ drivers/md/dm-mpath.c | 2 +- drivers/md/dm-raid1.c | 6 +++--- drivers/md/dm-thin.c | 2 +- drivers/md/dm-writecache.c | 4 ++-- drivers/md/md.c | 2 +- drivers/md/raid1-10.c | 2 +- drivers/md/raid1.c | 2 +- drivers/md/raid10.c | 10 +++++----- drivers/md/raid5.c | 4 ++-- drivers/nvdimm/btt.c | 2 +- fs/btrfs/bio.c | 6 +++--- fs/f2fs/data.c | 6 +++--- fs/verity/verify.c | 2 +- include/linux/bio.h | 4 ++-- 27 files changed, 61 insertions(+), 60 deletions(-) diff --git a/block/bio-integrity-auto.c b/block/bio-integrity-auto.c index 687952f63bbb..736d53a7f699 100644 --- a/block/bio-integrity-auto.c +++ b/block/bio-integrity-auto.c @@ -190,7 +190,7 @@ bool bio_integrity_prep(struct bio *bio) err_free_buf: kfree(buf); err_end_io: - bio->bi_status =3D BLK_STS_RESOURCE; + bio_set_status(bio, BLK_STS_RESOURCE); bio_endio(bio); return false; } diff --git a/block/blk-core.c b/block/blk-core.c index 14ae73eebe0d..4f7b7cf50d23 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -640,7 +640,7 @@ static void __submit_bio(struct bio *bio) =09 if ((bio->bi_opf & REQ_POLLED) && !(disk->queue->limits.features & BLK_FEAT_POLL)) { - bio->bi_status =3D BLK_STS_NOTSUPP; + bio_set_status(bio, BLK_STS_NOTSUPP); bio_endio(bio); } else { disk->fops->submit_bio(bio); diff --git a/block/blk-crypto-fallback.c b/block/blk-crypto-fallback.c index a9cb5647879c..8a2631b1e7e1 100644 --- a/block/blk-crypto-fallback.c +++ b/block/blk-crypto-fallback.c @@ -281,7 +281,7 @@ static bool blk_crypto_fallback_encrypt_bio(struct bio = **bio_ptr) /* Allocate bounce bio for encryption */ enc_bio =3D blk_crypto_fallback_clone_bio(src_bio); if (!enc_bio) { - src_bio->bi_status =3D BLK_STS_RESOURCE; + bio_set_status(src_bio, BLK_STS_RESOURCE); return false; } =20 @@ -298,7 +298,7 @@ static bool blk_crypto_fallback_encrypt_bio(struct bio = **bio_ptr) =20 /* and then allocate an skcipher_request for it */ if (!blk_crypto_fallback_alloc_cipher_req(slot, &ciph_req, &wait)) { - src_bio->bi_status =3D BLK_STS_RESOURCE; + bio_set_status(src_bio, BLK_STS_RESOURCE); goto out_release_keyslot; } =20 @@ -319,7 +319,7 @@ static bool blk_crypto_fallback_encrypt_bio(struct bio = **bio_ptr) enc_bvec->bv_page =3D ciphertext_page; =20 if (!ciphertext_page) { - src_bio->bi_status =3D BLK_STS_RESOURCE; + bio_set_status(src_bio, BLK_STS_RESOURCE); goto out_free_bounce_pages; } =20 @@ -334,7 +334,7 @@ static bool blk_crypto_fallback_encrypt_bio(struct bio = **bio_ptr) if (crypto_wait_req(crypto_skcipher_encrypt(ciph_req), &wait)) { i++; - src_bio->bi_status =3D BLK_STS_IOERR; + bio_set_status(src_bio, BLK_STS_IOERR); goto out_free_bounce_pages; } bio_crypt_dun_increment(curr_dun, 1); @@ -401,7 +401,7 @@ static void blk_crypto_fallback_decrypt_bio(struct work= _struct *work) =20 /* and then allocate an skcipher_request for it */ if (!blk_crypto_fallback_alloc_cipher_req(slot, &ciph_req, &wait)) { - bio->bi_status =3D BLK_STS_RESOURCE; + bio_set_status(bio, BLK_STS_RESOURCE); goto out; } =20 @@ -421,7 +421,7 @@ static void blk_crypto_fallback_decrypt_bio(struct work= _struct *work) blk_crypto_dun_to_iv(curr_dun, &iv); if (crypto_wait_req(crypto_skcipher_decrypt(ciph_req), &wait)) { - bio->bi_status =3D BLK_STS_IOERR; + bio_set_status(bio, BLK_STS_IOERR); goto out; } bio_crypt_dun_increment(curr_dun, 1); @@ -492,13 +492,13 @@ bool blk_crypto_fallback_bio_prep(struct bio **bio_pt= r) =20 if (WARN_ON_ONCE(!tfms_inited[bc->bc_key->crypto_cfg.crypto_mode])) { /* User didn't call blk_crypto_start_using_key() first */ - bio->bi_status =3D BLK_STS_IOERR; + bio_set_status(bio, BLK_STS_IOERR); return false; } =20 if (!__blk_crypto_cfg_supported(blk_crypto_fallback_profile, &bc->bc_key->crypto_cfg)) { - bio->bi_status =3D BLK_STS_NOTSUPP; + bio_set_status(bio, BLK_STS_NOTSUPP); return false; } =20 diff --git a/block/blk-crypto-internal.h b/block/blk-crypto-internal.h index ccf6dff6ff6b..fc606352a31a 100644 --- a/block/blk-crypto-internal.h +++ b/block/blk-crypto-internal.h @@ -235,7 +235,7 @@ blk_crypto_fallback_start_using_mode(enum blk_crypto_mo= de_num mode_num) static inline bool blk_crypto_fallback_bio_prep(struct bio **bio_ptr) { pr_warn_once("crypto API fallback disabled; failing request.\n"); - (*bio_ptr)->bi_status =3D BLK_STS_NOTSUPP; + bio_set_status((*bio_ptr), BLK_STS_NOTSUPP); return false; } =20 diff --git a/block/blk-crypto.c b/block/blk-crypto.c index 3e7bf1974cbd..cbba31cd4e58 100644 --- a/block/blk-crypto.c +++ b/block/blk-crypto.c @@ -287,12 +287,12 @@ bool __blk_crypto_bio_prep(struct bio **bio_ptr) =20 /* Error if bio has no data. */ if (WARN_ON_ONCE(!bio_has_data(bio))) { - bio->bi_status =3D BLK_STS_IOERR; + bio_set_status(bio, BLK_STS_IOERR); goto fail; } =20 if (!bio_crypt_check_alignment(bio)) { - bio->bi_status =3D BLK_STS_INVAL; + bio_set_status(bio, BLK_STS_INVAL); goto fail; } =20 diff --git a/block/blk-mq.c b/block/blk-mq.c index 9d1883d653c4..8fb35a258b4c 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -980,7 +980,7 @@ bool blk_update_request(struct request *req, blk_status= _t error, * as the BIO fragments may end up not being written * sequentially. */ - bio->bi_status =3D BLK_STS_IOERR; + bio_set_status(bio, BLK_STS_IOERR); } =20 /* Completion has already been traced */ @@ -3165,7 +3165,7 @@ void blk_mq_submit_bio(struct bio *bio) } =20 if ((bio->bi_opf & REQ_POLLED) && !blk_mq_can_poll(q)) { - bio->bi_status =3D BLK_STS_NOTSUPP; + bio_set_status(bio, BLK_STS_NOTSUPP); bio_endio(bio); goto queue_exit; } diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c index a9affb7c264d..a5eb4912fb3e 100644 --- a/drivers/block/aoe/aoecmd.c +++ b/drivers/block/aoe/aoecmd.c @@ -1112,7 +1112,7 @@ ktiocomplete(struct frame *f) ahout->cmdstat, ahin->cmdstat, d->aoemajor, d->aoeminor); noskb: if (buf) - buf->bio->bi_status =3D BLK_STS_IOERR; + bio_set_status(buf->bio, BLK_STS_IOERR); goto out; } =20 @@ -1125,7 +1125,7 @@ noskb: if (buf) "aoe: runt data size in read from", (long) d->aoemajor, d->aoeminor, skb->len, n); - buf->bio->bi_status =3D BLK_STS_IOERR; + bio_set_status(buf->bio, BLK_STS_IOERR); break; } if (n > f->iter.bi_size) { @@ -1133,7 +1133,7 @@ noskb: if (buf) "aoe: too-large data size in read from", (long) d->aoemajor, d->aoeminor, n, f->iter.bi_size); - buf->bio->bi_status =3D BLK_STS_IOERR; + bio_set_status(buf->bio, BLK_STS_IOERR); break; } bvcpy(skb, f->buf->bio, f->iter, n); @@ -1637,7 +1637,7 @@ aoe_failbuf(struct aoedev *d, struct buf *buf) if (buf =3D=3D NULL) return; buf->iter.bi_size =3D 0; - buf->bio->bi_status =3D BLK_STS_IOERR; + bio_set_status(buf->bio, BLK_STS_IOERR); if (buf->nframesout =3D=3D 0) aoe_end_buf(d, buf); } diff --git a/drivers/block/aoe/aoedev.c b/drivers/block/aoe/aoedev.c index 3a240755045b..11320258d0ce 100644 --- a/drivers/block/aoe/aoedev.c +++ b/drivers/block/aoe/aoedev.c @@ -170,7 +170,7 @@ aoe_failip(struct aoedev *d) =20 req =3D blk_mq_rq_to_pdu(rq); while ((bio =3D d->ip.nxbio)) { - bio->bi_status =3D BLK_STS_IOERR; + bio_set_status(bio, BLK_STS_IOERR); d->ip.nxbio =3D bio->bi_next; req->nr_bios--; } diff --git a/drivers/block/drbd/drbd_req.c b/drivers/block/drbd/drbd_req.c index d15826f6ee81..baa08d56494d 100644 --- a/drivers/block/drbd/drbd_req.c +++ b/drivers/block/drbd/drbd_req.c @@ -1143,7 +1143,7 @@ static void drbd_process_discard_or_zeroes_req(struct= drbd_request *req, int fla int err =3D drbd_issue_discard_or_zero_out(req->device, req->i.sector, req->i.size >> 9, flags); if (err) - req->private_bio->bi_status =3D BLK_STS_IOERR; + bio_set_status(req->private_bio, BLK_STS_IOERR); bio_endio(req->private_bio); } =20 @@ -1211,7 +1211,7 @@ drbd_request_prepare(struct drbd_device *device, stru= ct bio *bio) /* only pass the error to the upper layers. * if user cannot handle io errors, that's not our business. */ drbd_err(device, "could not kmalloc() req\n"); - bio->bi_status =3D BLK_STS_RESOURCE; + bio_set_status(bio, BLK_STS_RESOURCE); bio_endio(bio); return ERR_PTR(-ENOMEM); } diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index a43074657531..975757f01bb8 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -2341,7 +2341,7 @@ static void zram_bio_read(struct zram *zram, struct b= io *bio) =20 if (zram_bvec_read(zram, &bv, index, offset, bio) < 0) { atomic64_inc(&zram->stats.failed_reads); - bio->bi_status =3D BLK_STS_IOERR; + bio_set_status(bio, BLK_STS_IOERR); break; } flush_dcache_page(bv.bv_page); @@ -2372,7 +2372,7 @@ static void zram_bio_write(struct zram *zram, struct = bio *bio) =20 if (zram_bvec_write(zram, &bv, index, offset, bio) < 0) { atomic64_inc(&zram->stats.failed_writes); - bio->bi_status =3D BLK_STS_IOERR; + bio_set_status(bio, BLK_STS_IOERR); break; } =20 diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c index acccecd061ea..3ea67a8e252a 100644 --- a/drivers/md/bcache/request.c +++ b/drivers/md/bcache/request.c @@ -1120,7 +1120,7 @@ static void detached_dev_do_request(struct bcache_dev= ice *d, struct bio *bio, */ ddip =3D kzalloc(sizeof(struct detached_dev_io_private), GFP_NOIO); if (!ddip) { - bio->bi_status =3D BLK_STS_RESOURCE; + bio_set_status(bio, BLK_STS_RESOURCE); bio->bi_end_io(bio); return; } diff --git a/drivers/md/dm-cache-target.c b/drivers/md/dm-cache-target.c index 03816f0dcb58..d1dbd4ddaadb 100644 --- a/drivers/md/dm-cache-target.c +++ b/drivers/md/dm-cache-target.c @@ -1193,7 +1193,8 @@ static void mg_complete(struct dm_cache_migration *mg= , bool success) bio_set_status(mg->overwrite_bio, mg->k.input); else - mg->overwrite_bio->bi_status =3D BLK_STS_IOERR; + bio_set_status(mg->overwrite_bio, + BLK_STS_IOERR); bio_endio(mg->overwrite_bio); } else { if (success) @@ -1855,7 +1856,7 @@ static void requeue_deferred_bios(struct cache *cache) bio_list_merge_init(&bios, &cache->deferred_bios); =20 while ((bio =3D bio_list_pop(&bios))) { - bio->bi_status =3D BLK_STS_DM_REQUEUE; + bio_set_status(bio, BLK_STS_DM_REQUEUE); bio_endio(bio); cond_resched(); } diff --git a/drivers/md/dm-integrity.c b/drivers/md/dm-integrity.c index 170bf67a2edd..e380ed7b2a7b 100644 --- a/drivers/md/dm-integrity.c +++ b/drivers/md/dm-integrity.c @@ -2513,7 +2513,7 @@ static int dm_integrity_map_inline(struct dm_integrit= y_io *dio, bool from_map) sector_t recalc_sector; =20 if (unlikely(bio_integrity(bio))) { - bio->bi_status =3D BLK_STS_NOTSUPP; + bio_set_status(bio, BLK_STS_NOTSUPP); bio_endio(bio); return DM_MAPIO_SUBMITTED; } @@ -2535,7 +2535,7 @@ static int dm_integrity_map_inline(struct dm_integrit= y_io *dio, bool from_map) if (dio->payload_len > x_size) { unsigned sectors =3D ((x_size - extra_size) / ic->tuple_size) << ic->s= b->log2_sectors_per_block; if (WARN_ON(!sectors || sectors >=3D bio_sectors(bio))) { - bio->bi_status =3D BLK_STS_NOTSUPP; + bio_set_status(bio, BLK_STS_NOTSUPP); bio_endio(bio); return DM_MAPIO_SUBMITTED; } @@ -2616,7 +2616,7 @@ static int dm_integrity_map_inline(struct dm_integrit= y_io *dio, bool from_map) ret =3D bio_integrity_add_page(bio, virt_to_page(dio->integrity_payload), dio->payload_len, offset_in_page(dio->integrity_payload)); if (unlikely(ret !=3D dio->payload_len)) { - bio->bi_status =3D BLK_STS_RESOURCE; + bio_set_status(bio, BLK_STS_RESOURCE); bio_endio(bio); return DM_MAPIO_SUBMITTED; } @@ -2670,7 +2670,7 @@ static void dm_integrity_inline_recheck(struct work_s= truct *w) r =3D bio_integrity_add_page(outgoing_bio, virt_to_page(dio->integrity_p= ayload), ic->tuple_size, 0); if (unlikely(r !=3D ic->tuple_size)) { bio_put(outgoing_bio); - bio->bi_status =3D BLK_STS_RESOURCE; + bio_set_status(bio, BLK_STS_RESOURCE); bio_endio(bio); return; } @@ -2694,7 +2694,7 @@ static void dm_integrity_inline_recheck(struct work_s= truct *w) dm_audit_log_bio(DM_MSG_PREFIX, "integrity-checksum", bio, dio->bio_details.bi_iter.bi_sector, 0); =20 - bio->bi_status =3D BLK_STS_PROTECTION; + bio_set_status(bio, BLK_STS_PROTECTION); bio_endio(bio); return; } @@ -2784,7 +2784,7 @@ static void integrity_bio_wait(struct work_struct *w) int r =3D dm_integrity_map_inline(dio, false); switch (r) { case DM_MAPIO_KILL: - bio->bi_status =3D BLK_STS_IOERR; + bio_set_status(bio, BLK_STS_IOERR); fallthrough; case DM_MAPIO_REMAPPED: submit_bio_noacct(bio); diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c index 1424ef75d088..761e5e79d4a7 100644 --- a/drivers/md/dm-mpath.c +++ b/drivers/md/dm-mpath.c @@ -722,7 +722,7 @@ static void process_queued_bios(struct work_struct *wor= k) bio_io_error(bio); break; case DM_MAPIO_REQUEUE: - bio->bi_status =3D BLK_STS_DM_REQUEUE; + bio_set_status(bio, BLK_STS_DM_REQUEUE); bio_endio(bio); break; case DM_MAPIO_REMAPPED: diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c index 268f734ca9c3..c54995847db0 100644 --- a/drivers/md/dm-raid1.c +++ b/drivers/md/dm-raid1.c @@ -491,9 +491,9 @@ static void hold_bio(struct mirror_set *ms, struct bio = *bio) * If device is suspended, complete the bio. */ if (dm_noflush_suspending(ms->ti)) - bio->bi_status =3D BLK_STS_DM_REQUEUE; + bio_set_status(bio, BLK_STS_DM_REQUEUE); else - bio->bi_status =3D BLK_STS_IOERR; + bio_set_status(bio, BLK_STS_IOERR); =20 bio_endio(bio); return; @@ -627,7 +627,7 @@ static void write_callback(unsigned long error, void *c= ontext) * degrade the array. */ if (bio_op(bio) =3D=3D REQ_OP_DISCARD) { - bio->bi_status =3D BLK_STS_NOTSUPP; + bio_set_status(bio, BLK_STS_NOTSUPP); bio_endio(bio); return; } diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c index c84149ba4e38..00ede45a3d27 100644 --- a/drivers/md/dm-thin.c +++ b/drivers/md/dm-thin.c @@ -2731,7 +2731,7 @@ static int thin_bio_map(struct dm_target *ti, struct = bio *bio) thin_hook_bio(tc, bio); =20 if (tc->requeue_mode) { - bio->bi_status =3D BLK_STS_DM_REQUEUE; + bio_set_status(bio, BLK_STS_DM_REQUEUE); bio_endio(bio); return DM_MAPIO_SUBMITTED; } diff --git a/drivers/md/dm-writecache.c b/drivers/md/dm-writecache.c index 4f70e2673e4b..f615ff46cc41 100644 --- a/drivers/md/dm-writecache.c +++ b/drivers/md/dm-writecache.c @@ -1265,7 +1265,7 @@ static void bio_copy_block(struct dm_writecache *wc, = struct bio *bio, void *data flush_dcache_page(bio_page(bio)); if (unlikely(r)) { writecache_error(wc, r, "hardware memory error when reading data: %d",= r); - bio->bi_status =3D BLK_STS_IOERR; + bio_set_status(bio, BLK_STS_IOERR); } } else { flush_dcache_page(bio_page(bio)); @@ -1312,7 +1312,7 @@ static int writecache_flush_thread(void *data) writecache_flush(wc); wc_unlock(wc); if (writecache_has_error(wc)) - bio->bi_status =3D BLK_STS_IOERR; + bio_set_status(bio, BLK_STS_IOERR); bio_endio(bio); } } diff --git a/drivers/md/md.c b/drivers/md/md.c index 41c476b40c7a..cbca792fa380 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -447,7 +447,7 @@ static void md_submit_bio(struct bio *bio) =20 if (mddev->ro =3D=3D MD_RDONLY && unlikely(rw =3D=3D WRITE)) { if (bio_sectors(bio) !=3D 0) - bio->bi_status =3D BLK_STS_IOERR; + bio_set_status(bio, BLK_STS_IOERR); bio_endio(bio); return; } diff --git a/drivers/md/raid1-10.c b/drivers/md/raid1-10.c index 521625756128..504730aba9df 100644 --- a/drivers/md/raid1-10.c +++ b/drivers/md/raid1-10.c @@ -104,7 +104,7 @@ static void md_bio_reset_resync_pages(struct bio *bio, = struct resync_pages *rp, int len =3D min_t(int, size, PAGE_SIZE); =20 if (WARN_ON(!bio_add_page(bio, page, len, 0))) { - bio->bi_status =3D BLK_STS_RESOURCE; + bio_set_status(bio, BLK_STS_RESOURCE); bio_endio(bio); return; } diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 592a40233004..923b6a762858 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -301,7 +301,7 @@ static void call_bio_endio(struct r1bio *r1_bio) struct bio *bio =3D r1_bio->master_bio; =20 if (!test_bit(R1BIO_Uptodate, &r1_bio->state)) - bio->bi_status =3D BLK_STS_IOERR; + bio_set_status(bio, BLK_STS_IOERR); =20 bio_endio(bio); } diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 14dcd5142eb4..59b900672a7a 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -324,7 +324,7 @@ static void raid_end_bio_io(struct r10bio *r10_bio) =20 if (!test_and_set_bit(R10BIO_Returned, &r10_bio->state)) { if (!test_bit(R10BIO_Uptodate, &r10_bio->state)) - bio->bi_status =3D BLK_STS_IOERR; + bio_set_status(bio, BLK_STS_IOERR); bio_endio(bio); } =20 @@ -3600,7 +3600,7 @@ static sector_t raid10_sync_request(struct mddev *mdd= ev, sector_t sector_nr, r10_bio->devs[i].repl_bio->bi_end_io =3D NULL; =20 bio =3D r10_bio->devs[i].bio; - bio->bi_status =3D BLK_STS_IOERR; + bio_set_status(bio, BLK_STS_IOERR); rdev =3D conf->mirrors[d].rdev; if (rdev =3D=3D NULL || test_bit(Faulty, &rdev->flags)) continue; @@ -3637,7 +3637,7 @@ static sector_t raid10_sync_request(struct mddev *mdd= ev, sector_t sector_nr, =20 /* Need to set up for writing to the replacement */ bio =3D r10_bio->devs[i].repl_bio; - bio->bi_status =3D BLK_STS_IOERR; + bio_set_status(bio, BLK_STS_IOERR); =20 sector =3D r10_bio->devs[i].addr; bio->bi_next =3D biolist; @@ -3683,7 +3683,7 @@ static sector_t raid10_sync_request(struct mddev *mdd= ev, sector_t sector_nr, struct resync_pages *rp =3D get_resync_pages(bio); page =3D resync_fetch_page(rp, page_idx); if (WARN_ON(!bio_add_page(bio, page, len, 0))) { - bio->bi_status =3D BLK_STS_RESOURCE; + bio_set_status(bio, BLK_STS_RESOURCE); bio_endio(bio); goto giveup; } @@ -4865,7 +4865,7 @@ static sector_t reshape_request(struct mddev *mddev, = sector_t sector_nr, len =3D PAGE_SIZE; for (bio =3D blist; bio ; bio =3D bio->bi_next) { if (WARN_ON(!bio_add_page(bio, page, len, 0))) { - bio->bi_status =3D BLK_STS_RESOURCE; + bio_set_status(bio, BLK_STS_RESOURCE); bio_endio(bio); return sectors_done; } diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 24b32a0c95b4..fa84fadac2fd 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -5974,7 +5974,7 @@ static enum stripe_result make_stripe_request(struct = mddev *mddev, sh =3D raid5_get_active_stripe(conf, ctx, new_sector, flags); if (unlikely(!sh)) { /* cannot get stripe, just give-up */ - bi->bi_status =3D BLK_STS_IOERR; + bio_set_status(bi, BLK_STS_IOERR); return STRIPE_FAIL; } =20 @@ -6037,7 +6037,7 @@ static enum stripe_result make_stripe_request(struct = mddev *mddev, raid5_release_stripe(sh); out: if (ret =3D=3D STRIPE_SCHEDULE_AND_RETRY && reshape_interrupted(mddev)) { - bi->bi_status =3D BLK_STS_RESOURCE; + bio_set_status(bi, BLK_STS_RESOURCE); ret =3D STRIPE_WAIT_RESHAPE; pr_err_ratelimited("dm-raid456: io across reshape position while reshape= can't make progress"); } diff --git a/drivers/nvdimm/btt.c b/drivers/nvdimm/btt.c index a933db961ed7..3da30dcbf26c 100644 --- a/drivers/nvdimm/btt.c +++ b/drivers/nvdimm/btt.c @@ -1456,7 +1456,7 @@ static void btt_submit_bio(struct bio *bio) len % btt->sector_size) { dev_err_ratelimited(&btt->nd_btt->dev, "unaligned bio segment (len: %d)\n", len); - bio->bi_status =3D BLK_STS_IOERR; + bio_set_status(bio, BLK_STS_IOERR); break; } =20 diff --git a/fs/btrfs/bio.c b/fs/btrfs/bio.c index 21df48e6c4fa..519635e2833a 100644 --- a/fs/btrfs/bio.c +++ b/fs/btrfs/bio.c @@ -174,7 +174,7 @@ static void btrfs_end_repair_bio(struct btrfs_bio *repa= ir_bbio, mirror =3D next_repair_mirror(fbio, mirror); if (mirror =3D=3D fbio->bbio->mirror_num) { btrfs_debug(fs_info, "no mirror left"); - fbio->bbio->bio.bi_status =3D BLK_STS_IOERR; + bio_set_status(&fbio->bbio->bio, BLK_STS_IOERR); goto done; } =20 @@ -225,7 +225,7 @@ static struct btrfs_failed_bio *repair_one_sector(struc= t btrfs_bio *failed_bbio, num_copies =3D btrfs_num_copies(fs_info, logical, sectorsize); if (num_copies =3D=3D 1) { btrfs_debug(fs_info, "no copy to repair from"); - failed_bbio->bio.bi_status =3D BLK_STS_IOERR; + bio_set_status(&failed_bbio->bio, BLK_STS_IOERR); return fbio; } =20 @@ -382,7 +382,7 @@ static void btrfs_orig_write_end_io(struct bio *bio) * threshold. */ if (atomic_read(&bioc->error) > bioc->max_errors) - bio->bi_status =3D BLK_STS_IOERR; + bio_set_status(bio, BLK_STS_IOERR); else bio->bi_status =3D BLK_STS_OK; =20 diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 775aa4f63aa3..3b031d0391d3 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -188,7 +188,7 @@ static void f2fs_verify_bio(struct work_struct *work) =20 if (!f2fs_is_compressed_page(folio) && !fsverity_verify_page(&folio->page)) { - bio->bi_status =3D BLK_STS_IOERR; + bio_set_status(bio, BLK_STS_IOERR); break; } } @@ -286,7 +286,7 @@ static void f2fs_read_end_io(struct bio *bio) ctx =3D bio->bi_private; =20 if (time_to_inject(sbi, FAULT_READ_IO)) - bio->bi_status =3D BLK_STS_IOERR; + bio_set_status(bio, BLK_STS_IOERR); =20 if (bio->bi_status !=3D BLK_STS_OK) { f2fs_finish_read_bio(bio, intask); @@ -323,7 +323,7 @@ static void f2fs_write_end_io(struct bio *bio) sbi =3D bio->bi_private; =20 if (time_to_inject(sbi, FAULT_WRITE_IO)) - bio->bi_status =3D BLK_STS_IOERR; + bio_set_status(bio, BLK_STS_IOERR); =20 bio_for_each_folio_all(fi, bio) { struct folio *folio =3D fi.folio; diff --git a/fs/verity/verify.c b/fs/verity/verify.c index 86067c8b40cf..17a168744037 100644 --- a/fs/verity/verify.c +++ b/fs/verity/verify.c @@ -432,7 +432,7 @@ void fsverity_verify_bio(struct bio *bio) =20 ioerr: fsverity_clear_pending_blocks(&ctx); - bio->bi_status =3D BLK_STS_IOERR; + bio_set_status(bio, BLK_STS_IOERR); } EXPORT_SYMBOL_GPL(fsverity_verify_bio); #endif /* CONFIG_BLOCK */ diff --git a/include/linux/bio.h b/include/linux/bio.h index a1324ce61ebd..cf0f5aba7bee 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -394,14 +394,14 @@ static inline void bio_set_status(struct bio *bio, bl= k_status_t status) =20 static inline void bio_io_error(struct bio *bio) { - bio->bi_status =3D BLK_STS_IOERR; + bio_set_status(bio, BLK_STS_IOERR); bio_endio(bio); } =20 static inline void bio_wouldblock_error(struct bio *bio) { bio_set_flag(bio, BIO_QUIET); - bio->bi_status =3D BLK_STS_AGAIN; + bio_set_status(bio, BLK_STS_AGAIN); bio_endio(bio); } =20 --=20 2.52.0 From nobody Sun Feb 8 13:52:58 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 8BBAA22538F for ; Sun, 21 Dec 2025 02:53:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766285590; cv=none; b=unfWL4vmxV+0C66xG4HHpHhJOiaAIn9J9/73VFjnRhFcyzt0XXfIRL0tm/kuii+b2W0OUCrVn0xMgL8aGyCqoAY7d6EwMQOehyrJQ1NjxocMBTTfGOIulNVxE/JY0nVIlSUPc7+5Pnn1bV5F6AWOt2oTW6AisSSAx9ROVqDmwjg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766285590; c=relaxed/simple; bh=G5zNazOwnANuZl6Zkj9RKTqDaNGEAQbBly+9bJs0YTI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Fb2s28jJo9Q/2AnUpc47u0+JOrDSn/YDsc2kqKWWcOMbaMdxOUpBIz3PZ8jEDdpcqsX8DmbrIEKdZjYZqKK9RxJJ6CehPenyn+GxKSNApAR49qB3BKsUFBUew+9UdzzlAMIpzaFeU86urmlPTncnvrIjelebCUYfdeI8ZK7XYME= 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=W8i0IyEt; arc=none smtp.client-ip=170.10.129.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="W8i0IyEt" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1766285587; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ot0Li/Rd6I4GT/jTlGyYgi3ywYy+1RwNsdBzqtFhH9I=; b=W8i0IyEttFxuXOeWM1u4yyBBWc+1NouYLl1Ja+/5eDkX1c3sVkFiNZgC3egefpq8kXFW9k IC3/yQwx2DJ9uZRT2oG3cKSY+A1WYT1Ib14bMboHgK+3eaG239afPBi2U90S/DJVT2B3qX chN7FTFkOSik0exhriGSo0dBFG+v8TM= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-41-nzwPdJNfNdKtPdmRKsmofQ-1; Sat, 20 Dec 2025 21:53:03 -0500 X-MC-Unique: nzwPdJNfNdKtPdmRKsmofQ-1 X-Mimecast-MFC-AGG-ID: nzwPdJNfNdKtPdmRKsmofQ_1766285581 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id AAC7E1956088; Sun, 21 Dec 2025 02:53:01 +0000 (UTC) Received: from pasta.fast.eng.rdu2.dc.redhat.com (unknown [10.44.32.8]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 626A9180049F; Sun, 21 Dec 2025 02:52:58 +0000 (UTC) From: Andreas Gruenbacher To: Christoph Hellwig , Jens Axboe , Chris Mason , David Sterba , Satya Tangirala Cc: Andreas Gruenbacher , linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-raid@vger.kernel.org, dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [RFC v2 06/17] bio: do not check bio->bi_status before assigning to it Date: Sun, 21 Dec 2025 03:52:21 +0100 Message-ID: <20251221025233.87087-7-agruenba@redhat.com> In-Reply-To: <20251221025233.87087-1-agruenba@redhat.com> References: <20251221025233.87087-1-agruenba@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Content-Type: text/plain; charset="utf-8" In a few places, we check if to->bi_status is 0 before setting it. This creates the impression of preserving the first error code that occurs, but that is not actually the case because bio->bi_status is not updated atomically. (And even updating bio->bi_status atomically wouldn't preserve the first error in bio chains longer than two.) We don't actually need to preserve the first error code, though; and all that matters is that when an error occurs, one of the error codes is preserved. Checking bio->bi_status before assigning to it might also have been meant as an optimization. We are on an error path and the potential benefit is miniscule, though. So, don't check bio->bi_status before assigning to it. Created with Coccinelle using the following semantic patch: @@ expression status; struct bio *bio; @@ - if (status && !bio->bi_status) - bio->bi_status =3D status; + bio_set_status(bio, status); @@ expression status; struct bio *bio; @@ - if (status !=3D BLK_STS_OK && bio->bi_status =3D=3D BLK_STS_OK) - bio->bi_status =3D status; + bio_set_status(bio, status); @@ expression status; struct bio *bio; @@ - if (unlikely(status) && !bio->bi_status) - bio->bi_status =3D status; + bio_set_status(bio, status); @@ expression status; struct bio bio; @@ - if (status && !bio.bi_status) - bio.bi_status =3D status; + bio_set_status(&bio, status); --- block/bio.c | 3 +-- block/fops.c | 3 +-- drivers/md/dm-integrity.c | 3 +-- drivers/md/dm-zoned-target.c | 3 +-- drivers/md/md.c | 6 ++---- 5 files changed, 6 insertions(+), 12 deletions(-) diff --git a/block/bio.c b/block/bio.c index 3f408e1ba13f..5389321872f0 100644 --- a/block/bio.c +++ b/block/bio.c @@ -314,8 +314,7 @@ static struct bio *__bio_chain_endio(struct bio *bio) { struct bio *parent =3D bio->bi_private; =20 - if (bio->bi_status && !parent->bi_status) - parent->bi_status =3D bio->bi_status; + bio_set_status(parent, bio->bi_status); bio_put(bio); return parent; } diff --git a/block/fops.c b/block/fops.c index b4f911273289..a4a6972cbfbf 100644 --- a/block/fops.c +++ b/block/fops.c @@ -135,8 +135,7 @@ static void blkdev_bio_end_io(struct bio *bio) bool should_dirty =3D dio->flags & DIO_SHOULD_DIRTY; bool is_sync =3D dio->flags & DIO_IS_SYNC; =20 - if (bio->bi_status && !dio->bio.bi_status) - dio->bio.bi_status =3D bio->bi_status; + bio_set_status(&dio->bio, bio->bi_status); =20 if (bio_integrity(bio)) bio_integrity_unmap_user(bio); diff --git a/drivers/md/dm-integrity.c b/drivers/md/dm-integrity.c index e380ed7b2a7b..6d04b067060d 100644 --- a/drivers/md/dm-integrity.c +++ b/drivers/md/dm-integrity.c @@ -1616,8 +1616,7 @@ static void dec_in_flight(struct dm_integrity_io *dio) schedule_autocommit(ic); =20 bio =3D dm_bio_from_per_bio_data(dio, sizeof(struct dm_integrity_io)); - if (unlikely(dio->bi_status) && !bio->bi_status) - bio->bi_status =3D dio->bi_status; + bio_set_status(bio, dio->bi_status); if (likely(!bio->bi_status) && unlikely(bio_sectors(bio) !=3D dio->range= .n_sectors)) { dio->range.logical_sector +=3D dio->range.n_sectors; bio_advance(bio, dio->range.n_sectors << SECTOR_SHIFT); diff --git a/drivers/md/dm-zoned-target.c b/drivers/md/dm-zoned-target.c index 9da329078ea4..efb960eca8ea 100644 --- a/drivers/md/dm-zoned-target.c +++ b/drivers/md/dm-zoned-target.c @@ -77,8 +77,7 @@ static inline void dmz_bio_endio(struct bio *bio, blk_sta= tus_t status) struct dmz_bioctx *bioctx =3D dm_per_bio_data(bio, sizeof(struct dmz_bioctx)); =20 - if (status !=3D BLK_STS_OK && bio->bi_status =3D=3D BLK_STS_OK) - bio->bi_status =3D status; + bio_set_status(bio, status); if (bioctx->dev && bio->bi_status !=3D BLK_STS_OK) bioctx->dev->flags |=3D DMZ_CHECK_BDEV; =20 diff --git a/drivers/md/md.c b/drivers/md/md.c index cbca792fa380..5afc6d63aa7b 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -9084,8 +9084,7 @@ static void md_end_clone_io(struct bio *bio) if (bio_data_dir(orig_bio) =3D=3D WRITE && md_bitmap_enabled(mddev, false= )) md_bitmap_end(mddev, md_io_clone); =20 - if (bio->bi_status && !orig_bio->bi_status) - orig_bio->bi_status =3D bio->bi_status; + bio_set_status(orig_bio, bio->bi_status); =20 if (md_io_clone->start_time) bio_end_io_acct(orig_bio, md_io_clone->start_time); @@ -9136,8 +9135,7 @@ void md_free_cloned_bio(struct bio *bio) if (bio_data_dir(orig_bio) =3D=3D WRITE && md_bitmap_enabled(mddev, false= )) md_bitmap_end(mddev, md_io_clone); =20 - if (bio->bi_status && !orig_bio->bi_status) - orig_bio->bi_status =3D bio->bi_status; + bio_set_status(orig_bio, bio->bi_status); =20 if (md_io_clone->start_time) bio_end_io_acct(orig_bio, md_io_clone->start_time); --=20 2.52.0 From nobody Sun Feb 8 13:52:58 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 BC64E19992C for ; Sun, 21 Dec 2025 02:53:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766285593; cv=none; b=AMLT8bFJQqxbXIr48CVfthj8JmkT8f4K8r1uCelJjoWojz1EfdtC9Jv/MKucjz+fTAqh1uhecvQzJJuE53OmraIa5mWPwnARaNWAk0Sxn5ZPomw+oWyEdzPtslkAslkhnWR1wf/vJxTWx5eIzLB2VK7DKneXvOSkpECJ4F6fRQE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766285593; c=relaxed/simple; bh=HlLo7Z5T3L6YW5WV2SYQGIzlE+yrnw5rN480ipz1cY4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=icl3nOmbHe4MOW/ZkQwNFwTMf5UtsGO/OTCVgisQAhYB5z2/RIvVv1LIjMNoY3EHUS3Ll4JhXG/rSp3/an83S0nYq7Dd2NauinGY2UbplnLKM9X6rS6cC1G2khzfZ6U48oHcvQcvVFgxyDQ2ovH/uGI0AQRPVymNXiFx+YYx0rs= 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=g26xdoxP; arc=none smtp.client-ip=170.10.129.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="g26xdoxP" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1766285590; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NXr1FXAq9kqTCI2jVu7X1Njix3LfG6S6ti8goKp8pAY=; b=g26xdoxPBXha3XvR8m4+Hox8BG6PvyqH6ysQ3flPLVEGrj/ie11ciQ+HQBBLA26jR+dLOW sA08d8Ftunn8/A5CNIDm93pwQN/yuEsKVPmH5/XDbkfK1z8LeXj1NNWrhPFRuO+wqSDYqj oCs8tj0tW5BPGRtC+wN7894obxfdJ1c= 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-153-DS8p6C_BOSWeLSDTHIzoLg-1; Sat, 20 Dec 2025 21:53:07 -0500 X-MC-Unique: DS8p6C_BOSWeLSDTHIzoLg-1 X-Mimecast-MFC-AGG-ID: DS8p6C_BOSWeLSDTHIzoLg_1766285586 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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 B4B07180028B; Sun, 21 Dec 2025 02:53:05 +0000 (UTC) Received: from pasta.fast.eng.rdu2.dc.redhat.com (unknown [10.44.32.8]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 20347180049F; Sun, 21 Dec 2025 02:53:01 +0000 (UTC) From: Andreas Gruenbacher To: Christoph Hellwig , Jens Axboe , Chris Mason , David Sterba , Satya Tangirala Cc: Andreas Gruenbacher , linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-raid@vger.kernel.org, dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [RFC v2 07/17] block: consecutive blk_status_t error codes Date: Sun, 21 Dec 2025 03:52:22 +0100 Message-ID: <20251221025233.87087-8-agruenba@redhat.com> In-Reply-To: <20251221025233.87087-1-agruenba@redhat.com> References: <20251221025233.87087-1-agruenba@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Content-Type: text/plain; charset="utf-8" Since commit 9da3d1e912f3 ("block: Add core atomic write support"), there is a gap in the blk_status_t codes and block status code 18 is unused. This causes errno_to_blk_status() and blk_status_to_str() to return incorrect values for that code. Fix by making the blk_status_t codes consecutive again. Fixes: 9da3d1e912f3 ("block: Add core atomic write support") Signed-off-by: Andreas Gruenbacher --- include/linux/blk_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h index 44c30183ecc3..044a7cec1d70 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h @@ -168,7 +168,7 @@ typedef u16 blk_short_t; /* * Invalid size or alignment. */ -#define BLK_STS_INVAL ((__force blk_status_t)19) +#define BLK_STS_INVAL ((__force blk_status_t)18) =20 /** * blk_path_error - returns true if error may be path related --=20 2.52.0 From nobody Sun Feb 8 13:52:58 2026 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 262A52236E0 for ; Sun, 21 Dec 2025 02:53:14 +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=1766285597; cv=none; b=iBfXYBpeDGG9kpRRzNjnGeG4aHAMQXv6HFKqvIwB/BxX8OZvQKt54c5nAFHHkBQSCDNz5raJdKMQt2qJK2eaFCxa31mqD2/UH41wqFnubb2loHcKHWhLbIYcC7Mbp4s0XImSsxBKtDcjRb/WVvensorGYPVxNF90wCwEODr2r74= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766285597; c=relaxed/simple; bh=r+kpZSnrmH/jtmd1hDSOL/n3Adl+xnlQeDwR/UMYB7A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IeCK/uCM4+jdmqH1YwTtQlurAz80wSRzuUqs5eKgkz+SqhH6YjL0lwBO7+ObKcb12YmrZZfm+N1V2N9SXXfwj+O/fBQGv9fJC2UQuA96KyToKPT5/6b7eOfYaDze1qTylsHGj+EFvwq4O7606fIhtISAOpkzfr1SLzMuQoh8rLY= 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=D78F+IiN; 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="D78F+IiN" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1766285594; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=D1JskjMhrT7L2sDTvMTDHnPfov5h9SsZ7fKDyJLN1aE=; b=D78F+IiNBRrA13cbuhxg0oW7mlVVCA9cFL/KSwx9QHjiXGT4Inzr1hiLdR6Hxc8J00yGnk 4N20sPgKDcc47PUA/GN9VNE6Nf1zyAqHHGsbs06aNnJXYaOkkTUHxj+uRJ8HA5/5qhGju7 MBvEJmZ7RFdOO7Uv6KtUeVs66jQArGk= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-370-dzh2yQG1NdePxmIEEG69Rw-1; Sat, 20 Dec 2025 21:53:10 -0500 X-MC-Unique: dzh2yQG1NdePxmIEEG69Rw-1 X-Mimecast-MFC-AGG-ID: dzh2yQG1NdePxmIEEG69Rw_1766285589 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 27D661956046; Sun, 21 Dec 2025 02:53:09 +0000 (UTC) Received: from pasta.fast.eng.rdu2.dc.redhat.com (unknown [10.44.32.8]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2BE8E180049F; Sun, 21 Dec 2025 02:53:05 +0000 (UTC) From: Andreas Gruenbacher To: Christoph Hellwig , Jens Axboe , Chris Mason , David Sterba , Satya Tangirala Cc: Andreas Gruenbacher , linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-raid@vger.kernel.org, dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [RFC v2 08/17] block: fix blk_status_to_{errno,str} inconsistency Date: Sun, 21 Dec 2025 03:52:23 +0100 Message-ID: <20251221025233.87087-9-agruenba@redhat.com> In-Reply-To: <20251221025233.87087-1-agruenba@redhat.com> References: <20251221025233.87087-1-agruenba@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Content-Type: text/plain; charset="utf-8" Change blk_status_to_str() to be consistent with blk_status_to_errno() and return "I/O" for undefined status codes. With that, the fallback case in blk_errors can be removed with no change in behavior. Signed-off-by: Andreas Gruenbacher --- block/blk-core.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index 4f7b7cf50d23..47ce458b4f34 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -161,9 +161,6 @@ static const struct { [BLK_STS_DURATION_LIMIT] =3D { -ETIME, "duration limit exceeded" }, =20 [BLK_STS_INVAL] =3D { -EINVAL, "invalid" }, - - /* everything else not covered above: */ - [BLK_STS_IOERR] =3D { -EIO, "I/O" }, }; =20 blk_status_t errno_to_blk_status(int errno) @@ -194,7 +191,7 @@ const char *blk_status_to_str(blk_status_t status) int idx =3D (__force int)status; =20 if (WARN_ON_ONCE(idx >=3D ARRAY_SIZE(blk_errors))) - return ""; + return "I/O"; return blk_errors[idx].name; } EXPORT_SYMBOL_GPL(blk_status_to_str); --=20 2.52.0 From nobody Sun Feb 8 13:52:58 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 7E38323536B for ; Sun, 21 Dec 2025 02:53:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766285603; cv=none; b=FKUOtL1LGewBxc0ynIh9dIgzV2B4byAn2ERsipChgFx4Pqsxa2qp9pWSJL1g99yMVvEca5J75uZrSQk5ggYgcBO7GEhTsxNsAGJGCcU6rb9wkOH7gg2waryAb2GA7e2UbKYbs7OLC2rLwG2VLZQ9knLTWJMROLdzjc5ymxz61KQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766285603; c=relaxed/simple; bh=2wmg7dBrcbW7RMcYYgZ9zCJ+cTkup82Bel/BMblKyRc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ly2yvq7Ojh6YZobLanTVjibPYhFb0ORqEq2kKwkh6hZVbDyclJnNEJEhYPi/8qtfQ7DEqmdr5zxDjof+/vTwMs5s9Jx/Y1Wo56cA2ex0maulPKjcXaveixmuBM2hkr7xZ3c7aJ84zBfvAiKwRkBR+/aicCUSsKnn5utJDsOu6V8= 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=f3mMV4Am; arc=none smtp.client-ip=170.10.129.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="f3mMV4Am" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1766285600; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2avyz2OoJ/++uEdJ9fXNwDS5jcJ/iUxeG+6Kq9GellY=; b=f3mMV4AmsrO4NdSzdf4ab33X3X9y06szbzpuhjDSPDe+wqvvWvtodeA1bQ4+vBv69yzAvJ tCTohB1TT6kFiTeap3ciOln6bGhdjdYRQEFMgjPlmw/7LS9EdFtvVmV8B8K/sOS+zWRjAh my9JrTiszsXY9W/PiI9KxYMgFm2IqEs= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-629-a_U1lg8OMOKwSjfjcbh59A-1; Sat, 20 Dec 2025 21:53:14 -0500 X-MC-Unique: a_U1lg8OMOKwSjfjcbh59A-1 X-Mimecast-MFC-AGG-ID: a_U1lg8OMOKwSjfjcbh59A_1766285592 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8445819560A5; Sun, 21 Dec 2025 02:53:12 +0000 (UTC) Received: from pasta.fast.eng.rdu2.dc.redhat.com (unknown [10.44.32.8]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9177D180049F; Sun, 21 Dec 2025 02:53:09 +0000 (UTC) From: Andreas Gruenbacher To: Christoph Hellwig , Jens Axboe , Chris Mason , David Sterba , Satya Tangirala Cc: Andreas Gruenbacher , linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-raid@vger.kernel.org, dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [RFC v2 09/17] block: turn blk_errors array into a macro Date: Sun, 21 Dec 2025 03:52:24 +0100 Message-ID: <20251221025233.87087-10-agruenba@redhat.com> In-Reply-To: <20251221025233.87087-1-agruenba@redhat.com> References: <20251221025233.87087-1-agruenba@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Content-Type: text/plain; charset="utf-8" Get rid of the static blk_errors array and replace it with a macro for generating the appropriate switch statements in errno_to_blk_status(), blk_status_to_errno(), and blk_status_to_str(). Signed-off-by: Andreas Gruenbacher --- block/blk-core.c | 97 ++++++++++++++++++++++++++---------------------- 1 file changed, 52 insertions(+), 45 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index 47ce458b4f34..9b3100d171b7 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -132,70 +132,77 @@ inline const char *blk_op_str(enum req_op op) } EXPORT_SYMBOL_GPL(blk_op_str); =20 -static const struct { - int errno; - const char *name; -} blk_errors[] =3D { - [BLK_STS_OK] =3D { 0, "" }, - [BLK_STS_NOTSUPP] =3D { -EOPNOTSUPP, "operation not supported" }, - [BLK_STS_TIMEOUT] =3D { -ETIMEDOUT, "timeout" }, - [BLK_STS_NOSPC] =3D { -ENOSPC, "critical space allocation" }, - [BLK_STS_TRANSPORT] =3D { -ENOLINK, "recoverable transport" }, - [BLK_STS_TARGET] =3D { -EREMOTEIO, "critical target" }, - [BLK_STS_RESV_CONFLICT] =3D { -EBADE, "reservation conflict" }, - [BLK_STS_MEDIUM] =3D { -ENODATA, "critical medium" }, - [BLK_STS_PROTECTION] =3D { -EILSEQ, "protection" }, - [BLK_STS_RESOURCE] =3D { -ENOMEM, "kernel resource" }, - [BLK_STS_DEV_RESOURCE] =3D { -EBUSY, "device resource" }, - [BLK_STS_AGAIN] =3D { -EAGAIN, "nonblocking retry" }, - [BLK_STS_OFFLINE] =3D { -ENODEV, "device offline" }, - - /* device mapper special case, should not leak out: */ - [BLK_STS_DM_REQUEUE] =3D { -EREMCHG, "dm internal retry" }, - - /* zone device specific errors */ - [BLK_STS_ZONE_OPEN_RESOURCE] =3D { -ETOOMANYREFS, "open zones exceeded" }, - [BLK_STS_ZONE_ACTIVE_RESOURCE] =3D { -EOVERFLOW, "active zones exceeded" = }, - - /* Command duration limit device-side timeout */ - [BLK_STS_DURATION_LIMIT] =3D { -ETIME, "duration limit exceeded" }, - - [BLK_STS_INVAL] =3D { -EINVAL, "invalid" }, -}; +#define blk_errors(_) \ + _(BLK_STS_OK, 0, "") \ + _(BLK_STS_NOTSUPP, -EOPNOTSUPP, "operation not supported") \ + _(BLK_STS_TIMEOUT, -ETIMEDOUT, "timeout") \ + _(BLK_STS_NOSPC, -ENOSPC, "critical space allocation") \ + _(BLK_STS_TRANSPORT, -ENOLINK, "recoverable transport") \ + _(BLK_STS_TARGET, -EREMOTEIO, "critical target") \ + _(BLK_STS_RESV_CONFLICT, -EBADE, "reservation conflict") \ + _(BLK_STS_MEDIUM, -ENODATA, "critical medium") \ + _(BLK_STS_PROTECTION, -EILSEQ, "protection") \ + _(BLK_STS_RESOURCE, -ENOMEM, "kernel resource") \ + _(BLK_STS_DEV_RESOURCE, -EBUSY, "device resource") \ + _(BLK_STS_AGAIN, -EAGAIN, "nonblocking retry") \ + _(BLK_STS_OFFLINE, -ENODEV, "device offline") \ + \ + /* device mapper special case, should not leak out: */ \ + _(BLK_STS_DM_REQUEUE, -EREMCHG, "dm internal retry") \ + \ + /* zone device specific errors */ \ + _(BLK_STS_ZONE_OPEN_RESOURCE, -ETOOMANYREFS, "open zones exceeded") \ + _(BLK_STS_ZONE_ACTIVE_RESOURCE, -EOVERFLOW, "active zones exceeded" ) \ + \ + /* Command duration limit device-side timeout */ \ + _(BLK_STS_DURATION_LIMIT, -ETIME, "duration limit exceeded") \ + \ + _(BLK_STS_INVAL, -EINVAL, "invalid") =20 blk_status_t errno_to_blk_status(int errno) { - int i; - - for (i =3D 0; i < ARRAY_SIZE(blk_errors); i++) { - if (blk_errors[i].errno =3D=3D errno) - return (__force blk_status_t)i; + switch(errno) { +#define _(_status, _errno, _name) \ + case _errno: \ + return _status; + blk_errors(_) +#undef _ + default: + return BLK_STS_IOERR; } - - return BLK_STS_IOERR; } EXPORT_SYMBOL_GPL(errno_to_blk_status); =20 int blk_status_to_errno(blk_status_t status) { - int idx =3D (__force int)status; - - if (WARN_ON_ONCE(idx >=3D ARRAY_SIZE(blk_errors))) + switch(status) { +#define _(_status, _errno, _name) \ + case _status: \ + return _errno; + blk_errors(_) +#undef _ + default: return -EIO; - return blk_errors[idx].errno; + } } EXPORT_SYMBOL_GPL(blk_status_to_errno); =20 const char *blk_status_to_str(blk_status_t status) { - int idx =3D (__force int)status; - - if (WARN_ON_ONCE(idx >=3D ARRAY_SIZE(blk_errors))) + switch(status) { +#define _(_status, _errno, _name) \ + case _status: \ + return _name; + blk_errors(_) +#undef _ + default: return "I/O"; - return blk_errors[idx].name; + } } EXPORT_SYMBOL_GPL(blk_status_to_str); =20 +#undef blk_errors + /** * blk_sync_queue - cancel any pending callbacks on a queue * @q: the queue --=20 2.52.0 From nobody Sun Feb 8 13:52:58 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 8925723A562 for ; Sun, 21 Dec 2025 02:53:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766285606; cv=none; b=ARgW7uwQlOT0edFpWu4+h54iEUz95jeRKd/Qu8AViORdYL1yaKAKYE2aTGjdQxXsZESPBkwjdN7U8baK1HyrLezNcV0nv875Ibl1vYaM9wAnI8uRDH7+Uc3ABhKdMVipfXoLDJd9Y2dnQsGVa2joy5aVpcARBXn18efQ41Z/3vM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766285606; c=relaxed/simple; bh=HIqf22Ptud/9ac/5C/HAWxjPJyK8tFALQWxnuDFT/3Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ti7awi5d/+Wr1aKdRkhgXc9KWgM0o1X0Yz9QYO2KSlu+Va9+AbAo9N5SbONF1A1TCl2efQ4JRbAE/ho7vzOSFfoXT049RmKOkTQinAC45AAk68CwO1HC4YRZ7d918Iy424GOsAKbWEXe+sNC1kVaKszhboarOf6z9HAALKfn+Nk= 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=XhE2+em3; arc=none smtp.client-ip=170.10.129.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="XhE2+em3" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1766285603; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5lqEV0d5M/MjlyxOPZzQUlj9JHGomOy6Eck36K06ymo=; b=XhE2+em3Its3xg8nUZ28OmtkuEKhHiVSDQe/qpBe8ZimT8YyqAcwtkS0Vo0+AVBjLM62g1 BBt7nsZK1Sy9aEGHcKBeN4Du4+jd0huS7UfB8AzBOSsLqLyFoNFwD6rbR6ITY8/fitvG8p yAt/R5IOoycLccph4yZGqw5HkvAzh4A= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-235-9DEeJGNpMOmGqmAAYZY70Q-1; Sat, 20 Dec 2025 21:53:17 -0500 X-MC-Unique: 9DEeJGNpMOmGqmAAYZY70Q-1 X-Mimecast-MFC-AGG-ID: 9DEeJGNpMOmGqmAAYZY70Q_1766285596 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 010051956050; Sun, 21 Dec 2025 02:53:16 +0000 (UTC) Received: from pasta.fast.eng.rdu2.dc.redhat.com (unknown [10.44.32.8]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id EEBD6180049F; Sun, 21 Dec 2025 02:53:12 +0000 (UTC) From: Andreas Gruenbacher To: Christoph Hellwig , Jens Axboe , Chris Mason , David Sterba , Satya Tangirala Cc: Andreas Gruenbacher , linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-raid@vger.kernel.org, dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [RFC v2 10/17] block: optimize blk_status <=> errno conversion Date: Sun, 21 Dec 2025 03:52:25 +0100 Message-ID: <20251221025233.87087-11-agruenba@redhat.com> In-Reply-To: <20251221025233.87087-1-agruenba@redhat.com> References: <20251221025233.87087-1-agruenba@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Content-Type: text/plain; charset="utf-8" Handle the errno_to_blk_status(0) case inline so that the compiler can optimize when it knows that errno is not 0. Likewise for blk_status_to_errno(BLK_STATUS_OK). Signed-off-by: Andreas Gruenbacher --- block/blk-core.c | 11 ++++++----- include/linux/blkdev.h | 18 ++++++++++++++++-- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index 9b3100d171b7..381bdf66045b 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -133,7 +133,6 @@ inline const char *blk_op_str(enum req_op op) EXPORT_SYMBOL_GPL(blk_op_str); =20 #define blk_errors(_) \ - _(BLK_STS_OK, 0, "") \ _(BLK_STS_NOTSUPP, -EOPNOTSUPP, "operation not supported") \ _(BLK_STS_TIMEOUT, -ETIMEDOUT, "timeout") \ _(BLK_STS_NOSPC, -ENOSPC, "critical space allocation") \ @@ -159,7 +158,7 @@ EXPORT_SYMBOL_GPL(blk_op_str); \ _(BLK_STS_INVAL, -EINVAL, "invalid") =20 -blk_status_t errno_to_blk_status(int errno) +blk_status_t __errno_to_blk_status(int errno) { switch(errno) { #define _(_status, _errno, _name) \ @@ -171,9 +170,9 @@ blk_status_t errno_to_blk_status(int errno) return BLK_STS_IOERR; } } -EXPORT_SYMBOL_GPL(errno_to_blk_status); +EXPORT_SYMBOL_GPL(__errno_to_blk_status); =20 -int blk_status_to_errno(blk_status_t status) +int __blk_status_to_errno(blk_status_t status) { switch(status) { #define _(_status, _errno, _name) \ @@ -185,11 +184,13 @@ int blk_status_to_errno(blk_status_t status) return -EIO; } } -EXPORT_SYMBOL_GPL(blk_status_to_errno); +EXPORT_SYMBOL_GPL(__blk_status_to_errno); =20 const char *blk_status_to_str(blk_status_t status) { switch(status) { + case BLK_STS_OK: + return ""; #define _(_status, _errno, _name) \ case _status: \ return _name; diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 70b671a9a7f7..a2451fbd53a8 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1011,8 +1011,22 @@ extern void blk_sync_queue(struct request_queue *q); /* Helper to convert REQ_OP_XXX to its string format XXX */ extern const char *blk_op_str(enum req_op op); =20 -int blk_status_to_errno(blk_status_t status); -blk_status_t errno_to_blk_status(int errno); +int __blk_status_to_errno(blk_status_t status); +static inline int blk_status_to_errno(blk_status_t status) +{ + if (status =3D=3D BLK_STS_OK) + return 0; + return __blk_status_to_errno(status); +} + +blk_status_t __errno_to_blk_status(int errno); +static inline blk_status_t errno_to_blk_status(int errno) +{ + if (errno =3D=3D 0) + return BLK_STS_OK; + return __errno_to_blk_status(errno); +} + const char *blk_status_to_str(blk_status_t status); =20 /* only poll the hardware once, don't continue until a completion was foun= d */ --=20 2.52.0 From nobody Sun Feb 8 13:52:59 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 8F161239570 for ; Sun, 21 Dec 2025 02:53:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766285605; cv=none; b=Qmic6zZxE6NRmsfjCB1kQ+QR2Y2i4uhWI/24ThjYwEQfq6q94WSdtEQVY7Y5ghkSsTYWDkUr8+UUMRIUHZPQLVDlOUlUnkMaHHB90Q0HQyLJhY2g3H2iTDXf2rri4m4wDghVwNTmIY69T87r4ZjZj8dBrEYMGaxUvpxbNsjvAdw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766285605; c=relaxed/simple; bh=YOHiTj7zz01Ftau5ICbeu6JHmAuhzPI0DVL/WCq46oM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZVFfq5M7MsSXZgMlHTq/Jl/Lpm/KeOrAk9FJlIIXh7ns5Ydb+3ftAnD69DwYhqjEXU/l7De91nx+uJBhI6NQHQ8W/EP065VsxQgSM3X+YgDj6qrorWNEcxb9gvxhXlTEwdnRrUog8pv6ONW+h2NHd2ooaMwI+zqZoMxw7cT2RzQ= 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=CZe4EtdQ; arc=none smtp.client-ip=170.10.129.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="CZe4EtdQ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1766285602; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tdikDtYArLBH6tSr8rb+Y7nMetG0VOSDDLmbhd1+tro=; b=CZe4EtdQK6IJPIHNi2/gExmZhvY8UPGsPOXQWcblT4bwO26Bte3FVzk0OeaMh0NzbjD6ru hmerV5PAANZddCH0ZR+1lhlG77KyDOmEtgVgS8cFY1fVh3zzELMqUQGXkyOnSBlUOyGNDY UVsKknmtbAgbV8tzV/UxEgUdfr1oIRE= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-37-PNeO8f1ZMJCukkRtn-wWAw-1; Sat, 20 Dec 2025 21:53:21 -0500 X-MC-Unique: PNeO8f1ZMJCukkRtn-wWAw-1 X-Mimecast-MFC-AGG-ID: PNeO8f1ZMJCukkRtn-wWAw_1766285599 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5D2A8195608E; Sun, 21 Dec 2025 02:53:19 +0000 (UTC) Received: from pasta.fast.eng.rdu2.dc.redhat.com (unknown [10.44.32.8]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6A61A18004D4; Sun, 21 Dec 2025 02:53:16 +0000 (UTC) From: Andreas Gruenbacher To: Christoph Hellwig , Jens Axboe , Chris Mason , David Sterba , Satya Tangirala Cc: Andreas Gruenbacher , linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-raid@vger.kernel.org, dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [RFC v2 11/17] bio: bio_set_status from non-zero errno Date: Sun, 21 Dec 2025 03:52:26 +0100 Message-ID: <20251221025233.87087-12-agruenba@redhat.com> In-Reply-To: <20251221025233.87087-1-agruenba@redhat.com> References: <20251221025233.87087-1-agruenba@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Content-Type: text/plain; charset="utf-8" In these instances, the compiler knows that errno is not 0 and so it can optimize 'bio_set_status(bio, errno_to_blk_status(errno))' as 'bio->bi_status =3D __errno_to_blk_status(errno)'. Created with Coccinelle using the following semantic patch: @@ struct bio *bio; expression errno; @@ - if (errno) - bio->bi_status =3D errno_to_blk_status(errno); + if (errno) + bio_set_status(bio, errno_to_blk_status(errno)); @@ struct bio *bio; expression errno; @@ - if (unlikely(errno)) - bio->bi_status =3D errno_to_blk_status(errno); + if (unlikely(errno)) + bio_set_status(bio, errno_to_blk_status(errno)); @@ expression status; struct bio *bio; @@ if (IS_ERR(status)) { <... - bio->bi_status =3D errno_to_blk_status(PTR_ERR(status)); + bio_set_status(bio, errno_to_blk_status(PTR_ERR(status))); ...> } @@ expression errno; struct bio *bio; @@ if (!errno) return; -bio->bi_status =3D errno_to_blk_status(errno); +bio_set_status(bio, errno_to_blk_status(errno)); @@ expression errno; struct bio bio; @@ if (errno) - bio.bi_status =3D errno_to_blk_status(errno); + bio_set_status(&bio, errno_to_blk_status(errno)); @@ expression errno; struct bio bio; @@ if (IS_ERR_VALUE(errno)) - bio.bi_status =3D errno_to_blk_status(errno); + bio_set_status(&bio, errno_to_blk_status(errno)); @@ expression errno; struct bio *bio; @@ if (errno) { <... - bio->bi_status =3D errno_to_blk_status(errno); + bio_set_status(bio, errno_to_blk_status(errno)); ...> } @@ expression errno; struct iomap_ioend *ioend; struct bio bio; @@ if (errno) { <... - ioend->io_bio.bi_status =3D errno_to_blk_status(errno); + bio_set_status(&ioend->io_bio, errno_to_blk_status(errno)); ...> } @@ expression errno; struct bio *bio; @@ if (errno < 0) { <... - bio->bi_status =3D errno_to_blk_status(errno); + bio_set_status(bio, errno_to_blk_status(errno)); ...> } @@ expression errno; struct bio *bio; @@ if (unlikely(errno < 0)) { <... - bio->bi_status =3D errno_to_blk_status(errno); + bio_set_status(bio, errno_to_blk_status(errno)); ...> } @@ expression errno; struct bio *bio; @@ if (unlikely(errno !=3D 0)) { <... - bio->bi_status =3D errno_to_blk_status(errno); + bio_set_status(bio, errno_to_blk_status(errno)); ...> } Signed-off-by: Andreas Gruenbacher --- block/blk-merge.c | 4 ++-- drivers/block/drbd/drbd_req.c | 2 +- drivers/md/dm-ebs-target.c | 2 +- drivers/md/dm-integrity.c | 6 +++--- drivers/md/raid10.c | 6 ++++-- drivers/nvdimm/btt.c | 2 +- drivers/nvdimm/pmem.c | 2 +- fs/btrfs/bio.c | 2 +- fs/btrfs/direct-io.c | 2 +- fs/btrfs/raid56.c | 4 ++-- fs/crypto/bio.c | 2 +- fs/erofs/fscache.c | 8 +++++--- fs/iomap/ioend.c | 2 +- fs/xfs/xfs_aops.c | 2 +- 14 files changed, 25 insertions(+), 21 deletions(-) diff --git a/block/blk-merge.c b/block/blk-merge.c index 37864c5d287e..27ea5ffb8f77 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -122,7 +122,7 @@ struct bio *bio_submit_split_bioset(struct bio *bio, un= signed int split_sectors, struct bio *split =3D bio_split(bio, split_sectors, GFP_NOIO, bs); =20 if (IS_ERR(split)) { - bio->bi_status =3D errno_to_blk_status(PTR_ERR(split)); + bio_set_status(bio, errno_to_blk_status(PTR_ERR(split))); bio_endio(bio); return NULL; } @@ -143,7 +143,7 @@ EXPORT_SYMBOL_GPL(bio_submit_split_bioset); static struct bio *bio_submit_split(struct bio *bio, int split_sectors) { if (unlikely(split_sectors < 0)) { - bio->bi_status =3D errno_to_blk_status(split_sectors); + bio_set_status(bio, errno_to_blk_status(split_sectors)); bio_endio(bio); return NULL; } diff --git a/drivers/block/drbd/drbd_req.c b/drivers/block/drbd/drbd_req.c index baa08d56494d..983b2ff5eb6b 100644 --- a/drivers/block/drbd/drbd_req.c +++ b/drivers/block/drbd/drbd_req.c @@ -177,7 +177,7 @@ void complete_master_bio(struct drbd_device *device, struct bio_and_error *m) { if (unlikely(m->error)) - m->bio->bi_status =3D errno_to_blk_status(m->error); + bio_set_status(m->bio, errno_to_blk_status(m->error)); bio_endio(m->bio); dec_ap_bio(device); } diff --git a/drivers/md/dm-ebs-target.c b/drivers/md/dm-ebs-target.c index 6abb31ca9662..2c97c36df23a 100644 --- a/drivers/md/dm-ebs-target.c +++ b/drivers/md/dm-ebs-target.c @@ -217,7 +217,7 @@ static void __ebs_process_bios(struct work_struct *ws) } =20 if (r < 0) - bio->bi_status =3D errno_to_blk_status(r); + bio_set_status(bio, errno_to_blk_status(r)); } =20 /* diff --git a/drivers/md/dm-integrity.c b/drivers/md/dm-integrity.c index 6d04b067060d..c5c7c167b45d 100644 --- a/drivers/md/dm-integrity.c +++ b/drivers/md/dm-integrity.c @@ -2593,7 +2593,7 @@ static int dm_integrity_map_inline(struct dm_integrit= y_io *dio, bool from_map) =20 bip =3D bio_integrity_alloc(bio, GFP_NOIO, 1); if (IS_ERR(bip)) { - bio->bi_status =3D errno_to_blk_status(PTR_ERR(bip)); + bio_set_status(bio, errno_to_blk_status(PTR_ERR(bip))); bio_endio(bio); return DM_MAPIO_SUBMITTED; } @@ -2661,7 +2661,7 @@ static void dm_integrity_inline_recheck(struct work_s= truct *w) bip =3D bio_integrity_alloc(outgoing_bio, GFP_NOIO, 1); if (IS_ERR(bip)) { bio_put(outgoing_bio); - bio->bi_status =3D errno_to_blk_status(PTR_ERR(bip)); + bio_set_status(bio, errno_to_blk_status(PTR_ERR(bip))); bio_endio(bio); return; } @@ -2679,7 +2679,7 @@ static void dm_integrity_inline_recheck(struct work_s= truct *w) r =3D submit_bio_wait(outgoing_bio); if (unlikely(r !=3D 0)) { bio_put(outgoing_bio); - bio->bi_status =3D errno_to_blk_status(r); + bio_set_status(bio, errno_to_blk_status(r)); bio_endio(bio); return; } diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 59b900672a7a..3e15e190f103 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -1665,7 +1665,8 @@ static int raid10_handle_discard(struct mddev *mddev,= struct bio *bio) split_size =3D stripe_size - remainder; split =3D bio_split(bio, split_size, GFP_NOIO, &conf->bio_split); if (IS_ERR(split)) { - bio->bi_status =3D errno_to_blk_status(PTR_ERR(split)); + bio_set_status(bio, + errno_to_blk_status(PTR_ERR(split))); bio_endio(bio); return 0; } @@ -1682,7 +1683,8 @@ static int raid10_handle_discard(struct mddev *mddev,= struct bio *bio) split_size =3D bio_sectors(bio) - remainder; split =3D bio_split(bio, split_size, GFP_NOIO, &conf->bio_split); if (IS_ERR(split)) { - bio->bi_status =3D errno_to_blk_status(PTR_ERR(split)); + bio_set_status(bio, + errno_to_blk_status(PTR_ERR(split))); bio_endio(bio); return 0; } diff --git a/drivers/nvdimm/btt.c b/drivers/nvdimm/btt.c index 3da30dcbf26c..3b9a7d7b9694 100644 --- a/drivers/nvdimm/btt.c +++ b/drivers/nvdimm/btt.c @@ -1468,7 +1468,7 @@ static void btt_submit_bio(struct bio *bio) (op_is_write(bio_op(bio))) ? "WRITE" : "READ", (unsigned long long) iter.bi_sector, len); - bio->bi_status =3D errno_to_blk_status(err); + bio_set_status(bio, errno_to_blk_status(err)); break; } } diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index 4fdcbe56a3bc..6b64a217d180 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -233,7 +233,7 @@ static void pmem_submit_bio(struct bio *bio) ret =3D nvdimm_flush(nd_region, bio); =20 if (ret) - bio->bi_status =3D errno_to_blk_status(ret); + bio_set_status(bio, errno_to_blk_status(ret)); =20 bio_endio(bio); } diff --git a/fs/btrfs/bio.c b/fs/btrfs/bio.c index 519635e2833a..1947f1cb7d08 100644 --- a/fs/btrfs/bio.c +++ b/fs/btrfs/bio.c @@ -540,7 +540,7 @@ static void run_one_async_start(struct btrfs_work *work) =20 ret =3D btrfs_bio_csum(async->bbio); if (ret) - async->bbio->bio.bi_status =3D errno_to_blk_status(ret); + bio_set_status(&async->bbio->bio, errno_to_blk_status(ret)); } =20 /* diff --git a/fs/btrfs/direct-io.c b/fs/btrfs/direct-io.c index 802d4dbe5b38..04facbbe6994 100644 --- a/fs/btrfs/direct-io.c +++ b/fs/btrfs/direct-io.c @@ -738,7 +738,7 @@ static void btrfs_dio_submit_io(const struct iomap_iter= *iter, struct bio *bio, btrfs_finish_ordered_extent(dio_data->ordered, NULL, file_offset, dip->bytes, !ret); - bio->bi_status =3D errno_to_blk_status(ret); + bio_set_status(bio, errno_to_blk_status(ret)); iomap_dio_bio_end_io(bio); return; } diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c index 0135dceb7baa..b60ab0bb08ad 100644 --- a/fs/btrfs/raid56.c +++ b/fs/btrfs/raid56.c @@ -1750,7 +1750,7 @@ void raid56_parity_write(struct bio *bio, struct btrf= s_io_context *bioc) =20 rbio =3D alloc_rbio(fs_info, bioc); if (IS_ERR(rbio)) { - bio->bi_status =3D errno_to_blk_status(PTR_ERR(rbio)); + bio_set_status(bio, errno_to_blk_status(PTR_ERR(rbio))); bio_endio(bio); return; } @@ -2148,7 +2148,7 @@ void raid56_parity_recover(struct bio *bio, struct bt= rfs_io_context *bioc, =20 rbio =3D alloc_rbio(fs_info, bioc); if (IS_ERR(rbio)) { - bio->bi_status =3D errno_to_blk_status(PTR_ERR(rbio)); + bio_set_status(bio, errno_to_blk_status(PTR_ERR(rbio))); bio_endio(bio); return; } diff --git a/fs/crypto/bio.c b/fs/crypto/bio.c index 5f5599020e94..21a3a1c170a2 100644 --- a/fs/crypto/bio.c +++ b/fs/crypto/bio.c @@ -39,7 +39,7 @@ bool fscrypt_decrypt_bio(struct bio *bio) fi.offset); =20 if (err) { - bio->bi_status =3D errno_to_blk_status(err); + bio_set_status(bio, errno_to_blk_status(err)); return false; } } diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c index 362acf828279..9d84bf24e501 100644 --- a/fs/erofs/fscache.c +++ b/fs/erofs/fscache.c @@ -183,8 +183,10 @@ static void erofs_fscache_bio_endio(void *priv, ssize_= t transferred_or_error) { struct erofs_fscache_bio *io =3D priv; =20 - if (IS_ERR_VALUE(transferred_or_error)) - io->bio.bi_status =3D errno_to_blk_status(transferred_or_error); + if (IS_ERR_VALUE(transferred_or_error)) { + bio_set_status(&io->bio, + errno_to_blk_status(transferred_or_error)); + } io->bio.bi_end_io(&io->bio); BUILD_BUG_ON(offsetof(struct erofs_fscache_bio, io) !=3D 0); erofs_fscache_io_put(&io->io); @@ -215,7 +217,7 @@ void erofs_fscache_submit_bio(struct bio *bio) erofs_fscache_io_put(&io->io); if (!ret) return; - bio->bi_status =3D errno_to_blk_status(ret); + bio_set_status(bio, errno_to_blk_status(ret)); bio->bi_end_io(bio); } =20 diff --git a/fs/iomap/ioend.c b/fs/iomap/ioend.c index b49fa75eab26..1ebe6730d013 100644 --- a/fs/iomap/ioend.c +++ b/fs/iomap/ioend.c @@ -87,7 +87,7 @@ int iomap_ioend_writeback_submit(struct iomap_writepage_c= tx *wpc, int error) error =3D -EIO; =20 if (error) { - ioend->io_bio.bi_status =3D errno_to_blk_status(error); + bio_set_status(&ioend->io_bio, errno_to_blk_status(error)); bio_endio(&ioend->io_bio); return error; } diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c index a26f79815533..bd2b828164cb 100644 --- a/fs/xfs/xfs_aops.c +++ b/fs/xfs/xfs_aops.c @@ -653,7 +653,7 @@ xfs_zoned_writeback_submit( =20 ioend->io_bio.bi_end_io =3D xfs_end_bio; if (error) { - ioend->io_bio.bi_status =3D errno_to_blk_status(error); + bio_set_status(&ioend->io_bio, errno_to_blk_status(error)); bio_endio(&ioend->io_bio); return error; } --=20 2.52.0 From nobody Sun Feb 8 13:52:59 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 4EECE23C503 for ; Sun, 21 Dec 2025 02:53:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766285611; cv=none; b=H4PK4M4Jp6yds/3VJ3A09zOhMYuyZ57R7pE+l9YcDk83WxuUxItIu10cYreqO6wOFIYmvv29MIZnzi2EVDVES8Z+o6gR5KQBLKHGRyGLE24WXqr6MQHTW+I1bhCorOA02clzgWRYT1jg0zxaZVLs+GOHp6kh1k8EENoz+0GDo0M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766285611; c=relaxed/simple; bh=XuzBPd7weqP6eKh2byUN6HJgcTxm4e6z9RFRaspbX2o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=csTlKyQzTHNUv14pFmvDUaVIlPI5k151h9sJiBeUSBxvXtD5fbJ43UW9uMNZ04RZ90WYgxyjxmYbCGiKsK/kc5MaZlOgRaWJmovlQILKdbToIE78f5W2o5gQGF3zLdYBSXmpz47N761r7/TomXp77NlNsa4cbM67LTfo/uH3YQw= 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=AaXVcC5B; arc=none smtp.client-ip=170.10.129.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="AaXVcC5B" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1766285608; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X4U+/r6sUCuyiDnJIU2RJVG82MRW1R2RHAXhrJ/sLzs=; b=AaXVcC5Bf3kxuTtBCAvI4dPEET31c9p1ov6k5cIwUvxZ8tyWoHHngKeCdLXsmf64DlKJ3X rSuGNJRlLexxziwAcVHynm2kRgWedQ0dXJnKP5CbtvI6aVlHa0tmQ3b5fbTyMGmoCiClpa kEjKOV7hf7V714jGBXsqUeybs3TpsP0= 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-141-ugIClds1POG0hGBC36RWNg-1; Sat, 20 Dec 2025 21:53:24 -0500 X-MC-Unique: ugIClds1POG0hGBC36RWNg-1 X-Mimecast-MFC-AGG-ID: ugIClds1POG0hGBC36RWNg_1766285602 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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 BA1321800451; Sun, 21 Dec 2025 02:53:22 +0000 (UTC) Received: from pasta.fast.eng.rdu2.dc.redhat.com (unknown [10.44.32.8]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C77DE1800577; Sun, 21 Dec 2025 02:53:19 +0000 (UTC) From: Andreas Gruenbacher To: Christoph Hellwig , Jens Axboe , Chris Mason , David Sterba , Satya Tangirala Cc: Andreas Gruenbacher , linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-raid@vger.kernel.org, dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [RFC v2 12/17] bio: do not check bio->bi_status before assigning to it (part 2) Date: Sun, 21 Dec 2025 03:52:27 +0100 Message-ID: <20251221025233.87087-13-agruenba@redhat.com> In-Reply-To: <20251221025233.87087-1-agruenba@redhat.com> References: <20251221025233.87087-1-agruenba@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Content-Type: text/plain; charset="utf-8" Don't check bio->bi_status before assigning to it. These are the cases that involve an errno instead of a block status. See commit "do not check bio->bi_status before assigning to it" for a rationale. Created with Coccinelle using the following semantic patch and option '--disable-iso unlikely': @@ expression errno; struct bio *bio; @@ -if (unlikely(errno) && !bio->bi_status) - bio->bi_status =3D errno_to_blk_status(errno); +if (unlikely(errno)) + bio_set_status(bio, errno_to_blk_status(errno)); @@ expression errno; struct bio *bio; @@ -if (errno && !bio->bi_status) - bio->bi_status =3D errno_to_blk_status(errno); +bio_set_status(bio, errno_to_blk_status(errno)); @@ expression errno; struct bio bio; @@ -if (errno < 0 && !bio.bi_status) - bio.bi_status =3D errno_to_blk_status(errno); +if (errno < 0) + bio_set_status(&bio, errno_to_blk_status(errno)); Signed-off-by: Andreas Gruenbacher --- drivers/md/dm-integrity.c | 4 ++-- drivers/md/dm-thin.c | 3 +-- fs/erofs/fileio.c | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/md/dm-integrity.c b/drivers/md/dm-integrity.c index c5c7c167b45d..4a6e27c0d510 100644 --- a/drivers/md/dm-integrity.c +++ b/drivers/md/dm-integrity.c @@ -1580,8 +1580,8 @@ static void do_endio(struct dm_integrity_c *ic, struc= t bio *bio) int r; =20 r =3D dm_integrity_failed(ic); - if (unlikely(r) && !bio->bi_status) - bio->bi_status =3D errno_to_blk_status(r); + if (unlikely(r)) + bio_set_status(bio, errno_to_blk_status(r)); if (unlikely(ic->synchronous_mode) && bio_op(bio) =3D=3D REQ_OP_WRITE) { unsigned long flags; =20 diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c index 00ede45a3d27..42261bbe4771 100644 --- a/drivers/md/dm-thin.c +++ b/drivers/md/dm-thin.c @@ -422,8 +422,7 @@ static void end_discard(struct discard_op *op, int r) * Even if r is set, there could be sub discards in flight that we * need to wait for. */ - if (r && !op->parent_bio->bi_status) - op->parent_bio->bi_status =3D errno_to_blk_status(r); + bio_set_status(op->parent_bio, errno_to_blk_status(r)); bio_endio(op->parent_bio); } =20 diff --git a/fs/erofs/fileio.c b/fs/erofs/fileio.c index b7b3432a9882..7ed32cb9e670 100644 --- a/fs/erofs/fileio.c +++ b/fs/erofs/fileio.c @@ -32,8 +32,8 @@ static void erofs_fileio_ki_complete(struct kiocb *iocb, = long ret) ret =3D 0; } if (rq->bio.bi_end_io) { - if (ret < 0 && !rq->bio.bi_status) - rq->bio.bi_status =3D errno_to_blk_status(ret); + if (ret < 0) + bio_set_status(&rq->bio, errno_to_blk_status(ret)); rq->bio.bi_end_io(&rq->bio); } else { bio_for_each_folio_all(fi, &rq->bio) { --=20 2.52.0 From nobody Sun Feb 8 13:52:59 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 D9B85219E8C for ; Sun, 21 Dec 2025 02:53:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766285613; cv=none; b=C6FBlywMrczArCjJ63NjStvWFgEKf5nDe+cSI1hu6n370Zzo7jlcOWRwXJV4QTxS1HFwHCYv9yVBCCK+DMADP4XSXHDTbJCZbxJYNwXy99Cuwt6M27vJg0odKcPrvI0IV/TZHLglW75qYMdW5D5N2hclHq7alucH2dtfWMPgnYQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766285613; c=relaxed/simple; bh=V7ilqadfBXQOTYr9StUYy6E9eJ9EgwDYxG/6noZg4xI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CsqjTDtftQHFhrftksZ1W0nQJElqKSg13jGtGJ0FE4AiV6xzMgFMcspiNRVHSo9dBn75KvJBBbNpuZJYt+nzyjrBoMV6qpyAwqxGtQepx86pfUYm2V58pJ5+zgk5AOKwRbth3GUzAKzZ6wsZQbBWAYXpbmomIdcXS5E0Q/FGryU= 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=KyIWNEDT; arc=none smtp.client-ip=170.10.129.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="KyIWNEDT" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1766285609; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=G1uXTIV/q9QWEKYFCtmTYr1p7eCMWcmzNVFUPfueUQ4=; b=KyIWNEDTCBU7QprWW1Y710niq9oDN8Adnmn1j2n2TSL+e1SzP7RkctRCrTwZIZVZK0148+ mWNlLvCE3UqEwcVnCrIG2t1CKkeqCmUgIkFgdDldqN713snbPp/GCTaP3Rr3ImFpMgYukH M02Q1XbOnW0WnB33PcvUtlmaziFvujI= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-187-lXnjKGRIMTuWIEywNbTQxw-1; Sat, 20 Dec 2025 21:53:27 -0500 X-MC-Unique: lXnjKGRIMTuWIEywNbTQxw-1 X-Mimecast-MFC-AGG-ID: lXnjKGRIMTuWIEywNbTQxw_1766285606 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2A2A41956088; Sun, 21 Dec 2025 02:53:26 +0000 (UTC) Received: from pasta.fast.eng.rdu2.dc.redhat.com (unknown [10.44.32.8]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2F94F180049F; Sun, 21 Dec 2025 02:53:22 +0000 (UTC) From: Andreas Gruenbacher To: Christoph Hellwig , Jens Axboe , Chris Mason , David Sterba , Satya Tangirala Cc: Andreas Gruenbacher , linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-raid@vger.kernel.org, dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [RFC v2 13/17] xfs: use bio_set_status in xfs_zone_alloc_and_submit Date: Sun, 21 Dec 2025 03:52:28 +0100 Message-ID: <20251221025233.87087-14-agruenba@redhat.com> In-Reply-To: <20251221025233.87087-1-agruenba@redhat.com> References: <20251221025233.87087-1-agruenba@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Content-Type: text/plain; charset="utf-8" At label out_split_error in xfs_zone_alloc_and_submit(), IS_ERR(split) is true, so bio_set_status() compiles down to a simple assignment. Signed-off-by: Andreas Gruenbacher --- fs/xfs/xfs_zone_alloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/xfs/xfs_zone_alloc.c b/fs/xfs/xfs_zone_alloc.c index bd6f3ef095cb..2b069cffac00 100644 --- a/fs/xfs/xfs_zone_alloc.c +++ b/fs/xfs/xfs_zone_alloc.c @@ -896,7 +896,7 @@ xfs_zone_alloc_and_submit( return; =20 out_split_error: - ioend->io_bio.bi_status =3D errno_to_blk_status(PTR_ERR(split)); + bio_set_status(&ioend->io_bio, errno_to_blk_status(PTR_ERR(split))); bio_endio(&ioend->io_bio); return; =20 --=20 2.52.0 From nobody Sun Feb 8 13:52:59 2026 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 73831259CBF for ; Sun, 21 Dec 2025 02:53:35 +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=1766285616; cv=none; b=jCc0EwDn0E9zzfVfQmQkyDvoqOOu4LFJYCMEpynK1/qihXJd0CULMAFopp9f78NrBkuJI6VLIPcaqiweADGgQhToWdFl6pnZsN539H49siabygDHaugNtMfdfBl7G5TV91stQty8y79UDtdd6eLPp6svBksuEkbQobJl99pGqv4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766285616; c=relaxed/simple; bh=4P2dhr1JL9AniZ7kydn/X2v06EQ/REJNhKDabgui29c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OMWFxjrXSK+u6mXwlHSSlan60ayijrkiYfDIN+gw1oJIl+kOdVE89FIElTUJEsUyXwuDKRsx1Ssznai10nF3EOJKcEPHTnXhdrn7gsn1OptCSOnai8zHUa5Hu/zSjnh+H0In3yQOQyYkNH9yXAohyfk1xpu2qTKiI4GRV1sGTtU= 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=PQmFJlWG; 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="PQmFJlWG" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1766285614; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Fol6UoUTNivE27QS2qgrcPSW+57SEzmLBc6042LIvfY=; b=PQmFJlWGEWTUDzPhTCBLovR+eyIhmq6HR9p1lpDnuJziq06Zb/q0fDKPnG//dG5vIvRQLA lqofaikbEdsTT2AiyuLUo4TfilcNlfvymaaur5ZvabEvyAqHAM3UnZq58Hbydm6DbP6VHJ uNdejMjzEHi2WexoD+IoR3WeLkcHZf4= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-134-o5WEt6OwNsyRSe35HCz4Kw-1; Sat, 20 Dec 2025 21:53:31 -0500 X-MC-Unique: o5WEt6OwNsyRSe35HCz4Kw-1 X-Mimecast-MFC-AGG-ID: o5WEt6OwNsyRSe35HCz4Kw_1766285609 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 943D619560B2; Sun, 21 Dec 2025 02:53:29 +0000 (UTC) Received: from pasta.fast.eng.rdu2.dc.redhat.com (unknown [10.44.32.8]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 94EF8180049F; Sun, 21 Dec 2025 02:53:26 +0000 (UTC) From: Andreas Gruenbacher To: Christoph Hellwig , Jens Axboe , Chris Mason , David Sterba , Satya Tangirala Cc: Andreas Gruenbacher , linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-raid@vger.kernel.org, dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [RFC v2 14/17] bio: switch to bio_set_status in submit_bio_noacct Date: Sun, 21 Dec 2025 03:52:29 +0100 Message-ID: <20251221025233.87087-15-agruenba@redhat.com> In-Reply-To: <20251221025233.87087-1-agruenba@redhat.com> References: <20251221025233.87087-1-agruenba@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Content-Type: text/plain; charset="utf-8" In submit_bio_noacct(), call bio_endio() and return directly when successful. That way, bio_set_status(bio, status) will only be called for actual errors and the compiler can optimize out the 'status !=3D BLK_STS_OK' check inside bio_set_status(). Signed-off-by: Andreas Gruenbacher --- block/blk-core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index 381bdf66045b..acf0a82a90ce 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -821,8 +821,8 @@ void submit_bio_noacct(struct bio *bio) if (!bdev_write_cache(bdev)) { bio->bi_opf &=3D ~(REQ_PREFLUSH | REQ_FUA); if (!bio_sectors(bio)) { - status =3D BLK_STS_OK; - goto end_io; + bio_endio(bio); + return; } } } @@ -887,7 +887,7 @@ void submit_bio_noacct(struct bio *bio) not_supported: status =3D BLK_STS_NOTSUPP; end_io: - bio->bi_status =3D status; + bio_set_status(bio, status); bio_endio(bio); } EXPORT_SYMBOL(submit_bio_noacct); --=20 2.52.0 From nobody Sun Feb 8 13:52:59 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 EB14926E71E for ; Sun, 21 Dec 2025 02:53:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766285623; cv=none; b=MCVjH1x6O90OoR9uNpMJ22YfdZcg6WH5+Vn2Jc8MBvLODN0Ss4IAyzpafeoL1lV60c8vLeFqX+zBgUKLgSSYqIcCLmAOGJGpE9PEJJYBUyEtShjoarhGoOV1Gvfqtx/U6y/BACBhQ9Cbx6L3paNy8/ssp7QeBuoTX08iQ6FYG0s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766285623; c=relaxed/simple; bh=kS8wU+Kr6qroCP7DZhoh64x8fFSwe6S0dB5tsS+Jaw0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sKzLdeU8OsTtBDiPas8GyqIv4o1DYMo0kxbT7mLPdN9iJS0IWItBodsSJ+34QXx0YMx3Yul3UdNffsfYDf4xYy8JskF6abhUvtngTYxIiU4WJFp7hk08TdR+i7uxwq5dG5VdrPDWdDWRnr3X20+9qc5mrayoUSo0itivkK3Huh0= 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=AjyzC1f+; arc=none smtp.client-ip=170.10.129.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="AjyzC1f+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1766285618; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=x4YveIZPStQoOwAVRFZjjRjkOAhnls6D4Neb20u0xq8=; b=AjyzC1f+WKMGMO81rQBK+g/c5P3vQOX5m+badTgaiRfbHmF48eFbkOC8RtSppAHC3q2hXj JOz9+vKBngHNNQfE7qbnxKnno7qwydadaBQQNaYpbKb6/CuAcQimoSRuJnmOad9YCKoW8e OVJZEL69e+vV0DL9OVX/Mzy3zMw14PI= Received: from mx-prod-mc-08.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-101-s95MwjcOPB-9iFVMjIt5ng-1; Sat, 20 Dec 2025 21:53:34 -0500 X-MC-Unique: s95MwjcOPB-9iFVMjIt5ng-1 X-Mimecast-MFC-AGG-ID: s95MwjcOPB-9iFVMjIt5ng_1766285613 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 26FEB1800378; Sun, 21 Dec 2025 02:53:33 +0000 (UTC) Received: from pasta.fast.eng.rdu2.dc.redhat.com (unknown [10.44.32.8]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 075D9180049F; Sun, 21 Dec 2025 02:53:29 +0000 (UTC) From: Andreas Gruenbacher To: Christoph Hellwig , Jens Axboe , Chris Mason , David Sterba , Satya Tangirala Cc: Andreas Gruenbacher , linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-raid@vger.kernel.org, dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [RFC v2 15/17] bio: never set bi_status to BLK_STS_OK during completion Date: Sun, 21 Dec 2025 03:52:30 +0100 Message-ID: <20251221025233.87087-16-agruenba@redhat.com> In-Reply-To: <20251221025233.87087-1-agruenba@redhat.com> References: <20251221025233.87087-1-agruenba@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Content-Type: text/plain; charset="utf-8" In a few places in the code, we don't know if a bio has failed or completed successfully, so use bio_set_status() instead of setting bi_status directly. That way, bi_status will never be set to BI_STS_OK (0) during completion. Signed-off-by: Andreas Gruenbacher --- block/blk-crypto-fallback.c | 2 +- drivers/block/ps3vram.c | 2 +- drivers/md/dm-flakey.c | 2 +- drivers/md/dm-verity-target.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/block/blk-crypto-fallback.c b/block/blk-crypto-fallback.c index 8a2631b1e7e1..7014f646e236 100644 --- a/block/blk-crypto-fallback.c +++ b/block/blk-crypto-fallback.c @@ -150,7 +150,7 @@ static void blk_crypto_fallback_encrypt_endio(struct bi= o *enc_bio) mempool_free(enc_bio->bi_io_vec[i].bv_page, blk_crypto_bounce_page_pool); =20 - src_bio->bi_status =3D enc_bio->bi_status; + bio_set_status(src_bio, enc_bio->bi_status); =20 bio_uninit(enc_bio); kfree(enc_bio); diff --git a/drivers/block/ps3vram.c b/drivers/block/ps3vram.c index bdcf083b45e2..06844674c998 100644 --- a/drivers/block/ps3vram.c +++ b/drivers/block/ps3vram.c @@ -573,7 +573,7 @@ static struct bio *ps3vram_do_bio(struct ps3_system_bus= _device *dev, next =3D bio_list_peek(&priv->list); spin_unlock_irq(&priv->lock); =20 - bio->bi_status =3D error; + bio_set_status(bio, error); bio_endio(bio); return next; } diff --git a/drivers/md/dm-flakey.c b/drivers/md/dm-flakey.c index 08925aca838c..8dde47beb387 100644 --- a/drivers/md/dm-flakey.c +++ b/drivers/md/dm-flakey.c @@ -420,7 +420,7 @@ static void clone_free(struct bio *clone) static void clone_endio(struct bio *clone) { struct bio *bio =3D clone->bi_private; - bio->bi_status =3D clone->bi_status; + bio_set_status(bio, clone->bi_status); clone_free(clone); bio_endio(bio); } diff --git a/drivers/md/dm-verity-target.c b/drivers/md/dm-verity-target.c index 66a00a8ccb39..4793bcf546ad 100644 --- a/drivers/md/dm-verity-target.c +++ b/drivers/md/dm-verity-target.c @@ -544,7 +544,7 @@ static void verity_finish_io(struct dm_verity_io *io, b= lk_status_t status) struct bio *bio =3D dm_bio_from_per_bio_data(io, v->ti->per_io_data_size); =20 bio->bi_end_io =3D io->orig_bi_end_io; - bio->bi_status =3D status; + bio_set_status(bio, status); =20 if (!static_branch_unlikely(&use_bh_wq_enabled) || !io->in_bh) verity_fec_finish_io(io); --=20 2.52.0 From nobody Sun Feb 8 13:52:59 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 C4B7B219E8C for ; Sun, 21 Dec 2025 02:53:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766285625; cv=none; b=OlhPeI/kKR/RczGIXbIRPvygPrwOpi59UM4Lt8R1vge+ss9gH1nS/yqXjw/9GwwS2Ss0OwaNd/+Ge74fP7sKlhuR4nFp539CfLtnOOQRaBcFB4GJumMrgqyKYQgxj0y8sD3bUlhuij8JbP+Ic1Wa/Sh/ZN9ie4nO4CpFsFSO0+I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766285625; c=relaxed/simple; bh=NYyLbW6iEsrA8fkjIrv0STEvi9AYMBFhXV7z3OwZVbU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YwYznkVjulmCYZ9F2ewFSUB2jGMiCtRG7Nmcv/ygNxypqZKf8NO/RNrBPb7Oq2H1Vq67iilD2qIDt6heccUqHKy5F9oj7khz8cgL0QvK344AXbShYiwclsgRqQh5dp7kFqM6l7OUhlCUMqOEP7YE6j/aq21+LlnS1GME2NMJl4k= 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=NOp/9iUX; arc=none smtp.client-ip=170.10.129.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="NOp/9iUX" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1766285621; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tEwEGf2cVwym+KiRjPuOI3V34q9SnOs+PEKiirNkNWU=; b=NOp/9iUXsNg+VxddA/7K2lMfvSH7rqJE/txkC64a5TKWQq5JJd1Vs1CGcL30KO1L8JV5ov 19rrlNhEITLL459PDLZng6PLOYD6QUshBIOQZgwSw14XWafVqJURdp9Qa4kW5MmuSbgG/B Rn4ymr2zxyCEuRwgDJ363FieQQCGcwk= 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-193-f9R6PeB8NAWiX2Mn_4caXQ-1; Sat, 20 Dec 2025 21:53:37 -0500 X-MC-Unique: f9R6PeB8NAWiX2Mn_4caXQ-1 X-Mimecast-MFC-AGG-ID: f9R6PeB8NAWiX2Mn_4caXQ_1766285616 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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 56930180028B; Sun, 21 Dec 2025 02:53:36 +0000 (UTC) Received: from pasta.fast.eng.rdu2.dc.redhat.com (unknown [10.44.32.8]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6473F180049F; Sun, 21 Dec 2025 02:53:33 +0000 (UTC) From: Andreas Gruenbacher To: Christoph Hellwig , Jens Axboe , Chris Mason , David Sterba , Satya Tangirala Cc: Andreas Gruenbacher , linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-raid@vger.kernel.org, dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [RFC v2 16/17] bio: never set bi_status to BLK_STS_OK during completion (part 2) Date: Sun, 21 Dec 2025 03:52:31 +0100 Message-ID: <20251221025233.87087-17-agruenba@redhat.com> In-Reply-To: <20251221025233.87087-1-agruenba@redhat.com> References: <20251221025233.87087-1-agruenba@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Content-Type: text/plain; charset="utf-8" In these two places, it seems that errno can be 0. This would assign BLK_STS_OK (0) to bio->bi_status, which is not allowed. Fix that by using bio_set_status() instead. Created with Coccinelle using the following semantic patch. (Coccinelle occasionally likes to add unnecessary curly braces in if statements; those were removed by hand.) @@ struct bio *bio; expression errno; @@ - bio->bi_status =3D errno_to_blk_status(errno); + bio_set_status(bio, errno_to_blk_status(errno)); @@ struct bio bio; expression errno; @@ - bio.bi_status =3D errno_to_blk_status(errno); + bio_set_status(&bio, errno_to_blk_status(errno)); Signed-off-by: Andreas Gruenbacher --- drivers/md/dm-pcache/dm_pcache.c | 2 +- drivers/md/dm-vdo/data-vio.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/md/dm-pcache/dm_pcache.c b/drivers/md/dm-pcache/dm_pca= che.c index e5f5936fa6f0..086ae9b06bfb 100644 --- a/drivers/md/dm-pcache/dm_pcache.c +++ b/drivers/md/dm-pcache/dm_pcache.c @@ -74,7 +74,7 @@ static void end_req(struct kref *ref) pcache_req_get(pcache_req); defer_req(pcache_req); } else { - bio->bi_status =3D errno_to_blk_status(ret); + bio_set_status(bio, errno_to_blk_status(ret)); bio_endio(bio); =20 if (atomic_dec_and_test(&pcache->inflight_reqs)) diff --git a/drivers/md/dm-vdo/data-vio.c b/drivers/md/dm-vdo/data-vio.c index 262e11581f2d..11becc4138c4 100644 --- a/drivers/md/dm-vdo/data-vio.c +++ b/drivers/md/dm-vdo/data-vio.c @@ -287,7 +287,7 @@ static void acknowledge_data_vio(struct data_vio *data_= vio) if (data_vio->is_partial) vdo_count_bios(&vdo->stats.bios_acknowledged_partial, bio); =20 - bio->bi_status =3D errno_to_blk_status(error); + bio_set_status(bio, errno_to_blk_status(error)); bio_endio(bio); } =20 --=20 2.52.0 From nobody Sun Feb 8 13:52:59 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 1A4C82737F3 for ; Sun, 21 Dec 2025 02:53:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766285628; cv=none; b=suhl72c5meZadLppt76R4J+wfn9mPR98T2gPTlr9AE9cHgsSSqQ1ByraokH9OiRveFreYuym6goOgOGboAt6jJgMESc8AuDXAOVIO5GjK83pXfFboooOtj9NhTYHD1oCntqbL3w3LneFwr9Z4bahry+Bjz0BYCWBVdVVkKSbmQw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766285628; c=relaxed/simple; bh=tkUKQd/oOejzy1+4KfPeSYtNVDYc9mFOs+DgnnOeR+E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KNoJ3q0MIAC8EYXNSnlVFoS7OcP/pl9G++SOjIZBdZkpOh8vUCNoZrNNIB9FambyGARPE+KyVyBn4Jy8kbKAX+crJMffwi7Vt+RPSapO18llxDlv+YZLBnxwn9jnaQCQH75Pl4V7KrsUISNv+YW6/a6XeYldnYRUr3VqpuWb+7Q= 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=fnjNJMye; arc=none smtp.client-ip=170.10.129.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="fnjNJMye" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1766285625; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FggBl310SeU2z5ihOYBZTljJM6cUTkQcdyJAp+ym5x0=; b=fnjNJMyeRvws/naRZQ6bOtFuTV0fPLW9QRk6XUNK5gXWebPK88SbeA3A8/dWqwhHAI5PnW 86Xtxs5f4uLx7WklqoUJm/Rl0Gf1t3LHxg4gp97GwUTlm2jnacwY7haOcXyqnyY4CvtoEd Q+Rv8dfIQmvhcjb+NYjBWorFm6LPXuQ= 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-401-_V4fehw6PWaygTl_DPmMEQ-1; Sat, 20 Dec 2025 21:53:41 -0500 X-MC-Unique: _V4fehw6PWaygTl_DPmMEQ-1 X-Mimecast-MFC-AGG-ID: _V4fehw6PWaygTl_DPmMEQ_1766285619 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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 CB9051800637; Sun, 21 Dec 2025 02:53:39 +0000 (UTC) Received: from pasta.fast.eng.rdu2.dc.redhat.com (unknown [10.44.32.8]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C08BA180049F; Sun, 21 Dec 2025 02:53:36 +0000 (UTC) From: Andreas Gruenbacher To: Christoph Hellwig , Jens Axboe , Chris Mason , David Sterba , Satya Tangirala Cc: Andreas Gruenbacher , linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-raid@vger.kernel.org, dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [RFC v2 17/17] bio: add bio_endio_status Date: Sun, 21 Dec 2025 03:52:32 +0100 Message-ID: <20251221025233.87087-18-agruenba@redhat.com> In-Reply-To: <20251221025233.87087-1-agruenba@redhat.com> References: <20251221025233.87087-1-agruenba@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Content-Type: text/plain; charset="utf-8" Add a bio_endio_status() helper as a shortcut for calling bio_set_status() and bio_endio() in sequence. Use the new helper throughout the code. Created with Coccinelle using the following semantic patch: @@ expression bio, status; @@ - bio_set_status(bio, status); - bio_endio(bio); + bio_endio_status(bio, status); Signed-off-by: Andreas Gruenbacher --- block/bio-integrity-auto.c | 3 +-- block/blk-core.c | 6 ++---- block/blk-merge.c | 6 ++---- block/blk-mq.c | 6 ++---- drivers/block/drbd/drbd_req.c | 3 +-- drivers/block/ps3vram.c | 3 +-- drivers/md/dm-cache-target.c | 3 +-- drivers/md/dm-integrity.c | 25 +++++++++---------------- drivers/md/dm-mpath.c | 3 +-- drivers/md/dm-pcache/dm_pcache.c | 3 +-- drivers/md/dm-raid1.c | 3 +-- drivers/md/dm-thin.c | 6 ++---- drivers/md/dm-vdo/data-vio.c | 3 +-- drivers/md/dm.c | 3 +-- drivers/md/raid1-10.c | 3 +-- drivers/md/raid10.c | 16 ++++++---------- fs/btrfs/raid56.c | 6 ++---- fs/iomap/ioend.c | 3 +-- fs/xfs/xfs_aops.c | 3 +-- fs/xfs/xfs_zone_alloc.c | 3 +-- include/linux/bio.h | 12 ++++++++---- 21 files changed, 46 insertions(+), 76 deletions(-) diff --git a/block/bio-integrity-auto.c b/block/bio-integrity-auto.c index 736d53a7f699..1185f6e15d86 100644 --- a/block/bio-integrity-auto.c +++ b/block/bio-integrity-auto.c @@ -190,8 +190,7 @@ bool bio_integrity_prep(struct bio *bio) err_free_buf: kfree(buf); err_end_io: - bio_set_status(bio, BLK_STS_RESOURCE); - bio_endio(bio); + bio_endio_status(bio, BLK_STS_RESOURCE); return false; } EXPORT_SYMBOL(bio_integrity_prep); diff --git a/block/blk-core.c b/block/blk-core.c index acf0a82a90ce..119ac3156eeb 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -645,8 +645,7 @@ static void __submit_bio(struct bio *bio) =09 if ((bio->bi_opf & REQ_POLLED) && !(disk->queue->limits.features & BLK_FEAT_POLL)) { - bio_set_status(bio, BLK_STS_NOTSUPP); - bio_endio(bio); + bio_endio_status(bio, BLK_STS_NOTSUPP); } else { disk->fops->submit_bio(bio); } @@ -887,8 +886,7 @@ void submit_bio_noacct(struct bio *bio) not_supported: status =3D BLK_STS_NOTSUPP; end_io: - bio_set_status(bio, status); - bio_endio(bio); + bio_endio_status(bio, status); } EXPORT_SYMBOL(submit_bio_noacct); =20 diff --git a/block/blk-merge.c b/block/blk-merge.c index 27ea5ffb8f77..5ab948ed4c1a 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -122,8 +122,7 @@ struct bio *bio_submit_split_bioset(struct bio *bio, un= signed int split_sectors, struct bio *split =3D bio_split(bio, split_sectors, GFP_NOIO, bs); =20 if (IS_ERR(split)) { - bio_set_status(bio, errno_to_blk_status(PTR_ERR(split))); - bio_endio(bio); + bio_endio_status(bio, errno_to_blk_status(PTR_ERR(split))); return NULL; } =20 @@ -143,8 +142,7 @@ EXPORT_SYMBOL_GPL(bio_submit_split_bioset); static struct bio *bio_submit_split(struct bio *bio, int split_sectors) { if (unlikely(split_sectors < 0)) { - bio_set_status(bio, errno_to_blk_status(split_sectors)); - bio_endio(bio); + bio_endio_status(bio, errno_to_blk_status(split_sectors)); return NULL; } =20 diff --git a/block/blk-mq.c b/block/blk-mq.c index 8fb35a258b4c..3ad79017ceeb 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -3165,8 +3165,7 @@ void blk_mq_submit_bio(struct bio *bio) } =20 if ((bio->bi_opf & REQ_POLLED) && !blk_mq_can_poll(q)) { - bio_set_status(bio, BLK_STS_NOTSUPP); - bio_endio(bio); + bio_endio_status(bio, BLK_STS_NOTSUPP); goto queue_exit; } =20 @@ -3206,8 +3205,7 @@ void blk_mq_submit_bio(struct bio *bio) =20 ret =3D blk_crypto_rq_get_keyslot(rq); if (ret !=3D BLK_STS_OK) { - bio_set_status(bio, ret); - bio_endio(bio); + bio_endio_status(bio, ret); blk_mq_free_request(rq); return; } diff --git a/drivers/block/drbd/drbd_req.c b/drivers/block/drbd/drbd_req.c index 983b2ff5eb6b..3d3476707638 100644 --- a/drivers/block/drbd/drbd_req.c +++ b/drivers/block/drbd/drbd_req.c @@ -1211,8 +1211,7 @@ drbd_request_prepare(struct drbd_device *device, stru= ct bio *bio) /* only pass the error to the upper layers. * if user cannot handle io errors, that's not our business. */ drbd_err(device, "could not kmalloc() req\n"); - bio_set_status(bio, BLK_STS_RESOURCE); - bio_endio(bio); + bio_endio_status(bio, BLK_STS_RESOURCE); return ERR_PTR(-ENOMEM); } =20 diff --git a/drivers/block/ps3vram.c b/drivers/block/ps3vram.c index 06844674c998..8b8bdfa50c97 100644 --- a/drivers/block/ps3vram.c +++ b/drivers/block/ps3vram.c @@ -573,8 +573,7 @@ static struct bio *ps3vram_do_bio(struct ps3_system_bus= _device *dev, next =3D bio_list_peek(&priv->list); spin_unlock_irq(&priv->lock); =20 - bio_set_status(bio, error); - bio_endio(bio); + bio_endio_status(bio, error); return next; } =20 diff --git a/drivers/md/dm-cache-target.c b/drivers/md/dm-cache-target.c index d1dbd4ddaadb..da1b1eb29bb8 100644 --- a/drivers/md/dm-cache-target.c +++ b/drivers/md/dm-cache-target.c @@ -1856,8 +1856,7 @@ static void requeue_deferred_bios(struct cache *cache) bio_list_merge_init(&bios, &cache->deferred_bios); =20 while ((bio =3D bio_list_pop(&bios))) { - bio_set_status(bio, BLK_STS_DM_REQUEUE); - bio_endio(bio); + bio_endio_status(bio, BLK_STS_DM_REQUEUE); cond_resched(); } } diff --git a/drivers/md/dm-integrity.c b/drivers/md/dm-integrity.c index 4a6e27c0d510..c21b0d866627 100644 --- a/drivers/md/dm-integrity.c +++ b/drivers/md/dm-integrity.c @@ -2512,8 +2512,7 @@ static int dm_integrity_map_inline(struct dm_integrit= y_io *dio, bool from_map) sector_t recalc_sector; =20 if (unlikely(bio_integrity(bio))) { - bio_set_status(bio, BLK_STS_NOTSUPP); - bio_endio(bio); + bio_endio_status(bio, BLK_STS_NOTSUPP); return DM_MAPIO_SUBMITTED; } =20 @@ -2534,8 +2533,7 @@ static int dm_integrity_map_inline(struct dm_integrit= y_io *dio, bool from_map) if (dio->payload_len > x_size) { unsigned sectors =3D ((x_size - extra_size) / ic->tuple_size) << ic->s= b->log2_sectors_per_block; if (WARN_ON(!sectors || sectors >=3D bio_sectors(bio))) { - bio_set_status(bio, BLK_STS_NOTSUPP); - bio_endio(bio); + bio_endio_status(bio, BLK_STS_NOTSUPP); return DM_MAPIO_SUBMITTED; } dm_accept_partial_bio(bio, sectors); @@ -2593,8 +2591,7 @@ static int dm_integrity_map_inline(struct dm_integrit= y_io *dio, bool from_map) =20 bip =3D bio_integrity_alloc(bio, GFP_NOIO, 1); if (IS_ERR(bip)) { - bio_set_status(bio, errno_to_blk_status(PTR_ERR(bip))); - bio_endio(bio); + bio_endio_status(bio, errno_to_blk_status(PTR_ERR(bip))); return DM_MAPIO_SUBMITTED; } =20 @@ -2615,8 +2612,7 @@ static int dm_integrity_map_inline(struct dm_integrit= y_io *dio, bool from_map) ret =3D bio_integrity_add_page(bio, virt_to_page(dio->integrity_payload), dio->payload_len, offset_in_page(dio->integrity_payload)); if (unlikely(ret !=3D dio->payload_len)) { - bio_set_status(bio, BLK_STS_RESOURCE); - bio_endio(bio); + bio_endio_status(bio, BLK_STS_RESOURCE); return DM_MAPIO_SUBMITTED; } =20 @@ -2661,16 +2657,15 @@ static void dm_integrity_inline_recheck(struct work= _struct *w) bip =3D bio_integrity_alloc(outgoing_bio, GFP_NOIO, 1); if (IS_ERR(bip)) { bio_put(outgoing_bio); - bio_set_status(bio, errno_to_blk_status(PTR_ERR(bip))); - bio_endio(bio); + bio_endio_status(bio, + errno_to_blk_status(PTR_ERR(bip))); return; } =20 r =3D bio_integrity_add_page(outgoing_bio, virt_to_page(dio->integrity_p= ayload), ic->tuple_size, 0); if (unlikely(r !=3D ic->tuple_size)) { bio_put(outgoing_bio); - bio_set_status(bio, BLK_STS_RESOURCE); - bio_endio(bio); + bio_endio_status(bio, BLK_STS_RESOURCE); return; } =20 @@ -2679,8 +2674,7 @@ static void dm_integrity_inline_recheck(struct work_s= truct *w) r =3D submit_bio_wait(outgoing_bio); if (unlikely(r !=3D 0)) { bio_put(outgoing_bio); - bio_set_status(bio, errno_to_blk_status(r)); - bio_endio(bio); + bio_endio_status(bio, errno_to_blk_status(r)); return; } bio_put(outgoing_bio); @@ -2693,8 +2687,7 @@ static void dm_integrity_inline_recheck(struct work_s= truct *w) dm_audit_log_bio(DM_MSG_PREFIX, "integrity-checksum", bio, dio->bio_details.bi_iter.bi_sector, 0); =20 - bio_set_status(bio, BLK_STS_PROTECTION); - bio_endio(bio); + bio_endio_status(bio, BLK_STS_PROTECTION); return; } =20 diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c index 761e5e79d4a7..1097ffb05b00 100644 --- a/drivers/md/dm-mpath.c +++ b/drivers/md/dm-mpath.c @@ -722,8 +722,7 @@ static void process_queued_bios(struct work_struct *wor= k) bio_io_error(bio); break; case DM_MAPIO_REQUEUE: - bio_set_status(bio, BLK_STS_DM_REQUEUE); - bio_endio(bio); + bio_endio_status(bio, BLK_STS_DM_REQUEUE); break; case DM_MAPIO_REMAPPED: submit_bio_noacct(bio); diff --git a/drivers/md/dm-pcache/dm_pcache.c b/drivers/md/dm-pcache/dm_pca= che.c index 086ae9b06bfb..925a25aa8699 100644 --- a/drivers/md/dm-pcache/dm_pcache.c +++ b/drivers/md/dm-pcache/dm_pcache.c @@ -74,8 +74,7 @@ static void end_req(struct kref *ref) pcache_req_get(pcache_req); defer_req(pcache_req); } else { - bio_set_status(bio, errno_to_blk_status(ret)); - bio_endio(bio); + bio_endio_status(bio, errno_to_blk_status(ret)); =20 if (atomic_dec_and_test(&pcache->inflight_reqs)) wake_up(&pcache->inflight_wq); diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c index c54995847db0..1f53b125b333 100644 --- a/drivers/md/dm-raid1.c +++ b/drivers/md/dm-raid1.c @@ -627,8 +627,7 @@ static void write_callback(unsigned long error, void *c= ontext) * degrade the array. */ if (bio_op(bio) =3D=3D REQ_OP_DISCARD) { - bio_set_status(bio, BLK_STS_NOTSUPP); - bio_endio(bio); + bio_endio_status(bio, BLK_STS_NOTSUPP); return; } =20 diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c index 42261bbe4771..7fe004a330c0 100644 --- a/drivers/md/dm-thin.c +++ b/drivers/md/dm-thin.c @@ -422,8 +422,7 @@ static void end_discard(struct discard_op *op, int r) * Even if r is set, there could be sub discards in flight that we * need to wait for. */ - bio_set_status(op->parent_bio, errno_to_blk_status(r)); - bio_endio(op->parent_bio); + bio_endio_status(op->parent_bio, errno_to_blk_status(r)); } =20 /*----------------------------------------------------------------*/ @@ -2730,8 +2729,7 @@ static int thin_bio_map(struct dm_target *ti, struct = bio *bio) thin_hook_bio(tc, bio); =20 if (tc->requeue_mode) { - bio_set_status(bio, BLK_STS_DM_REQUEUE); - bio_endio(bio); + bio_endio_status(bio, BLK_STS_DM_REQUEUE); return DM_MAPIO_SUBMITTED; } =20 diff --git a/drivers/md/dm-vdo/data-vio.c b/drivers/md/dm-vdo/data-vio.c index 11becc4138c4..298957fa938a 100644 --- a/drivers/md/dm-vdo/data-vio.c +++ b/drivers/md/dm-vdo/data-vio.c @@ -287,8 +287,7 @@ static void acknowledge_data_vio(struct data_vio *data_= vio) if (data_vio->is_partial) vdo_count_bios(&vdo->stats.bios_acknowledged_partial, bio); =20 - bio_set_status(bio, errno_to_blk_status(error)); - bio_endio(bio); + bio_endio_status(bio, errno_to_blk_status(error)); } =20 static void copy_to_bio(struct bio *bio, char *data_ptr) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index cbc64377fa96..1743042db9f6 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -983,8 +983,7 @@ static void __dm_io_complete(struct dm_io *io, bool fir= st_stage) queue_io(md, bio); } else { /* done with normal IO or empty flush */ - bio_set_status(bio, io_error); - bio_endio(bio); + bio_endio_status(bio, io_error); } } =20 diff --git a/drivers/md/raid1-10.c b/drivers/md/raid1-10.c index 504730aba9df..53903bb91408 100644 --- a/drivers/md/raid1-10.c +++ b/drivers/md/raid1-10.c @@ -104,8 +104,7 @@ static void md_bio_reset_resync_pages(struct bio *bio, = struct resync_pages *rp, int len =3D min_t(int, size, PAGE_SIZE); =20 if (WARN_ON(!bio_add_page(bio, page, len, 0))) { - bio_set_status(bio, BLK_STS_RESOURCE); - bio_endio(bio); + bio_endio_status(bio, BLK_STS_RESOURCE); return; } =20 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 3e15e190f103..5bbef4954fd5 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -1665,9 +1665,8 @@ static int raid10_handle_discard(struct mddev *mddev,= struct bio *bio) split_size =3D stripe_size - remainder; split =3D bio_split(bio, split_size, GFP_NOIO, &conf->bio_split); if (IS_ERR(split)) { - bio_set_status(bio, - errno_to_blk_status(PTR_ERR(split))); - bio_endio(bio); + bio_endio_status(bio, + errno_to_blk_status(PTR_ERR(split))); return 0; } =20 @@ -1683,9 +1682,8 @@ static int raid10_handle_discard(struct mddev *mddev,= struct bio *bio) split_size =3D bio_sectors(bio) - remainder; split =3D bio_split(bio, split_size, GFP_NOIO, &conf->bio_split); if (IS_ERR(split)) { - bio_set_status(bio, - errno_to_blk_status(PTR_ERR(split))); - bio_endio(bio); + bio_endio_status(bio, + errno_to_blk_status(PTR_ERR(split))); return 0; } =20 @@ -3685,8 +3683,7 @@ static sector_t raid10_sync_request(struct mddev *mdd= ev, sector_t sector_nr, struct resync_pages *rp =3D get_resync_pages(bio); page =3D resync_fetch_page(rp, page_idx); if (WARN_ON(!bio_add_page(bio, page, len, 0))) { - bio_set_status(bio, BLK_STS_RESOURCE); - bio_endio(bio); + bio_endio_status(bio, BLK_STS_RESOURCE); goto giveup; } } @@ -4867,8 +4864,7 @@ static sector_t reshape_request(struct mddev *mddev, = sector_t sector_nr, len =3D PAGE_SIZE; for (bio =3D blist; bio ; bio =3D bio->bi_next) { if (WARN_ON(!bio_add_page(bio, page, len, 0))) { - bio_set_status(bio, BLK_STS_RESOURCE); - bio_endio(bio); + bio_endio_status(bio, BLK_STS_RESOURCE); return sectors_done; } } diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c index b60ab0bb08ad..5bd9dd132314 100644 --- a/fs/btrfs/raid56.c +++ b/fs/btrfs/raid56.c @@ -1750,8 +1750,7 @@ void raid56_parity_write(struct bio *bio, struct btrf= s_io_context *bioc) =20 rbio =3D alloc_rbio(fs_info, bioc); if (IS_ERR(rbio)) { - bio_set_status(bio, errno_to_blk_status(PTR_ERR(rbio))); - bio_endio(bio); + bio_endio_status(bio, errno_to_blk_status(PTR_ERR(rbio))); return; } rbio->operation =3D BTRFS_RBIO_WRITE; @@ -2148,8 +2147,7 @@ void raid56_parity_recover(struct bio *bio, struct bt= rfs_io_context *bioc, =20 rbio =3D alloc_rbio(fs_info, bioc); if (IS_ERR(rbio)) { - bio_set_status(bio, errno_to_blk_status(PTR_ERR(rbio))); - bio_endio(bio); + bio_endio_status(bio, errno_to_blk_status(PTR_ERR(rbio))); return; } =20 diff --git a/fs/iomap/ioend.c b/fs/iomap/ioend.c index 1ebe6730d013..10963b7c0837 100644 --- a/fs/iomap/ioend.c +++ b/fs/iomap/ioend.c @@ -87,8 +87,7 @@ int iomap_ioend_writeback_submit(struct iomap_writepage_c= tx *wpc, int error) error =3D -EIO; =20 if (error) { - bio_set_status(&ioend->io_bio, errno_to_blk_status(error)); - bio_endio(&ioend->io_bio); + bio_endio_status(&ioend->io_bio, errno_to_blk_status(error)); return error; } =20 diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c index bd2b828164cb..c56560715ba4 100644 --- a/fs/xfs/xfs_aops.c +++ b/fs/xfs/xfs_aops.c @@ -653,8 +653,7 @@ xfs_zoned_writeback_submit( =20 ioend->io_bio.bi_end_io =3D xfs_end_bio; if (error) { - bio_set_status(&ioend->io_bio, errno_to_blk_status(error)); - bio_endio(&ioend->io_bio); + bio_endio_status(&ioend->io_bio, errno_to_blk_status(error)); return error; } xfs_zone_alloc_and_submit(ioend, &XFS_ZWPC(wpc)->open_zone); diff --git a/fs/xfs/xfs_zone_alloc.c b/fs/xfs/xfs_zone_alloc.c index 2b069cffac00..e5f91580e6d9 100644 --- a/fs/xfs/xfs_zone_alloc.c +++ b/fs/xfs/xfs_zone_alloc.c @@ -896,8 +896,7 @@ xfs_zone_alloc_and_submit( return; =20 out_split_error: - bio_set_status(&ioend->io_bio, errno_to_blk_status(PTR_ERR(split))); - bio_endio(&ioend->io_bio); + bio_endio_status(&ioend->io_bio, errno_to_blk_status(PTR_ERR(split))); return; =20 out_error: diff --git a/include/linux/bio.h b/include/linux/bio.h index cf0f5aba7bee..94f0c7f58002 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -392,17 +392,21 @@ static inline void bio_set_status(struct bio *bio, bl= k_status_t status) WRITE_ONCE(bio->bi_status, status); } =20 -static inline void bio_io_error(struct bio *bio) +static inline void bio_endio_status(struct bio *bio, blk_status_t status) { - bio_set_status(bio, BLK_STS_IOERR); + bio_set_status(bio, status); bio_endio(bio); } =20 +static inline void bio_io_error(struct bio *bio) +{ + bio_endio_status(bio, BLK_STS_IOERR); +} + static inline void bio_wouldblock_error(struct bio *bio) { bio_set_flag(bio, BIO_QUIET); - bio_set_status(bio, BLK_STS_AGAIN); - bio_endio(bio); + bio_endio_status(bio, BLK_STS_AGAIN); } =20 /* --=20 2.52.0