[PATCH] erofs: support SEEK_HOLE/SEEK_DATA in inode_share mode
Jingbo Xu <[email protected]>
| Newsgroups | org.ozlabs.lists.linux-erofs,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
When inode_share is enabled, erofs_ishare_fops.llseek falls back to generic_file_llseek, which treats the whole file as data and always returns i_size for SEEK_HOLE, hiding real holes in sparse files. Switch it to erofs_file_llseek instead. For user files f_mapping->host is always the real erofs inode, so SEEK_HOLE/SEEK_DATA resolve the per-file on-disk layout via iomap_seek_hole()/iomap_seek_data(). Reported-by: Yuanhe Shu <[email protected]> Signed-off-by: Jingbo Xu <[email protected]> --- fs/erofs/data.c | 2 +- fs/erofs/internal.h | 2 ++ fs/erofs/ishare.c | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/erofs/data.c b/fs/erofs/data.c index d2f01245ee79..09d668deb86d 100644 --- a/fs/erofs/data.c +++ b/fs/erofs/data.c @@ -509,7 +509,7 @@ static int erofs_file_mmap_prepare(struct vm_area_desc *desc) #define erofs_file_mmap_prepare generic_file_readonly_mmap_prepare #endif -static loff_t erofs_file_llseek(struct file *file, loff_t offset, int whence) +loff_t erofs_file_llseek(struct file *file, loff_t offset, int whence) { struct inode *inode = file->f_mapping->host; const struct iomap_ops *ops = &erofs_iomap_ops; diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h index 57bd21859c65..3263c11d714c 100644 --- a/fs/erofs/internal.h +++ b/fs/erofs/internal.h @@ -528,6 +528,8 @@ static inline struct inode *erofs_real_inode(struct inode *inode, bool *need_ipu } #endif +loff_t erofs_file_llseek(struct file *file, loff_t offset, int whence); + long erofs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg); long erofs_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg); diff --git a/fs/erofs/ishare.c b/fs/erofs/ishare.c index fa7d4112dec5..4c7be60565cb 100644 --- a/fs/erofs/ishare.c +++ b/fs/erofs/ishare.c @@ -156,7 +156,7 @@ static int erofs_ishare_fadvise(struct file *file, loff_t offset, const struct file_operations erofs_ishare_fops = { .open = erofs_ishare_file_open, - .llseek = generic_file_llseek, + .llseek = erofs_file_llseek, .read_iter = erofs_ishare_file_read_iter, .mmap = erofs_ishare_mmap, .release = erofs_ishare_file_release, -- 2.19.1.6.gb485710b