Commit 4b148854 authored by Josef Bacik's avatar Josef Bacik Committed by Chuck Lever
Browse files

nfsd: make all of the nfsd stats per-network namespace



We have a global set of counters that we modify for all of the nfsd
operations, but now that we're exposing these stats across all network
namespaces we need to make the stats also be per-network namespace.  We
already have some caching stats that are per-network namespace, so move
these definitions into the same counter and then adjust all the helpers
and users of these stats to provide the appropriate nfsd_net struct so
that the stats are maintained for the per-network namespace objects.

Signed-off-by: default avatarJosef Bacik <josef@toxicpanda.com>
Reviewed-by: default avatarJeff Layton <jlayton@kernel.org>
Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
parent 93483ac5
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -80,8 +80,6 @@ enum {

int	nfsd_drc_slab_create(void);
void	nfsd_drc_slab_free(void);
int	nfsd_net_reply_cache_init(struct nfsd_net *nn);
void	nfsd_net_reply_cache_destroy(struct nfsd_net *nn);
int	nfsd_reply_cache_init(struct nfsd_net *);
void	nfsd_reply_cache_shutdown(struct nfsd_net *);
int	nfsd_cache_lookup(struct svc_rqst *rqstp, unsigned int start,
+15 −2
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@
#include <net/net_namespace.h>
#include <net/netns/generic.h>
#include <linux/filelock.h>
#include <linux/nfs4.h>
#include <linux/percpu_counter.h>
#include <linux/siphash.h>

@@ -29,7 +30,19 @@ enum {
	NFSD_STATS_PAYLOAD_MISSES,
	/* amount of memory (in bytes) currently consumed by the DRC */
	NFSD_STATS_DRC_MEM_USAGE,
	NFSD_NET_COUNTERS_NUM
	NFSD_STATS_RC_HITS,		/* repcache hits */
	NFSD_STATS_RC_MISSES,		/* repcache misses */
	NFSD_STATS_RC_NOCACHE,		/* uncached reqs */
	NFSD_STATS_FH_STALE,		/* FH stale error */
	NFSD_STATS_IO_READ,		/* bytes returned to read requests */
	NFSD_STATS_IO_WRITE,		/* bytes passed in write requests */
#ifdef CONFIG_NFSD_V4
	NFSD_STATS_FIRST_NFS4_OP,	/* count of individual nfsv4 operations */
	NFSD_STATS_LAST_NFS4_OP = NFSD_STATS_FIRST_NFS4_OP + LAST_NFS4_OP,
#define NFSD_STATS_NFS4_OP(op)	(NFSD_STATS_FIRST_NFS4_OP + (op))
	NFSD_STATS_WDELEG_GETATTR,	/* count of getattr conflict with wdeleg */
#endif
	NFSD_STATS_COUNTERS_NUM
};

/*
@@ -164,7 +177,7 @@ struct nfsd_net {
	atomic_t                 num_drc_entries;

	/* Per-netns stats counters */
	struct percpu_counter    counter[NFSD_NET_COUNTERS_NUM];
	struct percpu_counter    counter[NFSD_STATS_COUNTERS_NUM];

	/* longest hash chain seen */
	unsigned int             longest_chain;
+3 −3
Original line number Diff line number Diff line
@@ -2490,10 +2490,10 @@ nfsd4_proc_null(struct svc_rqst *rqstp)
	return rpc_success;
}

static inline void nfsd4_increment_op_stats(u32 opnum)
static inline void nfsd4_increment_op_stats(struct nfsd_net *nn, u32 opnum)
{
	if (opnum >= FIRST_NFS4_OP && opnum <= LAST_NFS4_OP)
		percpu_counter_inc(&nfsdstats.counter[NFSD_STATS_NFS4_OP(opnum)]);
		percpu_counter_inc(&nn->counter[NFSD_STATS_NFS4_OP(opnum)]);
}

static const struct nfsd4_operation nfsd4_ops[];
@@ -2768,7 +2768,7 @@ nfsd4_proc_compound(struct svc_rqst *rqstp)
					   status, nfsd4_op_name(op->opnum));

		nfsd4_cstate_clear_replay(cstate);
		nfsd4_increment_op_stats(op->opnum);
		nfsd4_increment_op_stats(nn, op->opnum);
	}

	fh_put(current_fh);
+2 −1
Original line number Diff line number Diff line
@@ -8450,6 +8450,7 @@ __be32
nfsd4_deleg_getattr_conflict(struct svc_rqst *rqstp, struct inode *inode)
{
	__be32 status;
	struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id);
	struct file_lock_context *ctx;
	struct file_lock *fl;
	struct nfs4_delegation *dp;
@@ -8479,7 +8480,7 @@ nfsd4_deleg_getattr_conflict(struct svc_rqst *rqstp, struct inode *inode)
			}
