block: remove QUEUE_FLAG_DISCARD

Just use a non-zero max_discard_sectors as an indicator for discard
support, similar to what is done for write zeroes.

The only places where needs special attention is the RAID5 driver,
which must clear discard support for security reasons by default,
even if the default stacking rules would allow for it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Acked-by: Christoph Böhmwalder <christoph.boehmwalder@linbit.com> [drbd]
Acked-by: Jan Höppner <hoeppner@linux.ibm.com> [s390]
Acked-by: Coly Li <colyli@suse.de> [bcache]
Acked-by: David Sterba <dsterba@suse.com> [btrfs]
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Link: https://lore.kernel.org/r/20220415045258.199825-25-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
This commit is contained in:
Christoph Hellwig authored and Namjae Jeon committed 2022-07-22 11:43:45 +09:00
1 parent 8d627e3001
commit dda72dc536
2 files changed
+22 -4

No files matched your search

+4
View File
@@ -379,7 +379,11 @@ static int exfat_ioctl_fitrim(struct inode *inode, unsigned long arg)
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 0)
if (!bdev_max_discard_sectors(inode->i_sb->s_bdev))
#else
if (!blk_queue_discard(q))
#endif
return -EOPNOTSUPP;
if (copy_from_user(&range, (struct fstrim_range __user *)arg, sizeof(range)))
+18 -4
View File
@@ -559,14 +559,21 @@ out:
if (opts->allow_utime == -1)
opts->allow_utime = ~opts->fs_dmask & (0022);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 0)
if (opts->discard && !bdev_max_discard_sectors(sb->s_bdev)) {
exfat_warn(sb, "mounting with \"discard\" option, but the device does not support discard");
opts->discard = 0;
}
#else
if (opts->discard) {
struct request_queue *q = bdev_get_queue(sb->s_bdev);
if (!blk_queue_discard(q))
exfat_msg(sb, KERN_WARNING,
"mounting with \"discard\" option, but the device does not support discard");
opts->discard = 0;
if (!blk_queue_discard(q)) {
exfat_warn(sb, "mounting with \"discard\" option, but the device does not support discard");
opts->discard = 0;
}
}
#endif
return 0;
}
@@ -896,6 +903,12 @@ static int exfat_fill_super(struct super_block *sb, void *data, int silent)
if (opts->allow_utime == (unsigned short)-1)
opts->allow_utime = ~opts->fs_dmask & 0022;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 0)
if (opts->discard && !bdev_max_discard_sectors(sb->s_bdev)) {
exfat_warn(sb, "mounting with \"discard\" option, but the device does not support discard");
opts->discard = 0;
}
#else
if (opts->discard) {
struct request_queue *q = bdev_get_queue(sb->s_bdev);
@@ -904,6 +917,7 @@ static int exfat_fill_super(struct super_block *sb, void *data, int silent)
opts->discard = 0;
}
}
#endif
#else
struct exfat_sb_info *sbi;