Debian Codegraph @

tapset/linux/nfs.stp

raw
1 // nfs tapset
2 // Copyright (C) 2006-2007 IBM Corp.
3 // Copyright (C) 2007 Intel Corporation.
4 // Copyright (C) 2007 Bull S.A.S
5 // Copyright (c) 2009-2017 Red Hat Inc.
6 //
7 // This file is part of systemtap, and is free software. You can
8 // redistribute it and/or modify it under the terms of the GNU General
9 // Public License (GPL); either version 2, or (at your option) any
10 // later version.
11
12 %{
13 #include <linux/kernel.h>
14 #include <linux/nfs_fs.h>
15 #include <linux/uaccess.h> /* For VERIFY_READ/VERIFY_WRITE */
16 %}
17
18 /* Get cache_validity flag from struct inode */
19 @__private30 function __nfsi_cache_valid:long (inode:long)
20 {
21 if (inode == 0)
22 return -1
23 return @cast(NFS_I(inode), "nfs_inode", "kernel:nfs")->cache_validity
24 }
25
26 /* Get read_cache_jiffies from struct inode */
27 @__private30 function __nfsi_rcache_time:long (inode:long)
28 {
29 if (inode == 0)
30 return -1
31 return @cast(NFS_I(inode), "nfs_inode", "kernel:nfs")->read_cache_jiffies
32 }
33
34 /* Get attrtimeo from struct inode */
35 @__private30 function __nfsi_attr_time :long (inode:long)
36 {
37 if (inode == 0)
38 return -1
39 return @cast(NFS_I(inode), "nfs_inode", "kernel:nfs")->attrtimeo
40 }
41
42 /* Get ndirty from struct inode */
43 @__private30 function __nfsi_ndirty:long (inode:long)
44 {
45 if (inode == 0)
46 return -1
47 return @choose_defined(@cast(NFS_I(inode), "nfs_inode", "kernel:nfs")->ndirty, -1)
48 }
49
50 /* Get rsize from struct inode */
51 @__private30 function __nfs_server_rsize:long (inode:long)
52 {
53 if (inode == 0)
54 return -1
55 return @cast(NFS_SERVER(inode), "nfs_server", "kernel:nfs")->rsize
56 }
57
58 /* Get version from struct inode */
59 function __nfs_version:long (inode:long)
60 {
61 if (inode == 0)
62 return -1
63 return @cast(NFS_PROTO(inode), "nfs_rpc_ops", "kernel:nfs")->version
64 }
65
66 /* Get wsize from struct inode */
67 @__private30 function __nfs_server_wsize:long (inode:long)
68 {
69 if (inode == 0)
70 return -1
71 return @cast(NFS_SERVER(inode), "nfs_server", "kernel:nfs")->wsize
72 }
73
74 /* Get rpages from struct inode */
75 @__private30 function __nfs_rpages:long (inode:long)
76 {
77 if (inode == 0)
78 return -1
79 return @cast(NFS_SERVER(inode), "nfs_server", "kernel:nfs")->rpages
80 }
81
82 /* Get wpages from struct inode */
83 @__private30 function __nfs_wpages:long (inode:long)
84 {
85 if (inode == 0)
86 return -1
87 return @cast(NFS_SERVER(inode), "nfs_server", "kernel:nfs")->wpages
88 }
89
90 /* Get struct inode from struct page */
91 @__private30 function __p2i :long (page:long)
92 {
93 mapping = page? @cast(page, "page", "kernel:nfs")->mapping : 0
94 if (mapping == 0)
95 return 0
96 return @cast(mapping, "address_space", "kernel:nfs")->host
97 }
98
99 /* Get i_flags from struct page */
100 @__private30 function __p2i_flag : long (page:long)
101 {
102 host = __p2i(page)
103 if (host == 0)
104 return -1
105 return @cast(host, "inode", "kernel:nfs")->i_flags
106 }
107
108 /* Get i_state from struct page */
109 @__private30 function __p2i_state :long (page:long)
110 {
111 host = __p2i(page)
112 if (host == 0)
113 return -1
114 return @cast(host, "inode", "kernel:nfs")->i_state
115 }
116
117 /* Get i_size from struct page */
118 @__private30 function __p2i_size :long (page:long)
119 {
120 host = __p2i(page)
121 if (host == 0)
122 return -1
123 return @cast(host, "inode", "kernel:nfs")->i_size
124 }
125
126 /* Get s_flags from struct page */
127 @__private30 function __p2sb_flag:long (page:long)
128 {
129 host = __p2i(page)
130 i_sb = host? @cast(host, "inode", "kernel:nfs")->i_sb : 0
131 if (i_sb == 0)
132 return -1
133 return @cast(i_sb, "super_block", "kernel:nfs")->s_flags
134 }
135
136 function __file_inode:long (file:long)
137 {
138 dentry = file
139 ? @choose_defined(@cast(file, "file", "kernel:nfs")->f_path->dentry,
140 @cast(file, "file", "kernel:nfs")->f_dentry)
141 : 0
142 if (dentry == 0)
143 return 0
144 return @cast(dentry, "dentry", "kernel:nfs")->d_inode
145 }
146
147 @__private30 function __file_id:long (file:long)
148 {
149 d_inode = __file_inode(file)
150 if (d_inode == 0)
151 return 0
152 return @cast(d_inode, "inode", "kernel:nfs")->i_sb->s_id
153 }
154
155 @__private30 function __file_mode:long (file:long)
156 {
157 d_inode = __file_inode(file)
158 if (d_inode == 0)
159 return 0
160 return @cast(d_inode, "inode", "kernel:nfs")->i_mode
161 }
162
163 @__private30 function __file_parentname:string (file:long)
164 {
165 dentry = file
166 ? @choose_defined(@cast(file, "file", "kernel:nfs")->f_path->dentry,
167 @cast(file, "file", "kernel:nfs")->f_dentry)
168 : 0
169 d_parent = dentry? @cast(dentry, "dentry", "kernel:nfs")->d_parent : 0
170 if (d_parent == 0)
171 return "NULL"
172 name = @cast(d_parent, "dentry", "kernel:nfs")->d_name->name
173 return kernel_string(name)
174 }
175
176 /*
177 * Combination of generic_segment_checks and iov_length functions
178 * @iov: io vector request
179 * @nr_segs: number of segments in the iovec
180 * @check_flag: whether to check (0 as iov_length, 1 as
181 * generic_segment_checks)
182 * @access_flags: valid when check_flag >0, type of access:
183 * VERIFY_READ - 0 or VERIFY_WRITE - 1
184 *
185 * @return: number of bytes to write/read
186 */
187 function __iov_length:long (iov:long, nr_segs:long, check_flag:long, access_flags:long) %{ /* pure */
188 unsigned long seg;
189 size_t ret = 0;
190 const struct iovec *iov = (const struct iovec *)(uintptr_t)STAP_ARG_iov;
191 unsigned long nr_segs = (unsigned long)STAP_ARG_nr_segs;
192
193 for (seg = 0; seg < nr_segs; seg++)
194 { __kernel_size_t iov_len = kread(&(iov[seg].iov_len));
195 ret += iov_len;
196
197 if (STAP_ARG_check_flag) {
198
199 if (unlikely((ssize_t)(ret|iov_len) < 0)) {
200 STAP_RETVALUE = -EINVAL;
201 return;
202 }
203
204 if (!_stp_lookup_bad_addr((int)STAP_ARG_access_flags,
205 iov_len, kread(&(iov[seg].iov_base)),
206 STP_KERNEL_DS))
207 continue;
208 if (seg == 0) {
209 STAP_RETVALUE = -EFAULT;
210 return;
211 }
212 ret -= iov_len; /* This segment is no good */
213 break;
214 }
215 }
216 STAP_RETVALUE = (long)ret;
217 CATCH_DEREF_FAULT();
218 %}
219
220 probe nfs.fop.entries = nfs.fop.llseek,
221 nfs.fop.read,
222 nfs.fop.write,
223 nfs.fop.aio_read,
224 nfs.fop.aio_write,
225 nfs.fop.read_iter ?,
226 nfs.fop.write_iter ?,
227 nfs.fop.mmap,
228 nfs.fop.open,
229 nfs.fop.flush,
230 nfs.fop.release,
231 nfs.fop.sendfile ?,
232 nfs.fop.fsync,
233 nfs.fop.lock
234 {
235 }
236
237 probe nfs.fop.return = nfs.fop.llseek.return,
238 nfs.fop.read.return,
239 nfs.fop.write.return,
240 nfs.fop.aio_read.return,
241 nfs.fop.aio_write.return,
242 nfs.fop.read_iter.return ?,
243 nfs.fop.write_iter.return ?,
244 nfs.fop.mmap.return,
245 nfs.fop.open.return,
246 nfs.fop.flush.return,
247 nfs.fop.release.return,
248 nfs.fop.sendfile.return ?,
249 nfs.fop.fsync.return,
250 nfs.fop.lock.return
251 {
252 }
253
254 /**
255 * probe nfs.fop.llseek - NFS client llseek operation
256 *
257 * @dev: device identifier
258 * @ino: inode number
259 * @offset: the offset of the file will be repositioned
260 * @whence: the position to seek from
261 * @whence_str: symbolic string representation of the position to seek from
262 */
263 probe nfs.fop.llseek = kernel.function ("nfs_file_llseek") !,
264 module("nfs").function("nfs_file_llseek")
265 {
266 dev = __file_dev($filp)
267 ino = __file_ino($filp)
268 s_id = __file_id($filp)
269 devname = kernel_string(s_id)
270
271 maxbyte = __file_maxbytes($filp)
272 offset = $offset
273 %(systemtap_v < "2.3" %?
274 origin = @choose_defined($whence, $origin)
275 %)
276 whence = @choose_defined($whence, $origin)
277 whence_str = _seek_whence_str(@choose_defined($whence, $origin))
278
279 name = "nfs.fop.llseek"
280 argstr = sprintf("%d, %d", offset, @choose_defined($whence, $origin))
281 }
282
283 probe nfs.fop.llseek.return = kernel.function ("nfs_file_llseek").return !,
284 module("nfs").function("nfs_file_llseek").return
285 {
286 name = "nfs.fop.llseek.return"
287 retstr = sprintf("%d", $return)
288 }
289
290 /**
291 * probe nfs.fop.read - NFS client read operation
292 *
293 * @devname: block device name
294 *
295 * SystemTap uses the vfs.do_sync_read probe to implement this probe
296 * and as a result will get operations other than the NFS client read
297 * operations.
298 */
299 probe nfs.fop.read = vfs.do_sync_read
300 {
301 s_id = __file_id(file)
302 devname = kernel_string(s_id)
303 name = "nfs.fop.read"
304 }
305
306 probe nfs.fop.read.return = vfs.do_sync_read.return
307 {
308 name = "nfs.fop.read.return"
309 }
310
311 /**
312 * probe nfs.fop.write - NFS client write operation
313 *
314 * @devname: block device name
315 *
316 * SystemTap uses the vfs.do_sync_write probe to implement this probe
317 * and as a result will get operations other than the NFS client write
318 * operations.
319 */
320 probe nfs.fop.write = vfs.do_sync_write
321 {
322 s_id = __file_id(file)
323 devname = kernel_string(s_id)
324 name = "nfs.fop.write"
325 }
326
327 probe nfs.fop.write.return = vfs.do_sync_write.return
328 {
329 name = "nfs.fop.write.return"
330 }
331
332 /**
333 * probe nfs.fop.aio_read - NFS client aio_read file operation
334 *
335 * @dev: device identifier
336 * @ino: inode number
337 * @count: read bytes
338 * @pos: current position of file
339 * @buf: the address of buf in user space
340 * @parent_name: parent dir name
341 * @file_name: file name
342 * @cache_valid: cache related bit mask flag
343 * @cache_time: when we started read-caching this inode
344 * @attrtimeo: how long the cached information is assumed to be valid.
345 * We need to revalidate the cached attrs for this inode
346 * if jiffies - read_cache_jiffies > attrtimeo.
347 */
348 %( kernel_v < "3.16" %?
349 probe nfs.fop.aio_read = kernel.function ("nfs_file_read") !,
350 module("nfs").function("nfs_file_read")
351 {
352 dev = __file_dev($iocb->ki_filp)
353 ino = __file_ino($iocb->ki_filp)
354 s_id = __file_id($iocb->ki_filp)
355 devname = kernel_string(s_id)
356
357 pos = $pos
358
359 if (@defined($iov)) {
360 buf = $iov->iov_base
361 count = __iov_length($iov, $nr_segs, 0, @const("VERIFY_WRITE"))
362 }
363 else {
364 buf = $buf
365 count = $count
366 }
367
368 parent_name = __file_parentname($iocb->ki_filp)
369 file_name = __file_filename($iocb->ki_filp)
370
371 cache_valid = __nfsi_cache_valid(__file_inode($iocb->ki_filp))
372 cache_time = __nfsi_rcache_time(__file_inode($iocb->ki_filp))
373 attr_time = __nfsi_attr_time(__file_inode($iocb->ki_filp))
374
375 name = "nfs.fop.aio_read"
376 argstr = sprintf("%p, %d, %d", buf, count, pos)
377
378 size = count
379 units = "bytes"
380 }
381
382 probe nfs.fop.aio_read.return = kernel.function ("nfs_file_read").return !,
383 module("nfs").function("nfs_file_read").return
384 {
385 name = "nfs.fop.aio_read.return"
386 retstr = sprintf("%d", $return)
387
388 if ($return > 0) {
389 size = $return
390 }
391 units = "bytes"
392 }
393 %:
394 probe nfs.fop.aio_read = never
395 {
396 dev = 0
397 ino = 0
398 s_id = 0
399 devname = ""
400
401 pos = 0
402
403 buf = 0
404 count = 0
405
406 parent_name = ""
407 file_name = ""
408
409 cache_valid = 0
410 cache_time = 0
411 attr_time = 0
412
413 name = "nfs.fop.aio_read"
414 argstr = sprintf("%p, %d, %d", buf, count, pos)
415
416 size = count
417 units = "bytes"
418 }
419
420 probe nfs.fop.aio_read.return = never
421 {
422 name = "nfs.fop.aio_read.return"
423 retstr = sprintf("%d", 0)
424
425 size = 0
426 units = "bytes"
427 }
428 %)
429
430 /**
431 * probe nfs.fop.read_iter - NFS client read_iter file operation
432 *
433 * @dev: device identifier
434 * @ino: inode number
435 * @count: read bytes
436 * @pos: current position of file
437 * @parent_name: parent dir name
438 * @file_name: file name
439 * @cache_valid: cache related bit mask flag
440 * @cache_time: when we started read-caching this inode
441 * @attrtimeo: how long the cached information is assumed to be valid.
442 * We need to revalidate the cached attrs for this inode
443 * if jiffies - read_cache_jiffies > attrtimeo.
444 */
445 %( kernel_v >= "3.16" %?
446 probe nfs.fop.read_iter = kernel.function ("nfs_file_read") !,
447 module("nfs").function("nfs_file_read")
448 {
449 dev = __file_dev($iocb->ki_filp)
450 ino = __file_ino($iocb->ki_filp)
451 s_id = __file_id($iocb->ki_filp)
452 devname = kernel_string(s_id)
453
454 pos = $to->iov_offset
455 count = __iov_length(@choose_defined($to->iov,$to->__iov),
456 $to->nr_segs, 0, @const("VERIFY_READ"))
457
458 parent_name = __file_parentname($iocb->ki_filp)
459 file_name = __file_filename($iocb->ki_filp)
460
461 cache_valid = __nfsi_cache_valid(__file_inode($iocb->ki_filp))
462 cache_time = __nfsi_rcache_time(__file_inode($iocb->ki_filp))
463 attr_time = __nfsi_attr_time(__file_inode($iocb->ki_filp))
464
465 name = "nfs.fop.read_iter"
466 argstr = sprintf("%d, %d", count, pos)
467
468 size = count
469 units = "bytes"
470 }
471
472 probe nfs.fop.read_iter.return = kernel.function ("nfs_file_read").return !,
473 module("nfs").function("nfs_file_read").return
474 {
475 name = "nfs.fop.read_iter.return"
476 retstr = sprintf("%d", $return)
477
478 if ($return > 0) {
479 size = $return
480 }
481 units = "bytes"
482 }
483 %)
484
485 /**
486 * probe nfs.fop.aio_write - NFS client aio_write file operation
487 *
488 * @dev: device identifier
489 * @ino: inode number
490 * @count: read bytes
491 * @pos: offset of the file
492 * @buf: the address of buf in user space
493 * @parent_name: parent dir name
494 * @file_name: file name
495 */
496 %( kernel_v < "3.16" %?
497 probe nfs.fop.aio_write = kernel.function("nfs_file_write") !,
498 module("nfs").function("nfs_file_write")
499 {
500 dev = __file_dev($iocb->ki_filp)
501 ino = __file_ino($iocb->ki_filp)
502 s_id = __file_id($iocb->ki_filp)
503 devname = kernel_string(s_id)
504
505 pos = $pos
506 if (@defined($iov)) {
507 buf = $iov->iov_base
508 count = __iov_length($iov, $nr_segs, 0, @const("VERIFY_WRITE"))
509 }
510 else {
511 buf = $buf
512 count = $count
513 }
514
515 parent_name = __file_parentname($iocb->ki_filp)
516 file_name = __file_filename($iocb->ki_filp)
517
518 name = "nfs.fop.aio_write"
519 argstr = sprintf("%p, %d, %d", buf, count, pos)
520
521 size = count
522 units = "bytes"
523 }
524
525 probe nfs.fop.aio_write.return = kernel.function("nfs_file_write").return !,
526 module("nfs").function("nfs_file_write").return
527 {
528 name = "nfs.fop.aio_write.return"
529 retstr = sprintf("%d", $return)
530
531 if ($return > 0) {
532 size = $return
533 }
534 units = "bytes"
535 }
536 %:
537 probe nfs.fop.aio_write = never
538 {
539 dev = 0
540 ino = 0
541 s_id = 0
542 devname = ""
543
544 pos = 0
545 buf = 0
546 count = 0
547
548 parent_name = ""
549 file_name = ""
550
551 name = "nfs.fop.aio_write"
552 argstr = sprintf("%p, %d, %d", buf, count, pos)
553
554 size = count
555 units = "bytes"
556 }
557
558 probe nfs.fop.aio_write.return = never
559 {
560 name = "nfs.fop.aio_write.return"
561 retstr = sprintf("%d", 0)
562
563 size = 0
564 units = "bytes"
565 }
566 %)
567
568 /**
569 * probe nfs.fop.write_iter - NFS client write_iter file operation
570 *
571 * @dev: device identifier
572 * @ino: inode number
573 * @count: read bytes
574 * @pos: offset of the file
575 * @parent_name: parent dir name
576 * @file_name: file name
577 */
578 %( kernel_v >= "3.16" %?
579 probe nfs.fop.write_iter = kernel.function("nfs_file_write") !,
580 module("nfs").function("nfs_file_write")
581 {
582 dev = __file_dev($iocb->ki_filp)
583 ino = __file_ino($iocb->ki_filp)
584 s_id = __file_id($iocb->ki_filp)
585 devname = kernel_string(s_id)
586
587 pos = $from->iov_offset
588 count = __iov_length(@choose_defined($from->iov, $from->__iov),
589 $from->nr_segs, 0, @const("VERIFY_READ"))
590
591 parent_name = __file_parentname($iocb->ki_filp)
592 file_name = __file_filename($iocb->ki_filp)
593
594 name = "nfs.fop.write_iter"
595 argstr = sprintf("%d, %d", count, pos)
596
597 size = count
598 units = "bytes"
599 }
600
601 probe nfs.fop.write_iter.return = kernel.function("nfs_file_write").return !,
602 module("nfs").function("nfs_file_write").return
603 {
604 name = "nfs.fop.write_iter.return"
605 retstr = sprintf("%d", $return)
606
607 if ($return > 0) {
608 size = $return
609 }
610 units = "bytes"
611 }
612 %)
613
614 /**
615 * probe nfs.fop.mmap - NFS client mmap operation
616 *
617 * @dev: device identifier
618 * @ino: inode number
619 * @vm_start: start address within vm_mm
620 * @vm_end: the first byte after end address within vm_mm
621 * @vm_flag: vm flags
622 * @buf: the address of buf in user space
623 * @parent_name: parent dir name
624 * @file_name: file name
625 * @cache_valid: cache related bit mask flag
626 * @cache_time: when we started read-caching this inode
627 * @attrtimeo: how long the cached information is assumed to be valid.
628 * We need to revalidate the cached attrs for this inode
629 * if jiffies - read_cache_jiffies > attrtimeo.
630 */
631 probe nfs.fop.mmap = kernel.function("nfs_file_mmap") !,
632 module("nfs").function("nfs_file_mmap")
633 {
634 dev = __file_dev($file)
635 ino = __file_ino($file)
636 s_id = __file_id($file)
637 devname = kernel_string(s_id)
638
639 vm_start = $vma->vm_start
640 vm_end = $vma->vm_end
641 vm_flags = $vma->vm_flags
642
643 parent_name = __file_parentname($file)
644 file_name = __file_filename($file)
645
646 cache_valid = __nfsi_cache_valid(__file_inode($file))
647 cache_time = __nfsi_rcache_time(__file_inode($file))
648 attr_time = __nfsi_attr_time(__file_inode($file))
649
650 name = "nfs.fop.mmap"
651 argstr = sprintf("0x%x, 0x%x, 0x%x", vm_start, vm_end, vm_flags)
652 }
653
654 probe nfs.fop.mmap.return = kernel.function("nfs_file_mmap").return !,
655 module("nfs").function("nfs_file_mmap").return
656 {
657 name = "nfs.fop.mmap.return"
658 retstr = sprintf("%d", $return)
659 }
660
661 /**
662 * probe nfs.fop.open - NFS client file open operation
663 *
664 * @dev: device identifier
665 * @ino: inode number
666 * @file_name: file name
667 * @flag: file flag
668 * @i_size: file length in bytes
669 */
670 probe nfs.fop.open = kernel.function("nfs_file_open") !,
671 module("nfs").function("nfs_file_open")
672 {
673 dev = __file_dev($filp)
674 ino = $inode->i_ino
675 s_id = $inode->i_sb->s_id
676 devname = kernel_string(s_id)
677
678 filename = __file_filename($filp)
679 flag = $filp->f_flags
680
681 i_size = $inode->i_size
682
683 name = "nfs.fop.open"
684 argstr = sprintf("%d, %d, %s", flag, ino, filename)
685 }
686
687 probe nfs.fop.open.return = kernel.function("nfs_file_open").return !,
688 module("nfs").function("nfs_file_open").return
689 {
690 name = "nfs.fop.open.return"
691 retstr = sprintf("%d", $return)
692 }
693
694 /**
695 * probe nfs.fop.flush - NFS client flush file operation
696 *
697 * @dev: device identifier
698 * @ino: inode number
699 * @mode: file mode
700 * @ndirty: number of dirty page
701 */
702 probe nfs.fop.flush = kernel.function("nfs_file_flush") !,
703 module("nfs").function("nfs_file_flush")
704 {
705 dev = __file_dev($file)
706 ino = __file_ino($file)
707 s_id = __file_id($file)
708 devname = kernel_string(s_id)
709
710 mode = $file->f_mode
711 ndirty = __nfsi_ndirty(__file_inode($file))
712
713 name = "nfs.fop.flush"
714 argstr = sprintf("%d", ino)
715 }
716
717 probe nfs.fop.flush.return = kernel.function("nfs_file_flush").return !,
718 module("nfs").function("nfs_file_flush").return
719 {
720 name = "nfs.fop.flush.return"
721 retstr = sprintf("%d", $return)
722 }
723
724 /**
725 * probe nfs.fop.release - NFS client release page operation
726 *
727 * @dev: device identifier
728 * @ino: inode number
729 * @mode: file mode
730 */
731 probe nfs.fop.release = kernel.function("nfs_file_release") !,
732 module("nfs").function("nfs_file_release")
733 {
734 dev = __file_dev($filp)
735 ino = $inode->i_ino
736 s_id = $inode->i_sb->s_id
737 devname = kernel_string(s_id)
738
739 mode = $filp->f_mode
740
741 name = "nfs.fop.release"
742 argstr = sprintf("%d", ino)
743 }
744
745 probe nfs.fop.release.return = kernel.function("nfs_file_release").return !,
746 module("nfs").function("nfs_file_release").return
747 {
748 name = "nfs.fop.release.return"
749 retstr = sprintf("%d", $return)
750 }
751
752 /**
753 * probe nfs.fop.fsync - NFS client fsync operation
754 *
755 * @dev: device identifier
756 * @ino: inode number
757 * @ndirty: number of dirty pages
758 */
759 probe nfs.fop.fsync = kernel.function("nfs_file_fsync") !,
760 module("nfs").function("nfs_file_fsync") !,
761 kernel.function("nfs_fsync") !,
762 module("nfs").function("nfs_fsync")
763 {
764 dev = __file_dev($file)
765 ino = __file_ino($file)
766 s_id = __file_id($file)
767 devname = kernel_string(s_id)
768
769 ndirty = __nfsi_ndirty(__file_inode($file))
770
771 name = "nfs.fop.fsync"
772 argstr = sprintf("%d", ino)
773 }
774
775 probe nfs.fop.fsync.return = kernel.function("nfs_file_fsync").return !,
776 module("nfs").function("nfs_file_fsync").return !,
777 kernel.function("nfs_fsync").return !,
778 module("nfs").function("nfs_fsync").return
779 {
780 name = "nfs.fop.fsync.return"
781 retstr = sprintf("%d", $return)
782 }
783
784 /**
785 * probe nfs.fop.lock - NFS client file lock operation
786 *
787 * @dev: device identifier
788 * @ino: inode number
789 * @i_mode: file type and access rights
790 * @cmd: cmd arguments
791 * @fl_type:lock type
792 * @fl_flag: lock flags
793 * @fl_start: starting offset of locked region
794 * @fl_end: ending offset of locked region
795 */
796 probe nfs.fop.lock = kernel.function("nfs_lock") !,
797 module("nfs").function("nfs_lock")
798 {
799 dev = __file_dev($filp)
800 ino = __file_ino($filp)
801 s_id = __file_id($filp)
802 devname = kernel_string(s_id)
803
804 i_mode = __file_mode($filp)
805 cmd = $cmd
806
807 fl_type = $fl->fl_type
808 fl_flag = $fl->fl_flags
809 fl_start = $fl->fl_start
810 fl_end = $fl->fl_end
811
812 name = "nfs.fop.lock"
813 argstr = sprintf("%d, %d", cmd, i_mode)
814 }
815
816 probe nfs.fop.lock.return = kernel.function("nfs_lock").return !,
817 module("nfs").function("nfs_lock").return
818 {
819 name = "nfs.fop.lock.return"
820 retstr = sprintf("%d", $return)
821 }
822
823 /**
824 * probe nfs.fop.sendfile - NFS client send file operation
825 *
826 * @dev: device identifier
827 * @ino: inode number
828 * @count: read bytes
829 * @ppos: current position of file
830 * @cache_valid: cache related bit mask flag
831 * @cache_time: when we started read-caching this inode
832 * @attrtimeo: how long the cached information is assumed to be valid.
833 * We need to revalidate the cached attrs for this inode
834 * if jiffies - read_cache_jiffies > attrtimeo.
835 */
836 probe nfs.fop.sendfile = kernel.function("nfs_file_sendfile") !,
837 module("nfs").function("nfs_file_sendfile") ?
838 {
839 dev = __file_dev($filp)
840 ino = __file_ino($filp)
841 s_id = __file_id($filp)
842 devname = kernel_string(s_id)
843
844 count = $count
845 ppos = $ppos ? kernel_pointer($ppos) : -1
846
847 cache_valid = __nfsi_cache_valid(__file_inode($filp))
848 cache_time = __nfsi_rcache_time(__file_inode($filp))
849 attr_time = __nfsi_attr_time(__file_inode($filp))
850
851 name = "nfs.fop.sendfile"
852 argstr = sprintf("%d, %d", count, ppos)
853
854 size = count
855 units = "bytes"
856 }
857
858 probe nfs.fop.sendfile.return =
859 kernel.function("nfs_file_sendfile").return !,
860 module("nfs").function("nfs_file_sendfile").return ?
861 {
862 name = "nfs.fop.sendfile.return"
863 retstr = sprintf("%d", $return)
864
865 if ($return > 0) {
866 size = $return
867 }
868 units = "bytes"
869 }
870
871 /**
872 * probe nfs.fop.check_flags - NFS client checking flag operation
873 *
874 * @flag: file flag
875 */
876 probe nfs.fop.check_flags = kernel.function("nfs_check_flags") !,
877 module("nfs").function("nfs_check_flags")
878 {
879 flag = $flags
880
881 name = "nfs.fop.check_flags"
882 argstr = sprintf("%d", flag)
883 }
884
885 probe nfs.fop.check_flags.return =
886 kernel.function("nfs_check_flags").return !,
887 module("nfs").function("nfs_check_flags").return
888 {
889 name = "nfs.fop.check_flags.return"
890 retstr = sprintf("%d", $return)
891 }
892
893 probe nfs.aop.read_page_folio = nfs.aop.readpage !,
894 nfs.aop.readfolio
895 {
896 }
897
898 probe nfs.aop.read_pages_ahead = nfs.aop.readpages !,
899 nfs.aop.readahead
900 {
901 }
902
903 probe nfs.aop.entries = nfs.aop.read_page_folio,
904 nfs.aop.read_pages_ahead,
905 nfs.aop.writepage,
906 nfs.aop.writepages,
907 nfs.aop.release_page ?,
908 nfs.aop.write_begin,
909 nfs.aop.write_end
910 {
911 }
912
913 probe nfs.aop.read_page_folio.return = nfs.aop.readpage.return !,
914 nfs.aop.readfolio.return
915 {
916 }
917
918 probe nfs.aop.read_pages_ahead.return = nfs.aop.readpages.return !,
919 nfs.aop.readahead.return
920 {
921 }
922
923 probe nfs.aop.return = nfs.aop.read_page_folio.return,
924 nfs.aop.read_pages_ahead.return,
925 nfs.aop.writepage.return,
926 nfs.aop.writepages.return,
927 nfs.aop.release_page.return ?,
928 nfs.aop.write_begin.return,
929 nfs.aop.write_end.return
930 {
931 }
932
933 /**
934 * probe nfs.aop.readpage - NFS client synchronously reading a page
935 * @__page: the address of page
936 * @dev: device identifier
937 * @ino: inode number
938 * @i_flag: file flags
939 * @i_size: file length in bytes
940 * @sb_flag: super block flags
941 * @file: file argument
942 * @page_index : offset within mapping, can used a page identifier
943 * and position identifier in the page frame
944 * @rsize: read size (in bytes)
945 * @size: number of pages to be read in this execution
946 *
947 * Read the page over, only fires when a previous async
948 * read operation failed
949 */
950 probe nfs.aop.readpage = kernel.function ("nfs_readpage") !,
951 module("nfs").function ("nfs_readpage") ?
952 {
953 __page = $page
954 dev = __page_dev(__page)
955 ino = __page_ino(__page)
956
957 i_flag = __p2i_flag($page)
958 i_size = __p2i_size($page)
959
960 sb_flag = __p2sb_flag($page)
961
962 file = $file
963 page_index = $page->index
964
965 __inode = __p2i($page)
966 rsize = __nfs_server_rsize(__inode)
967
968 name = "nfs.aop.readpage"
969 argstr = sprintf("%d, %d", page_index, rsize)
970
971 size = 1
972 units = "pages"
973 }
974
975 probe nfs.aop.readpage.return = kernel.function ("nfs_readpage").return !,
976 module("nfs").function ("nfs_readpage").return ?
977 {
978 name = "nfs.aop.readpage.return"
979 retstr = sprintf("%d", $return)
980
981 size = 1
982 units = "pages"
983 }
984
985 /**
986 * probe nfs.aop.readfolio
987 */
988 probe nfs.aop.readfolio = kernel.function ("nfs_read_folio") !,
989 module("nfs").function ("nfs_read_folio") ?
990 {
991 folio = $folio
992 file = $file
993
994 name = "nfs.aop.readfolio"
995 argstr = sprintf("%x, %x", folio, file)
996 }
997
998 probe nfs.aop.readfolio.return = kernel.function ("nfs_read_folio").return !,
999 module("nfs").function ("nfs_read_folio").return ?
1000 {
1001 name = "nfs.aop.readfolio.return"
1002 retstr = sprintf("%d", $return)
1003 }
1004
1005
1006 /**
1007 * probe nfs.aop.readpages - NFS client reading multiple pages
1008 * @dev: device identifier
1009 * @ino: inode number
1010 * @nr_pages: number of pages attempted to read in this execution
1011 * @file: filp argument
1012 * @rpages: read size (in pages)
1013 * @rsize: read size (in bytes)
1014 * @size: number of pages attempted to read in this execution
1015 *
1016 * Fires when in readahead way, read several pages once
1017 */
1018 probe nfs.aop.readpages = kernel.function ("nfs_readpages") !,
1019 module("nfs").function ("nfs_readpages") ?
1020 {
1021 dev = $mapping->host->i_sb->s_dev
1022 ino = $mapping->host->i_ino
1023
1024 nr_pages = $nr_pages
1025 file = @choose_defined($filp, $file)
1026
1027 rpages = __nfs_rpages($mapping->host)
1028 rsize = __nfs_server_rsize($mapping->host)
1029
1030 name = "nfs.aop.readpages"
1031 argstr = sprintf("%d", nr_pages)
1032
1033 size = nr_pages
1034 units = "pages"
1035 }
1036
1037 probe nfs.aop.readpages.return = kernel.function ("nfs_readpages").return !,
1038 module("nfs").function ("nfs_readpages").return ?
1039 {
1040 name = "nfs.aop.readpages.return"
1041 retstr = sprintf("%d", $return)
1042
1043 if ($return > 0 ) {
1044 size = $return
1045 }
1046 units = "pages"
1047 }
1048
1049 /**
1050 * probe nfs.aop.readahead - NFS client reading multiple pages
1051 * @dev: device identifier
1052 * @ino: inode number
1053 * @nr_pages: number of pages attempted to read in this execution
1054 * @file: filp argument
1055 * @rpages: read size (in pages)
1056 * @rsize: read size (in bytes)
1057 * @size: number of pages attempted to read in this execution
1058 *
1059 * Fires when in readahead way, read several pages once
1060 */
1061 probe nfs.aop.readahead = kernel.function ("nfs_readahead") !,
1062 module("nfs").function ("nfs_readahead") ?
1063 {
1064 dev = $ractl->mapping->host->i_sb->s_dev
1065 ino = $ractl->mapping->host->i_ino
1066
1067 nr_pages = $ractl->mapping->nrpages
1068 file = $ractl->file;
1069
1070 rpages = __nfs_rpages($ractl->mapping->host)
1071 rsize = __nfs_server_rsize($ractl->mapping->host)
1072
1073 name = "nfs.aop.readahead"
1074 argstr = sprintf("%d", nr_pages)
1075
1076 size = nr_pages
1077 units = "pages"
1078 }
1079
1080 probe nfs.aop.readahead.return = kernel.function ("nfs_readahead").return !,
1081 module("nfs").function ("nfs_readahead").return ?
1082 {
1083 name = "nfs.aop.readahead.return"
1084 retstr = "N/A"
1085 // This is attempted size rather and does not filter out
1086 // the cases where an error occurred.
1087 size = @entry($ractl->mapping->nrpages)
1088 units = "pages"
1089 }
1090
1091 /**
1092 * probe nfs.aop.set_page_dirty - NFS client marking page as dirty
1093 * @__page: the address of page
1094 * @page_flag: page flags
1095 *
1096 * This probe attaches to the generic __set_page_dirty_nobuffers function.
1097 * Thus, this probe is going to fire on many other file systems in
1098 * addition to the NFS client.
1099 */
1100 probe nfs.aop.set_page_dirty =
1101 kernel.function ("__set_page_dirty_nobuffers") !,
1102 module("nfs").function ("__set_page_dirty_nobuffers")
1103 {
1104 __page = $page
1105 page_flag = $page->flags
1106
1107 name = "nfs.aop.set_page_dirty"
1108 argstr = sprintf("%d", page_flag)
1109 }
1110
1111 probe nfs.aop.set_page_dirty.return =
1112 kernel.function ("__set_page_dirty_nobuffers") .return !,
1113 module("nfs").function ("__set_page_dirty_nobuffers").return
1114 {
1115 name = "nfs.aop.set_page_dirty.return"
1116 retstr = sprintf("%d", $return)
1117 }
1118
1119 /**
1120 * probe nfs.aop.writepage - NFS client writing a mapped page to the NFS server
1121 * @__page: the address of page
1122 * @dev: device identifier
1123 * @ino: inode number
1124 * @for_reclaim: a flag of writeback_control,
1125 * indicates if it's invoked from the page allocator
1126 * @for_kupdate: a flag of writeback_control,
1127 * indicates if it's a kupdate writeback
1128 * @i_flag: file flags
1129 * @i_size: file length in bytes
1130 * @i_state: inode state flags
1131 * @sb_flag: super block flags
1132 * @page_index: offset within mapping,
1133 * can used a page identifier and position identifier in the page frame
1134 * @wsize: write size
1135 * @size: number of pages to be written in this execution
1136 *
1137 * The priority of wb is decided by the flags
1138 * @for_reclaim and @for_kupdate.
1139 */
1140 probe nfs.aop.writepage = kernel.function ("nfs_writepage") !,
1141 module("nfs").function ("nfs_writepage")
1142 {
1143 __page = $page
1144 dev = __page_dev(__page)
1145 ino = __page_ino(__page)
1146
1147 for_reclaim = $wbc->for_reclaim
1148 for_kupdate = $wbc->for_kupdate
1149
1150 i_flag = __p2i_flag($page)
1151 i_state = __p2i_state($page)
1152 i_size = __p2i_size($page)
1153
1154 sb_flag = __p2sb_flag($page)
1155
1156 page_index = $page->index
1157
1158 __inode = __p2i($page)
1159 wsize = __nfs_server_wsize(__inode)
1160
1161 name = "nfs.aop.writepage"
1162 argstr = sprintf("%d", page_index)
1163
1164 size = 1
1165 units = "pages"
1166 }
1167
1168 probe nfs.aop.writepage.return = kernel.function ("nfs_writepage").return !,
1169 module("nfs").function ("nfs_writepage").return
1170 {
1171 name = "nfs.aop.writepage.return"
1172 retstr = sprintf("%d", $return)
1173 }
1174
1175 /**
1176 * probe nfs.aop.writepages - NFS client writing several dirty pages to the NFS server
1177 * @dev: device identifier
1178 * @ino: inode number
1179 * @for_reclaim: a flag of writeback_control,
1180 * indicates if it's invoked from the page allocator
1181 * @for_kupdate: a flag of writeback_control,
1182 * indicates if it's a kupdate writeback
1183 * @wsize: write size
1184 * @wpages: write size (in pages)
1185 * @nr_to_write: number of pages attempted to be written in this execution
1186 * @size: number of pages attempted to be written in this execution
1187 *
1188 * The priority of wb is decided by the flags
1189 * @for_reclaim and @for_kupdate.
1190 */
1191 probe nfs.aop.writepages = kernel.function ("nfs_writepages") !,
1192 module("nfs").function ("nfs_writepages")
1193 {
1194 dev = $mapping->host->i_sb->s_dev
1195 ino = $mapping->host->i_ino
1196
1197 for_reclaim = $wbc->for_reclaim
1198 for_kupdate = $wbc->for_kupdate
1199 nr_to_write = $wbc->nr_to_write
1200
1201 wsize = __nfs_server_wsize($mapping->host)
1202 wpages = __nfs_wpages($mapping->host)
1203
1204 name = "nfs.aop.writepages"
1205 argstr = sprintf("%d", nr_to_write)
1206
1207 size = nr_to_write
1208 units = "pages"
1209 }
1210
1211 probe nfs.aop.writepages.return =
1212 kernel.function ("nfs_writepages").return !,
1213 module("nfs").function ("nfs_writepages").return
1214 {
1215 name = "nfs.aop.writepages.return"
1216 retstr = sprintf("%d", $return)
1217 }
1218
1219 # kernel commit 4899f9c852564ce7b6d0ca932ac6674bf471fd28 removed
1220 # nfs_prepare_write()/nfs_commit_write() and created
1221 # nfs_write_begin()/nfs_write_end(). So, we try to find whatever the
1222 # current kernel has.
1223
1224 /**
1225 * probe nfs.aop.write_begin - NFS client begin to write data
1226 * @__page: the address of page
1227 * @dev: device identifier
1228 * @ino: inode number
1229 * @offset: start address of this write operation
1230 * @to: end address of this write operation
1231 * @page_index: offset within mapping, can used a page identifier
1232 * and position identifier in the page frame
1233 * @size: write bytes
1234 *
1235 * Occurs when write operation occurs on nfs. It prepare a page for writing,
1236 * look for a request corresponding to the page. If there
1237 * is one, and it belongs to another file, it flush it out
1238 * before it tries to copy anything into the page.
1239 * Also do the same if it finds a request from an existing
1240 * dropped page
1241 *
1242 */
1243 probe nfs.aop.write_begin = __nfs.aop.write_begin !,
1244 __nfs.aop.prepare_write
1245 {
1246 }
1247 probe nfs.aop.write_begin.return
1248 = __nfs.aop.write_begin.return !,
1249 __nfs.aop.prepare_write.return
1250 {
1251 }
1252
1253 /**
1254 * probe nfs.aop.write_end - NFS client complete writing data
1255 * @__page: the address of page
1256 * @dev: device identifier
1257 * @ino: inode number
1258 * @offset: start address of this write operation
1259 * @to: end address of this write operation
1260 * @i_flag: file flags
1261 * @i_size: file length in bytes
1262 * @sb_flag: super block flags
1263 * @page_index: offset within mapping, can used a page identifier and position identifier in the page frame
1264 * @size: write bytes
1265 *
1266 * Fires when do a write operation on nfs,
1267 * often after prepare_write
1268 *
1269 * Update and possibly write a cached page of an NFS file.
1270 */
1271 probe nfs.aop.write_end = __nfs.aop.write_end !,
1272 __nfs.aop.commit_write
1273 {
1274 }
1275 probe nfs.aop.write_end.return
1276 = __nfs.aop.write_end.return !,
1277 __nfs.aop.commit_write.return
1278 {
1279 }
1280
1281 probe __nfs.aop.write_begin = kernel.function ("nfs_write_begin") !,
1282 module("nfs").function("nfs_write_begin")
1283 {
1284 # Since __nfs.aop.write_begin and __nfs.aop.prepare_write
1285 # share a "parent" probe (nfs.aop.write_begin), they need to
1286 # have the same convenience variables. So, define a few fake
1287 # ones here. The optimizer will remove any that aren't
1288 # actually used.
1289 __page = -1
1290 offset = $pos
1291 to = $pos + $len
1292 page_index = -1
1293 size = $len
1294
1295 dev = __file_dev($file)
1296 ino = __file_ino($file)
1297 s_id = __file_id($file)
1298 devname = kernel_string(s_id)
1299
1300 pos = $pos
1301 count = $len
1302
1303 name = "nfs.aop.write_begin"
1304 argstr = sprintf("%d", ino)
1305
1306 units = "bytes"
1307 }
1308 probe __nfs.aop.write_begin.return
1309 = kernel.function ("nfs_write_begin").return !,
1310 module("nfs").function ("nfs_write_begin").return
1311 {
1312 name = "nfs.aop.write_begin.return"
1313 retstr = sprintf("%d", $return)
1314 }
1315
1316 probe __nfs.aop.write_end = kernel.function ("nfs_write_end") !,
1317 module("nfs").function("nfs_write_end")
1318 {
1319 # Since __nfs.aop.write_end and __nfs.aop.commit_write
1320 # share a "parent" probe (nfs.aop.write_end), they need to
1321 # have the same convenience variables. So, define a few fake
1322 # ones here. The optimizer will remove any that aren't
1323 # actually used.
1324 __page = -1
1325 offset = $pos
1326 to = $pos + $len
1327 i_flag = 0
1328 i_size = 0
1329 sb_flag = 0
1330 page_index = -1
1331 size = $len
1332
1333 dev = __file_dev($file)
1334 ino = __file_ino($file)
1335 s_id = __file_id($file)
1336 devname = kernel_string(s_id)
1337
1338 pos = $pos
1339 count = $len
1340
1341 name = "nfs.aop.write_end"
1342 argstr = sprintf("%d", ino)
1343
1344 units = "bytes"
1345 }
1346 probe __nfs.aop.write_end.return
1347 = kernel.function ("nfs_write_end").return !,
1348 module("nfs").function("nfs_write_end").return
1349 {
1350 name = "nfs.aop.write_end.return"
1351 retstr = sprintf("%d", $return)
1352 }
1353
1354 probe __nfs.aop.prepare_write = kernel.function ("nfs_prepare_write") !,
1355 module("nfs").function ("nfs_prepare_write")
1356 {
1357 # Since __nfs.aop.write_begin and __nfs.aop.prepare_write
1358 # share a "parent" probe (nfs.aop.write_begin), they need to
1359 # have the same convenience variables. So, define a few fake
1360 # ones here. The optimizer will remove any that aren't
1361 # actually used.
1362 s_id = -1
1363 pos = $offset
1364 count = $to - $offset
1365
1366 __page = $page
1367 dev = __page_dev(__page)
1368 devname = __find_bdevname(dev, __page_bdev(__page))
1369 ino = __page_ino(__page)
1370
1371 offset = $offset
1372 to = $to
1373
1374 page_index = $page->index
1375
1376 name = "nfs.aop.prepare_write"
1377 argstr = sprintf("%d", page_index)
1378
1379 size = $to - $offset
1380 units = "bytes"
1381 }
1382
1383 probe __nfs.aop.prepare_write.return =
1384 kernel.function ("nfs_prepare_write").return !,
1385 module("nfs").function ("nfs_prepare_write").return
1386 {
1387 name = "nfs.aop.prepare_write.return"
1388 retstr = sprintf("%d", $return)
1389 }
1390
1391 probe __nfs.aop.commit_write = kernel.function ("nfs_commit_write") !,
1392 module("nfs").function ("nfs_commit_write")
1393 {
1394 # Since __nfs.aop.write_end and __nfs.aop.commit_write
1395 # share a "parent" probe (nfs.aop.write_end), they need to
1396 # have the same convenience variables. So, define a few fake
1397 # ones here. The optimizer will remove any that aren't
1398 # actually used.
1399 s_id = -1
1400 pos = $offset
1401 count = $to - $offset
1402
1403 __page = $page
1404 dev = __page_dev(__page)
1405 devname = __find_bdevname(dev, __page_bdev(__page))
1406 ino = __page_ino(__page)
1407
1408 offset = $offset
1409 to = $to
1410
1411 i_flag = __p2i_flag($page)
1412 i_size = __p2i_size($page)
1413
1414 sb_flag = __p2sb_flag($page)
1415
1416 page_index = $page->index
1417
1418 name = "nfs.aop.commit_write"
1419 argstr = sprintf("%d, %d", offset, to)
1420
1421 size = $to - $offset
1422 units = "bytes"
1423 }
1424
1425 probe __nfs.aop.commit_write.return =
1426 kernel.function ("nfs_commit_write").return !,
1427 module("nfs").function ("nfs_commit_write").return
1428 {
1429 name = "nfs.aop.commit_write.return"
1430 retstr = sprintf("%d", $return)
1431 }
1432
1433 /**
1434 * probe nfs.aop.release_page - NFS client releasing page
1435 * @__page: the address of page
1436 * @dev: device identifier
1437 * @ino: inode number
1438 * @page_index: offset within mapping, can used a page identifier
1439 * and position identifier in the page frame
1440 * @size: release pages
1441 *
1442 * Fires when do a release operation on NFS.
1443 */
1444 probe nfs.aop.release_page = kernel.function ("nfs_release_page") !,
1445 module("nfs").function ("nfs_release_page") ?
1446 {
1447 __page = $page
1448 dev = __page_dev(__page)
1449 ino = __page_ino(__page)
1450
1451 // gfp = $gfp
1452 page_index = $page->index
1453
1454 name = "nfs.aop.release_page"
1455 argstr = sprintf("%d", page_index)
1456
1457 size = 1
1458 units = "pages"
1459
1460 }
1461
1462 probe nfs.aop.release_page.return =
1463 kernel.function ("nfs_release_page").return !,
1464 module("nfs").function ("nfs_release_page").return ?
1465 {
1466 name = "nfs.aop.release_page.return"
1467 retstr = sprintf("%d", $return)
1468 }