aboutsummaryrefslogtreecommitdiffstats
path: root/fs/f2fs/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/f2fs/file.c')
-rw-r--r--fs/f2fs/file.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 0e493f63ea41..47abb96098e4 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -2086,15 +2086,19 @@ static int f2fs_move_file_range(struct file *file_in, loff_t pos_in,
2086 if (unlikely(f2fs_readonly(src->i_sb))) 2086 if (unlikely(f2fs_readonly(src->i_sb)))
2087 return -EROFS; 2087 return -EROFS;
2088 2088
2089 if (S_ISDIR(src->i_mode) || S_ISDIR(dst->i_mode)) 2089 if (!S_ISREG(src->i_mode) || !S_ISREG(dst->i_mode))
2090 return -EISDIR; 2090 return -EINVAL;
2091 2091
2092 if (f2fs_encrypted_inode(src) || f2fs_encrypted_inode(dst)) 2092 if (f2fs_encrypted_inode(src) || f2fs_encrypted_inode(dst))
2093 return -EOPNOTSUPP; 2093 return -EOPNOTSUPP;
2094 2094
2095 inode_lock(src); 2095 inode_lock(src);
2096 if (src != dst) 2096 if (src != dst) {
2097 inode_lock(dst); 2097 if (!inode_trylock(dst)) {
2098 ret = -EBUSY;
2099 goto out;
2100 }
2101 }
2098 2102
2099 ret = -EINVAL; 2103 ret = -EINVAL;
2100 if (pos_in + len > src->i_size || pos_in + len < pos_in) 2104 if (pos_in + len > src->i_size || pos_in + len < pos_in)
@@ -2152,6 +2156,7 @@ static int f2fs_move_file_range(struct file *file_in, loff_t pos_in,
2152out_unlock: 2156out_unlock:
2153 if (src != dst) 2157 if (src != dst)
2154 inode_unlock(dst); 2158 inode_unlock(dst);
2159out:
2155 inode_unlock(src); 2160 inode_unlock(src);
2156 return ret; 2161 return ret;
2157} 2162}