fuse: use iversion for readdir cache verification

Use the internal iversion counter to make sure modifications of the
directory through this filesystem are not missed by the mtime check (due to
mtime granularity).

Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
This commit is contained in:
Miklos Szeredi
2018-10-01 10:07:05 +02:00
parent 7118883b44
commit 261aaba72f
3 changed files with 21 additions and 8 deletions

View File

@@ -8,6 +8,7 @@
#include "fuse_i.h"
#include <linux/iversion.h>
#include <linux/posix_acl.h>
#include <linux/pagemap.h>
#include <linux/highmem.h>
@@ -447,6 +448,7 @@ retry_locked:
/* Starting cache? Set cache mtime. */
if (!ctx->pos && !fi->rdc.size) {
fi->rdc.mtime = inode->i_mtime;
fi->rdc.iversion = inode_query_iversion(inode);
}
spin_unlock(&fi->rdc.lock);
return UNCACHED;
@@ -457,7 +459,8 @@ retry_locked:
* changed, and reset the cache if so.
*/
if (!ctx->pos) {
if (!timespec64_equal(&fi->rdc.mtime, &inode->i_mtime)) {
if (inode_peek_iversion(inode) != fi->rdc.iversion ||
!timespec64_equal(&fi->rdc.mtime, &inode->i_mtime)) {
fuse_rdc_reset(inode);
goto retry_locked;
}