From nobody Fri Dec 19 09:54:50 2025 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 AB7712EBB9A for ; Mon, 8 Dec 2025 12:10:38 +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=1765195840; cv=none; b=JwnCljnXgMMp1HTsFQVxdAuThL1WP/pvW9ZhYRRAhizfzv4S3dVF8HaytyBdOVkLdqag2cNbAgoLXQgm1SqzTum0Qq7yHoX2rKvOLL3zej7nBLdcJ7VKbhDdE4UlFJZ4kve2P/X8Lml4zHbncxDaR70zLrrDJaAXqPLkN1uF9T4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765195840; c=relaxed/simple; bh=9k1l5oP0yXJfVXtLxOCu5RYALmuhZB/zpoPE5QPpVGs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=m8+xcO83llPmxgJCqoiFlNZZAg9vwZOKts8J+0qnWoneWuhjPSgeUWkAYPRU5rjov39exqKj+bDLrAiSpG6t7aYwQkMunVJDlMTAXZkZttjE6L3Ncigef8tcSawwSoDe/1c/0o3AzkZ9+7RsnjF39ik1qRedDex6jQiCn07I1is= 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=U5DStzKN; 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="U5DStzKN" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1765195837; 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=X8Q0v07JW9uSTBXNVPvB76vEIqMmpZ+G2A5HsI4ewQk=; b=U5DStzKNwL6tAP6caAjIp4hDM32K1dQSmj8beYd1yH26XupizmVAPEeqLcFfawrc207jsq 5q+EOulk6Q1hkTzgMBE+a4ZosOPxm1ywMlCYtXs7QF6ynWqRldxsOECrCqkAnLKLqJEkSh eKaYr+ZDdRMcrfQfNgxBFa7/HqcjGpg= 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-642-kCi3znmHORW-rI5eE-cFgw-1; Mon, 08 Dec 2025 07:10:32 -0500 X-MC-Unique: kCi3znmHORW-rI5eE-cFgw-1 X-Mimecast-MFC-AGG-ID: kCi3znmHORW-rI5eE-cFgw_1765195831 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 A81971956080; Mon, 8 Dec 2025 12:10:30 +0000 (UTC) Received: from pasta.fast.eng.rdu2.dc.redhat.com (unknown [10.44.34.3]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7C8141956095; Mon, 8 Dec 2025 12:10:27 +0000 (UTC) From: Andreas Gruenbacher To: Christoph Hellwig , Jens Axboe , Chris Mason , David Sterba 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 01/12] bio: rename bio_chain arguments Date: Mon, 8 Dec 2025 12:10:08 +0000 Message-ID: <20251208121020.1780402-2-agruenba@redhat.com> In-Reply-To: <20251208121020.1780402-1-agruenba@redhat.com> References: <20251208121020.1780402-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.0 on 10.30.177.17 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.51.0 From nobody Fri Dec 19 09:54:50 2025 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 EBFC92F4A16 for ; Mon, 8 Dec 2025 12:10:40 +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=1765195842; cv=none; b=g6j/OsJtHuDbXObFvZRuBO3UoK6nVuUvQty6A5ngrc4F5R9BcOJQra0hZtDohDqpnarCofPczxq8aBIaxqm0wb349dPl+EVFhe0QRBTGdydAMwCIssBKU6uf485+hixAxeGW/XsGF6d0t5+dwKIvHwX18b/nU1fZaUN2LDj/Dmw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765195842; c=relaxed/simple; bh=6yNgwZD6RyqsZur17vkqMRg9mE/1zmq6b8V0MBZ/1ys=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fFqB8l0zeQA9mec0J8wKF68WHtwon4sg39LPRbWrSewuGUu7F0vx29UVeBcZD7O/n1dN9WwGpsOFawgLq6daP1CXA97BtV/HgVjKDbBwpfTa5jJZoJ3AQY7WACEQz1r3MGK/QkCdFzjFHsn+dmywinlGiu7pnrNfkcaHG9NxaEw= 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=htj5rI01; 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="htj5rI01" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1765195840; 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=jDJU7dKZfTVZdt88mgvhpQhy7QhmJF93sojddadeY3g=; b=htj5rI01aF5rNS00/Jhhs6AVejueGufYvbuH3+AoC5EsQhe6V6g8i3GvQ/kRCZtuAWfFnS 70DKzlBl9darJsbaRdCnoVN9nb/DqDLratMAHV6ECK4anLMtlvxKVtqkYEGMdC5VDdlN7I Xd53eivjhxRpTCYzWi9Lg1PRZVc8+4E= 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-610-HrQtQ-lRM--ZhZ_11CK8ag-1; Mon, 08 Dec 2025 07:10:37 -0500 X-MC-Unique: HrQtQ-lRM--ZhZ_11CK8ag-1 X-Mimecast-MFC-AGG-ID: HrQtQ-lRM--ZhZ_11CK8ag_1765195835 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 133CE18002DE; Mon, 8 Dec 2025 12:10:35 +0000 (UTC) Received: from pasta.fast.eng.rdu2.dc.redhat.com (unknown [10.44.34.3]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8C8321956095; Mon, 8 Dec 2025 12:10:30 +0000 (UTC) From: Andreas Gruenbacher To: Christoph Hellwig , Jens Axboe , Chris Mason , David Sterba 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 02/12] bio: use bio_io_error more often Date: Mon, 8 Dec 2025 12:10:09 +0000 Message-ID: <20251208121020.1780402-3-agruenba@redhat.com> In-Reply-To: <20251208121020.1780402-1-agruenba@redhat.com> References: <20251208121020.1780402-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.0 on 10.30.177.17 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.51.0 From nobody Fri Dec 19 09:54:50 2025 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 C86962EB873 for ; Mon, 8 Dec 2025 12:10:44 +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=1765195846; cv=none; b=oPlUnbVBfHG0WaqupNmw5qefrgOblkNqFuGVT78j4Wwn0RVYoiu0smK+Wd+Bsj0SdwzPt8OcvDYi7VIICwMM1DvBv1IsR9dFfPvwHZYLYAaA/zyTsJBjrs95f1y4UP5e4HKz2YtlNKzrbAG2dC9eZIyXomAVJT8rWOPpxt9T3iI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765195846; c=relaxed/simple; bh=CqnLgM9bxGlrVxyPzoFh+1bkpkx8bpzOqL+eTMygvt0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BOjARUu+2DtyQfClwCRqn/P8ZWZLlWVLfHTUjkedZKYYfjSyKBUE50N5akXrjf+12yocB8u11M66RVoKoheKoIYaLFWroY8y++vjv+n0/Bjeiq0RJ9czaJzEQzqxpbl2uoST/bT7DVR0NV7OCZue5yhY3O1zAzoVZzH8fx2jw0g= 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=JxYutkVP; 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="JxYutkVP" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1765195843; 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=H4kcdoSw7LDS9+yf8C2Tt+DzBl7/RT2q80T0a13WnlE=; b=JxYutkVPyOPP5opqr+aMfdfZNKJHp2pEXoxiAvMl4m41p6OBM1LmWNxBy/S/TpxqUb6URP PfZKeQVSMYVA935SUN+rQvMkdJDNiIq21C+jllza6XW4bB/qLx5TUTANOLB8YXPeWFoF4h AXOi+smClTdLPFssP5m+go+FcVkJzds= 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-618-NPV6KeqjMjW1Oqy3pjOVkA-1; Mon, 08 Dec 2025 07:10:40 -0500 X-MC-Unique: NPV6KeqjMjW1Oqy3pjOVkA-1 X-Mimecast-MFC-AGG-ID: NPV6KeqjMjW1Oqy3pjOVkA_1765195839 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 21E1B18001D7; Mon, 8 Dec 2025 12:10:39 +0000 (UTC) Received: from pasta.fast.eng.rdu2.dc.redhat.com (unknown [10.44.34.3]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id EC7F41956095; Mon, 8 Dec 2025 12:10:35 +0000 (UTC) From: Andreas Gruenbacher To: Christoph Hellwig , Jens Axboe , Chris Mason , David Sterba 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 03/12] bio: add bio_set_errno Date: Mon, 8 Dec 2025 12:10:10 +0000 Message-ID: <20251208121020.1780402-4-agruenba@redhat.com> In-Reply-To: <20251208121020.1780402-1-agruenba@redhat.com> References: <20251208121020.1780402-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.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" Add a bio_set_errno(bio, errno) helper that sets bio->bi_status to errno_to_blk_status(errno) if errno !=3D 0. Replace instances of this pattern in the code with a call to the new helper. The WRITE_ONCE() in bio_set_errno() ensures that the compiler won't reorder things in a weird way, but it isn't needed to prevent tearing because a single-byte field like bi_status cannot tear. Created with Coccinelle using the following semantic patch: @@ struct bio *bio; expression errno; @@ - if (errno) - bio->bi_status =3D errno_to_blk_status(errno); + bio_set_errno(bio, errno); @@ struct bio *bio; expression errno; @@ - if (unlikely(errno)) - bio->bi_status =3D errno_to_blk_status(errno); + bio_set_errno(bio, errno); Signed-off-by: Andreas Gruenbacher --- drivers/block/drbd/drbd_req.c | 3 +-- drivers/nvdimm/pmem.c | 3 +-- include/linux/bio.h | 8 ++++++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/block/drbd/drbd_req.c b/drivers/block/drbd/drbd_req.c index d15826f6ee81..bd4bc882cc5a 100644 --- a/drivers/block/drbd/drbd_req.c +++ b/drivers/block/drbd/drbd_req.c @@ -176,8 +176,7 @@ void start_new_tl_epoch(struct drbd_connection *connect= ion) 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_errno(m->bio, m->error); bio_endio(m->bio); dec_ap_bio(device); } diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index 05785ff21a8b..a2f8b5a85326 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -232,8 +232,7 @@ static void pmem_submit_bio(struct bio *bio) if (bio->bi_opf & REQ_FUA) ret =3D nvdimm_flush(nd_region, bio); =20 - if (ret) - bio->bi_status =3D errno_to_blk_status(ret); + bio_set_errno(bio, ret); =20 bio_endio(bio); } diff --git a/include/linux/bio.h b/include/linux/bio.h index 16c1c85613b7..38ebf03036cb 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -389,6 +389,14 @@ static inline void bio_wouldblock_error(struct bio *bi= o) bio_endio(bio); } =20 +blk_status_t errno_to_blk_status(int errno); + +static inline void bio_set_errno(struct bio *bio, int errno) +{ + if (errno) + WRITE_ONCE(bio->bi_status, errno_to_blk_status(errno)); +} + /* * Calculate number of bvec segments that should be allocated to fit data * pointed by @iter. If @iter is backed by bvec it's going to be reused --=20 2.51.0 From nobody Fri Dec 19 09:54:50 2025 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 0F5892EFDAD for ; Mon, 8 Dec 2025 12:10:49 +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=1765195852; cv=none; b=UmxqZK/tSX7iAbbW785O7DPyr0w+91H9ne/sSUx/FVM4gGg/mWl8DQuFkRswevY0DtFkCEES7GK+wa+FXvRWLRp5WUFcDSVPs99/ac6Id1TkjYGjyafWlIa0QY45MQiZFcVUrLVD/GVIWnLuryNImJNlxNWPEz1x7+iuwitGOac= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765195852; c=relaxed/simple; bh=HpnV20rr6ndnsBiMksVhcGhycFoozLiEWv42W/MgAIM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eucwMy+dbRcw0UB3wOFR+ijBo2Bxo68H2TyfFvxdcBXaDhdSr0OfvNsWDLRfCdYqMu+4y3VphvbIV9nYkhnCF0vcT8qqRWBMDHerDRhU8gu5RC/a2Rlr73ZmUbFHMMmB1levsQFazQpQZM3oAHeFZQZ3r0L0TU8FZ0FvlQ3peUk= 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=U/Q+Csy3; 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="U/Q+Csy3" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1765195849; 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=llhA/XktVdHDQw9IcSMkZaUbOu3Kj1S2mlzAS2mLG5s=; b=U/Q+Csy3vjx9Q+Je/3DzRSifPehkYNoMqjqL0PF58H1jaq8PcL/jFCgzDYHPYQCu4GVIem dxOq9ICyz95Nnc9NI6UlGxRMRDtH/rdpI+8fjb8kdadHoj/dUuyws6Bzkbh2p1O9JRwbSP XWrP7flehUNyO8EuFzXZ5OmctiHcwtM= 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-179--W1j2S5LOy2mP-0qp13q-Q-1; Mon, 08 Dec 2025 07:10:44 -0500 X-MC-Unique: -W1j2S5LOy2mP-0qp13q-Q-1 X-Mimecast-MFC-AGG-ID: -W1j2S5LOy2mP-0qp13q-Q_1765195843 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 ACFEE18002F7; Mon, 8 Dec 2025 12:10:42 +0000 (UTC) Received: from pasta.fast.eng.rdu2.dc.redhat.com (unknown [10.44.34.3]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9A4101956095; Mon, 8 Dec 2025 12:10:39 +0000 (UTC) From: Andreas Gruenbacher To: Christoph Hellwig , Jens Axboe , Chris Mason , David Sterba 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 04/12] bio: use bio_set_errno in more places Date: Mon, 8 Dec 2025 12:10:11 +0000 Message-ID: <20251208121020.1780402-5-agruenba@redhat.com> In-Reply-To: <20251208121020.1780402-1-agruenba@redhat.com> References: <20251208121020.1780402-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.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" Replace variations of 'bio->bi_status =3D errno_to_blk_status(errno)' with a call to bio_set_errno(bio, errno). Note that bio_set_errno(bio, errno) only sets bio->bi_status to errno_to_blk_status(errno) if errno is not 0. We must never set bio->bi_status to 0 during bio completion. Also note that bio_set_errno() is an inline function so that the compiler can get rid of the errno check in case it knows that errno is not 0. This is true for all bio_set_errno() calls this patch adds except for the following two: drivers/md/dm-pcache/dm_pcache.c:end_req() drivers/md/dm-vdo/data-vio.c:acknowledge_data_vio() In both of these cases, it seems that bi_status can be set to 0 during bio completion, so the additional check that comes with using bio_set_errno() appears to be necessary. Created with Coccinelle using the following semantic patch: @@ struct bio *bio; expression errno; @@ - bio->bi_status =3D errno_to_blk_status(errno); + bio_set_errno(bio, errno); @@ struct bio bio; expression errno; @@ - bio.bi_status =3D errno_to_blk_status(errno); + bio_set_errno(&bio, errno); @@ struct iomap_ioend *ioend; expression error; @@ - ioend->io_bio.bi_status =3D errno_to_blk_status(error); + bio_set_errno(&ioend->io_bio, error); Signed-off-by: Andreas Gruenbacher --- block/blk-merge.c | 4 ++-- drivers/md/dm-ebs-target.c | 2 +- drivers/md/dm-integrity.c | 8 ++++---- drivers/md/dm-pcache/dm_pcache.c | 2 +- drivers/md/dm-thin.c | 2 +- drivers/md/dm-vdo/data-vio.c | 2 +- drivers/md/raid10.c | 4 ++-- drivers/nvdimm/btt.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/fileio.c | 2 +- fs/erofs/fscache.c | 4 ++-- fs/iomap/ioend.c | 2 +- fs/xfs/xfs_aops.c | 2 +- fs/xfs/xfs_zone_alloc.c | 2 +- 17 files changed, 24 insertions(+), 24 deletions(-) diff --git a/block/blk-merge.c b/block/blk-merge.c index 37864c5d287e..441013bf59d7 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_errno(bio, 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_errno(bio, split_sectors); bio_endio(bio); return NULL; } diff --git a/drivers/md/dm-ebs-target.c b/drivers/md/dm-ebs-target.c index 6abb31ca9662..d9f46cbfe89f 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_errno(bio, r); } =20 /* diff --git a/drivers/md/dm-integrity.c b/drivers/md/dm-integrity.c index 170bf67a2edd..26e500730b3c 100644 --- a/drivers/md/dm-integrity.c +++ b/drivers/md/dm-integrity.c @@ -1581,7 +1581,7 @@ static void do_endio(struct dm_integrity_c *ic, struc= t bio *bio) =20 r =3D dm_integrity_failed(ic); if (unlikely(r) && !bio->bi_status) - bio->bi_status =3D errno_to_blk_status(r); + bio_set_errno(bio, r); if (unlikely(ic->synchronous_mode) && bio_op(bio) =3D=3D REQ_OP_WRITE) { unsigned long flags; =20 @@ -2594,7 +2594,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_errno(bio, PTR_ERR(bip)); bio_endio(bio); return DM_MAPIO_SUBMITTED; } @@ -2662,7 +2662,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_errno(bio, PTR_ERR(bip)); bio_endio(bio); return; } @@ -2680,7 +2680,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_errno(bio, r); bio_endio(bio); return; } diff --git a/drivers/md/dm-pcache/dm_pcache.c b/drivers/md/dm-pcache/dm_pca= che.c index e5f5936fa6f0..4acfaab91170 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_errno(bio, ret); bio_endio(bio); =20 if (atomic_dec_and_test(&pcache->inflight_reqs)) diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c index c84149ba4e38..ad6b8b3c12dd 100644 --- a/drivers/md/dm-thin.c +++ b/drivers/md/dm-thin.c @@ -423,7 +423,7 @@ static void end_discard(struct discard_op *op, int r) * need to wait for. */ if (r && !op->parent_bio->bi_status) - op->parent_bio->bi_status =3D errno_to_blk_status(r); + bio_set_errno(op->parent_bio, r); bio_endio(op->parent_bio); } =20 diff --git a/drivers/md/dm-vdo/data-vio.c b/drivers/md/dm-vdo/data-vio.c index 262e11581f2d..eaa435dd8e60 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_errno(bio, error); bio_endio(bio); } =20 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 14dcd5142eb4..9ac26d1f0764 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -1665,7 +1665,7 @@ 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_errno(bio, PTR_ERR(split)); bio_endio(bio); return 0; } @@ -1682,7 +1682,7 @@ 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_errno(bio, PTR_ERR(split)); bio_endio(bio); return 0; } diff --git a/drivers/nvdimm/btt.c b/drivers/nvdimm/btt.c index a933db961ed7..14a8b7622b0d 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_errno(bio, err); break; } } diff --git a/fs/btrfs/bio.c b/fs/btrfs/bio.c index 21df48e6c4fa..a0f55591fb90 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_errno(&async->bbio->bio, ret); } =20 /* diff --git a/fs/btrfs/direct-io.c b/fs/btrfs/direct-io.c index 802d4dbe5b38..d47c72abcdc3 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_errno(bio, ret); iomap_dio_bio_end_io(bio); return; } diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c index 0135dceb7baa..ff802b6513af 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_errno(bio, 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_errno(bio, PTR_ERR(rbio)); bio_endio(bio); return; } diff --git a/fs/crypto/bio.c b/fs/crypto/bio.c index 5f5599020e94..96977fb5eb1d 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_errno(bio, err); return false; } } diff --git a/fs/erofs/fileio.c b/fs/erofs/fileio.c index b7b3432a9882..0478243ca72e 100644 --- a/fs/erofs/fileio.c +++ b/fs/erofs/fileio.c @@ -33,7 +33,7 @@ static void erofs_fileio_ki_complete(struct kiocb *iocb, = long ret) } if (rq->bio.bi_end_io) { if (ret < 0 && !rq->bio.bi_status) - rq->bio.bi_status =3D errno_to_blk_status(ret); + bio_set_errno(&rq->bio, ret); rq->bio.bi_end_io(&rq->bio); } else { bio_for_each_folio_all(fi, &rq->bio) { diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c index 362acf828279..dc0790d08510 100644 --- a/fs/erofs/fscache.c +++ b/fs/erofs/fscache.c @@ -184,7 +184,7 @@ 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); + bio_set_errno(&io->bio, 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 +215,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_errno(bio, ret); bio->bi_end_io(bio); } =20 diff --git a/fs/iomap/ioend.c b/fs/iomap/ioend.c index b49fa75eab26..67cd48180fb2 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_errno(&ioend->io_bio, error); bio_endio(&ioend->io_bio); return error; } diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c index a26f79815533..61368223a069 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_errno(&ioend->io_bio, error); bio_endio(&ioend->io_bio); return error; } diff --git a/fs/xfs/xfs_zone_alloc.c b/fs/xfs/xfs_zone_alloc.c index ef7a931ebde5..1381ba5a878e 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_errno(&ioend->io_bio, PTR_ERR(split)); out_error: bio_io_error(&ioend->io_bio); } --=20 2.51.0 From nobody Fri Dec 19 09:54:50 2025 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 2BDAE2F39AD for ; Mon, 8 Dec 2025 12:10:54 +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=1765195855; cv=none; b=RV5WaLlMr0cD951RPTGKaRhDhkMkLPypO95cOoE6CSVVzVzGbX/+Bz9JpgqAuJxVzcxWv02C/SueP4GNSNlvLD/a9Tdo9KyVqKxAM3x42lsOEaIjKlgh92Ju6xdd2JBR4vu3M+dD+fHXqPT4PxjfDbeSvRMRKXPkjJab8Jzx9Ls= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765195855; c=relaxed/simple; bh=u8WVF7+TSibqALZYK0Rishqre6CUPToFoFVRzvaGMlo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=t5PmnAMLnICClMoJKvjrrxuszjGc4wZOyAGYBG2tiDn9zUahdIDjWkymaPH7tfc3QO2pXK5EGlY4KD7j7OC7tGL79/w7SPordSVuNxHkouu/P1hcA6WkNySNyF3TFNVZZQBkYQZGpT/BfqqbsWYD6uJlhuttG2tiuMSX94T1/Nw= 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=WL44Ks9P; 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="WL44Ks9P" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1765195853; 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=2aK6rSpeP7OmuKpy2WC08z3GtDIuL7UgtM7KA4SREDM=; b=WL44Ks9Pxxm1/PbJa1bFNk40rJvkkWBh6TQsctBPxxFpi0P37mRLg15wL7GXE2qC3ew/BX ZX+52ktisDm42IizxnzWj0M2jSep2ThY7ZWXxPs1mpssvi0MjvJzjPUrLI1zoeY4VGL1qX tFMp86lsFJcBJ7w1xhDj96wiYfOmvt4= 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-182-agrsE-LaMz-Nq-br0QCQKQ-1; Mon, 08 Dec 2025 07:10:47 -0500 X-MC-Unique: agrsE-LaMz-Nq-br0QCQKQ-1 X-Mimecast-MFC-AGG-ID: agrsE-LaMz-Nq-br0QCQKQ_1765195846 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 6228318002DE; Mon, 8 Dec 2025 12:10:46 +0000 (UTC) Received: from pasta.fast.eng.rdu2.dc.redhat.com (unknown [10.44.34.3]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 30AF71956095; Mon, 8 Dec 2025 12:10:42 +0000 (UTC) From: Andreas Gruenbacher To: Christoph Hellwig , Jens Axboe , Chris Mason , David Sterba 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 05/12] bio: add bio_set_status Date: Mon, 8 Dec 2025 12:10:12 +0000 Message-ID: <20251208121020.1780402-6-agruenba@redhat.com> In-Reply-To: <20251208121020.1780402-1-agruenba@redhat.com> References: <20251208121020.1780402-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.0 on 10.30.177.17 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 it isn't needed to prevent tearing because a single-byte field like bi_status cannot tear. Created with Coccinelle using the following semantic patch: @@ struct bio *bio; expression status; @@ - if (status) - bio->bi_status =3D status; + bio_set_status(bio, status); @@ struct bio *bio; expression status; @@ - if (unlikely(status)) - bio->bi_status =3D status; + bio_set_status(bio, status); Signed-off-by: Andreas Gruenbacher --- block/blk-mq.c | 3 +-- drivers/md/dm.c | 3 +-- include/linux/bio.h | 6 ++++++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index d626d32f6e57..bc837aa51daa 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -969,8 +969,7 @@ bool blk_update_request(struct request *req, blk_status= _t error, struct bio *bio =3D req->bio; 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; 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/include/linux/bio.h b/include/linux/bio.h index 38ebf03036cb..bf4df0b15ee1 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -376,6 +376,12 @@ void submit_bio(struct bio *bio); =20 extern void bio_endio(struct bio *); =20 +static inline void bio_set_status(struct bio *bio, blk_status_t status) +{ + if (status) + WRITE_ONCE(bio->bi_status, status); +} + static inline void bio_io_error(struct bio *bio) { bio->bi_status =3D BLK_STS_IOERR; --=20 2.51.0 From nobody Fri Dec 19 09:54:50 2025 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 5A5D52F1FD2 for ; Mon, 8 Dec 2025 12:10:56 +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=1765195858; cv=none; b=cMkKwjI5eloYAuaUAgtjegdDp+43MR8A8hKU4shU6RUTTD/Isw8dUF3U4oxi9iqYm7+GfKTomFtK/Iw1AtsHBFf7s0m3nPOKjyUKec735BHC9Lxbh/bdGtz0x85DSWFPlmhxNpDXoIwN3spMxnSpk8oc800f5B8EdvF4GMtQtCs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765195858; c=relaxed/simple; bh=/aqHmXm55QFzeqqO0MQ4tbyjsLlvwpwSXuw6KXp6ixY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=omBX+CUcku3d/HcjuOw+EN5LEstT8pHTAd5jAEGCO+daMvZmX/pku14CxSyGKlRq3murfOaQnj9RsTAI97FprW/T/pHDqqu5ayc+wM0RzvAyqBhVf+hPgXvvrptttoKRhvrMRP895GDC+A9qua5jpIEwVeNeAQrBQ7MOwr9nhu4= 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=gp53x1kL; 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="gp53x1kL" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1765195855; 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=orAO8UOdnlISH4Gd5iJpe1BuLdmoObqRmnQqdm1Ndjk=; b=gp53x1kLyU5VJDheNij/qtZshmlebfK0Zd9i0eq+/HoYcsRG/qkgBbAiifv+J23xidHsPP KQz0a8zfQH6+wDKdlV/bMn0fazK3QyaLsUOZZ5dXbMZClbFanHkvxrQBAB4pldIAz7UtP5 GyKS8S6BM2Daix19OuV3eHVjcnox6zI= 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-619-7VcLxnpTOg62OUOHeS6ngg-1; Mon, 08 Dec 2025 07:10:52 -0500 X-MC-Unique: 7VcLxnpTOg62OUOHeS6ngg-1 X-Mimecast-MFC-AGG-ID: 7VcLxnpTOg62OUOHeS6ngg_1765195850 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 94EF618002C0; Mon, 8 Dec 2025 12:10:50 +0000 (UTC) Received: from pasta.fast.eng.rdu2.dc.redhat.com (unknown [10.44.34.3]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2B8731956095; Mon, 8 Dec 2025 12:10:46 +0000 (UTC) From: Andreas Gruenbacher To: Christoph Hellwig , Jens Axboe , Chris Mason , David Sterba 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 06/12] bio: don't check target->bi_status on error Date: Mon, 8 Dec 2025 12:10:13 +0000 Message-ID: <20251208121020.1780402-7-agruenba@redhat.com> In-Reply-To: <20251208121020.1780402-1-agruenba@redhat.com> References: <20251208121020.1780402-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.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" In a few places, target->bi_status is set to source->bi_status only if source->bi_status is not 0 and target->bi_status is (still) 0. Here, checking the value of target->bi_status before setting it is an unnecessary micro optimization because we are already on an error path. In addition, we can be racing with other execution contexts in the case of chained bios, so there is no guarantee that target->bi_status won't be set concurrently. We don't require atomic test-and-set semantics here. Created with Coccinelle using the following semantic patch: @@ struct bio *source; struct bio *target; @@ - if (source->bi_status && !target->bi_status) - target->bi_status =3D source->bi_status; + bio_set_status(target, source->bi_status); @@ struct bio *source; struct bio target; @@ - if (source->bi_status && !target.bi_status) - target.bi_status =3D source->bi_status; + bio_set_status(&target, source->bi_status); Signed-off-by: Andreas Gruenbacher --- block/bio.c | 3 +-- block/fops.c | 3 +-- drivers/md/md.c | 6 ++---- 3 files changed, 4 insertions(+), 8 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/md.c b/drivers/md/md.c index 41c476b40c7a..f6f1aab18a8b 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.51.0 From nobody Fri Dec 19 09:54:50 2025 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 C90442F12D1 for ; Mon, 8 Dec 2025 12:10:58 +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=1765195861; cv=none; b=ad/+j2XCgFZu32LDYgiJbOV8MgSvgcNnpN+4Mc/M0PT7Mo2+7V6uiqn7DqsELk9JTavuPIngudl/EFUCzoBQWgeLbsQxgkTrCqjrDJJ/GmmyILSXT4V6kMan/DUmngmKE3opMwOqogAtKuItUAquCyouDvgA8buiQFqfrQbjEs4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765195861; c=relaxed/simple; bh=jdN3zclU3525rrr0JBy1+Jm0EVFmOArFoOHlgTydJf0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aR25Lxqo6CQOJg3NzPBRAfjnT8eCXs1+aRMtJHTCCF2PwsvP+ywsZn2hrnVycwPR83MfX8hnxKPuqLZszvUQkr/xarCyJmW0gK5FHO4gX6iyJi0CW5SuQBMSfWxlIqCo9CjZdJzuQRG83VTaup+ylLFG1yd1t7/jQanausO0Ils= 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=ZXshhEzo; 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="ZXshhEzo" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1765195857; 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=PryfkEachwkf3jXEOfd1/qHxkXJoX+SFtYslbEvBn6o=; b=ZXshhEzoE0D5uNQZSEHMV+9HYw3yCJ6z+Kl22Oucno1dPxgh21yf/Mj4FJab2vyDj+202j /n96V/7Qw8iFYVVgvYC6l5kRxs0kG/f/JU974XH3YNzB8lmJUvnnzrnSUkAQw7flPsesk1 vnPZo5g04xXY5hBGubnOytYg6Anv1dg= 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-167-I4_CTspuMI-YGZugFqzx9w-1; Mon, 08 Dec 2025 07:10:56 -0500 X-MC-Unique: I4_CTspuMI-YGZugFqzx9w-1 X-Mimecast-MFC-AGG-ID: I4_CTspuMI-YGZugFqzx9w_1765195854 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 C09801956058; Mon, 8 Dec 2025 12:10:54 +0000 (UTC) Received: from pasta.fast.eng.rdu2.dc.redhat.com (unknown [10.44.34.3]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 198E71956095; Mon, 8 Dec 2025 12:10:50 +0000 (UTC) From: Andreas Gruenbacher To: Christoph Hellwig , Jens Axboe , Chris Mason , David Sterba 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 07/12] bio: use bio_set_status for BLK_STS_* status codes Date: Mon, 8 Dec 2025 12:10:14 +0000 Message-ID: <20251208121020.1780402-8-agruenba@redhat.com> In-Reply-To: <20251208121020.1780402-1-agruenba@redhat.com> References: <20251208121020.1780402-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.0 on 10.30.177.17 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: @@ expression 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 | 2 +- fs/f2fs/data.c | 6 +++--- fs/verity/verify.c | 2 +- include/linux/bio.h | 4 ++-- 27 files changed, 59 insertions(+), 58 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 86b27f96051a..0e135ba26346 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 bc837aa51daa..4e13d9f9ea96 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -979,7 +979,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 */ @@ -3164,7 +3164,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 bd4bc882cc5a..95a58ad6fdcf 100644 --- a/drivers/block/drbd/drbd_req.c +++ b/drivers/block/drbd/drbd_req.c @@ -1142,7 +1142,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 @@ -1210,7 +1210,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 a10d75a562db..82d748eeb9aa 100644 --- a/drivers/md/dm-cache-target.c +++ b/drivers/md/dm-cache-target.c @@ -1192,7 +1192,8 @@ static void mg_complete(struct dm_cache_migration *mg= , bool success) else if (mg->k.input) mg->overwrite_bio->bi_status =3D 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) @@ -1854,7 +1855,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 26e500730b3c..d2288b9f2b0d 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 ad6b8b3c12dd..bd061a6bf016 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 f6f1aab18a8b..5afc6d63aa7b 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 9ac26d1f0764..62d5bc9f7b3e 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 14a8b7622b0d..a624bc9aa699 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 a0f55591fb90..00a7a13fab0c 100644 --- a/fs/btrfs/bio.c +++ b/fs/btrfs/bio.c @@ -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 bf4df0b15ee1..ad70a88cef09 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -384,14 +384,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.51.0 From nobody Fri Dec 19 09:54:50 2025 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 3628330FF36 for ; Mon, 8 Dec 2025 12:11:04 +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=1765195866; cv=none; b=UBvuAvPON85xXiUbArViQlQP0AzsnuMumX3j2eU+IvVMFWS0IXnLhGoeicQ4SG6EmixhEp37OfgFjAh711SijKLdLLFGBtXFBO0VYs95Wb09xbMYJpTEEu9KIZwo1vTIOi08JgvSBAcS2sXaOZV6n0WIBe4acftQduOXAbBDi8c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765195866; c=relaxed/simple; bh=sfhgXzszb3rbFgkWYul9C/4xAy/evRh0yzt6XOLy8uM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=V8K8qAFBXwIdzJnXgaEk0RRh6CIIk9BchzMKBpGkN+RXapn/mMK8dMiWGmMeuMxD8AhKoGuIuWKH36THT7QR3ZAzS/8g52CX8xTdvfCWxjV1IYLYha+NPSJdlwO2iQf9Kpj2nZcVilu1YeJ+WnTqWWU+OJ8ClV1Gj56Hgk5RSI0= 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=Qq7eaqMi; 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="Qq7eaqMi" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1765195863; 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=5xW1lJxzmKLAFtrC3EebAHHT/dFnpbfuFBCBcpMhy1w=; b=Qq7eaqMidv5VXKqXZ3QvdfqZeLzD9IGV+SWeyYjcJ7PUKbRb3EWQgdO9CCtwUvo57Ib1LS oniGGggBvtFeS0dH1mZ99iTkmeECzo+FEwQo5JSv8Kv1kHfg/zKQeDGw8dlsHTAs/vQKcB Kxll/w1LtYu3jW63Gxw+kLIoWR8UNd4= 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-590-APg6rgGfMN-B-RkeX6zkxg-1; Mon, 08 Dec 2025 07:10:59 -0500 X-MC-Unique: APg6rgGfMN-B-RkeX6zkxg-1 X-Mimecast-MFC-AGG-ID: APg6rgGfMN-B-RkeX6zkxg_1765195858 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 5749619560A7; Mon, 8 Dec 2025 12:10:58 +0000 (UTC) Received: from pasta.fast.eng.rdu2.dc.redhat.com (unknown [10.44.34.3]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 44DEE1956095; Mon, 8 Dec 2025 12:10:55 +0000 (UTC) From: Andreas Gruenbacher To: Christoph Hellwig , Jens Axboe , Chris Mason , David Sterba 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 08/12] bio: use bio_set_status in some more places Date: Mon, 8 Dec 2025 12:10:15 +0000 Message-ID: <20251208121020.1780402-9-agruenba@redhat.com> In-Reply-To: <20251208121020.1780402-1-agruenba@redhat.com> References: <20251208121020.1780402-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.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" In these places, the status is known not to be BLK_STS_OK (0), so the 'status !=3D BLK_STS_OK' check in bio_set_status() will be optimized out and we end up with identical code. Signed-off-by: Andreas Gruenbacher --- block/blk-crypto-fallback.c | 4 ++-- block/blk-mq.c | 2 +- block/t10-pi.c | 2 +- drivers/md/dm-cache-target.c | 3 ++- drivers/md/dm-integrity.c | 2 +- drivers/md/dm-zoned-target.c | 2 +- drivers/nvdimm/pmem.c | 2 +- fs/btrfs/bio.c | 4 ++-- 8 files changed, 11 insertions(+), 10 deletions(-) diff --git a/block/blk-crypto-fallback.c b/block/blk-crypto-fallback.c index 0e135ba26346..8a2631b1e7e1 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 4e13d9f9ea96..503ca259429f 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -3205,7 +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->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 82d748eeb9aa..d1dbd4ddaadb 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 bio_set_status(mg->overwrite_bio, BLK_STS_IOERR); diff --git a/drivers/md/dm-integrity.c b/drivers/md/dm-integrity.c index d2288b9f2b0d..5220e15b6537 100644 --- a/drivers/md/dm-integrity.c +++ b/drivers/md/dm-integrity.c @@ -1617,7 +1617,7 @@ static void dec_in_flight(struct dm_integrity_io *dio) =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..d0218a9f1c4f 100644 --- a/drivers/md/dm-zoned-target.c +++ b/drivers/md/dm-zoned-target.c @@ -78,7 +78,7 @@ static inline void dmz_bio_endio(struct bio *bio, blk_sta= tus_t status) 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/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index a2f8b5a85326..aa2a486522b5 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/fs/btrfs/bio.c b/fs/btrfs/bio.c index 00a7a13fab0c..a63d69509d05 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 --=20 2.51.0 From nobody Fri Dec 19 09:54:50 2025 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 C3E2E313523 for ; Mon, 8 Dec 2025 12:11:06 +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=1765195868; cv=none; b=i+imnK0Gd9lEtP9RSOCksyQ5LjHOfMRYLVzbRaplRm20RiH0xTlNFgkWG1xKaUCr2lQm8c3FYLef+mYmleGn7f8zzNFYI5PIBp/bv6n4zyF59k8qY5nnFe9H350AQEqLSCh8GnOJdXiR2MWcYYKoRZ1HaZCVKjSr5Jc2hMu3x4A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765195868; c=relaxed/simple; bh=VlZgUuAKsZkQhKNfzcqI5wh1dvmrS6O//2iahLfBSA0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=i69a94mPElrQ6+pyLhuIfH7/yQaSZY1aXwQgHDwrZCEoTkXB2dQTFGO1syfx4isK2h4ksCM5bwBYdax/lyjUmxPG3zS9oZhwYhMsjZba28/SgDk7MGRaFx5yIPD5iadQ6zh1FXqv0d6K93Y2Q6pULXwj0CjX2Kth5H2ApJq6XRY= 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=BSf8GbHY; 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="BSf8GbHY" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1765195865; 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=+3g+DHtAfN0xhOXLyepP76BJ3LQslId9qvhKNR5qEE4=; b=BSf8GbHY6YBE/XlA8Jjp7eDgZGIBPAV+pUg8gT393MGWc16NBvJUr7ckShokbnLBxW8rMk Rw80mT3gfLNolutn6j8PS2+6Te1Mfieh0Bxi2+u2SDuUpTg81Yzm9dUlvTZuQPqBJrTrtN DXQJk2AdDXskgx8YnMih8WRelBIuubQ= 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-316-YOFxhWDIMl2j-uVaNl9jVg-1; Mon, 08 Dec 2025 07:11:03 -0500 X-MC-Unique: YOFxhWDIMl2j-uVaNl9jVg-1 X-Mimecast-MFC-AGG-ID: YOFxhWDIMl2j-uVaNl9jVg_1765195862 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 ECE9518001C6; Mon, 8 Dec 2025 12:11:01 +0000 (UTC) Received: from pasta.fast.eng.rdu2.dc.redhat.com (unknown [10.44.34.3]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id CFF1F1955F24; Mon, 8 Dec 2025 12:10:58 +0000 (UTC) From: Andreas Gruenbacher To: Christoph Hellwig , Jens Axboe , Chris Mason , David Sterba 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 09/12] bio: switch to bio_set_status in submit_bio_noacct Date: Mon, 8 Dec 2025 12:10:16 +0000 Message-ID: <20251208121020.1780402-10-agruenba@redhat.com> In-Reply-To: <20251208121020.1780402-1-agruenba@redhat.com> References: <20251208121020.1780402-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.0 on 10.30.177.17 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 4f7b7cf50d23..95cbb3ffcf9f 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -816,8 +816,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; } } } @@ -882,7 +882,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.51.0 From nobody Fri Dec 19 09:54:50 2025 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 95BBD3148C8 for ; Mon, 8 Dec 2025 12:11:12 +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=1765195874; cv=none; b=hDz8FuJmbMWdmtyiGmfDwD9dFlya7vC5TFEtvrCTGhbvJk4vnBLZknTOZNY3hrlAGdBy0J7l/4OcUpAeyVUv91RxVRsBL1jypNHzEI3bfH7TvboPfxif5GiOX8LXY+k33JbXrVbfnhaE3oezzvY7x74cckADCEQTRiS9EYfrN6w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765195874; c=relaxed/simple; bh=GktH5BhrqlijaASwtvaLDFNN70Mk65V1f3iWJUGdRYc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=drtAsM4keKJ74tE0l/jV90YgzwTsB918jz1DIOZfCgXh8j4/wuafqjhFX2KsZvfbBy2HPxoFvoxVIhu33sgb+nYpuwJx+ys0gNo5bCGKAY0+Wsm9jYvTzD2mnyZ0ebvMedWp//kzk2aLFCnDdtlIFC2SsmEwektLFV9CMswBMZ8= 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=LYyuHBJR; 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="LYyuHBJR" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1765195871; 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=0Gcq94rGzUJI4YaB9u7yri6cXo1is4655WtuewIwIxc=; b=LYyuHBJRA8ICTzF+ZwICZvAECdJSNlQuOA2QM1tBGS2dAAXILicu6tcj1anF8GXfnvwXEp amh0ejSfmsWmdEHxGXxrfXdJurq+OAo7QeTF7PDekf3fP46NSqytZ3nbyy27p3IBYh7dcL 12L6JpJehrh1ZxmqIobQ5Fsw3QUpLOM= 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-255-vtkiox6yPw2ZhUT3eM8_IA-1; Mon, 08 Dec 2025 07:11:07 -0500 X-MC-Unique: vtkiox6yPw2ZhUT3eM8_IA-1 X-Mimecast-MFC-AGG-ID: vtkiox6yPw2ZhUT3eM8_IA_1765195865 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 A2AC6180060D; Mon, 8 Dec 2025 12:11:05 +0000 (UTC) Received: from pasta.fast.eng.rdu2.dc.redhat.com (unknown [10.44.34.3]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 70DBB1956095; Mon, 8 Dec 2025 12:11:02 +0000 (UTC) From: Andreas Gruenbacher To: Christoph Hellwig , Jens Axboe , Chris Mason , David Sterba 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 10/12] bio: never set bi_status to BLK_STS_OK during completion Date: Mon, 8 Dec 2025 12:10:17 +0000 Message-ID: <20251208121020.1780402-11-agruenba@redhat.com> In-Reply-To: <20251208121020.1780402-1-agruenba@redhat.com> References: <20251208121020.1780402-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.0 on 10.30.177.17 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.51.0 From nobody Fri Dec 19 09:54:50 2025 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 0268E3148C7 for ; Mon, 8 Dec 2025 12:11:14 +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=1765195876; cv=none; b=ETTGRSoRDD1iIDO/MtqOJxODWP/AGHn9WhqIqf1yY7c2ZYxmQxs1fspIcF8yW6t+dryB7/BlDeYKwyvlfODKkHisuw7mCfw0g87TFIcEhL1w07MioAMab0cWwuihOTzius1A5d3hkqYjMHuwUeeuiZIDKoXl0ASjwK8h34NTKYs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765195876; c=relaxed/simple; bh=ma2lFAo3foTNL8GPuoOXvRCzcKPR+3yVB6nerqkNVQw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RNFtXWPYBcR9aBYc1Sn5+j62UrEdBddeIdQ+N4rdUxDVnjkVOaUgqphejX0+kTlM7NOpTlR3nRAZ0hOReZ8S8Z5Xa1uI82eq7TR3rGZSXnxat9xONeVRuTSJ3Q8MwlGghz71cvH+fl0mDEsk4I6nUMeclve3bCaDbmm8cpDrtO8= 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=L3ydiboy; 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="L3ydiboy" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1765195874; 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=K9u8cA7lHo2dE6Tv8kTZzAaXvgSUqTY3isgQdGmVBD0=; b=L3ydiboywHp00X1D6gUzttSRi9Ga3PSkYUVYsZROZHEp3Oea/yuxo39tAwCzKlsT+ibCVJ erQ6kg3tzX/Dg0T60G3Gn6GzKB6TzlKhsGm1BnBKJxr0Fgf5jpe7prBjuYoonjkN7I6kgh UslhAZXlRqx68F7iZw8pey99JXWpS2g= 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-477-Kgvi1fWfOVOg7obb1k2nbw-1; Mon, 08 Dec 2025 07:11:10 -0500 X-MC-Unique: Kgvi1fWfOVOg7obb1k2nbw-1 X-Mimecast-MFC-AGG-ID: Kgvi1fWfOVOg7obb1k2nbw_1765195869 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 1B6BE1956080; Mon, 8 Dec 2025 12:11:09 +0000 (UTC) Received: from pasta.fast.eng.rdu2.dc.redhat.com (unknown [10.44.34.3]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 088791955F24; Mon, 8 Dec 2025 12:11:05 +0000 (UTC) From: Andreas Gruenbacher To: Christoph Hellwig , Jens Axboe , Chris Mason , David Sterba 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 11/12] bio: add bio_endio_errno Date: Mon, 8 Dec 2025 12:10:18 +0000 Message-ID: <20251208121020.1780402-12-agruenba@redhat.com> In-Reply-To: <20251208121020.1780402-1-agruenba@redhat.com> References: <20251208121020.1780402-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.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" Add a bio_endio_errno() helper as a shortcut for calling bio_set_errno() and bio_endio() in sequence. Use the new helper throughout the code. Created with Coccinelle using the following semantic patch: @@ expression bio, errno; @@ - bio_set_errno(bio, errno); - bio_endio(bio); + bio_endio_errno(bio, errno); Signed-off-by: Andreas Gruenbacher --- block/blk-merge.c | 6 ++---- drivers/block/drbd/drbd_req.c | 3 +-- drivers/md/dm-integrity.c | 9 +++------ drivers/md/dm-pcache/dm_pcache.c | 3 +-- drivers/md/dm-vdo/data-vio.c | 3 +-- drivers/md/raid10.c | 6 ++---- drivers/nvdimm/pmem.c | 4 +--- fs/btrfs/raid56.c | 6 ++---- fs/iomap/ioend.c | 3 +-- fs/xfs/xfs_aops.c | 3 +-- include/linux/bio.h | 6 ++++++ 11 files changed, 21 insertions(+), 31 deletions(-) diff --git a/block/blk-merge.c b/block/blk-merge.c index 441013bf59d7..25057d57e9ac 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_errno(bio, PTR_ERR(split)); - bio_endio(bio); + bio_endio_errno(bio, 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_errno(bio, split_sectors); - bio_endio(bio); + bio_endio_errno(bio, split_sectors); return NULL; } =20 diff --git a/drivers/block/drbd/drbd_req.c b/drivers/block/drbd/drbd_req.c index 95a58ad6fdcf..5bedc972b622 100644 --- a/drivers/block/drbd/drbd_req.c +++ b/drivers/block/drbd/drbd_req.c @@ -176,8 +176,7 @@ void start_new_tl_epoch(struct drbd_connection *connect= ion) void complete_master_bio(struct drbd_device *device, struct bio_and_error *m) { - bio_set_errno(m->bio, m->error); - bio_endio(m->bio); + bio_endio_errno(m->bio, m->error); dec_ap_bio(device); } =20 diff --git a/drivers/md/dm-integrity.c b/drivers/md/dm-integrity.c index 5220e15b6537..90780a112009 100644 --- a/drivers/md/dm-integrity.c +++ b/drivers/md/dm-integrity.c @@ -2594,8 +2594,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_errno(bio, PTR_ERR(bip)); - bio_endio(bio); + bio_endio_errno(bio, PTR_ERR(bip)); return DM_MAPIO_SUBMITTED; } =20 @@ -2662,8 +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_set_errno(bio, PTR_ERR(bip)); - bio_endio(bio); + bio_endio_errno(bio, PTR_ERR(bip)); return; } =20 @@ -2680,8 +2678,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_errno(bio, r); - bio_endio(bio); + bio_endio_errno(bio, r); return; } bio_put(outgoing_bio); diff --git a/drivers/md/dm-pcache/dm_pcache.c b/drivers/md/dm-pcache/dm_pca= che.c index 4acfaab91170..b3795e88f364 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_errno(bio, ret); - bio_endio(bio); + bio_endio_errno(bio, ret); =20 if (atomic_dec_and_test(&pcache->inflight_reqs)) wake_up(&pcache->inflight_wq); diff --git a/drivers/md/dm-vdo/data-vio.c b/drivers/md/dm-vdo/data-vio.c index eaa435dd8e60..47827ea61d91 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_errno(bio, error); - bio_endio(bio); + bio_endio_errno(bio, error); } =20 static void copy_to_bio(struct bio *bio, char *data_ptr) diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 62d5bc9f7b3e..7cc27819beb5 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -1665,8 +1665,7 @@ 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_errno(bio, PTR_ERR(split)); - bio_endio(bio); + bio_endio_errno(bio, PTR_ERR(split)); return 0; } =20 @@ -1682,8 +1681,7 @@ 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_errno(bio, PTR_ERR(split)); - bio_endio(bio); + bio_endio_errno(bio, PTR_ERR(split)); return 0; } =20 diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index aa2a486522b5..ed763c1ec955 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -232,9 +232,7 @@ static void pmem_submit_bio(struct bio *bio) if (bio->bi_opf & REQ_FUA) ret =3D nvdimm_flush(nd_region, bio); =20 - bio_set_errno(bio, ret); - - bio_endio(bio); + bio_endio_errno(bio, ret); } =20 /* see "strong" declaration in tools/testing/nvdimm/pmem-dax.c */ diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c index ff802b6513af..bf45e8fd3aa1 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_errno(bio, PTR_ERR(rbio)); - bio_endio(bio); + bio_endio_errno(bio, 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_errno(bio, PTR_ERR(rbio)); - bio_endio(bio); + bio_endio_errno(bio, PTR_ERR(rbio)); return; } =20 diff --git a/fs/iomap/ioend.c b/fs/iomap/ioend.c index 67cd48180fb2..d9e9659b55b3 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_errno(&ioend->io_bio, error); - bio_endio(&ioend->io_bio); + bio_endio_errno(&ioend->io_bio, error); return error; } =20 diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c index 61368223a069..4da13a15cb62 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_errno(&ioend->io_bio, error); - bio_endio(&ioend->io_bio); + bio_endio_errno(&ioend->io_bio, error); return error; } xfs_zone_alloc_and_submit(ioend, &XFS_ZWPC(wpc)->open_zone); diff --git a/include/linux/bio.h b/include/linux/bio.h index ad70a88cef09..06fb8ae018c4 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -403,6 +403,12 @@ static inline void bio_set_errno(struct bio *bio, int = errno) WRITE_ONCE(bio->bi_status, errno_to_blk_status(errno)); } =20 +static inline void bio_endio_errno(struct bio *bio, int errno) +{ + bio_set_errno(bio, errno); + bio_endio(bio); +} + /* * Calculate number of bvec segments that should be allocated to fit data * pointed by @iter. If @iter is backed by bvec it's going to be reused --=20 2.51.0 From nobody Fri Dec 19 09:54:50 2025 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 351BA314B9F for ; Mon, 8 Dec 2025 12:11:19 +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=1765195881; cv=none; b=iHdJe3tA1LLzkOjRnlMpbDP2eL9oE9BKV7ThB31gMcKqpmUWiB8jFjML+DxXUD+5471iTDE9pBjfDY+OmAW8esDMHuoHe85Q/xQpT1wVgEd67pIe7RJsbt3ogcvFj+JF1bQF3+nDVp49+KwOsMS6EgsJzJCiDlt4m5PjZ2qrvmA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765195881; c=relaxed/simple; bh=AjO5iyr3sycM8pkoxkFHi2j3JezglR+6at8iRF+LPlo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MmqExAqplgT51LMRGC0tUIZFGctmftdwXm421s8T04ZBrdwymYdJjHWqa6sUpkBbol2Br7DWgP5ajkShNvvmzwTjrL1M0FVtz4T9r0KJ6o65bRutaZWskGg8lltYxcUHdWB3TAxgHKrywxFf5APteX44HD+eSggjBUpysiFojnw= 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=bhIj1K+1; 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="bhIj1K+1" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1765195878; 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=vvXDl6FlzKKYicGNNkhEQN3ksEUv+vCfWRlQsDRp75M=; b=bhIj1K+1A2DFMdpRJpsuiIOmDN72rCiYE5cTg+BmZcptfPRXC/EXiFL84xUEIPkUISanlE JYPXgb9Pr1RH9kubCsqfjJyt2QmD+URuKGQ9bmRIlJsWEbRx4nuFn0Co5TpqBJ/d4y6hl8 +TEsyFycMZCQ19OiUnhs8VJ50I9Dqj8= 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-615-2pk4_5FGPfaZa_QA5J-5cw-1; Mon, 08 Dec 2025 07:11:14 -0500 X-MC-Unique: 2pk4_5FGPfaZa_QA5J-5cw-1 X-Mimecast-MFC-AGG-ID: 2pk4_5FGPfaZa_QA5J-5cw_1765195872 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 A7DA318002E4; Mon, 8 Dec 2025 12:11:12 +0000 (UTC) Received: from pasta.fast.eng.rdu2.dc.redhat.com (unknown [10.44.34.3]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 941921956095; Mon, 8 Dec 2025 12:11:09 +0000 (UTC) From: Andreas Gruenbacher To: Christoph Hellwig , Jens Axboe , Chris Mason , David Sterba 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 12/12] bio: add bio_endio_status Date: Mon, 8 Dec 2025 12:10:19 +0000 Message-ID: <20251208121020.1780402-13-agruenba@redhat.com> In-Reply-To: <20251208121020.1780402-1-agruenba@redhat.com> References: <20251208121020.1780402-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.0 on 10.30.177.17 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-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 | 15 +++++---------- drivers/md/dm-mpath.c | 3 +-- drivers/md/dm-raid1.c | 3 +-- drivers/md/dm-thin.c | 3 +-- drivers/md/dm.c | 3 +-- drivers/md/raid1-10.c | 3 +-- drivers/md/raid10.c | 6 ++---- include/linux/bio.h | 12 ++++++++---- 14 files changed, 28 insertions(+), 44 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 95cbb3ffcf9f..8b36674dc09a 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -640,8 +640,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); } @@ -882,8 +881,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-mq.c b/block/blk-mq.c index 503ca259429f..10933de73205 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -3164,8 +3164,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 @@ -3205,8 +3204,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 5bedc972b622..41dbf8bbcd61 100644 --- a/drivers/block/drbd/drbd_req.c +++ b/drivers/block/drbd/drbd_req.c @@ -1209,8 +1209,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 90780a112009..06e5cdfdec7d 100644 --- a/drivers/md/dm-integrity.c +++ b/drivers/md/dm-integrity.c @@ -2513,8 +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_set_status(bio, BLK_STS_NOTSUPP); - bio_endio(bio); + bio_endio_status(bio, BLK_STS_NOTSUPP); return DM_MAPIO_SUBMITTED; } =20 @@ -2535,8 +2534,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); @@ -2615,8 +2613,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 @@ -2668,8 +2665,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_set_status(bio, BLK_STS_RESOURCE); - bio_endio(bio); + bio_endio_status(bio, BLK_STS_RESOURCE); return; } =20 @@ -2691,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-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 bd061a6bf016..ae8850a3e728 100644 --- a/drivers/md/dm-thin.c +++ b/drivers/md/dm-thin.c @@ -2731,8 +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_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.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 7cc27819beb5..7750d6577b83 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -3681,8 +3681,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; } } @@ -4863,8 +4862,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/include/linux/bio.h b/include/linux/bio.h index 06fb8ae018c4..8f6ac5fa0a12 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -382,17 +382,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 blk_status_t errno_to_blk_status(int errno); --=20 2.51.0