summaryrefslogtreecommitdiffstats
path: root/src/kernel/xloop_file_fmt_raw.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/xloop_file_fmt_raw.c')
-rw-r--r--src/kernel/xloop_file_fmt_raw.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/kernel/xloop_file_fmt_raw.c b/src/kernel/xloop_file_fmt_raw.c
index 52d879a..17c5274 100644
--- a/src/kernel/xloop_file_fmt_raw.c
+++ b/src/kernel/xloop_file_fmt_raw.c
@@ -360,20 +360,20 @@ static int __raw_file_fmt_fallocate(struct xloop_device *xlo, struct request *rq
* information.
*/
struct file *file = xlo->xlo_backing_file;
- struct request_queue *q = xlo->xlo_queue;
int ret;
mode |= FALLOC_FL_KEEP_SIZE;
- if (!blk_queue_discard(q)) {
- ret = -EOPNOTSUPP;
- goto out;
- }
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 0)
+ if (!bdev_max_discard_sectors(xlo->xlo_device))
+#else
+ if (!blk_queue_discard(xlo->xlo_queue))
+#endif
+ return -EOPNOTSUPP;
ret = file->f_op->fallocate(file, mode, pos, blk_rq_bytes(rq));
if (unlikely(ret && ret != -EINVAL && ret != -EOPNOTSUPP))
ret = -EIO;
-out:
return ret;
}