From patchwork Mon Nov 4 14:05:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 13861581 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) (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 2D6211C1AAA for ; Mon, 4 Nov 2024 15:56:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.25 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730735783; cv=none; b=Av0nMc3QypRKf851lP2jPM0eFVmxksCvbqO6iqyPZe52CdgMLQ09hwWhGdgmIyEl4zvnJdi53avt4ysjkpfYE+HV6jtd1WbxMzSxeozoVV2OIlLVfDfMhBbuh1CIccCi7YEXMiJNoFwKNmxkXQ0YwhQtq/MTOaJ7ERlhik2v3Js= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730735783; c=relaxed/simple; bh=5SWlWgE0v/ZgsGIR4YjIdGynPoaBkFM3l3dgZp1M8u0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=fI48OhVbAwH+mM28ivR0xWYGKvkIb+e9n9pDXcU4hZZiA3DUlSdDZ0xqoIeZ87iRWn+nXdVHJAbCr1o4SVwJMJ2vaQxqz759Zw80Jh1nxfp/Dut7OnhwtAlWlSXWdvhYuyPm2Xfkog3cyufKQ494rrK2T3pMvbQw7aJP26imLJw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=vHJBO04X; arc=none smtp.client-ip=203.254.224.25 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="vHJBO04X" Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20241104155619epoutp02f987d954812aeb80a727eb47e47417a2~EzwWS22eB1479614796epoutp02V for ; Mon, 4 Nov 2024 15:56:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20241104155619epoutp02f987d954812aeb80a727eb47e47417a2~EzwWS22eB1479614796epoutp02V DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1730735779; bh=/SlWjlwmF9Rr5zYWclsqVal/XEMs0tmP/ImOW56sBng=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vHJBO04X174IB6PiydOMnBuPtpTUeF+aevCHG62zCIKn/hUsSOnuPGBGcYCih6G33 aURk5r4ae4iaguVP/Mlfs7flnUB0NLUv/UzgocWsy0rIwVqT7wFerYsVGp8qYskzln 2HlgNZ/GHD2yXXIEzOSHPnhAMCutv8QWOcy7T9CY= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20241104155618epcas5p45010de634170053529509503662c01e4~EzwVb-WQ32760427604epcas5p4V; Mon, 4 Nov 2024 15:56:18 +0000 (GMT) Received: from epsmgec5p1new.samsung.com (unknown [182.195.38.181]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4Xhx0K148Qz4x9Pp; Mon, 4 Nov 2024 15:56:17 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmgec5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id C3.75.08574.0AEE8276; Tue, 5 Nov 2024 00:56:17 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20241104141501epcas5p38203d98ce0b2ac95cc45e02a142e84ef~EyX56xglX2420824208epcas5p3F; Mon, 4 Nov 2024 14:15:01 +0000 (GMT) Received: from epsmgmc1p1new.samsung.com (unknown [182.195.42.40]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20241104141501epsmtrp12fbb65828dc52d86d498ccbefe8fda83~EyX55sgYH1340613406epsmtrp1V; Mon, 4 Nov 2024 14:15:01 +0000 (GMT) X-AuditID: b6c32a44-93ffa7000000217e-e9-6728eea0fcff Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgmc1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 67.8D.07371.5E6D8276; Mon, 4 Nov 2024 23:15:01 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20241104141459epsmtip2fec098a032b17ccd6841ce6d71d440c0~EyX3bKxX03097430974epsmtip2n; Mon, 4 Nov 2024 14:14:59 +0000 (GMT) From: Anuj Gupta To: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org, martin.petersen@oracle.com, asml.silence@gmail.com, anuj1072538@gmail.com, brauner@kernel.org, jack@suse.cz, viro@zeniv.linux.org.uk Cc: io-uring@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, gost.dev@samsung.com, linux-scsi@vger.kernel.org, vishak.g@samsung.com, linux-fsdevel@vger.kernel.org, Anuj Gupta , Kanchan Joshi Subject: [PATCH v7 07/10] block: introduce BIP_CHECK_GUARD/REFTAG/APPTAG bip_flags Date: Mon, 4 Nov 2024 19:35:58 +0530 Message-Id: <20241104140601.12239-8-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241104140601.12239-1-anuj20.g@samsung.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-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RpuTrsN7vWdJ7oZ+fatzjkgwFfaoYP++vFT8rc 8nRZ/ybfmDlT8AJTMfPK+dmKyxd/SIs4kPeo8nSi6jqD51v3J/2qZN3dv4CnWYl/ovuys15z j11+q9qZdtnG43rT6ZSq3/Hrq6KfT16xxIrj7hJeUWXNvuO3ThnF2d2TrDz/Zd8S5h17fp5v StywgP1Q11tt927utS/nTUs9UWYS8/COxQntQwctRK9Ie785sTLhwFK/JrHKPb7ZBz1PrmLS 9akLmrDD40anev7DiUosxRmJhlrMRcWJADMW6O0mAwAA X-CMS-MailID: 20241104141501epcas5p38203d98ce0b2ac95cc45e02a142e84ef X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241104141501epcas5p38203d98ce0b2ac95cc45e02a142e84ef References: <20241104140601.12239-1-anuj20.g@samsung.com> This patch introduces BIP_CHECK_GUARD/REFTAG/APPTAG bip_flags which indicate how the hardware should check the integrity payload. BIP_CHECK_GUARD/REFTAG are conversion of existing semantics, while BIP_CHECK_APPTAG is a new flag. The driver can now just rely on block layer flags, and doesn't need to know the integrity source. Submitter of PI decides which tags to check. This would also give us a unified interface for user and kernel generated integrity. Signed-off-by: Anuj Gupta Signed-off-by: Kanchan Joshi Reviewed-by: Christoph Hellwig Reviewed-by: Keith Busch --- block/bio-integrity.c | 5 +++++ drivers/nvme/host/core.c | 11 +++-------- include/linux/bio-integrity.h | 6 +++++- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index f56d01cec689..3bee43b87001 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -434,6 +434,11 @@ bool bio_integrity_prep(struct bio *bio) if (bi->csum_type == BLK_INTEGRITY_CSUM_IP) bip->bip_flags |= BIP_IP_CHECKSUM; + /* describe what tags to check in payload */ + if (bi->csum_type) + bip->bip_flags |= BIP_CHECK_GUARD; + if (bi->flags & BLK_INTEGRITY_REF_TAG) + bip->bip_flags |= BIP_CHECK_REFTAG; if (bio_integrity_add_page(bio, virt_to_page(buf), len, offset_in_page(buf)) < len) { printk(KERN_ERR "could not attach integrity payload\n"); diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 3de7555a7de7..79bd6b22e88d 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -1004,18 +1004,13 @@ static inline blk_status_t nvme_setup_rw(struct nvme_ns *ns, control |= NVME_RW_PRINFO_PRACT; } - switch (ns->head->pi_type) { - case NVME_NS_DPS_PI_TYPE3: + if (bio_integrity_flagged(req->bio, BIP_CHECK_GUARD)) control |= NVME_RW_PRINFO_PRCHK_GUARD; - break; - case NVME_NS_DPS_PI_TYPE1: - case NVME_NS_DPS_PI_TYPE2: - control |= NVME_RW_PRINFO_PRCHK_GUARD | - NVME_RW_PRINFO_PRCHK_REF; + if (bio_integrity_flagged(req->bio, BIP_CHECK_REFTAG)) { + control |= NVME_RW_PRINFO_PRCHK_REF; if (op == nvme_cmd_zone_append) control |= NVME_RW_APPEND_PIREMAP; nvme_set_ref_tag(ns, cmnd, req); - break; } } diff --git a/include/linux/bio-integrity.h b/include/linux/bio-integrity.h index 58ff9988433a..fe2bfe122db2 100644 --- a/include/linux/bio-integrity.h +++ b/include/linux/bio-integrity.h @@ -11,6 +11,9 @@ enum bip_flags { BIP_DISK_NOCHECK = 1 << 3, /* disable disk integrity checking */ BIP_IP_CHECKSUM = 1 << 4, /* IP checksum */ BIP_COPY_USER = 1 << 5, /* Kernel bounce buffer in use */ + BIP_CHECK_GUARD = 1 << 6, /* guard check */ + BIP_CHECK_REFTAG = 1 << 7, /* reftag check */ + BIP_CHECK_APPTAG = 1 << 8, /* apptag check */ }; struct bio_integrity_payload { @@ -31,7 +34,8 @@ struct bio_integrity_payload { }; #define BIP_CLONE_FLAGS (BIP_MAPPED_INTEGRITY | BIP_CTRL_NOCHECK | \ - BIP_DISK_NOCHECK | BIP_IP_CHECKSUM) + BIP_DISK_NOCHECK | BIP_IP_CHECKSUM | \ + BIP_CHECK_GUARD | BIP_CHECK_REFTAG | BIP_CHECK_APPTAG) #ifdef CONFIG_BLK_DEV_INTEGRITY