From patchwork Tue Oct 29 16:23:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Gupta X-Patchwork-Id: 13855191 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) (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 94C2E1FF618 for ; Tue, 29 Oct 2024 17:24:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.24 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730222644; cv=none; b=jquKgNSHMUMv75UJ9m8YbGu42zmOyGH/u9TuZjrOw1DOi/+rKfei1vj10kR96P94htYGDXm+gl/92vO4TVx03EyKGxpEvFN5vGFd5XsVqdjRYErX0a/MfVeNmtme0toHev2a5ttqGSYtTlpXxa/gbfLnZncDArVQxMW+ZqX8umY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730222644; c=relaxed/simple; bh=uhVUanvHeNYpdl7oe+2xBoF7IHpOF3ppOQIE4lSGydA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=gFNIXmayNn0pRq7c9w4OsAomgPHsTft4ixKvIq4nGpWEN6lfc7xPoIPBwtiY/sua/NJ4HmKr2Rrh/HpSfKO9fT7NMHinTgzXN4/cijNTJ0GWgbBaah9woHlgai6e7Nr7+C+r8LoTBosb3KomiTaza/YFm9DbdoiYISMSr2rXkYQ= 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=mzwrcwJo; arc=none smtp.client-ip=203.254.224.24 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="mzwrcwJo" Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20241029172400epoutp01eba704a6e602f0d7677cb65605cb1a53~C-FMkkRYC2780127801epoutp01N for ; Tue, 29 Oct 2024 17:24:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20241029172400epoutp01eba704a6e602f0d7677cb65605cb1a53~C-FMkkRYC2780127801epoutp01N DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1730222640; bh=OdnEOzPmE6BW4EwF3Q4T8kgPZcMcp2ktM4WfhkvkMt0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mzwrcwJoWpx3qi0WD6meqjI8n2fVLo8UNY8mkWBoUL6CwRti739qaPo/KpVPLmaH1 IL+6nqR1f86fdtXFPx36tM1TLn2/sbdUv9VIlWB/A4y6tnDXzk5B8jDZQq5PTrG05A zOgQ3bDF+ujc81rqWRurTWVd1DFgG0kRfsbAregY= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20241029172400epcas5p35e10bdeb507f2be65e1525872191a877~C-FL3KKcU2485924859epcas5p3E; Tue, 29 Oct 2024 17:24:00 +0000 (GMT) Received: from epsmgec5p1new.samsung.com (unknown [182.195.38.179]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4XdHDG3KqKz4x9Pp; Tue, 29 Oct 2024 17:23:58 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmgec5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 35.D6.08574.E2A11276; Wed, 30 Oct 2024 02:23:58 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20241029163228epcas5p1cd9d1df3d8000250d58092ba82faa870~C_YMG540n2488624886epcas5p1x; Tue, 29 Oct 2024 16:32:28 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20241029163228epsmtrp139fca113c34f528ccc23763785f13784~C_YMF-1lz0723107231epsmtrp1z; Tue, 29 Oct 2024 16:32:27 +0000 (GMT) X-AuditID: b6c32a44-6dbff7000000217e-2d-67211a2e9da0 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 24.67.08229.B1E01276; Wed, 30 Oct 2024 01:32:27 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20241029163225epsmtip2d329feefdeb3e08ac163b88a9a07b6eb~C_YJpfwvB0998409984epsmtip2b; Tue, 29 Oct 2024 16:32:25 +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 v5 07/10] block: introduce BIP_CHECK_GUARD/REFTAG/APPTAG bip_flags Date: Tue, 29 Oct 2024 21:53:59 +0530 Message-Id: <20241029162402.21400-8-anuj20.g@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241029162402.21400-1-anuj20.g@samsung.com> Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail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mXtXwsAt7MA0pR23C5I+31JLOXchX9Zy/uWVjJxfLy8/+3Pd5/O7uSfw VHWycb8Ozv7IWHK+WniT/nX1q37OV99GfBPu0X3IPuOKW25ZyESm0gt/U/obsxTSH6v7e57p Fz9iPed274NvzXaLVMrPnl454eAU5/jHJV8+7S62N0/z0TJZsOOdZp36xSmK9zd0XJvw/um+ 9P4bUY1Wiv5333nGX3PctMnsPIMzS8bLKMvlRx9+WW/SHZ/Cc0H+65H97/4XOE+bpTrliGTV ky+BK/JucnrteTjd2EiJpTgj0VCLuag4EQDbS0EhJgMAAA== X-CMS-MailID: 20241029163228epcas5p1cd9d1df3d8000250d58092ba82faa870 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241029163228epcas5p1cd9d1df3d8000250d58092ba82faa870 References: <20241029162402.21400-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: Keith Busch Reviewed-by: Christoph Hellwig --- 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