This file is indexed.

/usr/share/systemtap/tapset/linux/ioblock.stp is in systemtap-common 2.6-0.2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
// Block I/O tapset
// Copyright (C) 2006 Intel Corp.
// Copyright (C) 2006 IBM Corp.
// Copyright (C) 2014 Red Hat Inc.
//
// This file is part of systemtap, and is free software.  You can
// redistribute it and/or modify it under the terms of the GNU General
// Public License (GPL); either version 2, or (at your option) any
// later version.

%{
#include <linux/bio.h>
#include <linux/genhd.h>
#ifdef STAPCONF_BLK_TYPES
#include <linux/blk_types.h>
#else
#define REQ_WRITE               (1 << BIO_RW)
#endif
%}

/* get i-node number of mapped file */
function __bio_ino:long(bio:long)
%{ /* pure */
    struct bio *bio = (struct bio *)(long)STAP_ARG_bio;
    struct page *bv_page = (bio && bio->bi_vcnt) ? kread(&(bio->bi_io_vec[0].bv_page)) : NULL;
    struct address_space *mapping;
    struct inode *host;
    STAP_RETVALUE = -1;
    if (bv_page && !PageSlab(bv_page) && !PageSwapCache(bv_page)) {
        mapping = kread(&(bv_page->mapping));
        if (mapping && ((unsigned long)mapping & PAGE_MAPPING_ANON) == 0) {
            host = kread(&(mapping->host));
            if (host)
                STAP_RETVALUE = kread(&(host->i_ino));
        }
    }
    CATCH_DEREF_FAULT();
%}

/* returns 0 for read, 1 for write */
function bio_rw_num:long(rw:long)
%{ /* pure */
    long rw = (long)STAP_ARG_rw;
    STAP_RETVALUE = (rw & REQ_WRITE);
%}

/* returns R for read, W for write */
function bio_rw_str(rw:long)
{
    return bio_rw_num(rw) == BIO_READ ? "R" : "W"
}

/* returns start sector */
function __bio_start_sect:long(bio:long)
{
    try {
        return @cast(bio, "bio")->bi_bdev->bd_part->start_sect
    } catch {
        return -1
    }
}

/* returns the block device name */
function __bio_devname:string(bio:long)
{
    return bdevname(@cast(bio, "bio")->bi_bdev)
}

global BIO_READ = 0, BIO_WRITE = 1


/**
 *  probe ioblock.request - Fires whenever making a generic block I/O request.
 *
 *  @name      - name of the probe point
 *  @devname   - block device name
 *  @ino       - i-node number of the mapped file
 *  @sector    - beginning sector for the entire bio
 *  @flags     - see below
 *  	BIO_UPTODATE    0       ok after I/O completion
 *  	BIO_RW_BLOCK    1       RW_AHEAD set, and read/write would block
 *  	BIO_EOF         2       out-out-bounds error
 *  	BIO_SEG_VALID   3       nr_hw_seg valid 
 *  	BIO_CLONED      4       doesn't own data
 *  	BIO_BOUNCED     5       bio is a bounce bio
 *  	BIO_USER_MAPPED 6       contains user pages
 *  	BIO_EOPNOTSUPP  7       not supported
 *  
 *  @rw        - binary trace for read/write request
 *  @vcnt      - bio vector count which represents number of array element (page, offset, length) which make up this I/O request
 *  @idx       - offset into the bio vector array
 *  @phys_segments - number of segments in this bio after physical address coalescing is performed
 *  @hw_segments -   number of segments after physical and DMA remapping hardware coalescing is performed
 *  @size      - total size in bytes
 *  @bdev      - target block device
 *  @bdev_contains - points to the device object which contains the partition (when bio structure represents a partition)
 *  @p_start_sect -  points to the start sector of the partition structure of the device
 *
 * Context:
 *  The process makes block I/O request
 */
probe ioblock.request = kernel.function ("generic_make_request")
{
	name = "ioblock.request"
        devname = __bio_devname($bio)
        ino = __bio_ino($bio)

        sector = @choose_defined($bio->bi_iter->bi_sector, $bio->bi_sector)
        flags = $bio->bi_flags
        rw = $bio->bi_rw
        vcnt = $bio->bi_vcnt
        idx = @choose_defined($bio->bi_iter->bi_idx, $bio->bi_idx)
        phys_segments = $bio->bi_phys_segments
	hw_segments = @choose_defined($bio->bi_hw_segments, 0)
        size = @choose_defined($bio->bi_iter->bi_size, $bio->bi_size)

        bdev = $bio->bi_bdev
        bdev_contains = $bio->bi_bdev->bd_contains
        p_start_sect = __bio_start_sect($bio)
}

