OSDN Git Service

nfsd: Add tracepoints for update of the expkey and export cache entries
authorTrond Myklebust <trondmy@gmail.com>
Sun, 1 Mar 2020 23:21:41 +0000 (18:21 -0500)
committerChuck Lever <chuck.lever@oracle.com>
Mon, 16 Mar 2020 16:04:33 +0000 (12:04 -0400)
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfsd/export.c
fs/nfsd/trace.h

index e867db0..6e6cbeb 100644 (file)
@@ -141,7 +141,9 @@ static int expkey_parse(struct cache_detail *cd, char *mesg, int mlen)
        if (len == 0) {
                set_bit(CACHE_NEGATIVE, &key.h.flags);
                ek = svc_expkey_update(cd, &key, ek);
-               if (!ek)
+               if (ek)
+                       trace_nfsd_expkey_update(ek, NULL);
+               else
                        err = -ENOMEM;
        } else {
                err = kern_path(buf, 0, &key.ek_path);
@@ -151,7 +153,9 @@ static int expkey_parse(struct cache_detail *cd, char *mesg, int mlen)
                dprintk("Found the path %s\n", buf);
 
                ek = svc_expkey_update(cd, &key, ek);
-               if (!ek)
+               if (ek)
+                       trace_nfsd_expkey_update(ek, buf);
+               else
                        err = -ENOMEM;
                path_put(&key.ek_path);
        }
@@ -644,15 +648,17 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen)
        }
 
        expp = svc_export_lookup(&exp);
-       if (expp)
-               expp = svc_export_update(&exp, expp);
-       else
-               err = -ENOMEM;
-       cache_flush();
-       if (expp == NULL)
+       if (!expp) {
                err = -ENOMEM;
-       else
+               goto out4;
+       }
+       expp = svc_export_update(&exp, expp);
+       if (expp) {
+               trace_nfsd_export_update(expp);
+               cache_flush();
                exp_put(expp);
+       } else
+               err = -ENOMEM;
 out4:
        nfsd4_fslocs_free(&exp.ex_fslocs);
        kfree(exp.ex_uuid);
index 3b9277d..78c5742 100644 (file)
@@ -105,6 +105,32 @@ TRACE_EVENT(nfsd_exp_find_key,
        )
 );
 
+TRACE_EVENT(nfsd_expkey_update,
+       TP_PROTO(const struct svc_expkey *key, const char *exp_path),
+       TP_ARGS(key, exp_path),
+       TP_STRUCT__entry(
+               __field(int, fsidtype)
+               __array(u32, fsid, 6)
+               __string(auth_domain, key->ek_client->name)
+               __string(path, exp_path)
+               __field(bool, cache)
+       ),
+       TP_fast_assign(
+               __entry->fsidtype = key->ek_fsidtype;
+               memcpy(__entry->fsid, key->ek_fsid, 4*6);
+               __assign_str(auth_domain, key->ek_client->name);
+               __assign_str(path, exp_path);
+               __entry->cache = !test_bit(CACHE_NEGATIVE, &key->h.flags);
+       ),
+       TP_printk("fsid=%x::%s domain=%s path=%s cache=%s",
+               __entry->fsidtype,
+               __print_array(__entry->fsid, 6, 4),
+               __get_str(auth_domain),
+               __get_str(path),
+               __entry->cache ? "pos" : "neg"
+       )
+);
+
 TRACE_EVENT(nfsd_exp_get_by_name,
        TP_PROTO(const struct svc_export *key,
                 int status),
@@ -126,6 +152,26 @@ TRACE_EVENT(nfsd_exp_get_by_name,
        )
 );
 
+TRACE_EVENT(nfsd_export_update,
+       TP_PROTO(const struct svc_export *key),
+       TP_ARGS(key),
+       TP_STRUCT__entry(
+               __string(path, key->ex_path.dentry->d_name.name)
+               __string(auth_domain, key->ex_client->name)
+               __field(bool, cache)
+       ),
+       TP_fast_assign(
+               __assign_str(path, key->ex_path.dentry->d_name.name);
+               __assign_str(auth_domain, key->ex_client->name);
+               __entry->cache = !test_bit(CACHE_NEGATIVE, &key->h.flags);
+       ),
+       TP_printk("path=%s domain=%s cache=%s",
+               __get_str(path),
+               __get_str(auth_domain),
+               __entry->cache ? "pos" : "neg"
+       )
+);
+
 DECLARE_EVENT_CLASS(nfsd_io_class,
        TP_PROTO(struct svc_rqst *rqstp,
                 struct svc_fh  *fhp,