Add new function for block_device_operations, which will be used for SEEK_HOLE and SEEK_DATA llseek calls
https://jira.vzint.dev/browse/PSBM-145746 Signed-off-by: Andrey Zhadchenko <andrey.zhadche...@virtuozzo.com> --- block/fops.c | 11 +++++++++++ include/linux/blkdev.h | 1 + 2 files changed, 12 insertions(+) diff --git a/block/fops.c b/block/fops.c index 6518e17450b3..1cd6c05acf9e 100644 --- a/block/fops.c +++ b/block/fops.c @@ -434,8 +434,19 @@ const struct address_space_operations def_blk_aops = { static loff_t blkdev_llseek(struct file *file, loff_t offset, int whence) { struct inode *bd_inode = bdev_file_inode(file); + struct block_device *bdev = I_BDEV(bd_inode); + bool is_hole_seek = whence & (SEEK_HOLE | SEEK_DATA); loff_t retval; + if (is_hole_seek && bdev->bd_disk->fops->find_hole) { + retval = bdev->bd_disk->fops->find_hole(bdev, offset, whence); + if (retval < 0) + return retval; + + offset = retval; + whence = SEEK_SET; + } + inode_lock(bd_inode); retval = fixed_size_llseek(file, offset, whence, i_size_read(bd_inode)); inode_unlock(bd_inode); diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 94944d8584d8..939e8893ad11 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1447,6 +1447,7 @@ struct block_device_operations { void (*unlock_native_capacity) (struct gendisk *); int (*getgeo)(struct block_device *, struct hd_geometry *); int (*set_read_only)(struct block_device *bdev, bool ro); + loff_t (*find_hole)(struct block_device *bdev, loff_t offset, int whence); void (*free_disk)(struct gendisk *disk); /* this callback is with swap_lock and sometimes page table lock held */ void (*swap_slot_free_notify) (struct block_device *, unsigned long); -- 2.39.3 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel