Skip to content

Commit

Permalink
sunrpc: add a new cache_detail operation for when a cache is flushed
Browse files Browse the repository at this point in the history
When the exports table is changed, exportfs will usually write a new
time to the "flush" file in the nfsd.export cache procfile. This tells
the kernel to flush any entries that are older than that value.

This gives us a mechanism to tell whether an unexport might have
occurred. Add a new ->flush cache_detail operation that is called after
flushing the cache whenever someone writes to a "flush" file.

Signed-off-by: Jeff Layton <jeff.layton@primarydata.com>
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
  • Loading branch information
Jeff Layton authored and J. Bruce Fields committed Aug 19, 2019
1 parent 4866073 commit f69d6d8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/linux/sunrpc/cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ struct cache_detail {
int has_died);

struct cache_head * (*alloc)(void);
void (*flush)(void);
int (*match)(struct cache_head *orig, struct cache_head *new);
void (*init)(struct cache_head *orig, struct cache_head *new);
void (*update)(struct cache_head *orig, struct cache_head *new);
Expand Down
3 changes: 3 additions & 0 deletions net/sunrpc/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -1524,6 +1524,9 @@ static ssize_t write_flush(struct file *file, const char __user *buf,
cd->nextcheck = now;
cache_flush();

if (cd->flush)
cd->flush();

*ppos += count;
return count;
}
Expand Down

0 comments on commit f69d6d8

Please sign in to comment.