NFSv4/pnfs: Add tracing for the deviceid cache

Add tracepoints to allow debugging of the deviceid cache.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
This commit is contained in:
Trond Myklebust 2020-12-16 16:31:26 -05:00
parent 3316fb80a0
commit cac1d3a2b8
3 changed files with 92 additions and 8 deletions

View file

@ -9662,6 +9662,8 @@ _nfs4_proc_getdeviceinfo(struct nfs_server *server,
if (res.notification != args.notify_types)
pdev->nocache = 1;
trace_nfs4_getdeviceinfo(server, &pdev->dev_id, status);
dprintk("<-- %s status=%d\n", __func__, status);
return status;

View file

@ -2189,6 +2189,81 @@ DEFINE_PNFS_LAYOUT_EVENT(pnfs_mds_fallback_write_done);
DEFINE_PNFS_LAYOUT_EVENT(pnfs_mds_fallback_read_pagelist);
DEFINE_PNFS_LAYOUT_EVENT(pnfs_mds_fallback_write_pagelist);
DECLARE_EVENT_CLASS(nfs4_deviceid_event,
TP_PROTO(
const struct nfs_client *clp,
const struct nfs4_deviceid *deviceid
),
TP_ARGS(clp, deviceid),
TP_STRUCT__entry(
__string(dstaddr, clp->cl_hostname)
__array(unsigned char, deviceid, NFS4_DEVICEID4_SIZE)
),
TP_fast_assign(
__assign_str(dstaddr, clp->cl_hostname);
memcpy(__entry->deviceid, deviceid->data,
NFS4_DEVICEID4_SIZE);
),
TP_printk(
"deviceid=%s, dstaddr=%s",
__print_hex(__entry->deviceid, NFS4_DEVICEID4_SIZE),
__get_str(dstaddr)
)
);
#define DEFINE_PNFS_DEVICEID_EVENT(name) \
DEFINE_EVENT(nfs4_deviceid_event, name, \
TP_PROTO(const struct nfs_client *clp, \
const struct nfs4_deviceid *deviceid \
), \
TP_ARGS(clp, deviceid))
DEFINE_PNFS_DEVICEID_EVENT(nfs4_deviceid_free);
DECLARE_EVENT_CLASS(nfs4_deviceid_status,
TP_PROTO(
const struct nfs_server *server,
const struct nfs4_deviceid *deviceid,
int status
),
TP_ARGS(server, deviceid, status),
TP_STRUCT__entry(
__field(dev_t, dev)
__field(int, status)
__string(dstaddr, server->nfs_client->cl_hostname)
__array(unsigned char, deviceid, NFS4_DEVICEID4_SIZE)
),
TP_fast_assign(
__entry->dev = server->s_dev;
__entry->status = status;
__assign_str(dstaddr, server->nfs_client->cl_hostname);
memcpy(__entry->deviceid, deviceid->data,
NFS4_DEVICEID4_SIZE);
),
TP_printk(
"dev=%02x:%02x: deviceid=%s, dstaddr=%s, status=%d",
MAJOR(__entry->dev), MINOR(__entry->dev),
__print_hex(__entry->deviceid, NFS4_DEVICEID4_SIZE),
__get_str(dstaddr),
__entry->status
)
);
#define DEFINE_PNFS_DEVICEID_STATUS(name) \
DEFINE_EVENT(nfs4_deviceid_status, name, \
TP_PROTO(const struct nfs_server *server, \
const struct nfs4_deviceid *deviceid, \
int status \
), \
TP_ARGS(server, deviceid, status))
DEFINE_PNFS_DEVICEID_STATUS(nfs4_getdeviceinfo);
DEFINE_PNFS_DEVICEID_STATUS(nfs4_find_deviceid);
DECLARE_EVENT_CLASS(nfs4_flexfiles_io_event,
TP_PROTO(
const struct nfs_pgio_header *hdr

View file

@ -34,6 +34,8 @@
#include "internal.h"
#include "pnfs.h"
#include "nfs4trace.h"
#define NFSDBG_FACILITY NFSDBG_PNFS
/*
@ -192,24 +194,28 @@ nfs4_find_get_deviceid(struct nfs_server *server,
d = __nfs4_find_get_deviceid(server, id, hash);
if (d)
return d;
goto found;
new = nfs4_get_device_info(server, id, cred, gfp_mask);
if (!new)
if (!new) {
trace_nfs4_find_deviceid(server, id, -ENOENT);
return new;
}
spin_lock(&nfs4_deviceid_lock);
d = __nfs4_find_get_deviceid(server, id, hash);
if (d) {
spin_unlock(&nfs4_deviceid_lock);
server->pnfs_curr_ld->free_deviceid_node(new);
return d;
} else {
atomic_inc(&new->ref);
hlist_add_head_rcu(&new->node, &nfs4_deviceid_cache[hash]);
spin_unlock(&nfs4_deviceid_lock);
d = new;
}
hlist_add_head_rcu(&new->node, &nfs4_deviceid_cache[hash]);
atomic_inc(&new->ref);
spin_unlock(&nfs4_deviceid_lock);
return new;
found:
trace_nfs4_find_deviceid(server, id, 0);
return d;
}
EXPORT_SYMBOL_GPL(nfs4_find_get_deviceid);
@ -278,6 +284,7 @@ nfs4_put_deviceid_node(struct nfs4_deviceid_node *d)
}
if (!atomic_dec_and_test(&d->ref))
return false;
trace_nfs4_deviceid_free(d->nfs_client, &d->deviceid);
d->ld->free_deviceid_node(d);
return true;
}