[PATCH v4 11/11] scsi: add support for user-meta interface
Anuj Gupta
anuj20.g at samsung.com
Fri Oct 18 01:26:48 PDT 2024
On Thu, Oct 17, 2024 at 04:39:18PM +0200, Christoph Hellwig wrote:
> On Thu, Oct 17, 2024 at 05:09:23PM +0530, Anuj Gupta wrote:
> > This snippet prevents a scenario where a apptag check is specified without
> > a reftag check and vice-versa, which is not possible for scsi[1].
> > But for
> > block layer generated integrity apptag check (BIP_CHECK_APPTAG) is not
> > specified. When scsi drive is formatted with type1/2 PI, block layer would
> > specify refcheck but not appcheck. Hence, these I/O's would fail. Do you
> > see how we can handle this?
>
> Well, this is also related to difference in capability checking.
Right.
> Just curious, do you have any user of the more fine grained checking
> in NVMe? If not we could support the SCSI semantics only and emulate
> them using the fine grained NVMe semantics and have no portability
> problems.
We can choose to support scsi semantics only and expose only the valid
scsi combinations to userspace i.e.
1. no check
2. guard check only
3. ref + app check only
4. guard + ref + app check
Something like this [*] on top of this series, untested though. Does
this align with what you have in mind?
[*]
diff --git a/block/bio-integrity.c b/block/bio-integrity.c
index 24fad9b6f3ec..2ca27910770b 100644
--- a/block/bio-integrity.c
+++ b/block/bio-integrity.c
@@ -308,12 +308,10 @@ static void bio_uio_meta_to_bip(struct bio *bio, struct uio_meta *meta)
{
struct bio_integrity_payload *bip = bio_integrity(bio);
- if (meta->flags & BLK_INTEGRITY_CHK_GUARD)
+ if (meta->flags & IO_INTEGRITY_CHK_GUARD)
bip->bip_flags |= BIP_CHECK_GUARD;
- if (meta->flags & BLK_INTEGRITY_CHK_APPTAG)
- bip->bip_flags |= BIP_CHECK_APPTAG;
- if (meta->flags & BLK_INTEGRITY_CHK_REFTAG)
- bip->bip_flags |= BIP_CHECK_REFTAG;
+ if (meta->flags & IO_INTEGRITY_CHK_REF_APP)
+ bip->bip_flags |= BIP_CHECK_REFTAG | BIP_CHECK_APPTAG;
bip->app_tag = meta->app_tag;
}
@@ -329,9 +327,9 @@ int bio_integrity_map_iter(struct bio *bio, struct uio_meta *meta)
return -EINVAL;
/* should fit into two bytes */
- BUILD_BUG_ON(BLK_INTEGRITY_VALID_FLAGS >= (1 << 16));
+ BUILD_BUG_ON(IO_INTEGRITY_VALID_FLAGS >= (1 << 16));
- if (meta->flags && (meta->flags & ~BLK_INTEGRITY_VALID_FLAGS))
+ if (meta->flags && (meta->flags & ~IO_INTEGRITY_VALID_FLAGS))
return -EINVAL;
/*
diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h
index 753971770733..714700f9826e 100644
--- a/include/uapi/linux/fs.h
+++ b/include/uapi/linux/fs.h
@@ -40,6 +40,15 @@
#define BLOCK_SIZE_BITS 10
#define BLOCK_SIZE (1<<BLOCK_SIZE_BITS)
+/*
+ * flags for integrity meta
+ */
+#define IO_INTEGRITY_CHK_GUARD (1U << 0) /* enforce guard check */
+#define IO_INTEGRITY_CHK_REF_APP (1U << 1) /* enforce ref and app check */
+
+#define IO_INTEGRITY_VALID_FLAGS (IO_INTEGRITY_CHK_GUARD | \
+ IO_INTEGRITY_CHK_REF_APP)
+
#define SEEK_SET 0 /* seek relative to beginning of file */
#define SEEK_CUR 1 /* seek relative to current file position */
#define SEEK_END 2 /* seek relative to end of file */
More information about the Linux-nvme
mailing list