Skip to content

Commit 2c0487d

Browse files
Anuj Guptaaxboe
authored andcommitted
block: introduce BIP_CHECK_GUARD/REFTAG/APPTAG bip_flags
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 <[email protected]> Signed-off-by: Kanchan Joshi <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Keith Busch <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 59a7d12 commit 2c0487d

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

block/bio-integrity.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,11 @@ bool bio_integrity_prep(struct bio *bio)
434434
if (bi->csum_type == BLK_INTEGRITY_CSUM_IP)
435435
bip->bip_flags |= BIP_IP_CHECKSUM;
436436

437+
/* describe what tags to check in payload */
438+
if (bi->csum_type)
439+
bip->bip_flags |= BIP_CHECK_GUARD;
440+
if (bi->flags & BLK_INTEGRITY_REF_TAG)
441+
bip->bip_flags |= BIP_CHECK_REFTAG;
437442
if (bio_integrity_add_page(bio, virt_to_page(buf), len,
438443
offset_in_page(buf)) < len) {
439444
printk(KERN_ERR "could not attach integrity payload\n");

drivers/nvme/host/core.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,18 +1017,13 @@ static inline blk_status_t nvme_setup_rw(struct nvme_ns *ns,
10171017
control |= NVME_RW_PRINFO_PRACT;
10181018
}
10191019

1020-
switch (ns->head->pi_type) {
1021-
case NVME_NS_DPS_PI_TYPE3:
1020+
if (bio_integrity_flagged(req->bio, BIP_CHECK_GUARD))
10221021
control |= NVME_RW_PRINFO_PRCHK_GUARD;
1023-
break;
1024-
case NVME_NS_DPS_PI_TYPE1:
1025-
case NVME_NS_DPS_PI_TYPE2:
1026-
control |= NVME_RW_PRINFO_PRCHK_GUARD |
1027-
NVME_RW_PRINFO_PRCHK_REF;
1022+
if (bio_integrity_flagged(req->bio, BIP_CHECK_REFTAG)) {
1023+
control |= NVME_RW_PRINFO_PRCHK_REF;
10281024
if (op == nvme_cmd_zone_append)
10291025
control |= NVME_RW_APPEND_PIREMAP;
10301026
nvme_set_ref_tag(ns, cmnd, req);
1031-
break;
10321027
}
10331028
}
10341029

include/linux/bio-integrity.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ enum bip_flags {
1111
BIP_DISK_NOCHECK = 1 << 3, /* disable disk integrity checking */
1212
BIP_IP_CHECKSUM = 1 << 4, /* IP checksum */
1313
BIP_COPY_USER = 1 << 5, /* Kernel bounce buffer in use */
14+
BIP_CHECK_GUARD = 1 << 6, /* guard check */
15+
BIP_CHECK_REFTAG = 1 << 7, /* reftag check */
16+
BIP_CHECK_APPTAG = 1 << 8, /* apptag check */
1417
};
1518

1619
struct bio_integrity_payload {
@@ -31,7 +34,8 @@ struct bio_integrity_payload {
3134
};
3235

3336
#define BIP_CLONE_FLAGS (BIP_MAPPED_INTEGRITY | BIP_CTRL_NOCHECK | \
34-
BIP_DISK_NOCHECK | BIP_IP_CHECKSUM)
37+
BIP_DISK_NOCHECK | BIP_IP_CHECKSUM | \
38+
BIP_CHECK_GUARD | BIP_CHECK_REFTAG | BIP_CHECK_APPTAG)
3539

3640
#ifdef CONFIG_BLK_DEV_INTEGRITY
3741

0 commit comments

Comments
 (0)