@@ -79,6 +79,8 @@ int __blkdev_issue_discard(struct block_device *bdev, sector_t sector,
WARN_ON_ONCE((req_sects << 9) > UINT_MAX);
+ pr_info("%s %d sector %llu nr_sects %llu\n",
+ __func__, __LINE__, sector, nr_sects);
bio = blk_next_bio(bio, bdev, 0, op, gfp_mask);
bio->bi_iter.bi_sector = sector;
bio->bi_iter.bi_size = req_sects << 9;
@@ -237,6 +239,8 @@ static int __blkdev_issue_write_zeroes(struct block_device *bdev,
return -EOPNOTSUPP;
while (nr_sects) {
+ pr_info("%s %d sector %llu nr_sects %llu\n",
+ __func__, __LINE__, sector, nr_sects);
bio = blk_next_bio(bio, bdev, 0, REQ_OP_WRITE_ZEROES, gfp_mask);
bio->bi_iter.bi_sector = sector;
if (flags & BLKDEV_ZERO_NOUNMAP)
@@ -282,6 +286,8 @@ static int __blkdev_issue_zero_pages(struct block_device *bdev,
return -EPERM;
while (nr_sects != 0) {
+ pr_info("%s %d sector %llu nr_sects %llu\n",
+ __func__, __LINE__, sector, nr_sects);
bio = blk_next_bio(bio, bdev, __blkdev_sectors_to_bio_pages(nr_sects),
REQ_OP_WRITE, gfp_mask);
bio->bi_iter.bi_sector = sector;
@@ -84,6 +84,9 @@ static bool g_virt_boundary = false;
module_param_named(virt_boundary, g_virt_boundary, bool, 0444);
MODULE_PARM_DESC(virt_boundary, "Require a virtual boundary for the device. Default: False");
+static bool g_write_zeroes = false;
+module_param_named(write_zeroes, g_write_zeroes, bool, 0444);
+
static int g_no_sched;
module_param_named(no_sched, g_no_sched, int, 0444);
MODULE_PARM_DESC(no_sched, "No io scheduler");
@@ -1755,25 +1758,12 @@ static void null_del_dev(struct nullb *nullb)
static void null_config_discard(struct nullb *nullb)
{
- if (nullb->dev->discard == false)
- return;
-
- if (!nullb->dev->memory_backed) {
- nullb->dev->discard = false;
- pr_info("discard option is ignored without memory backing\n");
- return;
- }
-
- if (nullb->dev->zoned) {
- nullb->dev->discard = false;
- pr_info("discard option is ignored in zoned mode\n");
- return;
- }
-
nullb->q->limits.discard_granularity = nullb->dev->blocksize;
nullb->q->limits.discard_alignment = nullb->dev->blocksize;
blk_queue_max_discard_sectors(nullb->q, UINT_MAX >> 9);
blk_queue_flag_set(QUEUE_FLAG_DISCARD, nullb->q);
+ if (g_write_zeroes)
+ blk_queue_max_write_zeroes_sectors(nullb->q, UINT_MAX >> 9);
}
static const struct block_device_operations null_bio_ops = {