[PATCH 08/12] block: don't pretend to generate/verify for non-PI metadata

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The kernel won't ever generate or verify non-PI metadata, so don't
set the flags and don't allow the user to modify them.

Signed-off-by: Christoph Hellwig <hch@xxxxxx>
---
 block/blk-integrity.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/block/blk-integrity.c b/block/blk-integrity.c
index bb3cd1e0eeb58e..c2fcb8e659ed56 100644
--- a/block/blk-integrity.c
+++ b/block/blk-integrity.c
@@ -248,6 +248,9 @@ static ssize_t flag_store(struct device *dev, struct device_attribute *attr,
 	unsigned long val;
 	int err;
 
+	if (bi->csum_type == BLK_INTEGRITY_CSUM_NONE)
+		return -EINVAL;
+
 	err = kstrtoul(page, 10, &val);
 	if (err)
 		return err;
@@ -369,8 +372,9 @@ void blk_integrity_register(struct gendisk *disk, struct blk_integrity *template
 	struct blk_integrity *bi = &disk->queue->integrity;
 
 	bi->csum_type = template->csum_type;
-	bi->flags = BLK_INTEGRITY_VERIFY | BLK_INTEGRITY_GENERATE |
-		template->flags;
+	bi->flags = template->flags;
+	if (bi->csum_type != BLK_INTEGRITY_CSUM_NONE)
+		bi->flags |= BLK_INTEGRITY_VERIFY | BLK_INTEGRITY_GENERATE;
 	bi->interval_exp = template->interval_exp ? :
 		ilog2(queue_logical_block_size(disk->queue));
 	bi->tuple_size = template->tuple_size;
-- 
2.43.0





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux