Skip to content

Commit c6c745b

Browse files
author
Miklos Szeredi
committed
fuse: only update necessary attributes
fuse_update_attributes() refreshes metadata for internal use. Each use needs a particular set of attributes to be refreshed, but currently that cannot be expressed and all but atime are refreshed. Add a mask argument, which lets fuse_update_get_attr() to decide based on the cache_mask and the inval_mask whether a GETATTR call is needed or not. Reported-by: Yongji Xie <[email protected]> Signed-off-by: Miklos Szeredi <[email protected]>
1 parent ec85537 commit c6c745b

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

fs/fuse/dir.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,11 +1045,9 @@ static int fuse_update_get_attr(struct inode *inode, struct file *file,
10451045
return err;
10461046
}
10471047

1048-
int fuse_update_attributes(struct inode *inode, struct file *file)
1048+
int fuse_update_attributes(struct inode *inode, struct file *file, u32 mask)
10491049
{
1050-
/* Do *not* need to get atime for internal purposes */
1051-
return fuse_update_get_attr(inode, file, NULL,
1052-
STATX_BASIC_STATS & ~STATX_ATIME, 0);
1050+
return fuse_update_get_attr(inode, file, NULL, mask, 0);
10531051
}
10541052

10551053
int fuse_reverse_inval_entry(struct fuse_conn *fc, u64 parent_nodeid,

fs/fuse/file.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,7 @@ static ssize_t fuse_cache_read_iter(struct kiocb *iocb, struct iov_iter *to)
996996
if (fc->auto_inval_data ||
997997
(iocb->ki_pos + iov_iter_count(to) > i_size_read(inode))) {
998998
int err;
999-
err = fuse_update_attributes(inode, iocb->ki_filp);
999+
err = fuse_update_attributes(inode, iocb->ki_filp, STATX_SIZE);
10001000
if (err)
10011001
return err;
10021002
}
@@ -1282,7 +1282,8 @@ static ssize_t fuse_cache_write_iter(struct kiocb *iocb, struct iov_iter *from)
12821282

12831283
if (fc->writeback_cache) {
12841284
/* Update size (EOF optimization) and mode (SUID clearing) */
1285-
err = fuse_update_attributes(mapping->host, file);
1285+
err = fuse_update_attributes(mapping->host, file,
1286+
STATX_SIZE | STATX_MODE);
12861287
if (err)
12871288
return err;
12881289

@@ -2633,7 +2634,7 @@ static loff_t fuse_lseek(struct file *file, loff_t offset, int whence)
26332634
return vfs_setpos(file, outarg.offset, inode->i_sb->s_maxbytes);
26342635

26352636
fallback:
2636-
err = fuse_update_attributes(inode, file);
2637+
err = fuse_update_attributes(inode, file, STATX_SIZE);
26372638
if (!err)
26382639
return generic_file_llseek(file, offset, whence);
26392640
else
@@ -2653,7 +2654,7 @@ static loff_t fuse_file_llseek(struct file *file, loff_t offset, int whence)
26532654
break;
26542655
case SEEK_END:
26552656
inode_lock(inode);
2656-
retval = fuse_update_attributes(inode, file);
2657+
retval = fuse_update_attributes(inode, file, STATX_SIZE);
26572658
if (!retval)
26582659
retval = generic_file_llseek(file, offset, whence);
26592660
inode_unlock(inode);

fs/fuse/fuse_i.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1161,7 +1161,7 @@ u64 fuse_lock_owner_id(struct fuse_conn *fc, fl_owner_t id);
11611161
void fuse_flush_time_update(struct inode *inode);
11621162
void fuse_update_ctime(struct inode *inode);
11631163

1164-
int fuse_update_attributes(struct inode *inode, struct file *file);
1164+
int fuse_update_attributes(struct inode *inode, struct file *file, u32 mask);
11651165

11661166
void fuse_flush_writepages(struct inode *inode);
11671167

fs/fuse/readdir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ static int fuse_readdir_cached(struct file *file, struct dir_context *ctx)
454454
* cache; both cases require an up-to-date mtime value.
455455
*/
456456
if (!ctx->pos && fc->auto_inval_data) {
457-
int err = fuse_update_attributes(inode, file);
457+
int err = fuse_update_attributes(inode, file, STATX_MTIME);
458458

459459
if (err)
460460
return err;

0 commit comments

Comments
 (0)