Skip to content

Commit 3ba7583

Browse files
author
J. Bruce Fields
committed
nfsd4: drc containerization
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>
1 parent b401170 commit 3ba7583

File tree

4 files changed

+154
-125
lines changed

4 files changed

+154
-125
lines changed

fs/nfsd/cache.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#define NFSCACHE_H
1111

1212
#include <linux/sunrpc/svc.h>
13+
#include "netns.h"
1314

1415
/*
1516
* Representation of a reply cache entry.
@@ -77,8 +78,8 @@ enum {
7778
/* Checksum this amount of the request */
7879
#define RC_CSUMLEN (256U)
7980

80-
int nfsd_reply_cache_init(void);
81-
void nfsd_reply_cache_shutdown(void);
81+
int nfsd_reply_cache_init(struct nfsd_net *);
82+
void nfsd_reply_cache_shutdown(struct nfsd_net *);
8283
int nfsd_cache_lookup(struct svc_rqst *);
8384
void nfsd_cache_update(struct svc_rqst *, int, __be32 *);
8485
int nfsd_reply_cache_stats_open(struct inode *, struct file *);

fs/nfsd/netns.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,41 @@ struct nfsd_net {
127127
*/
128128
bool *nfsd_versions;
129129
bool *nfsd4_minorversions;
130+
131+
/*
132+
* Duplicate reply cache
133+
*/
134+
struct nfsd_drc_bucket *drc_hashtbl;
135+
struct kmem_cache *drc_slab;
136+
137+
/* max number of entries allowed in the cache */
138+
unsigned int max_drc_entries;
139+
140+
/* number of significant bits in the hash value */
141+
unsigned int maskbits;
142+
unsigned int drc_hashsize;
143+
144+
/*
145+
* Stats and other tracking of on the duplicate reply cache. All of these and
146+
* the "rc" fields in nfsdstats are protected by the cache_lock
147+
*/
148+
149+
/* total number of entries */
150+
atomic_t num_drc_entries;
151+
152+
/* cache misses due only to checksum comparison failures */
153+
unsigned int payload_misses;
154+
155+
/* amount of memory (in bytes) currently consumed by the DRC */
156+
unsigned int drc_mem_usage;
157+
158+
/* longest hash chain seen */
159+
unsigned int longest_chain;
160+
161+
/* size of cache when we saw the longest hash chain */
162+
unsigned int longest_chain_cachesize;
163+
164+
struct shrinker nfsd_reply_cache_shrinker;
130165
};
131166

132167
/* Simple check to find out if a given net was properly initialized */

0 commit comments

Comments
 (0)