/**
 * probe ioblock.end - Fires whenever a block I/O transfer is complete.
 *
 *  @name      - name of the probe point
 *  @devname   - block device name
 *  @ino       - i-node number of the mapped file
 *  @bytes_done - number of bytes transferred
 *  @sector    - beginning sector for the entire bio
 *  @flags     - see below
 *      BIO_UPTODATE    0       ok after I/O completion
 *      BIO_RW_BLOCK    1       RW_AHEAD set, and read/write would block
 *      BIO_EOF         2       out-out-bounds error
 *      BIO_SEG_VALID   3       nr_hw_seg valid
 *      BIO_CLONED      4       doesn't own data
 *      BIO_BOUNCED     5       bio is a bounce bio
 *      BIO_USER_MAPPED 6       contains user pages
 *      BIO_EOPNOTSUPP  7       not supported
 *  @error     - 0 on success
 *  @rw        - binary trace for read/write request
 *  @vcnt      - bio vector count which represents number of array element (page, offset, length) which makes up this I/O request
 *  @idx       - offset into the bio vector array
 *  @phys_segments - number of segments in this bio after physical address coalescing is performed.
 *  @hw_segments -   number of segments after physical and DMA remapping hardware coalescing is performed
 *  @size      - total size in bytes
 *
 * Context:
 *  The process signals the transfer is done.
 */
probe ioblock.end = kernel.function("bio_endio")
{
	name = "ioblock.end"
        devname = __bio_devname($bio)
        ino = __bio_ino($bio)

        bytes_done = @choose_defined($bytes_done,
				     @choose_defined($bio->bi_iter->bi_size,
						     $bio->bi_size))
        error = $error

        sector = @choose_defined($bio->bi_iter->bi_sector, $bio->bi_sector)
        flags = $bio->bi_flags
        rw = $bio->bi_rw
        vcnt = $bio->bi_vcnt
        idx = @choose_defined($bio->bi_iter->bi_idx, $bio->bi_idx)
        phys_segments = $bio->bi_phys_segments
	hw_segments = @choose_defined($bio->bi_hw_segments, 0)
        size = @choose_defined($bio->bi_iter->bi_size, $bio->bi_size)
}

/**
 * probe ioblock_trace.bounce - Fires whenever a buffer bounce is needed for at least one page of a block IO request.
 *
 *  @name      - name of the probe point
 *  @q         - request queue on which this bio was queued.
 *  @devname   - device for which a buffer bounce was needed.
 *  @ino       - i-node number of the mapped file
 *  @bytes_done - number of bytes transferred
 *  @sector    - beginning sector for the entire bio
 *  @flags     - see below
 *      BIO_UPTODATE    0       ok after I/O completion
 *      BIO_RW_BLOCK    1       RW_AHEAD set, and read/write would block
 *      BIO_EOF         2       out-out-bounds error
 *      BIO_SEG_VALID   3       nr_hw_seg valid
 *      BIO_CLONED      4       doesn't own data
 *      BIO_BOUNCED     5       bio is a bounce bio
 *      BIO_USER_MAPPED 6       contains user pages
 *      BIO_EOPNOTSUPP  7       not supported
 *  @rw        - binary trace for read/write request
 *  @vcnt      - bio vector count which represents number of array element (page, offset, length) which makes up this I/O request
 *  @idx       - offset into the bio vector array
 *  @phys_segments - number of segments in this bio after physical address coalescing is performed.
 *  @size      - total size in bytes
 *  @bdev      - target block device
 *  @bdev_contains - points to the device object which contains the partition (when bio structure represents a partition)
 *  @p_start_sect -  points to the start sector of the partition structure of the device
 *
 * Context :
 *	The process creating a block IO request.
 */
probe ioblock_trace.bounce = kernel.trace("block_bio_bounce")
{
	name = "ioblock_trace.bounce"
	q = $q
        devname = __bio_devname($bio)
        ino = __bio_ino($bio)

        bytes_done = @choose_defined($bio->bi_iter->bi_size, $bio->bi_size)
        sector = @choose_defined($bio->bi_iter->bi_sector, $bio->bi_sector)
        flags = $bio->bi_flags
        rw = $bio->bi_rw
        vcnt = $bio->bi_vcnt
        idx = @choose_defined($bio->bi_iter->bi_idx, $bio->bi_idx)
        phys_segments = $bio->bi_phys_segments
        size = @choose_defined($bio->bi_iter->bi_size, $bio->bi_size)
        bdev_contains = $bio->bi_bdev->bd_contains
        bdev = $bio->bi_bdev
        p_start_sect = __bio_start_sect($bio)
}

