On Mar 10, 2021 / 08:45, Christoph Hellwig wrote: > > switch (cmd) { > > case BLKRESETZONE: > > op = REQ_OP_ZONE_RESET; > > + > > + capacity = get_capacity(bdev->bd_disk); > > + if (zrange.sector + zrange.nr_sectors <= zrange.sector || > > + zrange.sector + zrange.nr_sectors > capacity) > > + /* Out of range */ > > + return -EINVAL; > > + > > + start = zrange.sector << SECTOR_SHIFT; > > + end = ((zrange.sector + zrange.nr_sectors) << SECTOR_SHIFT) - 1; > > + > > + /* Invalidate the page cache, including dirty pages. */ > > + ret = truncate_bdev_range(bdev, mode, start, end); > > + if (ret) > > + return ret; > > Can we factor this out into a truncate_zone_range() helper? Yes, we can. The helper will be as follows. I will rework the patch and send v3. static int blkdev_truncate_zone_range(struct block_device *bdev, fmode_t mode, const struct blk_zone_range *zrange) { loff_t start, end; if (zrange->sector + zrange->nr_sectors <= zrange->sector || zrange->sector + zrange->nr_sectors > get_capacity(bdev->bd_disk)) /* Out of range */ return -EINVAL; start = zrange->sector << SECTOR_SHIFT; end = ((zrange->sector + zrange->nr_sectors) << SECTOR_SHIFT) - 1; return truncate_bdev_range(bdev, mode, start, end); } -- Best Regards, Shin'ichiro Kawasaki