From: Anuj Gupta <[email protected]>
To: [email protected], [email protected], [email protected],
[email protected], [email protected],
[email protected]
Cc: [email protected], [email protected],
[email protected], [email protected],
[email protected], Anuj Gupta <[email protected]>
Subject: [PATCH v3 10/10] scsi: add support for user-meta interface
Date: Fri, 23 Aug 2024 16:08:11 +0530 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
Add support for sending user-meta buffer. Set tags to be checked
using flags specified by user/block-layer user and underlying DIF/DIX
configuration. Introduce BLK_INTEGRITY_APP_TAG to specify apptag.
This provides a way for upper layers to specify apptag checking.
Signed-off-by: Anuj Gupta <[email protected]>
---
block/bio-integrity.c | 2 ++
drivers/scsi/sd.c | 25 +++++++++++++++++++++++--
drivers/scsi/sd_dif.c | 2 +-
include/linux/blk-integrity.h | 1 +
4 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/block/bio-integrity.c b/block/bio-integrity.c
index 02b766c2e57d..ff7de4fe74c4 100644
--- a/block/bio-integrity.c
+++ b/block/bio-integrity.c
@@ -492,6 +492,8 @@ bool bio_integrity_prep(struct bio *bio)
bip->bip_flags |= BIP_CHECK_GUARD;
if (bi->flags & BLK_INTEGRITY_REF_TAG)
bip->bip_flags |= BIP_CHECK_REFTAG;
+ if (bi->flags & BLK_INTEGRITY_APP_TAG)
+ bip->bip_flags |= BIP_CHECK_APPTAG;
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/scsi/sd.c b/drivers/scsi/sd.c
index 699f4f9674d9..6ebef140cec2 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -803,6 +803,23 @@ static unsigned int sd_prot_flag_mask(unsigned int prot_op)
return flag_mask[prot_op];
}
+/*
+ * Can't check reftag alone or apptag alone
+ */
+static bool sd_prot_flags_valid(struct scsi_cmnd *scmd)
+{
+ struct request *rq = scsi_cmd_to_rq(scmd);
+ struct bio *bio = rq->bio;
+
+ if (bio_integrity_flagged(bio, BIP_CHECK_REFTAG) &&
+ !bio_integrity_flagged(bio, BIP_CHECK_APPTAG))
+ return false;
+ if (!bio_integrity_flagged(bio, BIP_CHECK_REFTAG) &&
+ bio_integrity_flagged(bio, BIP_CHECK_APPTAG))
+ return false;
+ return true;
+}
+
static unsigned char sd_setup_protect_cmnd(struct scsi_cmnd *scmd,
unsigned int dix, unsigned int dif)
{
@@ -815,14 +832,16 @@ static unsigned char sd_setup_protect_cmnd(struct scsi_cmnd *scmd,
if (bio_integrity_flagged(bio, BIP_IP_CHECKSUM))
scmd->prot_flags |= SCSI_PROT_IP_CHECKSUM;
- if (bio_integrity_flagged(bio, BIP_CTRL_NOCHECK) == false)
+ if (bio_integrity_flagged(bio, BIP_CTRL_NOCHECK) == false &&
+ (bio_integrity_flagged(bio, BIP_CHECK_GUARD)))
scmd->prot_flags |= SCSI_PROT_GUARD_CHECK;
}
if (dif != T10_PI_TYPE3_PROTECTION) { /* DIX/DIF Type 0, 1, 2 */
scmd->prot_flags |= SCSI_PROT_REF_INCREMENT;
- if (bio_integrity_flagged(bio, BIP_CTRL_NOCHECK) == false)
+ if ((bio_integrity_flagged(bio, BIP_CTRL_NOCHECK) == false) &&
+ (!dix || bio_integrity_flagged(bio, BIP_CHECK_REFTAG)))
scmd->prot_flags |= SCSI_PROT_REF_CHECK;
}
@@ -1374,6 +1393,8 @@ static blk_status_t sd_setup_read_write_cmnd(struct scsi_cmnd *cmd)
dif = scsi_host_dif_capable(cmd->device->host, sdkp->protection_type);
dld = sd_cdl_dld(sdkp, cmd);
+ if (!sd_prot_flags_valid(cmd))
+ goto fail;
if (dif || dix)
protect = sd_setup_protect_cmnd(cmd, dix, dif);
else
diff --git a/drivers/scsi/sd_dif.c b/drivers/scsi/sd_dif.c
index ae6ce6f5d622..6c53e3b9d7d7 100644
--- a/drivers/scsi/sd_dif.c
+++ b/drivers/scsi/sd_dif.c
@@ -50,7 +50,7 @@ void sd_dif_config_host(struct scsi_disk *sdkp, struct queue_limits *lim)
bi->csum_type = BLK_INTEGRITY_CSUM_CRC;
if (type != T10_PI_TYPE3_PROTECTION)
- bi->flags |= BLK_INTEGRITY_REF_TAG;
+ bi->flags |= BLK_INTEGRITY_REF_TAG | BLK_INTEGRITY_APP_TAG;
bi->tuple_size = sizeof(struct t10_pi_tuple);
diff --git a/include/linux/blk-integrity.h b/include/linux/blk-integrity.h
index 2ff65c933c50..865e0c4a7255 100644
--- a/include/linux/blk-integrity.h
+++ b/include/linux/blk-integrity.h
@@ -13,6 +13,7 @@ enum blk_integrity_flags {
BLK_INTEGRITY_DEVICE_CAPABLE = 1 << 2,
BLK_INTEGRITY_REF_TAG = 1 << 3,
BLK_INTEGRITY_STACKED = 1 << 4,
+ BLK_INTEGRITY_APP_TAG = 1 << 5,
};
const char *blk_integrity_profile_name(struct blk_integrity *bi);
--
2.25.1
next prev parent reply other threads:[~2024-08-23 10:48 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20240823104552epcas5p226dbbbd448cd0ee0955ffdd3ad1b112d@epcas5p2.samsung.com>
2024-08-23 10:38 ` [PATCH v3 00/10] Read/Write with meta/integrity Anuj Gupta
[not found] ` <CGME20240823104616epcas5p4bd315bd116ea7e32b1abf7e174af64a1@epcas5p4.samsung.com>
2024-08-23 10:38 ` [PATCH v3 01/10] block: define set of integrity flags to be inherited by cloned bip Anuj Gupta
2024-08-24 8:24 ` Christoph Hellwig
2024-08-29 3:05 ` Martin K. Petersen
[not found] ` <CGME20240823104618epcas5p4b9983678886dceed75edd9cbec9341b2@epcas5p4.samsung.com>
2024-08-23 10:38 ` [PATCH v3 02/10] block: introduce a helper to determine metadata bytes from data iter Anuj Gupta
2024-08-24 8:24 ` Christoph Hellwig
2024-08-29 3:06 ` Martin K. Petersen
[not found] ` <CGME20240823104620epcas5p2118c152963d6cadfbc9968790ac0e536@epcas5p2.samsung.com>
2024-08-23 10:38 ` [PATCH v3 03/10] block: handle split correctly for user meta bounce buffer Anuj Gupta
2024-08-24 8:31 ` Christoph Hellwig
2024-08-28 11:18 ` Anuj Gupta
2024-08-29 4:04 ` Christoph Hellwig
[not found] ` <CGME20240823104622epcas5p2e3b29f793eff9857c5712b3d6d327ed5@epcas5p2.samsung.com>
2024-08-23 10:38 ` [PATCH v3 04/10] block: modify bio_integrity_map_user to accept iov_iter as argument Anuj Gupta
[not found] ` <CGME20240823104624epcas5p40c1b0f3516100f69cbd31d45867cd289@epcas5p4.samsung.com>
2024-08-23 10:38 ` [PATCH v3 05/10] block: define meta io descriptor Anuj Gupta
2024-08-24 8:31 ` Christoph Hellwig
2024-08-29 3:05 ` Martin K. Petersen
[not found] ` <CGME20240823104627epcas5p2abcd2283f6fb3301e1a8e828e3c270ae@epcas5p2.samsung.com>
2024-08-23 10:38 ` [PATCH v3 06/10] io_uring/rw: add support to send meta along with read/write Anuj Gupta
2024-08-24 8:33 ` Christoph Hellwig
[not found] ` <CGME20240823104629epcas5p3fea0cb7e66b0446ddacf7648c08c3ba8@epcas5p3.samsung.com>
2024-08-23 10:38 ` [PATCH v3 07/10] block: introduce BIP_CHECK_GUARD/REFTAG/APPTAG bip_flags Anuj Gupta
2024-08-24 8:35 ` Christoph Hellwig
2024-08-28 13:42 ` Kanchan Joshi
2024-08-29 3:16 ` Martin K. Petersen
2024-08-29 4:06 ` Christoph Hellwig
2024-08-29 13:29 ` Anuj gupta
2024-09-12 12:40 ` Anuj Gupta
2024-09-13 2:06 ` Martin K. Petersen
2024-08-29 4:06 ` Christoph Hellwig
[not found] ` <CGME20240823104631epcas5p4f83b92081107fbefca78008ee319ff7e@epcas5p4.samsung.com>
2024-08-23 10:38 ` [PATCH v3 07/10] block,nvme: " Anuj Gupta
[not found] ` <CGME20240823104634epcas5p4ef1af26cc7146b4e8b7a4a1844ffe476@epcas5p4.samsung.com>
2024-08-23 10:38 ` [PATCH v3 08/10] block: add support to pass user meta buffer Anuj Gupta
2024-08-24 8:44 ` Christoph Hellwig
[not found] ` <CGME20240823104636epcas5p4825a6d2dd9e45cfbcc97895264662d30@epcas5p4.samsung.com>
2024-08-23 10:38 ` [PATCH v3 09/10] nvme: add handling for app_tag Anuj Gupta
2024-08-24 8:49 ` Christoph Hellwig
2024-08-29 3:00 ` Martin K. Petersen
2024-08-29 10:18 ` Kanchan Joshi
2024-09-13 2:05 ` Martin K. Petersen
[not found] ` <CGME20240823104639epcas5p11dbab393122841419368a86b4bd5c04b@epcas5p1.samsung.com>
2024-08-23 10:38 ` Anuj Gupta [this message]
2024-08-24 8:52 ` [PATCH v3 10/10] scsi: add support for user-meta interface Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox