From 9f8bf22054b693c5c77367290db3b135f117d5a4 Mon Sep 17 00:00:00 2001 From: Gleb Chesnokov Date: Wed, 4 Sep 2024 12:17:39 +0300 Subject: [PATCH 1/3] scst_lib: Port to Linux kernel v6.11 Support for the following block layer changes in the Linux kernel v6.11: - e94b45d08b5d ("block: move dma_pad_mask into queue_limits") --- scst/src/scst_lib.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index c9d60c7c8..551afbaf2 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -8431,6 +8431,16 @@ static struct request *blk_make_request(struct request_queue *q, } #endif +static inline unsigned int +queue_dma_pad_mask(const struct request_queue *q) +{ +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 11, 0) + return q->dma_pad_mask; +#else + return q->limits.dma_pad_mask; +#endif +} + /* __blk_map_kern_sg - map kernel data to a request for REQ_TYPE_BLOCK_PC */ static struct request *__blk_map_kern_sg(struct request_queue *q, struct scatterlist *sgl, int nents, struct blk_kern_sg_work *bw, @@ -8553,7 +8563,7 @@ static struct request *__blk_map_kern_sg(struct request_queue *q, } /* Total length must satisfy DMA padding alignment */ - if ((tot_len & q->dma_pad_mask) && bw != NULL) { + if (bw && (tot_len & queue_dma_pad_mask(q))) { rq = ERR_PTR(-EINVAL); goto out_free_bios; } From 817279a4b46cf28aa8dde9eca57cadfea12f50b0 Mon Sep 17 00:00:00 2001 From: Gleb Chesnokov Date: Wed, 4 Sep 2024 12:30:56 +0300 Subject: [PATCH 2/3] scst_vdisk: Port to Linux kernel v6.11 Support for the following block layer changes in the Linux kernel v6.11: - e9f5f44ad372 ("block: remove the blk_integrity_profile structure") --- scst/src/dev_handlers/scst_vdisk.c | 39 ++++++++++++++++-------------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index 4f65d1ab4..0234743ba 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -983,48 +983,51 @@ static int vdisk_init_block_integrity(struct scst_vdisk_dev *virt_dev) #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) bi_profile_name = bi->name; -#else +#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 11, 0) bi_profile_name = bi->profile->name; +#else + bi_profile_name = blk_integrity_profile_name(bi); #endif + TRACE_DBG("BI name %s", bi_profile_name); if (!strcmp(bi_profile_name, "T10-DIF-TYPE1-CRC")) { dev->dev_dif_ip_not_supported = 1; if (virt_dev->dif_type != 1) { - PRINT_ERROR("Integrity type mismatch, %d expected, " - "but block device has 1 (dev %s)", - virt_dev->dif_type, dev->virt_name); + PRINT_ERROR( + "Integrity type mismatch, %d expected, but block device has 1 (dev %s)", + virt_dev->dif_type, dev->virt_name); res = -EINVAL; goto out_close; } } else if (!strcmp(bi_profile_name, "T10-DIF-TYPE1-IP")) { if (virt_dev->dif_type != 1) { - PRINT_ERROR("Integrity type mismatch, %d expected, " - "but block device has 1 (dev %s)", - virt_dev->dif_type, dev->virt_name); + PRINT_ERROR( + "Integrity type mismatch, %d expected, but block device has 1 (dev %s)", + virt_dev->dif_type, dev->virt_name); res = -EINVAL; goto out_close; } } else if (!strcmp(bi_profile_name, "T10-DIF-TYPE3-CRC")) { dev->dev_dif_ip_not_supported = 1; if (virt_dev->dif_type != 3) { - PRINT_ERROR("Integrity type mismatch, %d expected, " - "but block device has 1 (dev %s)", - virt_dev->dif_type, dev->virt_name); + PRINT_ERROR( + "Integrity type mismatch, %d expected, but block device has 1 (dev %s)", + virt_dev->dif_type, dev->virt_name); res = -EINVAL; goto out_close; } } else if (!strcmp(bi_profile_name, "T10-DIF-TYPE3-IP")) { if (virt_dev->dif_type != 3) { - PRINT_ERROR("Integrity type mismatch, %d expected, " - "but block device has 3 (dev %s)", - virt_dev->dif_type, dev->virt_name); + PRINT_ERROR( + "Integrity type mismatch, %d expected, but block device has 3 (dev %s)", + virt_dev->dif_type, dev->virt_name); res = -EINVAL; goto out_close; } } else { - PRINT_ERROR("Unable to understand integrity name %s" - "(dev %s)", bi_profile_name, dev->virt_name); + PRINT_ERROR("Unable to understand integrity name %s (dev %s)", + bi_profile_name, dev->virt_name); res = -EINVAL; goto out_close; } @@ -1033,15 +1036,15 @@ static int vdisk_init_block_integrity(struct scst_vdisk_dev *virt_dev) if ((virt_dev->dif_mode & SCST_DIF_MODE_DEV_CHECK) && !(virt_dev->dif_mode & SCST_DIF_MODE_DEV_STORE)) { - PRINT_ERROR("Blockio dev_check is not possible without " - "dev_store (dev %s)", dev->virt_name); + PRINT_ERROR("Blockio dev_check is not possible without dev_store (dev %s)", + dev->virt_name); res = -EINVAL; goto out_close; } if (!(virt_dev->dif_mode & SCST_DIF_MODE_DEV_CHECK)) PRINT_WARNING("Blk integrity implies dev_check (dev %s)", - dev->virt_name); + dev->virt_name); out_no_bi: res = 0; From 862b84fb9dca6ecb07c98266aac376e41ad945cc Mon Sep 17 00:00:00 2001 From: Gleb Chesnokov Date: Wed, 4 Sep 2024 12:42:49 +0300 Subject: [PATCH 3/3] scst_local: Port to Linux kernel v6.11 Support for the following driver core changes in the Linux kernel v6.11: - d69d80484598 ("driver core: have match() callback in struct bus_type take a const *") --- scst_local/scst_local.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scst_local/scst_local.c b/scst_local/scst_local.c index 0e0efedff..902153220 100644 --- a/scst_local/scst_local.c +++ b/scst_local/scst_local.c @@ -1500,8 +1500,11 @@ static DRIVER_REMOVE_RET scst_local_driver_remove(struct device *dev) return (DRIVER_REMOVE_RET)0; } -static int scst_local_bus_match(struct device *dev, - struct device_driver *dev_driver) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 11, 0) +static int scst_local_bus_match(struct device *dev, struct device_driver *drv) +#else +static int scst_local_bus_match(struct device *dev, const struct device_driver *drv) +#endif { TRACE_ENTRY();