From nobody Sat Feb 7 09:59:12 2026 Received: from mail-pl1-f225.google.com (mail-pl1-f225.google.com [209.85.214.225]) (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 2D5D7221FBA for ; Tue, 6 Jan 2026 00:58:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.225 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767661099; cv=none; b=T/Zi+MHYhMFs7NTwPnGcMeQY4yE0hZL3/ZDB0iCNa2NExrGyXD4m5ZXgtKdrr8JmBMhYSL3GT8LnUORc2zsOZcwDyqYcCels1ftj08elv1jWsBPKgoRqHxX8wJ6qJ5EvWIxqE5yvdKDogiL54d2RHeZYbsC5hIymz9cr7CAwliI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767661099; c=relaxed/simple; bh=Z1UdenNqomW1Gdmx86hqjdPqAqBfGOKQ/CBxjOYJH6g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=c1YKSWBJy0QuIEuiWdPcBhNPwaqWM5vwmY7C8ELJ8r2X63mY8mxQ9GXd5Na4o3TD5m9R1jCZ5VklREOvKleKv91VaPSfwAeVyPZ3kkBHqdvL63/FrjUZP23Nen5W8xp2SNEmADPr8xCNdoAxR5KnHJ9plp9z+he62TPcSVGRJCg= 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=Nvu4zP1A; arc=none smtp.client-ip=209.85.214.225 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="Nvu4zP1A" Received: by mail-pl1-f225.google.com with SMTP id d9443c01a7336-2a355c8b808so632845ad.3 for ; Mon, 05 Jan 2026 16:58:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google2022; t=1767661092; x=1768265892; 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=iWgbGYobkvaFSQnhmymI3uWpc8/0KXyANTacEmbRQf4=; b=Nvu4zP1AUR1u2OTOlSMg1Gt/rqgn6E7TwHYkzScRZgn95dYdn5uIBZiZJYMROpju/0 sHiWsiLHEE21xxGhXelaOufc79a1wWGWL/E/P4kl6sF/2zdQtRlwMQADZbcSsaxTBCiw 5K4NvPnajm7HIcoSDGrHqR81S3F5LixvAFPa2xWAxIE61Khvw05UIHQp5sT3ohv97AB1 qyefiE4TTxxsd4PMiZP4QOPUvfbMY+i556dIrsY9VvX45oETOWYjDYOu/JMlxCoezKbB DS8ZfqdYHZ0CpcUP3U4ACIDgKT/2DRMMooQqibn2xzDyxMBnyqYPn56JSv0b33vDz4Cv RBKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767661092; x=1768265892; 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=iWgbGYobkvaFSQnhmymI3uWpc8/0KXyANTacEmbRQf4=; b=iCu7YJmmj9SEHEqEgamb8xqe+WbJayPC1HmDxNWYlUXpBXu9f6WRFevHDbWpxqQA7Z D0rb5jp2QuedZoSEwPPMaMgefQSnLbVeJNdFCW9fSQnF1/6+R7H4EXvrEJURTTuP9OBJ NFtT1tDStY1orp/UWvfAtgpmBkofnYg5vWJbysykwRGDZ71LNG9f+hlXBhAwUCurCvSm 2sEPSU+cDN0egQQUdt+K6MA2yFgVqjs9GdNi+ySRIloX3b/7ZkX0d3up1VVQs1TjYGjo 2rRywfya3c+dDM5IJ95LsrJk167IlC3Grjbq1sH0bwd39I4VDqT3Q6plKH1hkN+LgY+T a49w== X-Forwarded-Encrypted: i=1; AJvYcCXXZ9ztH8O9Svy35ME/Sy7yADz9OCnTvXXFoNqiQqcOpulX1Qqb5sR012lPLrybtydqz+J2v9dE7TsRmHc=@vger.kernel.org X-Gm-Message-State: AOJu0YyFkk32ECp0Im9MHPsVFeDaRsmBZ1/Q00xNPX+aYdu+ijebIEqX /PW2qmEaob3PpHs63qV7oDicNm+/INnqdCEMNvh9VWqy2cLpx/JTuAzUQXioQ3Cl3aP17nsuGFv yq8zITfdlFX+kfeufY/tsVHZEa6QmeMc/wPId X-Gm-Gg: AY/fxX53esVsIHTDkIa5LoVYBwxLZkq02AXaOCbf0jQfKma9JbXtcHdtAvpNgSwrQj/ ev/03oFGy3i+tL6P+SeFnfir2cN2nSIwlwKRHbueaZ654XWGhA6oTXo+Olf7b/sqw+lYDHVGSdt AAs8hmWwiLq/eP/bQ1aGAy4qRiPKPJD+cGlBDnOCf3kOcJz3DVabNZQUjIiwU/XmlFSeiEsk8QG nd5scG1tfz2PUC6kl6NiZN/+kYYaCBFtZQ6ayr+rRH8bngyMCNVET25/5/zfuDS1iRHBpx0FZIc ekxYzkZ5Qv5EIXCUJ2l1j9UsT8VGSD/bgW1KV9o+dgnK9hjJ++OzM99Ax7ZBJZkkXIG6W5q7hzg dz91CjDIn9wwJZt61SH1U1rUIjb9uyWldTRzqFYC0mg== X-Google-Smtp-Source: AGHT+IGOfp+6bH84vad2EBQ2+Dwb3Z0fUV6/3dMYfGye5S2Vf4an6Zy5q/XCGn88/corDJ9YMoIic3ed4Enw X-Received: by 2002:a17:90b:2884:b0:340:be2e:9884 with SMTP id 98e67ed59e1d1-34f5f284472mr709682a91.1.1767661092230; Mon, 05 Jan 2026 16:58:12 -0800 (PST) Received: from c7-smtp-2023.dev.purestorage.com ([208.88.159.128]) by smtp-relay.gmail.com with ESMTPS id 98e67ed59e1d1-34f5faf11e2sm107244a91.4.2026.01.05.16.58.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jan 2026 16:58:12 -0800 (PST) X-Relaying-Domain: purestorage.com Received: from dev-csander.dev.purestorage.com (dev-csander.dev.purestorage.com [10.49.34.222]) by c7-smtp-2023.dev.purestorage.com (Postfix) with ESMTP id AB19434173B; Mon, 5 Jan 2026 17:58:11 -0700 (MST) Received: by dev-csander.dev.purestorage.com (Postfix, from userid 1557716354) id 9D880E44554; Mon, 5 Jan 2026 17:58:11 -0700 (MST) From: Caleb Sander Mateos To: Ming Lei , Jens Axboe , Shuah Khan Cc: linux-block@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Stanley Zhang , Uday Shankar , "Martin K . Petersen" , Caleb Sander Mateos Subject: [PATCH v3 19/19] selftests: ublk: add end-to-end integrity test Date: Mon, 5 Jan 2026 17:57:51 -0700 Message-ID: <20260106005752.3784925-20-csander@purestorage.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20260106005752.3784925-1-csander@purestorage.com> References: <20260106005752.3784925-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" Add test case loop_08 to verify the ublk integrity data flow. It uses the kublk loop target to create a ublk device with integrity on top of backing data and integrity files. It then writes to the whole device with fio configured to generate integrity data. Then it reads back the whole device with fio configured to verify the integrity data. It also verifies that injected guard, reftag, and apptag corruptions are correctly detected. Signed-off-by: Caleb Sander Mateos --- tools/testing/selftests/ublk/Makefile | 1 + tools/testing/selftests/ublk/test_loop_08.sh | 111 +++++++++++++++++++ 2 files changed, 112 insertions(+) create mode 100755 tools/testing/selftests/ublk/test_loop_08.sh diff --git a/tools/testing/selftests/ublk/Makefile b/tools/testing/selftest= s/ublk/Makefile index bfd68ae64142..ab745443fd58 100644 --- a/tools/testing/selftests/ublk/Makefile +++ b/tools/testing/selftests/ublk/Makefile @@ -33,10 +33,11 @@ TEST_PROGS +=3D test_loop_02.sh TEST_PROGS +=3D test_loop_03.sh TEST_PROGS +=3D test_loop_04.sh TEST_PROGS +=3D test_loop_05.sh TEST_PROGS +=3D test_loop_06.sh TEST_PROGS +=3D test_loop_07.sh +TEST_PROGS +=3D test_loop_08.sh TEST_PROGS +=3D test_stripe_01.sh TEST_PROGS +=3D test_stripe_02.sh TEST_PROGS +=3D test_stripe_03.sh TEST_PROGS +=3D test_stripe_04.sh TEST_PROGS +=3D test_stripe_05.sh diff --git a/tools/testing/selftests/ublk/test_loop_08.sh b/tools/testing/s= elftests/ublk/test_loop_08.sh new file mode 100755 index 000000000000..ca289cfb2ad4 --- /dev/null +++ b/tools/testing/selftests/ublk/test_loop_08.sh @@ -0,0 +1,111 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh + +if ! _have_program fio; then + exit $UBLK_SKIP_CODE +fi + +fio_version=3D$(fio --version) +if [[ "$fio_version" =3D~ fio-[0-9]+\.[0-9]+$ ]]; then + echo "Requires development fio version with https://github.com/axboe/fio/= pull/1992" + exit $UBLK_SKIP_CODE +fi + +TID=3Dloop_08 + +_prep_test "loop" "end-to-end integrity" + +_create_backfile 0 256M +_create_backfile 1 32M # 256M * (64 integrity bytes / 512 data bytes) +integrity_params=3D"--integrity_capable --integrity_reftag + --metadata_size 64 --pi_offset 56 --csum_type t10dif" +dev_id=3D$(_add_ublk_dev -t loop -u $integrity_params "${UBLK_BACKFILES[@]= }") +_check_add_dev $TID $? + +# 1M * (64 integrity bytes / 512 data bytes) =3D 128K +fio_args=3D"--ioengine io_uring --direct 1 --bsrange 512-1M --iodepth 32 + --md_per_io_size 128K --pi_act 0 --pi_chk GUARD,REFTAG,APPTAG + --filename /dev/ublkb$dev_id" +fio --name fill --rw randwrite $fio_args > /dev/null +err=3D$? +if [ $err !=3D 0 ]; then + echo "fio fill failed" + _show_result $TID $err +fi + +fio --name verify --rw randread $fio_args > /dev/null +err=3D$? +if [ $err !=3D 0 ]; then + echo "fio verify failed" + _show_result $TID $err +fi + +fio_err=3D$(mktemp fio_err_XXXXX) + +# Overwrite 4-byte reftag at offset 56 + 4 =3D 60 +dd_reftag_args=3D"bs=3D1 seek=3D60 count=3D4 oflag=3Ddsync conv=3Dnotrunc = status=3Dnone" +dd if=3D/dev/urandom "of=3D${UBLK_BACKFILES[1]}" $dd_reftag_args +err=3D$? +if [ $err !=3D 0 ]; then + echo "dd corrupted_reftag failed" + rm -f "$fio_err" + _show_result $TID $err +fi +if fio --name corrupted_reftag --rw randread $fio_args > /dev/null 2> "$fi= o_err"; then + echo "fio corrupted_reftag unexpectedly succeeded" + rm -f "$fio_err" + _show_result $TID 255 +fi +expected_err=3D"REFTAG compare error: LBA: 0 Expected=3D0, Actual=3D" +if ! grep -q "$expected_err" "$fio_err"; then + echo "fio corrupted_reftag message not found: $expected_err" + rm -f "$fio_err" + _show_result $TID 255 +fi +# Reset to 0 +dd if=3D/dev/zero "of=3D${UBLK_BACKFILES[1]}" $dd_reftag_args +err=3D$? +if [ $err !=3D 0 ]; then + echo "dd restore corrupted_reftag failed" + rm -f "$fio_err" + _show_result $TID $err +fi + +dd_data_args=3D"bs=3D512 count=3D1 oflag=3Ddirect,dsync conv=3Dnotrunc sta= tus=3Dnone" +dd if=3D/dev/zero "of=3D${UBLK_BACKFILES[0]}" $dd_data_args +err=3D$? +if [ $err !=3D 0 ]; then + echo "dd corrupted_data failed" + rm -f "$fio_err" + _show_result $TID $err +fi +if fio --name corrupted_data --rw randread $fio_args > /dev/null 2> "$fio_= err"; then + echo "fio corrupted_data unexpectedly succeeded" + rm -f "$fio_err" + _show_result $TID 255 +fi +expected_err=3D"Guard compare error: LBA: 0 Expected=3D0, Actual=3D" +if ! grep -q "$expected_err" "$fio_err"; then + echo "fio corrupted_data message not found: $expected_err" + rm -f "$fio_err" + _show_result $TID 255 +fi + +if fio --name bad_apptag --rw randread $fio_args --apptag 0x4321 > /dev/nu= ll 2> "$fio_err"; then + echo "fio bad_apptag unexpectedly succeeded" + rm -f "$fio_err" + _show_result $TID 255 +fi +expected_err=3D"APPTAG compare error: LBA: [0-9]* Expected=3D4321, Actual= =3D1234" +if ! grep -q "$expected_err" "$fio_err"; then + echo "fio bad_apptag message not found: $expected_err" + rm -f "$fio_err" + _show_result $TID 255 +fi + +rm -f "$fio_err" + +_cleanup_test +_show_result $TID 0 --=20 2.45.2