linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH v2] f2fs: fix to use per-inode maxbytes in f2fs_fiemap
@ 2021-03-09  5:09 Chengguang Xu
  0 siblings, 0 replies; only message in thread
From: Chengguang Xu @ 2021-03-09  5:09 UTC (permalink / raw)
  To: jaegeuk, chao; +Cc: Chengguang Xu, linux-f2fs-devel

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

Signed-off-by: Chengguang Xu <cgxu519@mykernel.net>
---
v1->v2:

- Calculate max bytes in inode lock.

 fs/f2fs/data.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 7c95818639a6..3cbcde4174e6 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -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;
-- 
2.27.0




_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-03-09  5:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-09  5:09 [f2fs-dev] [PATCH v2] f2fs: fix to use per-inode maxbytes in f2fs_fiemap Chengguang Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).