Skip to contentSkip to conversation

f2fs: fix to use per-inode maxbytes in f2fs_fiemap

PATCH New Chengguang Xu 1 participant 1 message Mar 9, 2021 F2FS file system

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 f2fs: fix to use per-inode maxbytes in f2fs_fiemap

F2FS inode may have different max size,
so change to use per-inode maxbytes.

---
v1->v2:

- Calculate max bytes in inode lock.

 fs/f2fs/data.c | 9 +++++++++
 1 file changed, 9 insertions(+)
fs/f2fs/data.c +9 -0
index 7c95818639a6..3cbcde4174e6 100644
@@ -1850,6 +1850,15 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
 
 	inode_lock(inode);
 
+	maxbytes = max_file_blocks(inode) << F2FS_BLKSIZE_BITS;
+	if (start > maxbytes) {
+		ret = -EFBIG;
+		goto out;
+	}
+
+	if (len > maxbytes || (maxbytes - len) < start)
+		len = maxbytes - start;
+
 	if (fieinfo->fi_flags & FIEMAP_FLAG_XATTR) {
 		ret = f2fs_xattr_fiemap(inode, fieinfo);
 		goto out;
Signature · 9 lines
2.27.0




_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel