From ba7071cd1ca2ed84d351e6cfbe1db5c0bf1a5a09 Mon Sep 17 00:00:00 2001
From: David Smith <dsmith@redhat.com>
Date: Mon, 10 Feb 2014 09:59:21 -0600
Subject: [PATCH] rhbz1062076
---
tapset/linux/nfsd.stp | 130 +++++++++++++++++++++++++++++++++-----------------
tapset/linux/rpc.stp | 15 ++++--
tapset/linux/scsi.stp | 16 ++++---
3 files changed, 106 insertions(+), 55 deletions(-)
diff --git a/tapset/linux/nfsd.stp b/tapset/linux/nfsd.stp
index 092f55d..83765a3 100644
--- a/tapset/linux/nfsd.stp
+++ b/tapset/linux/nfsd.stp
@@ -146,6 +146,34 @@ function ftype:string(type:long) %{ /* pure */
}
%}
+function __rqstp_uid:long(rqstp:long)
+{
+%( CONFIG_USER_NS == "y" %?
+ # Notice we're using the 'init_user_ns' here, not
+ # 'current_user_ns()'. This matches up with the use in
+ # net/sunrpc/auth_generic.c.
+ return %{ /* pure */
+ from_kuid_munged(&init_user_ns,
+ ((struct svc_rqst *)STAP_ARG_rqstp)->rq_cred.cr_uid) %}
+%:
+ return @cast(rqstp, "svc_rqst", "kernel:nfsd")->rq_cred->cr_uid
+%)
+}
+
+function __rqstp_gid:long(rqstp:long)
+{
+%( CONFIG_USER_NS == "y" %?
+ # Notice we're using the 'init_user_ns' here, not
+ # 'current_user_ns()'. This matches up with the use in
+ # net/sunrpc/auth_generic.c.
+ return %{ /* pure */
+ from_kgid_munged(&init_user_ns,
+ ((struct svc_rqst *)STAP_ARG_rqstp)->rq_cred.cr_gid) %}
+%:
+ return @cast(rqstp, "svc_rqst", "kernel:nfsd")->rq_cred->cr_gid
+%)
+}
+
/**
* probe nfsd.dispatch - NFS server receives an operation from client
*
@@ -230,8 +258,8 @@ probe nfsd.proc2.lookup = kernel.function("nfsd_proc_lookup") !,
filelen = $argp->len
filename = kernel_string_n($argp->name, $argp->len)
- uid = $rqstp->rq_cred->cr_uid
- gid = $rqstp->rq_cred->cr_gid
+ uid = __rqstp_uid($rqstp)
+ gid = __rqstp_gid($rqstp)
name = "nfsd.proc2.lookup"
argstr = sprintf("%s", kernel_string_n($argp->name, $argp->len))
@@ -259,8 +287,8 @@ probe nfsd.proc3.lookup = kernel.function("nfsd3_proc_lookup") !,
filelen = $argp->len
filename = kernel_string_n($argp->name, $argp->len)
- uid = $rqstp->rq_cred->cr_uid
- gid = $rqstp->rq_cred->cr_gid
+ uid = __rqstp_uid($rqstp)
+ gid = __rqstp_gid($rqstp)
name = "nfsd.proc3.lookup"
argstr = sprintf("%s", kernel_string_n($argp->name, $argp->len))
@@ -306,8 +334,8 @@ probe nfsd.proc4.lookup = kernel.function("nfsd4_lookup").call !,
filelen = $lookup->lo_len
filename = kernel_string_n($lookup->lo_name, $lookup->lo_len)
- uid = $rqstp->rq_cred->cr_uid
- gid = $rqstp->rq_cred->cr_gid
+ uid = __rqstp_uid($rqstp)
+ gid = __rqstp_gid($rqstp)
name = "nfsd.proc4.lookup"
argstr = sprintf("%s", kernel_string_n($lookup->lo_name, $lookup->lo_len))
@@ -364,8 +392,8 @@ probe nfsd.proc2.read = kernel.function("nfsd_proc_read") !,
vec = @choose_defined($rqstp->rq_vec, $argp->vec)
vlen = $argp->vlen
- uid = $rqstp->rq_cred->cr_uid
- gid = $rqstp->rq_cred->cr_gid
+ uid = __rqstp_uid($rqstp)
+ gid = __rqstp_gid($rqstp)
name = "nfsd.proc2.read"
argstr = sprintf("%d,%d",count,offset)
@@ -398,8 +426,8 @@ probe nfsd.proc3.read = kernel.function("nfsd3_proc_read") !,
vec = @choose_defined($rqstp->rq_vec, $argp->vec)
vlen = $argp->vlen
- uid = $rqstp->rq_cred->cr_uid
- gid = $rqstp->rq_cred->cr_gid
+ uid = __rqstp_uid($rqstp)
+ gid = __rqstp_gid($rqstp)
name = "nfsd.proc3.read"
argstr = sprintf("%d,%d",count,offset)
@@ -432,8 +460,8 @@ probe nfsd.proc4.read = kernel.function("nfsd4_read").call !,
vec = $rqstp->rq_vec
vlen = $read->rd_vlen
- uid = $rqstp->rq_cred->cr_uid
- gid = $rqstp->rq_cred->cr_gid
+ uid = __rqstp_uid($rqstp)
+ gid = __rqstp_gid($rqstp)
name = "nfsd.proc4.read"
argstr = sprintf("%d,%d",count,offset)
@@ -494,8 +522,8 @@ probe nfsd.proc2.write = kernel.function("nfsd_proc_write") !,
vlen = $argp->vlen
stable = 1 # hardcoded in nfsd_proc_write()
- uid = $rqstp->rq_cred->cr_uid
- gid = $rqstp->rq_cred->cr_gid
+ uid = __rqstp_uid($rqstp)
+ gid = __rqstp_gid($rqstp)
name = "nfsd.proc2.write"
argstr = sprintf("%d,%d",count,offset)
@@ -531,8 +559,8 @@ probe nfsd.proc3.write = kernel.function("nfsd3_proc_write") !,
vlen = $argp->vlen
stable = $argp->stable
- uid = $rqstp->rq_cred->cr_uid
- gid = $rqstp->rq_cred->cr_gid
+ uid = __rqstp_uid($rqstp)
+ gid = __rqstp_gid($rqstp)
name = "nfsd.proc3.write"
argstr = sprintf("%d,%d",count,offset)
@@ -567,8 +595,8 @@ probe nfsd.proc4.write = kernel.function("nfsd4_write").call !,
vlen = @choose_defined($write->wr_vlen, 0)
stable = $write->wr_stable_how
- uid = $rqstp->rq_cred->cr_uid
- gid = $rqstp->rq_cred->cr_gid
+ uid = __rqstp_uid($rqstp)
+ gid = __rqstp_gid($rqstp)
name = "nfsd.proc4.write"
argstr = sprintf("%d,%d",count,offset)
@@ -625,8 +653,8 @@ probe nfsd.proc3.commit = kernel.function("nfsd3_proc_commit") !,
count = $argp->count
offset = $argp->offset
- uid = $rqstp->rq_cred->cr_uid
- gid = $rqstp->rq_cred->cr_gid
+ uid = __rqstp_uid($rqstp)
+ gid = __rqstp_gid($rqstp)
name = "nfsd.proc3.commit"
argstr = sprintf("%d,%d",count,offset)
@@ -656,8 +684,8 @@ probe nfsd.proc4.commit = kernel.function("nfsd4_commit").call !,
count = $commit->co_count
offset = $commit->co_offset
- uid = $rqstp->rq_cred->cr_uid
- gid = $rqstp->rq_cred->cr_gid
+ uid = __rqstp_uid($rqstp)
+ gid = __rqstp_gid($rqstp)
name = "nfsd.proc4.commit"
argstr = sprintf("%d,%d",count,offset)
@@ -712,8 +740,8 @@ probe nfsd.proc2.create = kernel.function("nfsd_proc_create") !,
filename = kernel_string_n($argp->name, $argp->len)
createmode = 0 # gets computed by nfsd_proc_create
- uid = $rqstp->rq_cred->cr_uid
- gid = $rqstp->rq_cred->cr_gid
+ uid = __rqstp_uid($rqstp)
+ gid = __rqstp_gid($rqstp)
name = "nfsd.proc2.create"
argstr = sprintf("%s", kernel_string_n($argp->name, $argp->len))
@@ -742,8 +770,8 @@ probe nfsd.proc3.create = kernel.function("nfsd3_proc_create") !,
filename = kernel_string_n($argp->name, $argp->len)
createmode = $argp->createmode
- uid = $rqstp->rq_cred->cr_uid
- gid = $rqstp->rq_cred->cr_gid
+ uid = __rqstp_uid($rqstp)
+ gid = __rqstp_gid($rqstp)
name = "nfsd.proc3.create"
argstr = sprintf("%s (mode=%s)",
@@ -775,8 +803,8 @@ probe nfsd.proc4.create = kernel.function("nfsd4_create").call !,
filename = kernel_string_n($create->cr_name, $create->cr_namelen)
createmode = $create->cr_type
- uid = $rqstp->rq_cred->cr_uid
- gid = $rqstp->rq_cred->cr_gid
+ uid = __rqstp_uid($rqstp)
+ gid = __rqstp_gid($rqstp)
name = "nfsd.proc4.create"
argstr = sprintf("%s (type=%s)",
@@ -830,8 +858,8 @@ probe nfsd.proc2.remove = kernel.function("nfsd_proc_remove") !,
filelen = $argp->len
filename = kernel_string_n($argp->name, $argp->len)
- uid = $rqstp->rq_cred->cr_uid
- gid = $rqstp->rq_cred->cr_gid
+ uid = __rqstp_uid($rqstp)
+ gid = __rqstp_gid($rqstp)
name = "nfsd.proc2.remove"
argstr = sprintf("%s", kernel_string_n($argp->name, $argp->len))
@@ -859,8 +887,8 @@ probe nfsd.proc3.remove = kernel.function("nfsd3_proc_remove") !,
filelen = $argp->len
filename = kernel_string_n($argp->name, $argp->len)
- uid = $rqstp->rq_cred->cr_uid
- gid = $rqstp->rq_cred->cr_gid
+ uid = __rqstp_uid($rqstp)
+ gid = __rqstp_gid($rqstp)
name = "nfsd.proc3.remove"
argstr = sprintf("%s", kernel_string_n($argp->name, $argp->len))
@@ -887,8 +915,8 @@ probe nfsd.proc4.remove = kernel.function("nfsd4_remove").call !,
filelen = $remove->rm_namelen
filename = kernel_string_n($remove->rm_name, $remove->rm_namelen)
- uid = $rqstp->rq_cred->cr_uid
- gid = $rqstp->rq_cred->cr_gid
+ uid = __rqstp_uid($rqstp)
+ gid = __rqstp_gid($rqstp)
name = "nfsd.proc4.remove"
argstr = sprintf("%s",
@@ -946,8 +974,8 @@ probe nfsd.proc2.rename = kernel.function("nfsd_proc_rename") !,
tlen = $argp->tlen
tname = kernel_string_n($argp->tname, $argp->tlen)
- uid = $rqstp->rq_cred->cr_uid
- gid = $rqstp->rq_cred->cr_gid
+ uid = __rqstp_uid($rqstp)
+ gid = __rqstp_gid($rqstp)
name = "nfsd.proc2.rename"
argstr = sprintf("%s to %s",
@@ -980,8 +1008,8 @@ probe nfsd.proc3.rename = kernel.function("nfsd3_proc_rename") !,
tlen = $argp->tlen
tname = kernel_string_n($argp->tname, $argp->tlen)
- uid = $rqstp->rq_cred->cr_uid
- gid = $rqstp->rq_cred->cr_gid
+ uid = __rqstp_uid($rqstp)
+ gid = __rqstp_gid($rqstp)
name = "nfsd.proc3.rename"
argstr = sprintf("%s to %s",
@@ -1014,8 +1042,8 @@ probe nfsd.proc4.rename = kernel.function("nfsd4_rename").call !,
tlen = $rename->rn_tnamelen
tname = kernel_string_n($rename->rn_tname, $rename->rn_tnamelen)
- uid = $rqstp->rq_cred->cr_uid
- gid = $rqstp->rq_cred->cr_gid
+ uid = __rqstp_uid($rqstp)
+ gid = __rqstp_gid($rqstp)
name = "nfsd.proc4.rename"
argstr = sprintf("%s to %s",
@@ -1093,15 +1121,29 @@ probe nfsd.open.return = kernel.function("nfsd_open").return !,
*
* @filename: file name
*/
-probe nfsd.close = kernel.function("nfsd_close") !,
- module("nfsd").function("nfsd_close") ?
+probe nfsd.close = __nfsd.call_close ?, __nfsd.inlined_close ?
{
client_ip ="N/A"
- filename = __file_filename($filp)
-
name = "nfsd.close"
argstr = sprintf("%s",filename)
}
+/*
+ * Why split nfsd.close up into '__nfsd.call_close' and
+ * '__nfds.inlined_close'? We need the '@choose_defined()' since
+ * SystemTap has trouble accessing the arguments of inlined functions
+ * (PR 1155). But, if we only used '@choose_defined()', we wouldn't
+ * automatically notice a change in the argument name.
+ */
+probe __nfsd.call_close = kernel.function("nfsd_close").call !,
+ module("nfsd").function("nfsd_close").call ?
+{
+ filename = __file_filename($filp)
+}
+probe __nfsd.inlined_close = kernel.function("nfsd_close").inline !,
+ module("nfsd").function("nfsd_close").inline ?
+{
+ filename = __file_filename(@choose_defined($filp, 0))
+}
probe nfsd.close.return = kernel.function("nfsd_close").return !,
module("nfsd").function("nfsd_close").return ?
diff --git a/tapset/linux/rpc.stp b/tapset/linux/rpc.stp
index 0b8d957..10c9d74 100644
--- a/tapset/linux/rpc.stp
+++ b/tapset/linux/rpc.stp
@@ -289,7 +289,8 @@ probe sunrpc.clnt.clone_client = kernel.function("rpc_clone_client") !,
servername = kernel_string(@choose_defined($clnt->cl_server,
@cast(rcu_dereference($clnt->cl_xprt),
"struct rpc_xprt")->servername))
- progname = kernel_string($clnt->cl_protname)
+ progname = kernel_string(@choose_defined($clnt->cl_program->name,
+ $clnt->cl_protname))
prog = prog_from_clnt($clnt)
vers = vers_from_clnt($clnt)
prot = prot_from_clnt($clnt)
@@ -337,7 +338,8 @@ probe sunrpc.clnt.shutdown_client = kernel.function("rpc_shutdown_client") !,
servername = kernel_string(@choose_defined($clnt->cl_server,
@cast(rcu_dereference($clnt->cl_xprt),
"struct rpc_xprt")->servername))
- progname = kernel_string($clnt->cl_protname)
+ progname = kernel_string(@choose_defined($clnt->cl_program->name,
+ $clnt->cl_protname))
prog = prog_from_clnt($clnt)
vers = vers_from_clnt($clnt)
prot = prot_from_clnt($clnt)
@@ -409,7 +411,8 @@ probe sunrpc.clnt.bind_new_program =
servername = kernel_string(@choose_defined($old->cl_server,
@cast(rcu_dereference($old->cl_xprt),
"struct rpc_xprt")->servername))
- old_progname = kernel_string($old->cl_protname)
+ old_progname = kernel_string(@choose_defined($old->cl_program->name,
+ $old->cl_protname))
old_prog = prog_from_clnt($old)
old_vers = vers_from_clnt($old)
progname = kernel_string($program->name)
@@ -450,7 +453,8 @@ probe sunrpc.clnt.call_sync = kernel.function("rpc_call_sync") !,
servername = kernel_string(@choose_defined($clnt->cl_server,
@cast(rcu_dereference($clnt->cl_xprt),
"struct rpc_xprt")->servername))
- progname = kernel_string($clnt->cl_protname)
+ progname = kernel_string(@choose_defined($clnt->cl_program->name,
+ $clnt->cl_protname))
prog = prog_from_clnt($clnt)
vers = vers_from_clnt($clnt)
prot = prot_from_clnt($clnt)
@@ -497,7 +501,8 @@ probe sunrpc.clnt.call_async = kernel.function("rpc_call_async") !,
servername = kernel_string(@choose_defined($clnt->cl_server,
@cast(rcu_dereference($clnt->cl_xprt),
"struct rpc_xprt")->servername))
- progname = kernel_string($clnt->cl_protname)
+ progname = kernel_string(@choose_defined($clnt->cl_program->name,
+ $clnt->cl_protname))
prog = prog_from_clnt($clnt)
vers = vers_from_clnt($clnt)
prot = prot_from_clnt($clnt)
diff --git a/tapset/linux/scsi.stp b/tapset/linux/scsi.stp
index b8f0c2c..d54e83e 100644
--- a/tapset/linux/scsi.stp
+++ b/tapset/linux/scsi.stp
@@ -126,15 +126,19 @@ probe scsi.iodispatching
* @scsi_timer_pending: 1 if a timer is pending on this request
*/
probe scsi.iodone
- = module("scsi_mod").function("scsi_done@drivers/scsi/scsi.c")!,
+ = kernel.trace("scsi_dispatch_cmd_done")!,
+ module("scsi_mod").function("scsi_done@drivers/scsi/scsi.c")!,
kernel.function("scsi_done@drivers/scsi/scsi.c")?
{
- host_no = $cmd->device->host->host_no
- channel = $cmd->device->channel
- lun = $cmd->device->lun
- dev_id = $cmd->device->id
- device_state = $cmd->device->sdev_state
+ # Why is the @cast() needed here? When the probe alias uses
+ # the "scsi_dispatch_cmd_done" tracepoint, the type info isn't
+ # in scope.
+ host_no = @cast($cmd->device, "scsi_device", "kernel:scsi_mod")->host->host_no
+ channel = @cast($cmd->device, "scsi_device", "kernel:scsi_mod")->channel
+ lun = @cast($cmd->device, "scsi_device", "kernel:scsi_mod")->lun
+ dev_id = @cast($cmd->device, "scsi_device", "kernel:scsi_mod")->id
+ device_state = @cast($cmd->device, "scsi_device", "kernel:scsi_mod")->sdev_state
device_state_str = describe_device_state(device_state)
data_direction = $cmd->sc_data_direction
data_direction_str = describe_data_direction(data_direction)
--
1.8.3.1