mirror of
https://github.com/SCST-project/scst.git
synced 2026-08-18 13:16:34 +00:00
scst_vdisk: Port to Linux kernel v5.19
Support for the following block layer changes in the Linux Kernel v5.19:
- 44abff2c0b97 ("block: decouple REQ_OP_SECURE_ERASE from REQ_OP_DISCARD")
- 70200574cc22 ("block: remove QUEUE_FLAG_DISCARD")
This commit is contained in:
@@ -206,6 +206,23 @@ void blk_execute_rq_nowait_backport(struct request *rq, bool at_head)
|
||||
#define blk_execute_rq_nowait blk_execute_rq_nowait_backport
|
||||
#endif
|
||||
|
||||
/* <linux/blkdev.h> */
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 19, 0)
|
||||
/*
|
||||
* See also commit 44abff2c0b97 ("block: decouple REQ_OP_SECURE_ERASE
|
||||
* from REQ_OP_DISCARD") # v5.19.
|
||||
*/
|
||||
static inline
|
||||
int blkdev_issue_discard_backport(struct block_device *bdev, sector_t sector,
|
||||
sector_t nr_sects, gfp_t gfp_mask)
|
||||
{
|
||||
return blkdev_issue_discard(bdev, sector, nr_sects, gfp_mask, 0);
|
||||
}
|
||||
|
||||
#define blkdev_issue_discard blkdev_issue_discard_backport
|
||||
#endif
|
||||
|
||||
/* <linux/byteorder/generic.h> */
|
||||
/*
|
||||
* See also f2f2efb807d3 ("byteorder: Move {cpu_to_be32, be32_to_cpu}_array()
|
||||
|
||||
@@ -562,8 +562,13 @@ static void vdisk_check_tp_support(struct scst_vdisk_dev *virt_dev)
|
||||
fd_open = true;
|
||||
|
||||
if (virt_dev->blockio) {
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 0)
|
||||
virt_dev->dev_thin_provisioned =
|
||||
!!bdev_max_discard_sectors(bdev);
|
||||
#else
|
||||
virt_dev->dev_thin_provisioned =
|
||||
blk_queue_discard(bdev_get_queue(bdev));
|
||||
#endif
|
||||
} else {
|
||||
virt_dev->dev_thin_provisioned = (fd->f_op->fallocate != NULL);
|
||||
}
|
||||
@@ -581,7 +586,6 @@ check:
|
||||
if (virt_dev->thin_provisioned)
|
||||
PRINT_INFO("Auto enable thin provisioning for device "
|
||||
"%s", virt_dev->filename);
|
||||
|
||||
}
|
||||
|
||||
if (virt_dev->thin_provisioned) {
|
||||
@@ -1811,8 +1815,7 @@ static int vdisk_unmap_range(struct scst_cmd *cmd,
|
||||
sector_t nr_sects = blocks << (cmd->dev->block_shift - 9);
|
||||
gfp_t gfp = cmd->cmd_gfp_mask;
|
||||
|
||||
err = blkdev_issue_discard(bdev, start_sector, nr_sects, gfp,
|
||||
0);
|
||||
err = blkdev_issue_discard(bdev, start_sector, nr_sects, gfp);
|
||||
if (unlikely(err != 0)) {
|
||||
PRINT_ERROR("blkdev_issue_discard() for "
|
||||
"LBA %lld, blocks %lld failed: %d",
|
||||
|
||||
Reference in New Issue
Block a user