Skip to contentSkip to conversation

nvme-fc: add DIF support for intergrity metadata

PATCH In review Atharva Tiwari 2 participants 2 messages Dec 26, 2024 – Jan 3, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvme-fc: add DIF support for intergrity metadata

This patch enhances the NVMe over Fibre Channel (NVMe-FC) driver to handle requests with integrity metadata (DIF).

- Added the inclusion of <linux/blk-integrity.h> to enable integrity operations.
- Implemented support for mapping integrity metadata using blk_rq_map_integrity_sg.
- Ensures proper handling of requests with integrity metadata, including error cases where mapping fails.

This update improves the reliability of data integrity checks in environments utilizing DIF.

---
 drivers/nvme/host/fc.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/nvme/host/fc.c +11 -4
index b81af7919e94..d0343133413f 100644
@@ -17,6 +17,7 @@
 #include "fc.h"
 #include <scsi/scsi_transport_fc.h>
 #include <linux/blk-mq-pci.h>
+#include <linux/blk-integrity.h>
 
 /* *************************** Data Structures/Defines ****************** */
 
@@ -2620,10 +2621,16 @@ nvme_fc_map_data(struct nvme_fc_ctrl *ctrl, struct request *rq,
 		freq->sg_cnt = 0;
 		return -EFAULT;
 	}
-
-	/*
-	 * TODO: blk_integrity_rq(rq)  for DIF
-	 */
+	/* Handle requests with integrity metadata (DIF) */
+	if (blk_integrity_rq(rq)) {
+		ret = blk_rq_map_integrity_sg(rq, freq->sg_table.sgl);
+		if (ret < 0) {
+			sg_free_table_chained(&freq->sg_table, NVME_INLINE_SG_CNT);
+			freq->sg_cnt = 0;
+			return -EFAULT;
+		}
+		freq->sg_cnt += ret;
+	}
 	return 0;
 }
 
Signature · 1 line
2.39.5
#1 lore raw
Quoted 6 lines · Atharva Tiwari

This patch enhances the NVMe over Fibre Channel (NVMe-FC) driver to handle requests with integrity metadata (DIF).

- Added the inclusion of <linux/blk-integrity.h> to enable integrity operations.
- Implemented support for mapping integrity metadata using blk_rq_map_integrity_sg.
- Ensures proper handling of requests with integrity metadata, including error cases where mapping fails.

This isn't really how we write commit logs. The mechanics are visible in the patch. Also please wrap commit log lines after 73 characters.

drivers/nvme/host/fc.c nvme_fc_map_data(struct nvme_fc_ctrl *ctrl, struct request *rq, · line 2633

Quoted 10 lines
drivers/nvme/host/fc.c +10 -0
+	/* Handle requests with integrity metadata (DIF) */
+	if (blk_integrity_rq(rq)) {
+		ret = blk_rq_map_integrity_sg(rq, freq->sg_table.sgl);
+		if (ret < 0) {
+			sg_free_table_chained(&freq->sg_table, NVME_INLINE_SG_CNT);
+			freq->sg_cnt = 0;
+			return -EFAULT;
+		}
+		freq->sg_cnt += ret;
+	}

Who is going to look at the integrity sglist? Who is setting a max_integrity_segments value for nvme-fc?

How was this tested?