
From: Amir Goldstein <amir73il@gmail.com> mainline inclusion from mainline-v6.8-rc1 commit e389b76a7ee1b62392ab52c22f9ba81f23145824 category: feature bugzilla: https://gitee.com/src-openeuler/kernel/issues/IBHLU4 Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?i... -------------------------------- The coda host file is a backing file for the coda inode on a different filesystem than the coda inode. Change the locking order to take the coda inode lock before taking the backing host file freeze protection, same as in ovl_write_iter() and in network filesystems that use cachefiles. Link: https://lore.kernel.org/r/CAOQ4uxjcnwuF1gMxe64WLODGA_MyAy8x-DtqkCUxqVQKk3Xbn... Acked-by: Jan Harkes <jaharkes@cs.cmu.edu> Signed-off-by: Amir Goldstein <amir73il@gmail.com> Link: https://lore.kernel.org/r/20231122122715.2561213-10-amir73il@gmail.com Reviewed-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: Christian Brauner <brauner@kernel.org> Signed-off-by: Yifan Qiao <qiaoyifan4@huawei.com> --- fs/coda/file.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/coda/file.c b/fs/coda/file.c index 42346618b4ed..6e671fc03f64 100644 --- a/fs/coda/file.c +++ b/fs/coda/file.c @@ -79,14 +79,14 @@ coda_file_write_iter(struct kiocb *iocb, struct iov_iter *to) if (ret) goto finish_write; - file_start_write(host_file); inode_lock(coda_inode); + file_start_write(host_file); ret = vfs_iter_write(cfi->cfi_container, to, &iocb->ki_pos, 0); coda_inode->i_size = file_inode(host_file)->i_size; coda_inode->i_blocks = (coda_inode->i_size + 511) >> 9; coda_inode->i_mtime = inode_set_ctime_current(coda_inode); - inode_unlock(coda_inode); file_end_write(host_file); + inode_unlock(coda_inode); finish_write: venus_access_intent(coda_inode->i_sb, coda_i2f(coda_inode), -- 2.39.2