From nobody Sun Feb 8 05:42:10 2026 Received: from mail-pf1-f227.google.com (mail-pf1-f227.google.com [209.85.210.227]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4843F28A3F2 for ; Thu, 8 Jan 2026 17:22:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.227 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767892953; cv=none; b=QUxb88WJCdeAGMLXKTdfNLyGALe1qEUjTOzx+F1RT3Z6C/RFL6OK0qJPJl6i71GpuZoCHIvM0gY6duiw9evVkVDSS9/hWJx3Cb8zU7rbfSZpgtgSiC62HsdbUgKRnkaKLVWb2mpDWgEXMM+Wu6a9W7iD8ZUkxyJGyQvXSeO73X0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767892953; c=relaxed/simple; bh=CckKC6RZ+oPaTv9HyFuTRMTDCyj+fC6YhxQ/fz2Myrs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=H7nodWsRy86s3Gciy1ktMuSLzXl4Lg9RkUy2BzQDgMaYrBaU8+6HjjCFM1gd2r+TqXKJRumtWaNeMnRQF5ySdp/dIhMhaelcW2/YfuUVgSS3fQGbMQv5bwfWGMkikzsIHj6sLHLYKsZ1Lhjt2k+ZcyLnkkMnSGYg+q6jR0nDbKg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com; spf=fail smtp.mailfrom=purestorage.com; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b=AiP22DXU; arc=none smtp.client-ip=209.85.210.227 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=purestorage.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b="AiP22DXU" Received: by mail-pf1-f227.google.com with SMTP id d2e1a72fcca58-81ddb954e91so15289b3a.2 for ; Thu, 08 Jan 2026 09:22:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google2022; t=1767892951; x=1768497751; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2QhEY7hgCdpB6RVRGnQ1mrXyT489vZO6/9jC3EwBTpg=; b=AiP22DXUhsrmiaFupdsP/BdQmi48/LcRIkhZup+vl04oAhIIGO5f3wtI1Vvf4zDr5L t6XPCJ8JfeFecK5zaYPyJylY1w+1LDWOe6mdgN9InyPZRjrC3R1dHdBE8WrbZnnPd7EO 6xePVJ+0GqsPYcM2ZGHUtrlrnwDN1akFcGuv/oqSdBFO8QiCuXIZyUceW9fnewn/Y0du dLZ3UldiavYwWU8X0ACyPoc9madfn4vPux124qYV8M1ioQ1WqR0Z9ddAYOvdQOH25RwT X0H7XTPdBnDhgF0qZpHCkK3cDftC7SFlIlkKCzkJSy9ADSomGPsTu4W3iv6tDisu06kx 6y4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767892951; x=1768497751; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=2QhEY7hgCdpB6RVRGnQ1mrXyT489vZO6/9jC3EwBTpg=; b=i6dBTOterP2rLtnYl8mxP2stsI+YOIOw3xt2YWX5dpa7ZpAt5IjnZw3Ma01QRpve01 1rYU1yeyN2TCNx2PmKuWcLFbmT5Q1Nf2tBFIoSsHjYz979kvhONN2FBfXFUi+RYlzEGO IrUR0aazozJyLsMuR8Lt0X4ertQb9hbWeRbi+RwVxRKCJ/7BLW/b0uIz68i6QArLxU/u /YXO5qnNxxqfUnuG+rTtLRLAfFc5TqC+duMIrqPe8tcg4iPJ5RK8jbZSaZfcSvwW1SJK q4t4EbwJoAlB6CMCaoOe9uUIZ8eiNSSysYFCEjDnXX1566Cu+cCW49j24o01jRlVv40Z uISw== X-Forwarded-Encrypted: i=1; AJvYcCWCPqAaNypEoDgT/KFlcgPOhWuPoSjXdSX+qR59ZTcwumeKgNqIwNc0SyPmjTMNgJr1wx4sEYLtP4nHlTc=@vger.kernel.org X-Gm-Message-State: AOJu0YzfWxDtpU9Ti/lhqQz0W6lDxpHDKicR0qSCFRMBmXtJsXGDdxNz OxeDoKT0mxslJm0d99yhXFIk0tBP4VlnzwsXjYaGwHgUpyjmrVB/+eK/vRjyyA0FUPaQn9gKHX7 dRJmf6xQXLeSreaj8GBLmYQIc+IQ946x/fyeI X-Gm-Gg: AY/fxX6AieQKlMnjcqO+2lBacqXrn/eRlVlcWRSr4DSe13Ymx3obvPtvZciHZ4Vi1Rn rwvxYg+QtczuZSZvOr9Jafn0bf417ODxpTMDomusrqjekRWVZRisxxKVS78BgwRnZbTe0YIAJCL RG/LD6vPHMIdyR/WRjUcdwet6lb3NIBdmBGBk0Vsicealyv/qWEh1I8KBX4nVJPD5heqzJwnKa0 g1sLtr1qFYW5YFUuXxe6rdKiE2yGnvWIoM1iDCMgM0zBPM8SP6Qqk+IjocYmCBdhGtExZfB0GV+ jAheKgPOLcLoLNPduC1YeDmhjUSNu5IFQMqaJIHdFElApXXR0TTwyzvdAVaaXJBAWo5spfkvKQg zjW2s+ifnFZzhKPSHm+45xYA0G7gyDeXWpUKwjkQodQ== X-Google-Smtp-Source: AGHT+IG6KNczYB0X/xd9Rc6/z8KE+B7GiusKbrx8S6lyyK2KJmERN2c2OQbFVpoYg/jZDIam4cmzYsw5IxpM X-Received: by 2002:a05:6a21:3996:b0:341:29af:3be7 with SMTP id adf61e73a8af0-3898fa60c6cmr4313070637.7.1767892950617; Thu, 08 Jan 2026 09:22:30 -0800 (PST) Received: from c7-smtp-2023.dev.purestorage.com ([208.88.159.129]) by smtp-relay.gmail.com with ESMTPS id 41be03b00d2f7-c54d23d7235sm78957a12.1.2026.01.08.09.22.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jan 2026 09:22:30 -0800 (PST) X-Relaying-Domain: purestorage.com Received: from dev-csander.dev.purestorage.com (dev-csander.dev.purestorage.com [10.112.6.120]) by c7-smtp-2023.dev.purestorage.com (Postfix) with ESMTP id E83EB34059B; Thu, 8 Jan 2026 10:22:29 -0700 (MST) Received: by dev-csander.dev.purestorage.com (Postfix, from userid 1557716354) id DD892E42165; Thu, 8 Jan 2026 10:22:29 -0700 (MST) From: Caleb Sander Mateos To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Anuj Gupta , Christoph Hellwig , Caleb Sander Mateos Subject: [PATCH v2 1/3] block: zero non-PI portion of auto integrity buffer Date: Thu, 8 Jan 2026 10:22:10 -0700 Message-ID: <20260108172212.1402119-2-csander@purestorage.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20260108172212.1402119-1-csander@purestorage.com> References: <20260108172212.1402119-1-csander@purestorage.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 Content-Type: text/plain; charset="utf-8" The auto-generated integrity buffer for writes needs to be fully initialized before being passed to the underlying block device, otherwise the uninitialized memory can be read back by userspace or anyone with physical access to the storage device. If protection information is generated, that portion of the integrity buffer is already initialized. The integrity data is also zeroed if PI generation is disabled via sysfs or the PI tuple size is 0. However, this misses the case where PI is generated and the PI tuple size is nonzero, but the metadata size is larger than the PI tuple. In this case, the remainder ("opaque") of the metadata is left uninitialized. Generalize the BLK_INTEGRITY_CSUM_NONE check to cover any case when the metadata is larger than just the PI tuple. Signed-off-by: Caleb Sander Mateos Fixes: c546d6f43833 ("block: only zero non-PI metadata tuples in bio_integr= ity_prep") Reviewed-by: Anuj Gupta Reviewed-by: Christoph Hellwig Reviewed-by: Martin K. Petersen --- block/bio-integrity-auto.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/bio-integrity-auto.c b/block/bio-integrity-auto.c index 9850c338548d..cff025b06be1 100644 --- a/block/bio-integrity-auto.c +++ b/block/bio-integrity-auto.c @@ -138,11 +138,11 @@ bool bio_integrity_prep(struct bio *bio) if (bi->flags & BLK_INTEGRITY_NOGENERATE) { if (bi_offload_capable(bi)) return true; set_flags =3D false; gfp |=3D __GFP_ZERO; - } else if (bi->csum_type =3D=3D BLK_INTEGRITY_CSUM_NONE) + } else if (bi->metadata_size > bi->pi_tuple_size) gfp |=3D __GFP_ZERO; break; default: return true; } --=20 2.45.2 From nobody Sun Feb 8 05:42:10 2026 Received: from mail-yx1-f102.google.com (mail-yx1-f102.google.com [74.125.224.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 39EC02FF17A for ; Thu, 8 Jan 2026 17:22:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.102 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767892953; cv=none; b=Nm/EFabOOh+/goyW0qnbgJEv+ILrLLLY4VC21fuFjpxKWQWZVK/FD9NbulBtdgy+F4q/TcbJCq0uVu7yp0dENfCzcmrhHadWKSvyuvPZp27UfYjS284AIWGuOBT6ZT7TIkzL+nmNBBgvL4IRQ1X2T7/z5CKph0pHAnQBj3W40ZU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767892953; c=relaxed/simple; bh=i4p29NAYQUFaC6TakPUiO6FyaXMSmwrUFhPBK4q5+XY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WOQozlqh5AcYOMGP3vgx9TZ3n4GtZ6cCzKwLDniXphKWdANNUqIfIR51/W77SG8BSeKWj6rHleyYTz9WIqVlPegZbH992Q3ae03yylBKZdaSwZO2ugpybIbkBabKu9sZfPBQFbzr3PNMGPR4kCyO6ZuxlrZopF/peVGNUMzxHRc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com; spf=fail smtp.mailfrom=purestorage.com; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b=eVgl0rGd; arc=none smtp.client-ip=74.125.224.102 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=purestorage.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b="eVgl0rGd" Received: by mail-yx1-f102.google.com with SMTP id 956f58d0204a3-644746e3793so501461d50.3 for ; Thu, 08 Jan 2026 09:22:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google2022; t=1767892951; x=1768497751; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jxex0w2xVdLJ5pj+6cE9HhLbWu2So1kRLspmYigE0yw=; b=eVgl0rGd9VsthzbNMoscq8+rAN8Q2gD0jdD9qqPPEJ8hFGXp5W4mq4biznrcLYUB3y ybjSuvg5Ce8RCb00M49kMoX+Ou+43XiEeH7CmzszZZkrnCUvZj/OqTgUf9TzGc4j+RFT M8gdtudPJj3AE+qLg8lDFpkOqKidvG9YU6H+RJKSt6NBWJlHQH+lqP0tjAx57UhKQ3qg c6zsPwPxqqMMWOub4EdTgDsWZVCJBkFxqnqJBK1jrhNctycVxjhG5xPj1EBaW2t5IuTe SAh3nzYmv1/hhQ5hB2Ds7m4mpQPOe2/IL7OO4CFKzLL5s8E0WK5Ebi4xamdPPJ77GXr7 7QHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767892951; x=1768497751; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=jxex0w2xVdLJ5pj+6cE9HhLbWu2So1kRLspmYigE0yw=; b=eeRQqJ4IPKzh4xc7MuJSu8n5u1qBfm8T/AE5cszhcuVc1DwSbO+dmpUXCp1rSIV1XX fEGQCoUMZlJPAyKgjYaVSN/JM7BEGntVOTDY73wkgg8/SHJ59TavJm/v64FWsbA7p7Fh SRe41T+3r+6lWPTQehGuSFPQ/DMffMbpGpVLOwl2d6HyIk30LlpR85TQn56WMK1pmsd/ veMAC6d4dQyNauRxAcR/gcV8AkKk2ioZFrHSpNOQL58fXWYr/FkQLTYRzlr4bm1PaeOK /FZ4jZgwvxFKNnYzA/DlX5RCjIKqzbSjboXlmWxTmxwHwaKBbCM487Adn/ad5zmfh0Ip cZ1A== X-Forwarded-Encrypted: i=1; AJvYcCVSsi5jvfRQqWa+YfWTjHgDYu+Z/wLyLtKKNOStStAMlDWc84GXA8MpaHrhThWA8c58M6OXG9Et50cYKlU=@vger.kernel.org X-Gm-Message-State: AOJu0YwS7vGkjO/QcPdsCy+FbHxXqPKtEEzOWgeY7xy9GoiUVM6HTMVt tYPmCJCIg1LY3/wyvZHur/TGzm1syaiKZbp6Rs/Eg7vAZsWvCV7odwugX25qWxnIZr9srbXpMVr y4r3nAyelbPy8aAL8R5AicfYU+9OKXJWGgluKFtL1IQVIVtdMc79E X-Gm-Gg: AY/fxX7DbWyX567hdo5R0/dFiBpEBgxLTZ/ngZ3+CB6qkmvkTB7pTg/moaFXMXDVWly y8ekoLgZI+qIqmCnPBvBYdXZZJl2e57h+VVfn9e13VYUkgVfNYMXbzy2ogNpbAbicrtrnz98rAS cM0l1SPHQu9Ybq3xasW8cfknM/NuRnOTh+OwyyNHkpXpAR3kwa1O+T9ZYDPgzjIHsyBslHXCKBZ yyfkSAFU1TAy1yQ+YuEtodUl9ZFMqxuFHVA3G6x6XmBYEoVWDQcfsVFfG94PiMbL/fWMt2w8dW4 g6GTdJBgX7mkEKdqyzTMegujIXzuSi/oeagVZaiHchgHuYqnHVGHfKzI+YkoBXAwjTwHJN/ebO0 fzYPMjb+6hNN3oxASLtOAgSTZ5bg= X-Google-Smtp-Source: AGHT+IHT4rzoi1pIcJ2b2EbFL4SNsnV2Kx5sXAVunV6KAEhZUrhWimnE1b6DVrmZ22bjEufdrqkaea05RYU3 X-Received: by 2002:a05:690c:6608:b0:78f:c943:b2f3 with SMTP id 00721157ae682-790b568e27emr61630227b3.4.1767892951115; Thu, 08 Jan 2026 09:22:31 -0800 (PST) Received: from c7-smtp-2023.dev.purestorage.com ([2620:125:9017:12:36:3:5:0]) by smtp-relay.gmail.com with ESMTPS id 00721157ae682-790aa6a9f37sm6287247b3.17.2026.01.08.09.22.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jan 2026 09:22:31 -0800 (PST) X-Relaying-Domain: purestorage.com Received: from dev-csander.dev.purestorage.com (dev-csander.dev.purestorage.com [10.112.6.120]) by c7-smtp-2023.dev.purestorage.com (Postfix) with ESMTP id 2966A3406AA; Thu, 8 Jan 2026 10:22:30 -0700 (MST) Received: by dev-csander.dev.purestorage.com (Postfix, from userid 1557716354) id 1E459E42165; Thu, 8 Jan 2026 10:22:30 -0700 (MST) From: Caleb Sander Mateos To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Anuj Gupta , Christoph Hellwig , Caleb Sander Mateos Subject: [PATCH v2 2/3] block: replace gfp_t with bool in bio_integrity_prep() Date: Thu, 8 Jan 2026 10:22:11 -0700 Message-ID: <20260108172212.1402119-3-csander@purestorage.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20260108172212.1402119-1-csander@purestorage.com> References: <20260108172212.1402119-1-csander@purestorage.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 Content-Type: text/plain; charset="utf-8" Since commit ec7f31b2a2d3 ("block: make bio auto-integrity deadlock safe"), the gfp_t gfp variable in bio_integrity_prep() is no longer passed to an allocation function. It's only used to compute the zero_buffer argument to bio_integrity_alloc_buf(). So change the variable to bool zero_buffer to simplify the code. Signed-off-by: Caleb Sander Mateos Reviewed-by: Anuj Gupta Reviewed-by: Christoph Hellwig Reviewed-by: Martin K. Petersen --- block/bio-integrity-auto.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/block/bio-integrity-auto.c b/block/bio-integrity-auto.c index cff025b06be1..605403b52c90 100644 --- a/block/bio-integrity-auto.c +++ b/block/bio-integrity-auto.c @@ -107,11 +107,11 @@ bool __bio_integrity_endio(struct bio *bio) bool bio_integrity_prep(struct bio *bio) { struct blk_integrity *bi =3D blk_get_integrity(bio->bi_bdev->bd_disk); struct bio_integrity_data *bid; bool set_flags =3D true; - gfp_t gfp =3D GFP_NOIO; + bool zero_buffer =3D false; =20 if (!bi) return true; =20 if (!bio_sectors(bio)) @@ -137,13 +137,14 @@ bool bio_integrity_prep(struct bio *bio) */ if (bi->flags & BLK_INTEGRITY_NOGENERATE) { if (bi_offload_capable(bi)) return true; set_flags =3D false; - gfp |=3D __GFP_ZERO; - } else if (bi->metadata_size > bi->pi_tuple_size) - gfp |=3D __GFP_ZERO; + zero_buffer =3D true; + } else { + zero_buffer =3D bi->metadata_size > bi->pi_tuple_size; + } break; default: return true; } =20 @@ -152,11 +153,11 @@ bool bio_integrity_prep(struct bio *bio) =20 bid =3D mempool_alloc(&bid_pool, GFP_NOIO); bio_integrity_init(bio, &bid->bip, &bid->bvec, 1); bid->bio =3D bio; bid->bip.bip_flags |=3D BIP_BLOCK_INTEGRITY; - bio_integrity_alloc_buf(bio, gfp & __GFP_ZERO); + bio_integrity_alloc_buf(bio, zero_buffer); =20 bip_set_seed(&bid->bip, bio->bi_iter.bi_sector); =20 if (set_flags) { if (bi->csum_type =3D=3D BLK_INTEGRITY_CSUM_IP) --=20 2.45.2 From nobody Sun Feb 8 05:42:10 2026 Received: from mail-dy1-f228.google.com (mail-dy1-f228.google.com [74.125.82.228]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E56C92FF14C for ; Thu, 8 Jan 2026 17:22:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.228 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767892953; cv=none; b=O/ze2mSjQiLp2yK5BOKLqSHrXgRLqn0Iny/jsecZboIrMwJzrr/qokEsYAllxdKkYP7vyB0KZAmh6MEoxz71a8g/JGhZ+aVlUwStZ8Yyv21HBDG/BWao+itQwX7m6w0XHuI7nISing7t/93svvaxFJgJRWrUXsE3ogQMiLv191g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767892953; c=relaxed/simple; bh=uSp6bgEKbOC3tTzvHqcKfBiWs/omsHUdUObr3QB3yFg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oufArWkmg7uFwz6u6I2nmyPzIaciXPI9QggACh8SRoakq9JCimNfz958dINapYlWDhDt/Hs2NpsrPaDQPzYz45qTkmX7ySniv0SA36Ds5pVvzKz9oWmEQeminfQX+FaRLzn3bEKwjwM+Aly8Wv5265SRps0P+zdU6NHlw5va0K4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com; spf=fail smtp.mailfrom=purestorage.com; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b=Mstndcqe; arc=none smtp.client-ip=74.125.82.228 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=purestorage.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b="Mstndcqe" Received: by mail-dy1-f228.google.com with SMTP id 5a478bee46e88-2a49022ae5dso210794eec.1 for ; Thu, 08 Jan 2026 09:22:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google2022; t=1767892951; x=1768497751; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mGTTq8K3vQ+V+uQpl8CqSqa2h/Tj/HL+yYnwJhFFpIE=; b=Mstndcqe7JoWjeRacZGw3DMPhZ5pFIhSg9eTj7v7gVu27+aLfux6wLaBUzpBrE1Ep5 EbufN0R52mYWR4KaBtL4SJM4TumoWCCB+oUYf5NsUsq2lYLrzmk1qW1xL3qNDZ5mBjMy sM0kc7tZg2L29F0VIS62J/PyGivNzdyjA2ndDaiEZoInUpceHkPTikyJ99e7E9ojGnu3 bgx12avOsoed5Qg7NqZrkY84YRD0V5cJFTnjZ0mUohv1hKpKJerSi0wdNFsKmBGp+b1N 6P1YXGS4+J8NZgv1REP0UxIaN4qQCk59entYshzbp3zJDfud+Rolm3dZ/ZtgL+/4pd3R m6Og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767892951; x=1768497751; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=mGTTq8K3vQ+V+uQpl8CqSqa2h/Tj/HL+yYnwJhFFpIE=; b=JzGjiPV32ouLoCsuwMFO9oc+umqb3eBLTg0Hx8rjUD+Yu9Sb1INVQIWke2jPrkYgQm RxI2QJIWIOfEMKl6z0kis+kM5IpMpYWl8C4rTzeqdjfEGwCM+mhVM5hB+ffAU3eg2mfV ez3dvRSNIKB/dggJYJxSmsRdhnZIgYUhRx6rg5gr9NxVh0wnKKFllgWNKRRxTxqJNr+y VTarIwYvg+3nBsi0rU+QT2OAydCL39Poc52PTbF6ozvRL50PQu8AJn5qILZP6wwkyRZy x9D3yxE7dpwAdynPxoL7yxXeU51IMzjZ3A9HRshqjyBZX0qvxl1o/cR/POd4LsdQ1jys hm/Q== X-Forwarded-Encrypted: i=1; AJvYcCXu08SLJDmoIeb8/9CvcFxNCdW+A6DXb+8xoGSnXQUmYbIzXaJK7M94WDV7RYKAgrFFhaC1f5tdAlz234U=@vger.kernel.org X-Gm-Message-State: AOJu0Yzzv8f92hfHbT1sjdbsIoiDmO40c34Qqwm5jqVKARGlUGrEqOv+ sggb0Wkl9l5q8EVU7cAepMuFMZjYGBjDSWwY4YO9YGxn+zliTT/8e2Pesi2TKOrJlVQNP3A2AQ3 D7tUGWP/XoKMkXJ1801RJIpJO0mDFB3KfOt0biCD70MX+MRyuT8CH X-Gm-Gg: AY/fxX7z3t5F39hZwws7OKcs6IGRdzL/mtibVrMAKZWhTmjWcYzSTXv5J5a/nywsdg0 No0JBjkGlQnx4s8tTO5aoEOxoEOoH2wcwS3odC2cx8PPsnT/iphbRN7UTxfXAJReOidMvYXnFge gX530MkgmSzoL598j0/b8ZI4Wp6sb+4x0SfrlgP6pQgcwhDV3WjaCKYZQC7/09/alcXqkiVxNd5 mOxKBiI7VlP8lfN2eCLbiPolc9DpWsj7JL5TqGka1duAZVbVeko8BrFdjjGELzNbr8BPMNbwpF0 l2Y4b9u4aTqMn7p/EJfKckw4R18OOk2gkYTq1MfGfPzvxndhIA1BpQGJ+u9FUJhVKJf45iEA9fo +etAlt26MaKBzt32LxaXWFPW5B8I= X-Google-Smtp-Source: AGHT+IFJWaVqXL8QZVhWAMzKEfobRXwlVmAyoGeEH2E3UTRcXBRpGCtErafdB8C1hiJLzqQPDnJzA1hizh0L X-Received: by 2002:a05:7022:2483:b0:122:33e:6ec1 with SMTP id a92af1059eb24-122033e706emr617564c88.0.1767892950828; Thu, 08 Jan 2026 09:22:30 -0800 (PST) Received: from c7-smtp-2023.dev.purestorage.com ([2620:125:9017:12:36:3:5:0]) by smtp-relay.gmail.com with ESMTPS id a92af1059eb24-121f23c0e38sm1872968c88.0.2026.01.08.09.22.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jan 2026 09:22:30 -0800 (PST) X-Relaying-Domain: purestorage.com Received: from dev-csander.dev.purestorage.com (dev-csander.dev.purestorage.com [10.112.6.120]) by c7-smtp-2023.dev.purestorage.com (Postfix) with ESMTP id 5BE58340794; Thu, 8 Jan 2026 10:22:30 -0700 (MST) Received: by dev-csander.dev.purestorage.com (Postfix, from userid 1557716354) id 51786E42165; Thu, 8 Jan 2026 10:22:30 -0700 (MST) From: Caleb Sander Mateos To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Anuj Gupta , Christoph Hellwig , Caleb Sander Mateos Subject: [PATCH v2 3/3] block: use pi_tuple_size in bi_offload_capable() Date: Thu, 8 Jan 2026 10:22:12 -0700 Message-ID: <20260108172212.1402119-4-csander@purestorage.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20260108172212.1402119-1-csander@purestorage.com> References: <20260108172212.1402119-1-csander@purestorage.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 Content-Type: text/plain; charset="utf-8" bi_offload_capable() returns whether a block device's metadata size matches its PI tuple size. Use pi_tuple_size instead of switching on csum_type. This makes the code considerably simpler and less branchy. Signed-off-by: Caleb Sander Mateos Reviewed-by: Anuj Gupta Reviewed-by: Christoph Hellwig Reviewed-by: Martin K. Petersen --- block/bio-integrity-auto.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/block/bio-integrity-auto.c b/block/bio-integrity-auto.c index 605403b52c90..626bbe17eb23 100644 --- a/block/bio-integrity-auto.c +++ b/block/bio-integrity-auto.c @@ -50,23 +50,11 @@ static bool bip_should_check(struct bio_integrity_paylo= ad *bip) return bip->bip_flags & BIP_CHECK_FLAGS; } =20 static bool bi_offload_capable(struct blk_integrity *bi) { - switch (bi->csum_type) { - case BLK_INTEGRITY_CSUM_CRC64: - return bi->metadata_size =3D=3D sizeof(struct crc64_pi_tuple); - case BLK_INTEGRITY_CSUM_CRC: - case BLK_INTEGRITY_CSUM_IP: - return bi->metadata_size =3D=3D sizeof(struct t10_pi_tuple); - default: - pr_warn_once("%s: unknown integrity checksum type:%d\n", - __func__, bi->csum_type); - fallthrough; - case BLK_INTEGRITY_CSUM_NONE: - return false; - } + return bi->metadata_size =3D=3D bi->pi_tuple_size; } =20 /** * __bio_integrity_endio - Integrity I/O completion function * @bio: Protected bio --=20 2.45.2