break_lease:
			spin_unlock(&ctx->flc_lock);
			nfsd_stats_wdeleg_getattr_inc();
			nfsd_stats_wdeleg_getattr_inc(nn);
			status = nfserrno(nfsd_open_break_lease(inode, NFSD_MAY_READ));
			if (status != nfserr_jukebox ||
					!nfsd_wait_for_delegreturn(rqstp, inode))
+7 −29
Original line number Diff line number Diff line
@@ -176,27 +176,6 @@ void nfsd_drc_slab_free(void)
	kmem_cache_destroy(drc_slab);
}

/**
 * nfsd_net_reply_cache_init - per net namespace reply cache set-up
 * @nn: nfsd_net being initialized
 *
 * Returns zero on succes; otherwise a negative errno is returned.
 */
int nfsd_net_reply_cache_init(struct nfsd_net *nn)
{
	return nfsd_percpu_counters_init(nn->counter, NFSD_NET_COUNTERS_NUM);
}

/**
 * nfsd_net_reply_cache_destroy - per net namespace reply cache tear-down
 * @nn: nfsd_net being freed
 *
 */
void nfsd_net_reply_cache_destroy(struct nfsd_net *nn)
{
	nfsd_percpu_counters_destroy(nn->counter, NFSD_NET_COUNTERS_NUM);
}

int nfsd_reply_cache_init(struct nfsd_net *nn)
{
	unsigned int hashsize;
@@ -501,7 +480,7 @@ nfsd_cache_insert(struct nfsd_drc_bucket *b, struct nfsd_cacherep *key,
int nfsd_cache_lookup(struct svc_rqst *rqstp, unsigned int start,
		      unsigned int len, struct nfsd_cacherep **cacherep)
{
	struct nfsd_net		*nn;
	struct nfsd_net		*nn = net_generic(SVC_NET(rqstp), nfsd_net_id);
	struct nfsd_cacherep	*rp, *found;
	__wsum			csum;
	struct nfsd_drc_bucket	*b;
@@ -510,7 +489,7 @@ int nfsd_cache_lookup(struct svc_rqst *rqstp, unsigned int start,
	int rtn = RC_DOIT;

	if (type == RC_NOCACHE) {
		nfsd_stats_rc_nocache_inc();
		nfsd_stats_rc_nocache_inc(nn);
		goto out;
	}

@@ -520,7 +499,6 @@ int nfsd_cache_lookup(struct svc_rqst *rqstp, unsigned int start,
	 * Since the common case is a cache miss followed by an insert,
	 * preallocate an entry.
	 */
	nn = net_generic(SVC_NET(rqstp), nfsd_net_id);
	rp = nfsd_cacherep_alloc(rqstp, csum, nn);
	if (!rp)
		goto out;
@@ -537,7 +515,7 @@ int nfsd_cache_lookup(struct svc_rqst *rqstp, unsigned int start,

	nfsd_cacherep_dispose(&dispose);

	nfsd_stats_rc_misses_inc();
	nfsd_stats_rc_misses_inc(nn);
	atomic_inc(&nn->num_drc_entries);
	nfsd_stats_drc_mem_usage_add(nn, sizeof(*rp));
	goto out;
@@ -545,7 +523,7 @@ int nfsd_cache_lookup(struct svc_rqst *rqstp, unsigned int start,
found_entry:
	/* We found a matching entry which is either in progress or done. */
	nfsd_reply_cache_free_locked(NULL, rp, nn);
	nfsd_stats_rc_hits_inc();
	nfsd_stats_rc_hits_inc(nn);
	rtn = RC_DROPIT;
	rp = found;

@@ -689,11 +667,11 @@ int nfsd_reply_cache_stats_show(struct seq_file *m, void *v)
	seq_printf(m, "mem usage:             %lld\n",
		   percpu_counter_sum_positive(&nn->counter[NFSD_STATS_DRC_MEM_USAGE]));
	seq_printf(m, "cache hits:            %lld\n",
		   percpu_counter_sum_positive(&nfsdstats.counter[NFSD_STATS_RC_HITS]));
		   percpu_counter_sum_positive(&nn->counter[NFSD_STATS_RC_HITS]));
	seq_printf(m, "cache misses:          %lld\n",
		   percpu_counter_sum_positive(&nfsdstats.counter[NFSD_STATS_RC_MISSES]));
		   percpu_counter_sum_positive(&nn->counter[NFSD_STATS_RC_MISSES]));
	seq_printf(m, "not cached:            %lld\n",
		   percpu_counter_sum_positive(&nfsdstats.counter[NFSD_STATS_RC_NOCACHE]));
		   percpu_counter_sum_positive(&nn->counter[NFSD_STATS_RC_NOCACHE]));
	seq_printf(m, "payload misses:        %lld\n",
		   percpu_counter_sum_positive(&nn->counter[NFSD_STATS_PAYLOAD_MISSES]));
	seq_printf(m, "longest chain len:     %u\n", nn->longest_chain);
Loading