All of lore.kernel.org
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH] f2fs: change the way of handling range.len in F2FS_IOC_SEC_TRIM_FILE
@ 2020-07-10  2:15 ` Daeho Jeong
  0 siblings, 0 replies; 28+ messages in thread
From: Daeho Jeong @ 2020-07-10  2:15 UTC (permalink / raw)
  To: linux-kernel, linux-f2fs-devel, kernel-team; +Cc: Daeho Jeong

From: Daeho Jeong <daehojeong@google.com>

Changed the way of handling range.len of F2FS_IOC_SEC_TRIM_FILE.
 1. Added -1 value support for range.len to signify the end of file.
 2. If the end of the range passes over the end of file, it means until
    the end of file.
 3. ignored the case of that range.len is zero to prevent the function
    from making end_addr zero and triggering different behaviour of
    the function.

Signed-off-by: Daeho Jeong <daehojeong@google.com>
---
 fs/f2fs/file.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 368c80f8e2a1..1c4601f99326 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -3813,21 +3813,19 @@ static int f2fs_sec_trim_file(struct file *filp, unsigned long arg)
 	file_start_write(filp);
 	inode_lock(inode);
 
-	if (f2fs_is_atomic_file(inode) || f2fs_compressed_file(inode)) {
+	if (f2fs_is_atomic_file(inode) || f2fs_compressed_file(inode) ||
+			range.start >= inode->i_size) {
 		ret = -EINVAL;
 		goto err;
 	}
 
-	if (range.start >= inode->i_size) {
-		ret = -EINVAL;
+	if (range.len == 0)
 		goto err;
-	}
 
-	if (inode->i_size - range.start < range.len) {
-		ret = -E2BIG;
-		goto err;
-	}
-	end_addr = range.start + range.len;
+	if (range.len == (u64)-1 || inode->i_size - range.start < range.len)
+		end_addr = inode->i_size;
+	else
+		end_addr = range.start + range.len;
 
 	to_end = (end_addr == inode->i_size);
 	if (!IS_ALIGNED(range.start, F2FS_BLKSIZE) ||
-- 
2.27.0.383.g050319c2ae-goog



_______________________________________________
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] 28+ messages in thread

end of thread, other threads:[~2020-07-10  7:30 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-07-10  2:15 [f2fs-dev] [PATCH] f2fs: change the way of handling range.len in F2FS_IOC_SEC_TRIM_FILE Daeho Jeong
2020-07-10  2:15 ` Daeho Jeong
2020-07-10  3:02 ` [f2fs-dev] " Jaegeuk Kim
2020-07-10  3:02   ` Jaegeuk Kim
2020-07-10  3:17   ` Daeho Jeong
2020-07-10  3:17     ` Daeho Jeong
2020-07-10  3:20     ` Jaegeuk Kim
2020-07-10  3:20       ` Jaegeuk Kim
2020-07-10  3:25       ` Eric Biggers
2020-07-10  3:25         ` Eric Biggers
2020-07-10  3:29         ` Jaegeuk Kim
2020-07-10  3:29           ` Jaegeuk Kim
2020-07-10  3:21   ` Chao Yu
2020-07-10  3:21     ` Chao Yu
2020-07-10  3:31     ` Jaegeuk Kim
2020-07-10  3:31       ` Jaegeuk Kim
2020-07-10  3:36       ` Chao Yu
2020-07-10  3:36         ` Chao Yu
2020-07-10  3:52         ` Jaegeuk Kim
2020-07-10  3:52           ` Jaegeuk Kim
2020-07-10  4:26           ` Daeho Jeong
2020-07-10  4:26             ` Daeho Jeong
2020-07-10  6:31           ` Chao Yu
2020-07-10  6:31             ` Chao Yu
2020-07-10  6:46             ` Jaegeuk Kim
2020-07-10  6:46               ` Jaegeuk Kim
2020-07-10  7:29               ` Chao Yu
2020-07-10  7:29                 ` Chao Yu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.