@@ -234,7 +234,8 @@ For each extent in the request range, the file system should call
the helper function, fiemap_fill_next_extent()::
int fiemap_fill_next_extent(struct fiemap_extent_info *info, u64 logical,
- u64 phys, u64 len, u32 flags, u32 dev);
+ u64 phys, u64 log_len, u64 phys_len, u32 flags,
+ u32 dev);
fiemap_fill_next_extent() will use the passed values to populate the
next free extent in the fm_extents array. 'General' extent flags will
@@ -927,7 +927,9 @@ static int bch2_fill_extent(struct bch_fs *c,
ret = fiemap_fill_next_extent(info,
bkey_start_offset(k.k) << 9,
offset << 9,
- k.k->size << 9, flags|flags2);
+ k.k->size << 9,
+ k.k->size << 9,
+ flags|flags2);
if (ret)
return ret;
}
@@ -937,12 +939,14 @@ static int bch2_fill_extent(struct bch_fs *c,
return fiemap_fill_next_extent(info,
bkey_start_offset(k.k) << 9,
0, k.k->size << 9,
+ k.k->size << 9,
flags|
FIEMAP_EXTENT_DATA_INLINE);
} else if (k.k->type == KEY_TYPE_reservation) {
return fiemap_fill_next_extent(info,
bkey_start_offset(k.k) << 9,
0, k.k->size << 9,
+ k.k->size << 9,
flags|
FIEMAP_EXTENT_DELALLOC|
FIEMAP_EXTENT_UNWRITTEN);
@@ -2743,7 +2743,7 @@ static int emit_last_fiemap_cache(struct fiemap_extent_info *fieinfo,
return 0;
ret = fiemap_fill_next_extent(fieinfo, cache->offset, cache->phys,
- cache->len, cache->flags);
+ cache->len, cache->len, cache->flags);
cache->cached = false;
if (ret > 0)
ret = 0;
@@ -2215,6 +2215,7 @@ static int ext4_fill_es_cache_info(struct inode *inode,
(__u64)es.es_lblk << blksize_bits,
(__u64)es.es_pblk << blksize_bits,
(__u64)es.es_len << blksize_bits,
+ (__u64)es.es_len << blksize_bits,
flags);
if (next == 0)
break;
@@ -1843,7 +1843,8 @@ static int f2fs_xattr_fiemap(struct inode *inode,
if (!xnid)
flags |= FIEMAP_EXTENT_LAST;
- err = fiemap_fill_next_extent(fieinfo, 0, phys, len, flags);
+ err = fiemap_fill_next_extent(
+ fieinfo, 0, phys, len, len, flags);
trace_f2fs_fiemap(inode, 0, phys, len, flags, err);
if (err)
return err;
@@ -1869,7 +1870,8 @@ static int f2fs_xattr_fiemap(struct inode *inode,
}
if (phys) {
- err = fiemap_fill_next_extent(fieinfo, 0, phys, len, flags);
+ err = fiemap_fill_next_extent(
+ fieinfo, 0, phys, len, len, flags);
trace_f2fs_fiemap(inode, 0, phys, len, flags, err);
}
@@ -1988,7 +1990,7 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
flags |= FIEMAP_EXTENT_DATA_ENCRYPTED;
ret = fiemap_fill_next_extent(fieinfo, logical,
- phys, size, flags);
+ phys, size, size, flags);
trace_f2fs_fiemap(inode, logical, phys, size, flags, ret);
if (ret)
goto out;
@@ -806,7 +806,8 @@ int f2fs_inline_data_fiemap(struct inode *inode,
byteaddr = (__u64)ni.blk_addr << inode->i_sb->s_blocksize_bits;
byteaddr += (char *)inline_data_addr(inode, ipage) -
(char *)F2FS_INODE(ipage);
- err = fiemap_fill_next_extent(fieinfo, start, byteaddr, ilen, flags);
+ err = fiemap_fill_next_extent(
+ fieinfo, start, byteaddr, ilen, ilen, flags);
trace_f2fs_fiemap(inode, start, byteaddr, ilen, flags, err);
out:
f2fs_put_page(ipage, 1);
@@ -99,7 +99,8 @@ static int ioctl_fibmap(struct file *filp, int __user *p)
* @fieinfo: Fiemap context passed into ->fiemap
* @logical: Extent logical start offset, in bytes
* @phys: Extent physical start offset, in bytes
- * @len: Extent length, in bytes
+ * @log_len: Extent logical length, in bytes
+ * @phys_len: Extent physical length, in bytes
* @flags: FIEMAP_EXTENT flags that describe this extent
*
* Called from file system ->fiemap callback. Will populate extent
@@ -110,7 +111,7 @@ static int ioctl_fibmap(struct file *filp, int __user *p)
* extent that will fit in user array.
*/
int fiemap_fill_next_extent(struct fiemap_extent_info *fieinfo, u64 logical,
- u64 phys, u64 len, u32 flags)
+ u64 phys, u64 log_len, u64 phys_len, u32 flags)
{
struct fiemap_extent extent;
struct fiemap_extent __user *dest = fieinfo->fi_extents_start;
@@ -138,8 +139,8 @@ int fiemap_fill_next_extent(struct fiemap_extent_info *fieinfo, u64 logical,
memset(&extent, 0, sizeof(extent));
extent.fe_logical = logical;
extent.fe_physical = phys;
- extent.fe_length = len;
- extent.fe_physical_length = len;
+ extent.fe_length = log_len;
+ extent.fe_physical_length = phys_len;
extent.fe_flags = flags;
dest += fieinfo->fi_extents_mapped;
@@ -36,7 +36,7 @@ static int iomap_to_fiemap(struct fiemap_extent_info *fi,
return fiemap_fill_next_extent(fi, iomap->offset,
iomap->addr != IOMAP_NULL_ADDR ? iomap->addr : 0,
- iomap->length, flags);
+ iomap->length, iomap->length, flags);
}
static loff_t iomap_fiemap_iter(const struct iomap_iter *iter,
@@ -1190,7 +1190,8 @@ int nilfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
if (size) {
/* End of the current extent */
ret = fiemap_fill_next_extent(
- fieinfo, logical, phys, size, flags);
+ fieinfo, logical, phys, size, size,
+ flags);
if (ret)
break;
}
@@ -1240,7 +1241,8 @@ int nilfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
flags |= FIEMAP_EXTENT_LAST;
ret = fiemap_fill_next_extent(
- fieinfo, logical, phys, size, flags);
+ fieinfo, logical, phys, size, size,
+ flags);
if (ret)
break;
size = 0;
@@ -1256,7 +1258,7 @@ int nilfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
/* Terminate the current extent */
ret = fiemap_fill_next_extent(
fieinfo, logical, phys, size,
- flags);
+ size, flags);
if (ret || blkoff > end_blkoff)
break;
@@ -1948,6 +1948,7 @@ int ni_fiemap(struct ntfs_inode *ni, struct fiemap_extent_info *fieinfo,
err = fiemap_fill_next_extent(
fieinfo, 0, 0,
attr ? le32_to_cpu(attr->res.data_size) : 0,
+ attr ? le32_to_cpu(attr->res.data_size) : 0,
FIEMAP_EXTENT_DATA_INLINE | FIEMAP_EXTENT_LAST |
FIEMAP_EXTENT_MERGED);
goto out;
@@ -2042,7 +2043,7 @@ int ni_fiemap(struct ntfs_inode *ni, struct fiemap_extent_info *fieinfo,
flags |= FIEMAP_EXTENT_LAST;
err = fiemap_fill_next_extent(fieinfo, vbo, lbo, dlen,
- flags);
+ dlen, flags);
if (err < 0)
break;
if (err == 1) {
@@ -2062,7 +2063,8 @@ int ni_fiemap(struct ntfs_inode *ni, struct fiemap_extent_info *fieinfo,
if (vbo + bytes >= end)
flags |= FIEMAP_EXTENT_LAST;
- err = fiemap_fill_next_extent(fieinfo, vbo, lbo, bytes, flags);
+ err = fiemap_fill_next_extent(fieinfo, vbo, lbo, bytes, bytes,
+ flags);
if (err < 0)
break;
if (err == 1) {
@@ -723,7 +723,7 @@ static int ocfs2_fiemap_inline(struct inode *inode, struct buffer_head *di_bh,
id2.i_data.id_data);
ret = fiemap_fill_next_extent(fieinfo, 0, phys, id_count,
- flags);
+ id_count, flags);
if (ret < 0)
return ret;
}
@@ -794,7 +794,7 @@ int ocfs2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
virt_bytes = (u64)le32_to_cpu(rec.e_cpos) << osb->s_clustersize_bits;
ret = fiemap_fill_next_extent(fieinfo, virt_bytes, phys_bytes,
- len_bytes, fe_flags);
+ len_bytes, len_bytes, fe_flags);
if (ret)
break;
@@ -3778,6 +3778,7 @@ static int smb3_fiemap(struct cifs_tcon *tcon,
le64_to_cpu(out_data[i].file_offset),
le64_to_cpu(out_data[i].file_offset),
le64_to_cpu(out_data[i].length),
+ le64_to_cpu(out_data[i].length),
flags);
if (rc < 0)
goto out;
@@ -16,6 +16,6 @@ struct fiemap_extent_info {
int fiemap_prep(struct inode *inode, struct fiemap_extent_info *fieinfo,
u64 start, u64 *len, u32 supported_flags);
int fiemap_fill_next_extent(struct fiemap_extent_info *info, u64 logical,
- u64 phys, u64 len, u32 flags);
+ u64 phys, u64 log_len, u64 phys_len, u32 flags);
#endif /* _LINUX_FIEMAP_H 1 */
Update the signature of fiemap_fill_next_extent() to allow passing a physical length, and update all callers to pass the same logical and physical lengths. Signed-off-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me> --- Documentation/filesystems/fiemap.rst | 3 ++- fs/bcachefs/fs.c | 6 +++++- fs/btrfs/extent_io.c | 2 +- fs/ext4/extents.c | 1 + fs/f2fs/data.c | 8 +++++--- fs/f2fs/inline.c | 3 ++- fs/ioctl.c | 9 +++++---- fs/iomap/fiemap.c | 2 +- fs/nilfs2/inode.c | 8 +++++--- fs/ntfs3/frecord.c | 6 ++++-- fs/ocfs2/extent_map.c | 4 ++-- fs/smb/client/smb2ops.c | 1 + include/linux/fiemap.h | 2 +- 13 files changed, 35 insertions(+), 20 deletions(-)