Skip to content

Commit 5ddd9ce

Browse files
author
Miklos Szeredi
committed
fuse: update attr_version counter on fuse_notify_inval_inode()
A GETATTR request can race with FUSE_NOTIFY_INVAL_INODE, resulting in the attribute cache being updated with stale information after the invalidation. Fix this by bumping the attribute version in fuse_reverse_inval_inode(). Reported-by: Krzysztof Rusek <[email protected]> Signed-off-by: Miklos Szeredi <[email protected]>
1 parent 32f9887 commit 5ddd9ce

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

fs/fuse/inode.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,8 @@ struct inode *fuse_iget(struct super_block *sb, u64 nodeid,
321321
int fuse_reverse_inval_inode(struct super_block *sb, u64 nodeid,
322322
loff_t offset, loff_t len)
323323
{
324+
struct fuse_conn *fc = get_fuse_conn_super(sb);
325+
struct fuse_inode *fi;
324326
struct inode *inode;
325327
pgoff_t pg_start;
326328
pgoff_t pg_end;
@@ -329,6 +331,11 @@ int fuse_reverse_inval_inode(struct super_block *sb, u64 nodeid,
329331
if (!inode)
330332
return -ENOENT;
331333

334+
fi = get_fuse_inode(inode);
335+
spin_lock(&fi->lock);
336+
fi->attr_version = atomic64_inc_return(&fc->attr_version);
337+
spin_unlock(&fi->lock);
338+
332339
fuse_invalidate_attr(inode);
333340
forget_all_cached_acls(inode);
334341
if (offset >= 0) {

0 commit comments

Comments
 (0)