use notify prune from upstream#137
use notify prune from upstream#137hbirth wants to merge 2 commits intoDDNStorage:redfs-ubuntu-hwe-6.17.0-16.16-24.04.1from
Conversation
Some fuse servers need to prune their caches, which can only be done if the
kernel's own dentry/inode caches are pruned first to avoid dangling
references.
Add FUSE_NOTIFY_PRUNE, which takes an array of node ID's to try and get rid
of. Inodes with active references are skipped.
A similar functionality is already provided by FUSE_NOTIFY_INVAL_ENTRY with
the FUSE_EXPIRE_ONLY flag. Differences in the interface are
FUSE_NOTIFY_INVAL_ENTRY:
- can only prune one dentry
- dentry is determined by parent ID and name
- if inode has multiple aliases (cached hard links), then they would have
to be invalidated individually to be able to get rid of the inode
FUSE_NOTIFY_PRUNE:
- can prune multiple inodes
- inodes determined by their node ID
- aliases are taken care of automatically
Reviewed-by: Joanne Koong <joannelkoong@gmail.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
(cherry picked from commit 3f29d59)
4748957 to
d25cddd
Compare
|
@yongzech Please also take a look. |
|
@yongzech your patch contained the explicit invalidation of the fuse cache ... Miklos left that out. He probably relies on some mechanism that the cache will be cleaned anyway. Was there a special reason why you invalidated the fuse cache explicitly? It actually just sets the time to 0. |
When the inode that has to be pruned is a directory call shrink_dcache_parent() before trying to prune. This will try to free all related dcache entries. Signed-off-by: Horst Birthelmer <hbirthelmer@ddn.com>
d25cddd to
f297a15
Compare
|
| case FUSE_NOTIFY_INC_EPOCH: | ||
| return fuse_notify_inc_epoch(fc); | ||
|
|
||
| case FUSE_NOTIFY_PRUNE: |
There was a problem hiding this comment.
We already have libfuse interface for FUSE_NOTIFY_PRUNE ?
There was a problem hiding this comment.
no ... but we have to start at the kernel ... the libfuse code is in a PR
| if (S_ISDIR(inode->i_mode)) { | ||
| dentry = d_find_alias(inode); | ||
| if (dentry) { | ||
| shrink_dcache_parent(dentry); |
There was a problem hiding this comment.
But this only remove the children which with ref count is zero?
| } | ||
| } | ||
|
|
||
| d_prune_aliases(inode); |
There was a problem hiding this comment.
Same here, only when d_lockref.count is zero. But when lost a lock, we need to invalidate dcache entry
There was a problem hiding this comment.
we do at the moment ... that's why I left that code in
There was a problem hiding this comment.
I think issue with d_invalidate is if it is currently used for for something, which is why Miklos is suggesting shrink_dcache_parent()
There was a problem hiding this comment.
But the problem with shrink_dcache_parent and `d_prune_aliases is that, if another node delete a file whose dcache already cached in this node, then don't invalidate dcache.
Miklos said that he does not want to dehash the dentry ... but I think WE want exactly that ... that's why I think at the moment we need both |
|
Well, let's say something is currently actively using the dentry while it gets invalidated - the racing process would then work with an unhashed dentry. I think the critical call is And there the question is if this couldn't cause a null pointer deref at some point. |
|
@yongzech do we want FUSE_NOTIFY_PRUNE? |
No description provided.