Skip to content
This repository has been archived by the owner on Sep 11, 2019. It is now read-only.

Commit

Permalink
nfsd4: drc containerization
Browse files Browse the repository at this point in the history
The nfsd duplicate reply cache should not be shared between network
namespaces.

The most straightforward way to fix this is just to move every global in
the code to per-net-namespace memory, so that's what we do.

Still todo: sort out which members of nfsd_stats should be global and
which per-net-namespace.

Signed-off-by: J. Bruce Fields <bfields@redhat.com>
  • Loading branch information
J. Bruce Fields committed Jul 3, 2019
1 parent b401170 commit 3ba7583
Show file tree
Hide file tree
Showing 4 changed files with 154 additions and 125 deletions.
5 changes: 3 additions & 2 deletions fs/nfsd/cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#define NFSCACHE_H

#include <linux/sunrpc/svc.h>
#include "netns.h"

/*
* Representation of a reply cache entry.
Expand Down Expand Up @@ -77,8 +78,8 @@ enum {
/* Checksum this amount of the request */
#define RC_CSUMLEN (256U)

int nfsd_reply_cache_init(void);
void nfsd_reply_cache_shutdown(void);
int nfsd_reply_cache_init(struct nfsd_net *);
void nfsd_reply_cache_shutdown(struct nfsd_net *);
int nfsd_cache_lookup(struct svc_rqst *);
void nfsd_cache_update(struct svc_rqst *, int, __be32 *);
int nfsd_reply_cache_stats_open(struct inode *, struct file *);
Expand Down
35 changes: 35 additions & 0 deletions fs/nfsd/netns.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,41 @@ struct nfsd_net {
*/
bool *nfsd_versions;
bool *nfsd4_minorversions;

/*
* Duplicate reply cache
*/
struct nfsd_drc_bucket *drc_hashtbl;
struct kmem_cache *drc_slab;

/* max number of entries allowed in the cache */
unsigned int max_drc_entries;

/* number of significant bits in the hash value */
unsigned int maskbits;
unsigned int drc_hashsize;

/*
* Stats and other tracking of on the duplicate reply cache. All of these and
* the "rc" fields in nfsdstats are protected by the cache_lock
*/

/* total number of entries */
atomic_t num_drc_entries;

/* cache misses due only to checksum comparison failures */
unsigned int payload_misses;

/* amount of memory (in bytes) currently consumed by the DRC */
unsigned int drc_mem_usage;

/* longest hash chain seen */
unsigned int longest_chain;

/* size of cache when we saw the longest hash chain */
unsigned int longest_chain_cachesize;

struct shrinker nfsd_reply_cache_shrinker;
};

/* Simple check to find out if a given net was properly initialized */
Expand Down
Loading

0 comments on commit 3ba7583

Please sign in to comment.