From nobody Mon Feb 9 16:17:25 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8925723A562 for ; Sun, 21 Dec 2025 02:53:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766285606; cv=none; b=ARgW7uwQlOT0edFpWu4+h54iEUz95jeRKd/Qu8AViORdYL1yaKAKYE2aTGjdQxXsZESPBkwjdN7U8baK1HyrLezNcV0nv875Ibl1vYaM9wAnI8uRDH7+Uc3ABhKdMVipfXoLDJd9Y2dnQsGVa2joy5aVpcARBXn18efQ41Z/3vM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766285606; c=relaxed/simple; bh=HIqf22Ptud/9ac/5C/HAWxjPJyK8tFALQWxnuDFT/3Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ti7awi5d/+Wr1aKdRkhgXc9KWgM0o1X0Yz9QYO2KSlu+Va9+AbAo9N5SbONF1A1TCl2efQ4JRbAE/ho7vzOSFfoXT049RmKOkTQinAC45AAk68CwO1HC4YRZ7d918Iy424GOsAKbWEXe+sNC1kVaKszhboarOf6z9HAALKfn+Nk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=XhE2+em3; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="XhE2+em3" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1766285603; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5lqEV0d5M/MjlyxOPZzQUlj9JHGomOy6Eck36K06ymo=; b=XhE2+em3Its3xg8nUZ28OmtkuEKhHiVSDQe/qpBe8ZimT8YyqAcwtkS0Vo0+AVBjLM62g1 BBt7nsZK1Sy9aEGHcKBeN4Du4+jd0huS7UfB8AzBOSsLqLyFoNFwD6rbR6ITY8/fitvG8p yAt/R5IOoycLccph4yZGqw5HkvAzh4A= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-235-9DEeJGNpMOmGqmAAYZY70Q-1; Sat, 20 Dec 2025 21:53:17 -0500 X-MC-Unique: 9DEeJGNpMOmGqmAAYZY70Q-1 X-Mimecast-MFC-AGG-ID: 9DEeJGNpMOmGqmAAYZY70Q_1766285596 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 010051956050; Sun, 21 Dec 2025 02:53:16 +0000 (UTC) Received: from pasta.fast.eng.rdu2.dc.redhat.com (unknown [10.44.32.8]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id EEBD6180049F; Sun, 21 Dec 2025 02:53:12 +0000 (UTC) From: Andreas Gruenbacher To: Christoph Hellwig , Jens Axboe , Chris Mason , David Sterba , Satya Tangirala Cc: Andreas Gruenbacher , linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-raid@vger.kernel.org, dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [RFC v2 10/17] block: optimize blk_status <=> errno conversion Date: Sun, 21 Dec 2025 03:52:25 +0100 Message-ID: <20251221025233.87087-11-agruenba@redhat.com> In-Reply-To: <20251221025233.87087-1-agruenba@redhat.com> References: <20251221025233.87087-1-agruenba@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Content-Type: text/plain; charset="utf-8" Handle the errno_to_blk_status(0) case inline so that the compiler can optimize when it knows that errno is not 0. Likewise for blk_status_to_errno(BLK_STATUS_OK). Signed-off-by: Andreas Gruenbacher --- block/blk-core.c | 11 ++++++----- include/linux/blkdev.h | 18 ++++++++++++++++-- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index 9b3100d171b7..381bdf66045b 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -133,7 +133,6 @@ inline const char *blk_op_str(enum req_op op) EXPORT_SYMBOL_GPL(blk_op_str); =20 #define blk_errors(_) \ - _(BLK_STS_OK, 0, "") \ _(BLK_STS_NOTSUPP, -EOPNOTSUPP, "operation not supported") \ _(BLK_STS_TIMEOUT, -ETIMEDOUT, "timeout") \ _(BLK_STS_NOSPC, -ENOSPC, "critical space allocation") \ @@ -159,7 +158,7 @@ EXPORT_SYMBOL_GPL(blk_op_str); \ _(BLK_STS_INVAL, -EINVAL, "invalid") =20 -blk_status_t errno_to_blk_status(int errno) +blk_status_t __errno_to_blk_status(int errno) { switch(errno) { #define _(_status, _errno, _name) \ @@ -171,9 +170,9 @@ blk_status_t errno_to_blk_status(int errno) return BLK_STS_IOERR; } } -EXPORT_SYMBOL_GPL(errno_to_blk_status); +EXPORT_SYMBOL_GPL(__errno_to_blk_status); =20 -int blk_status_to_errno(blk_status_t status) +int __blk_status_to_errno(blk_status_t status) { switch(status) { #define _(_status, _errno, _name) \ @@ -185,11 +184,13 @@ int blk_status_to_errno(blk_status_t status) return -EIO; } } -EXPORT_SYMBOL_GPL(blk_status_to_errno); +EXPORT_SYMBOL_GPL(__blk_status_to_errno); =20 const char *blk_status_to_str(blk_status_t status) { switch(status) { + case BLK_STS_OK: + return ""; #define _(_status, _errno, _name) \ case _status: \ return _name; diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 70b671a9a7f7..a2451fbd53a8 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1011,8 +1011,22 @@ extern void blk_sync_queue(struct request_queue *q); /* Helper to convert REQ_OP_XXX to its string format XXX */ extern const char *blk_op_str(enum req_op op); =20 -int blk_status_to_errno(blk_status_t status); -blk_status_t errno_to_blk_status(int errno); +int __blk_status_to_errno(blk_status_t status); +static inline int blk_status_to_errno(blk_status_t status) +{ + if (status =3D=3D BLK_STS_OK) + return 0; + return __blk_status_to_errno(status); +} + +blk_status_t __errno_to_blk_status(int errno); +static inline blk_status_t errno_to_blk_status(int errno) +{ + if (errno =3D=3D 0) + return BLK_STS_OK; + return __errno_to_blk_status(errno); +} + const char *blk_status_to_str(blk_status_t status); =20 /* only poll the hardware once, don't continue until a completion was foun= d */ --=20 2.52.0