fuse: cache POSIX ACLs when setting them
PATCH 1/1 fuse: cache POSIX ACLs when setting them
When setting an ACL in an inode we can immediately add it to the cache. This is a small optimisation, as currently an ACL is only added to the cache when reading it again, which involves an extra GETXATTR hop into user-space.
--- fs/fuse/acl.c | 2 ++ 1 file changed, 2 insertions(+)
fs/fuse/acl.c +2 -0
@@ -155,6 +155,8 @@ int fuse_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,*/ forget_all_cached_acls (inode);fuse_invalidate_attr (inode); +if (!ret) +set_cached_acl (inode, type, acl); }return ret;
Quoted 16 lines · Luis Henriques
When setting an ACL in an inode we can immediately add it to the cache. This is a small optimisation, as currently an ACL is only added to the cache when reading it again, which involves an extra GETXATTR hop into user-space.
Signed-off-by Luis Henriques <[email protected]>--- fs/fuse/acl.c | 2 ++ 1 file changed, 2 insertions(+)fs/fuse/acl.c +0
-0
fs/fuse/acl.c int fuse_set_acl(struct mnt_idmap *idmap, struct dentry *dentry, · line 162
Quoted 8 lines
fs/fuse/acl.c +2
-0@@ -155,6 +155,8 @@ int fuse_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,*/ forget_all_cached_acls (inode);fuse_invalidate_attr (inode); +if (!ret) +set_cached_acl (inode, type, acl); }return ret;
LGTM
Feel free to add
Quoted 16 lines · Luis Henriques
When setting an ACL in an inode we can immediately add it to the cache. This is a small optimisation, as currently an ACL is only added to the cache when reading it again, which involves an extra GETXATTR hop into user-space.
Signed-off-by Luis Henriques <[email protected]>--- fs/fuse/acl.c | 2 ++ 1 file changed, 2 insertions(+)fs/fuse/acl.c +0
-0
fs/fuse/acl.c int fuse_set_acl(struct mnt_idmap *idmap, struct dentry *dentry, · line 159
Quoted 5 lines
fs/fuse/acl.c +2
-0@@ -155,6 +155,8 @@ int fuse_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,*/ forget_all_cached_acls (inode);fuse_invalidate_attr (inode); +if (!ret) +set_cached_acl (inode, type, acl);
This is undoing what forget_all_cached_acls() explicitly tries to do. I think the reason is that kernel code cannot assume the server did not modify ACL before storing them, not sure, but NFS does the same thing with nfs_zap_acl_cache().
Thanks,
Amir.
Quoted 28 lines · Amir Goldstein
Quoted 16 lines · Luis Henriques
When setting an ACL in an inode we can immediately add it to the cache. This is a small optimisation, as currently an ACL is only added to the cache when reading it again, which involves an extra GETXATTR hop into user-space.
Signed-off-by Luis Henriques <[email protected]>--- fs/fuse/acl.c | 2 ++ 1 file changed, 2 insertions(+)fs/fuse/acl.c +0
-0fs/fuse/acl.c int fuse_set_acl(struct mnt_idmap *idmap, struct dentry *dentry, · line 159
Quoted 5 lines
fs/fuse/acl.c +2
-0@@ -155,6 +155,8 @@ int fuse_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,*/ forget_all_cached_acls (inode);fuse_invalidate_attr (inode); +if (!ret) +set_cached_acl (inode, type, acl);This is undoing what
forget_all_cached_acls()explicitly tries to do. I think the reason is that kernel code cannot assume the server did not modify ACL before storing them, not sure, but NFS does the same thing withnfs_zap_acl_cache().
Quoted 3 lines
Thanks,
Amir.
I just thought it would be a good idea to save us a trip to user space.
Horst
Quoted 12 lines · Amir Goldstein
Quoted 11 lines · Luis Henriques
When setting an ACL in an inode we can immediately add it to the cache. This is a small optimisation, as currently an ACL is only added to the cache when reading it again, which involves an extra GETXATTR hop into user-space.
Signed-off-by Luis Henriques <[email protected]>--- fs/fuse/acl.c | 2 ++ 1 file changed, 2 insertions(+)
Quoted 15 lines
fs/fuse/acl.c int fuse_set_acl(struct mnt_idmap *idmap, struct dentry *dentry, · line 159
Quoted 10 lines
fs/fuse/acl.c +2
-0@@ -155,6 +155,8 @@ int fuse_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,*/ forget_all_cached_acls (inode);fuse_invalidate_attr (inode); +if (!ret) +set_cached_acl (inode, type, acl);This is undoing what
forget_all_cached_acls()explicitly tries to do. I think the reason is that kernel code cannot assume the server did not modify ACL before storing them, not sure, but NFS does the same thing withnfs_zap_acl_cache().
In my understanding, forget_all_cached_acls() is cleaning any previously cached ACLs (even if the SETXATTR failed!). So it made sense to me to cache the new ACL just like other filesystems seem to be doing.
On the other hand, having a server modifying the ACL without notifying the kernel didn't sound right to me, specially because it has explicitly set the FUSE_POSIX_ACL flag -- otherwise this code wouldn't be executed. And that's why I assumed it would be acceptable to have this optimisation:
because user-space asked the VFS to do permission checking *and* caching ACLs.
I did actually took a look into the NFS code, but it seems to be doing it's own ACL caching. But yeah, I can't claim to have fully understood what (and why) NFS is really doing :-)
Cheers,
Signature · 1 line
Luís
Quoted 31 lines · Luis Henriques
Quoted 12 lines · Amir Goldstein
Quoted 11 lines · Luis Henriques
When setting an ACL in an inode we can immediately add it to the cache. This is a small optimisation, as currently an ACL is only added to the cache when reading it again, which involves an extra GETXATTR hop into user-space.
Signed-off-by Luis Henriques <[email protected]>--- fs/fuse/acl.c | 2 ++ 1 file changed, 2 insertions(+)Quoted 15 lines
fs/fuse/acl.c int fuse_set_acl(struct mnt_idmap *idmap, struct dentry *dentry, · line 159
Quoted 10 lines
fs/fuse/acl.c +2
-0@@ -155,6 +155,8 @@ int fuse_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,*/ forget_all_cached_acls (inode);fuse_invalidate_attr (inode); +if (!ret) +set_cached_acl (inode, type, acl);This is undoing what
forget_all_cached_acls()explicitly tries to do. I think the reason is that kernel code cannot assume the server did not modify ACL before storing them, not sure, but NFS does the same thing withnfs_zap_acl_cache().
Quoted 3 lines
In my understanding,
forget_all_cached_acls()is cleaning any previously cached ACLs (even if the SETXATTR failed!). So it made sense to me to cache the new ACL just like other filesystems seem to be doing.
Local filesystems do, remote filesystems not always.
Quoted 7 lines
On the other hand, having a server modifying the ACL without notifying the kernel didn't sound right to me, specially because it has explicitly set the
FUSE_POSIX_ACLflag -- otherwise this code wouldn't be executed. And that's why I assumed it would be acceptable to have this optimisation:
because user-space asked the VFS to do permission checking *and* caching ACLs.
Your arguments make sense to me.
Only it appears so simple so it feels like I am missing something. Why wasn't this implemented like that in the first place?
Thanks,
Amir.
Quoted 32 lines · Amir Goldstein
Quoted 31 lines · Luis Henriques
Quoted 27 lines · Amir Goldstein
Quoted 16 lines · Luis Henriques
When setting an ACL in an inode we can immediately add it to the cache. This is a small optimisation, as currently an ACL is only added to the cache when reading it again, which involves an extra GETXATTR hop into user-space.
Signed-off-by Luis Henriques <[email protected]>--- fs/fuse/acl.c | 2 ++ 1 file changed, 2 insertions(+)fs/fuse/acl.c +0
-0fs/fuse/acl.c int fuse_set_acl(struct mnt_idmap *idmap, struct dentry *dentry, · line 159
Quoted 5 lines
fs/fuse/acl.c +2
-0@@ -155,6 +155,8 @@ int fuse_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,*/ forget_all_cached_acls (inode);fuse_invalidate_attr (inode); +if (!ret) +set_cached_acl (inode, type, acl);This is undoing what
forget_all_cached_acls()explicitly tries to do. I think the reason is that kernel code cannot assume the server did not modify ACL before storing them, not sure, but NFS does the same thing withnfs_zap_acl_cache().
Quoted 5 lines
Quoted 3 lines
In my understanding,
forget_all_cached_acls()is cleaning any previously cached ACLs (even if the SETXATTR failed!). So it made sense to me to cache the new ACL just like other filesystems seem to be doing.Local filesystems do, remote filesystems not always.
True. Even ceph, which is the remote filesystem I'm most familiar with, caches ACLs when setting them only if the client has the right capabilities for doing so.
Quoted 10 lines
Quoted 6 lines
On the other hand, having a server modifying the ACL without notifying the kernel didn't sound right to me, specially because it has explicitly set the
FUSE_POSIX_ACLflag -- otherwise this code wouldn't be executed. And that's why I assumed it would be acceptable to have this optimisation:
because user-space asked the VFS to do permission checking *and* caching ACLs.Your arguments make sense to me.
Only it appears so simple so it feels like I am missing something. Why wasn't this implemented like that in the first place?
Yeah, maybe your right, maybe I'm missing something as well and there is a good reason for not doing it.
I was going to CC Christian, but I see you did that already :-)
Maybe he remembers the reasons behind this while working on commit facd61053cff ("fuse: fixes after adapting to new posix acl api").
Cheers,
Signature · 1 line
Luís
Miklos Szeredi
maintainerQuoted 7 lines · Luis Henriques
Yeah, maybe your right, maybe I'm missing something as well and there is a good reason for not doing it.
I was going to CC Christian, but I see you did that already :-)
Maybe he remembers the reasons behind this while working on commit
facd61053cff("fuse: fixes after adapting to new posix acl api").
It's not that. Those lines come from the original fuse acl support in commit 60bcc88ad185 ("fuse: Add posix ACL support").
Maybe the thinking behind that was that the server might modify the acl when setting it. Not sure if this can actually happen for network fs.
In any case it is unlikely to matter in real world cases. For now let's just document these quirks.
Thanks,
Miklos
Quoted 6 lines · Miklos Szeredi
Quoted 3 lines · Luis Henriques
Yeah, maybe your right, maybe I'm missing something as well and there is a good reason for not doing it.
Quoted 7 lines
Quoted 4 lines
I was going to CC Christian, but I see you did that already :-)
Maybe he remembers the reasons behind this while working on commit
facd61053cff("fuse: fixes after adapting to new posix acl api").It's not that. Those lines come from the original fuse acl support in commit
60bcc88ad185("fuse: Add posix ACL support").
Right.
Quoted 4 lines
Maybe the thinking behind that was that the server might modify the acl when setting it. Not sure if this can actually happen for network fs.
Same conclusion that Luis and me reached - it is technically possible that a server like that exists, but they probably don't.
Quoted 3 lines
In any case it is unlikely to matter in real world cases. For now let's just document these quirks.
unlikely to matter if we do cache on setacl or unlikely to matter if we don't cache?
I guess both are true.
Thanks,
Amir.
Miklos Szeredi
maintainerQuoted 2 lines · Amir Goldstein
unlikely to matter if we do cache on setacl or unlikely to matter if we don't cache?
Unlikely to matter that we don't cache setacl, because it should be a rare operation, so an additional roundtrip just shouldn't make any difference to performance.
Changing this does carry a small risk of regressions.
Thanks,
Mikos
Quoted 10 lines · Miklos Szeredi
Quoted 2 lines · Amir Goldstein
unlikely to matter if we do cache on setacl or unlikely to matter if we don't cache?
Unlikely to matter that we don't cache setacl, because it should be a rare operation, so an additional roundtrip just shouldn't make any difference to performance.
Changing this does carry a small risk of regressions.
Right, I've tried to document this behaviour already [1], as I wasn't sure this patch would be OK -- I understand why it makes sense to have this extra hop into user-space and it makes sense to drop this patch.
[1] https://lore.kernel.org/all/[email protected]
Cheers,
--
Luis