diff options
-rw-r--r-- | fs/fuse/file.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 0f0225686aee..6edf949b9139 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c | |||
@@ -217,7 +217,7 @@ int fuse_open_common(struct inode *inode, struct file *file, bool isdir) | |||
217 | { | 217 | { |
218 | struct fuse_conn *fc = get_fuse_conn(inode); | 218 | struct fuse_conn *fc = get_fuse_conn(inode); |
219 | int err; | 219 | int err; |
220 | bool lock_inode = (file->f_flags & O_TRUNC) && | 220 | bool is_wb_truncate = (file->f_flags & O_TRUNC) && |
221 | fc->atomic_o_trunc && | 221 | fc->atomic_o_trunc && |
222 | fc->writeback_cache; | 222 | fc->writeback_cache; |
223 | 223 | ||
@@ -225,16 +225,20 @@ int fuse_open_common(struct inode *inode, struct file *file, bool isdir) | |||
225 | if (err) | 225 | if (err) |
226 | return err; | 226 | return err; |
227 | 227 | ||
228 | if (lock_inode) | 228 | if (is_wb_truncate) { |
229 | inode_lock(inode); | 229 | inode_lock(inode); |
230 | fuse_set_nowrite(inode); | ||
231 | } | ||
230 | 232 | ||
231 | err = fuse_do_open(fc, get_node_id(inode), file, isdir); | 233 | err = fuse_do_open(fc, get_node_id(inode), file, isdir); |
232 | 234 | ||
233 | if (!err) | 235 | if (!err) |
234 | fuse_finish_open(inode, file); | 236 | fuse_finish_open(inode, file); |
235 | 237 | ||
236 | if (lock_inode) | 238 | if (is_wb_truncate) { |
239 | fuse_release_nowrite(inode); | ||
237 | inode_unlock(inode); | 240 | inode_unlock(inode); |
241 | } | ||
238 | 242 | ||
239 | return err; | 243 | return err; |
240 | } | 244 | } |