/**
 * probe ioblock_trace.request - Fires just as a generic block I/O request is created for a bio.
 *
 *  @name      - name of the probe point
 *  @q         - request queue on which this bio was queued.
 *  @devname   - block device name
 *  @ino       - i-node number of the mapped file
 *  @bytes_done - number of bytes transferred
 *  @sector    - beginning sector for the entire bio
 *  @flags     - see below
 *	BIO_UPTODATE    0       ok after I/O completion
 *	BIO_RW_BLOCK    1       RW_AHEAD set, and read/write would block
 *	BIO_EOF         2       out-out-bounds error
 *	BIO_SEG_VALID   3       nr_hw_seg valid
 *	BIO_CLONED      4       doesn't own data
 *	BIO_BOUNCED     5       bio is a bounce bio
 *	BIO_USER_MAPPED 6       contains user pages
 *	BIO_EOPNOTSUPP  7       not supported
 *
 *  @rw        - binary trace for read/write request
 *  @vcnt      - bio vector count which represents number of array element (page, offset, length) which make up this I/O request
 *  @idx       - offset into the bio vector array
 *  @phys_segments - number of segments in this bio after physical address coalescing is performed.
 *  @size      - total size in bytes
 *  @bdev      - target block device
 *  @bdev_contains - points to the device object which contains the partition (when bio structure represents a partition)
 *  @p_start_sect -  points to the start sector of the partition structure of the device
 *
 * Context:
 *  The process makes block I/O request
 */

probe ioblock_trace.request = kernel.trace("block_bio_queue")
{
	name = "ioblock_trace.request"
	q = $q
        devname = __bio_devname($bio)
        ino = __bio_ino($bio)

        bytes_done = @choose_defined($bio->bi_iter->bi_size, $bio->bi_size)
        sector = @choose_defined($bio->bi_iter->bi_sector, $bio->bi_sector)
        flags = $bio->bi_flags
        rw = $bio->bi_rw
        vcnt = $bio->bi_vcnt
        idx = @choose_defined($bio->bi_iter->bi_idx, $bio->bi_idx)
        phys_segments = $bio->bi_phys_segments
        size = @choose_defined($bio->bi_iter->bi_size, $bio->bi_size)
        bdev_contains = $bio->bi_bdev->bd_contains
        bdev = $bio->bi_bdev
        p_start_sect = __bio_start_sect($bio)
}

/**
 * probe ioblock_trace.end - Fires whenever a block I/O transfer is complete.
 *
 *  @name      - name of the probe point
 *  @q         - request queue on which this bio was queued.
 *  @devname   - block device name
 *  @ino       - i-node number of the mapped file
 *  @bytes_done - number of bytes transferred
 *  @sector    - beginning sector for the entire bio
 *  @flags     - see below
 *      BIO_UPTODATE    0       ok after I/O completion
 *      BIO_RW_BLOCK    1       RW_AHEAD set, and read/write would block
 *      BIO_EOF         2       out-out-bounds error
 *      BIO_SEG_VALID   3       nr_hw_seg valid
 *      BIO_CLONED      4       doesn't own data
 *      BIO_BOUNCED     5       bio is a bounce bio
 *      BIO_USER_MAPPED 6       contains user pages
 *      BIO_EOPNOTSUPP  7       not supported
 *
 *  @rw        - binary trace for read/write request
 *  @vcnt      - bio vector count which represents number of array element (page, offset, length) which makes up this I/O request
 *  @idx       - offset into the bio vector array
 *  @phys_segments - number of segments in this bio after physical address coalescing is performed.
 *  @size      - total size in bytes
 *  @bdev      - target block device
 *  @bdev_contains - points to the device object which contains the partition (when bio structure represents a partition)
 *  @p_start_sect -  points to the start sector of the partition structure of the device
 *
 * Context:
 *  The process signals the transfer is done.
 */
probe ioblock_trace.end = kernel.trace("block_bio_complete")
{
	name = "ioblock_trace.end"
	q = $q
        devname = __bio_devname($bio)
        ino = __bio_ino($bio)

        bytes_done = @choose_defined($bio->bi_iter->bi_size, $bio->bi_size)

        sector = @choose_defined($bio->bi_iter->bi_sector, $bio->bi_sector)
        flags = $bio->bi_flags
        rw = $bio->bi_rw
        vcnt = $bio->bi_vcnt
        idx = @choose_defined($bio->bi_iter->bi_idx, $bio->bi_idx)
        phys_segments = $bio->bi_phys_segments
        size = @choose_defined($bio->bi_iter->bi_size, $bio->bi_size)
        bdev_contains = $bio->bi_bdev->bd_contains
        bdev = $bio->bi_bdev
        p_start_sect = __bio_start_sect($bio)
}