I need to be able to see if a mount request generated an error in the mountd daemon. I have a custom kernel that has changed the mount() function call to return the error code. So, now I'm using a very simple DTrace script to catch the error codes:
#!/usr/sbin/dtrace -s
pid$1::mount:return
{
printf("rc = %d", args[1]);
}
pid$1::audit_mountd_mount:return
{
printf("rc = %d", args[1]);
}
The issue is what happens when I try to run it:
[root@pnfs-4-11 ~]> ./mountd_res.d `pgrep -x mountd` dtrace: failed to compile script ./mountd_res.d: line 18: args[ ] may not be referenced because probe description pid100824::mount:return matches an unstable set of probes
What I think this means is that I've got multiple declarations of mount() and they all do not return something. Okay, I can narrow down the probe to just the one I want:
[root@pnfs-4-11 ~]> dtrace -l -f mount ID PROVIDER MODULE FUNCTION NAME 2378 lx-syscall mount entry 2379 lx-syscall mount return 13708 fbt genunix mount entry 13709 fbt genunix mount return 31190 syscall mount entry 31191 syscall mount return 65944 pid100824 mountd mount entry 65945 pid100824 libc.so.1 mount entry 65946 pid100824 mountd mount return 65947 pid100824 libc.so.1 mount return
And if I adjust my script:
pid$1:mountd:mount:return
{
printf("rc = %d", args[1]);
}
We see I've fixed this issue!
[root@pnfs-4-11 ~]> ./mountd_res.d `pgrep -x mountd` dtrace: failed to compile script ./mountd_res.d: line 18: index 1 is out of range for pid100824:mountd:mount:return args[ ]
Okay, I got my syntax wrong for the return code:
pid$1:mountd:mount:return
{
printf("rc = %d", arg1);
}
And now I see the correct output:
[root@pnfs-4-11 ~]> ./mountd_res.d `pgrep -x mountd` dtrace: script './mountd_res.d' matched 2 probes CPU ID FUNCTION:NAME 0 65946 mount:return rc = 0 0 65240 audit_mountd_mount:return rc = 1 0 65946 mount:return rc = 0 0 65240 audit_mountd_mount:return rc = 1