]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blobdiff - block/blk-lib.c
perf tools: Add FIFO file names as alternative options to --control
[mirror_ubuntu-hirsute-kernel.git] / block / blk-lib.c
index 019e09bb9c0e67463176441a4a025435758126ae..0d1811e57ac704972f383fb4133386af940a71e6 100644 (file)
@@ -47,6 +47,15 @@ int __blkdev_issue_discard(struct block_device *bdev, sector_t sector,
                op = REQ_OP_DISCARD;
        }
 
+       /* In case the discard granularity isn't set by buggy device driver */
+       if (WARN_ON_ONCE(!q->limits.discard_granularity)) {
+               char dev_name[BDEVNAME_SIZE];
+
+               bdevname(bdev, dev_name);
+               pr_err_ratelimited("%s: Error: discard_granularity is 0.\n", dev_name);
+               return -EOPNOTSUPP;
+       }
+
        bs_mask = (bdev_logical_block_size(bdev) >> 9) - 1;
        if ((sector | nr_sects) & bs_mask)
                return -EINVAL;