Skip to content

Commit 20235b4

Browse files
author
Miklos Szeredi
committed
fuse: cleanup code conditional on fc->writeback_cache
It's safe to call file_update_time() if writeback cache is not enabled, since S_NOCMTIME is set in this case. This part is purely a cleanup. __fuse_copy_file_range() also calls fuse_write_update_attr() only in the writeback cache case. This is inconsistent with other callers, where it's called unconditionally. Signed-off-by: Miklos Szeredi <[email protected]>
1 parent 484ce65 commit 20235b4

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

fs/fuse/file.c

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,8 @@ void fuse_finish_open(struct inode *inode, struct file *file)
211211
i_size_write(inode, 0);
212212
spin_unlock(&fi->lock);
213213
truncate_pagecache(inode, 0);
214+
file_update_time(file);
214215
fuse_invalidate_attr_mask(inode, FUSE_STATX_MODSIZE);
215-
if (fc->writeback_cache)
216-
file_update_time(file);
217216
} else if (!(ff->open_flags & FOPEN_KEEP_CACHE)) {
218217
invalidate_inode_pages2(inode->i_mapping);
219218
}
@@ -2986,10 +2985,7 @@ static long fuse_file_fallocate(struct file *file, int mode, loff_t offset,
29862985

29872986
/* we could have extended the file */
29882987
if (!(mode & FALLOC_FL_KEEP_SIZE)) {
2989-
bool changed = fuse_write_update_attr(inode, offset + length,
2990-
length);
2991-
2992-
if (changed && fm->fc->writeback_cache)
2988+
if (fuse_write_update_attr(inode, offset + length, length))
29932989
file_update_time(file);
29942990
}
29952991

@@ -3104,13 +3100,8 @@ static ssize_t __fuse_copy_file_range(struct file *file_in, loff_t pos_in,
31043100
ALIGN_DOWN(pos_out, PAGE_SIZE),
31053101
ALIGN(pos_out + outarg.size, PAGE_SIZE) - 1);
31063102

3107-
if (fc->writeback_cache) {
3108-
fuse_write_update_attr(inode_out, pos_out + outarg.size,
3109-
outarg.size);
3110-
file_update_time(file_out);
3111-
}
3112-
3113-
fuse_invalidate_attr_mask(inode_out, FUSE_STATX_MODSIZE);
3103+
file_update_time(file_out);
3104+
fuse_write_update_attr(inode_out, pos_out + outarg.size, outarg.size);
31143105

31153106
err = outarg.size;
31163107
out:

0 commit comments

Comments
 (0)