[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230506114033.23908-1-frank.li@vivo.com>
Date: Sat, 6 May 2023 19:40:33 +0800
From: Yangtao Li <frank.li@...o.com>
To: jaegeuk@...nel.org, chao@...nel.org
Cc: linux-f2fs-devel@...ts.sourceforge.net,
linux-kernel@...r.kernel.org, Yangtao Li <frank.li@...o.com>
Subject: [PATCH 2/2] f2fs: move the conditional statement after holding the inode lock in f2fs_fallocate()
For judging the inode flag state, the inode lock must be held.
Fixes: fcc85a4d86b5 ("f2fs crypto: activate encryption support for fs APIs")
Signed-off-by: Yangtao Li <frank.li@...o.com>
---
fs/f2fs/file.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 850e745ecf88..0837c500b990 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -1801,6 +1801,13 @@ static long f2fs_fallocate(struct file *file, int mode,
if (!S_ISREG(inode->i_mode))
return -EINVAL;
+ if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE |
+ FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_ZERO_RANGE |
+ FALLOC_FL_INSERT_RANGE))
+ return -EOPNOTSUPP;
+
+ inode_lock(inode);
+
if (IS_ENCRYPTED(inode) &&
(mode & (FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_INSERT_RANGE)))
return -EOPNOTSUPP;
@@ -1814,13 +1821,6 @@ static long f2fs_fallocate(struct file *file, int mode,
FALLOC_FL_ZERO_RANGE | FALLOC_FL_INSERT_RANGE)))
return -EOPNOTSUPP;
- if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE |
- FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_ZERO_RANGE |
- FALLOC_FL_INSERT_RANGE))
- return -EOPNOTSUPP;
-
- inode_lock(inode);
-
ret = file_modified(file);
if (ret)
goto out;
--
2.39.0
Powered by blists - more mailing lists