Skip to content

Commit 8ab5cb4

Browse files
authored
Merge pull request #4 from gwu-ddn/redfs-6.8
fuse: fix race between concurrent setattrs from multiple nodes
2 parents de28c1f + 5ce281c commit 8ab5cb4

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

fs/fuse/dir.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1889,6 +1889,7 @@ int fuse_do_setattr(struct dentry *dentry, struct iattr *attr,
18891889
int err;
18901890
bool trust_local_cmtime = is_wb;
18911891
bool fault_blocked = false;
1892+
u64 attr_version;
18921893

18931894
if (!fc->default_permissions)
18941895
attr->ia_valid |= ATTR_FORCE;
@@ -1973,6 +1974,8 @@ int fuse_do_setattr(struct dentry *dentry, struct iattr *attr,
19731974
if (fc->handle_killpriv_v2 && !capable(CAP_FSETID))
19741975
inarg.valid |= FATTR_KILL_SUIDGID;
19751976
}
1977+
1978+
attr_version = fuse_get_attr_version(fm->fc);
19761979
fuse_setattr_fill(fc, &args, inode, &inarg, &outarg);
19771980
err = fuse_simple_request(fm, &args);
19781981
if (err) {
@@ -1998,6 +2001,14 @@ int fuse_do_setattr(struct dentry *dentry, struct iattr *attr,
19982001
/* FIXME: clear I_DIRTY_SYNC? */
19992002
}
20002003

2004+
if (fi->attr_version > attr_version) {
2005+
/*
2006+
* Apply attributes, for example for fsnotify_change(), but set
2007+
* attribute timeout to zero.
2008+
*/
2009+
outarg.attr_valid = outarg.attr_valid_nsec = 0;
2010+
}
2011+
20012012
fuse_change_attributes_common(inode, &outarg.attr, NULL,
20022013
ATTR_TIMEOUT(&outarg),
20032014
fuse_get_cache_mask(inode), 0);

0 commit comments

Comments
 (0)