-
Notifications
You must be signed in to change notification settings - Fork 2
/
bookmark_read.xd
385 lines (318 loc) · 11.6 KB
/
bookmark_read.xd
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
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
#pragma D option quiet
#pragma D option bufsize=16M
#pragma D option switchrate=10hz
#define P2PHASE(x, align) ((x) & ((align) - 1))
#define BF64_DECODE(x, low, len) P2PHASE((x) >> (low), 1ULL << (len))
#define BF64_GET(x, low, len) BF64_DECODE(x, low, len)
#define BF64_GET_SB(x, low, len, shift, bias) \
((BF64_GET(x, low, len) + (bias)) << (shift))
#define SPA_MINBLOCKSHIFT 9
#define SPA_MAXBLOCKSHIFT 17
#define SPA_MINBLOCKSIZE (1ULL << SPA_MINBLOCKSHIFT)
#define SPA_MAXBLOCKSIZE (1ULL << SPA_MAXBLOCKSHIFT)
#define SPA_LSIZEBITS 16 /* LSIZE up to 32M (2^16 * 512) */
#define SPA_PSIZEBITS 16 /* PSIZE up to 32M (2^16 * 512) */
#define SPA_ASIZEBITS 24 /* ASIZE up to 64 times larger */
#define SPA_BLKPTRSHIFT 7 /* blkptr_t is 128 bytes */
#define SPA_DVAS_PER_BP 3 /* Number of DVAs in a bp */
#define BPE_GET_ETYPE(bp) \
BF64_GET((bp)->blk_prop, 40, 8)
#define BPE_GET_LSIZE(bp) \
BF64_GET_SB((bp)->blk_prop, 0, 25, 0, 1)
#define BPE_GET_PSIZE(bp) \
BF64_GET_SB((bp)->blk_prop, 25, 7, 0, 1)
#define DVA_GET_ASIZE(dva) \
BF64_GET_SB((dva)->dva_word[0], 0, 24, SPA_MINBLOCKSHIFT, 0)
#define DVA_GET_GRID(dva) BF64_GET((dva)->dva_word[0], 24, 8)
#define DVA_GET_VDEV(dva) BF64_GET((dva)->dva_word[0], 32, 32)
#define DVA_GET_OFFSET(dva) \
BF64_GET_SB((dva)->dva_word[1], 0, 63, SPA_MINBLOCKSHIFT, 0)
#define DVA_GET_GANG(dva) BF64_GET((dva)->dva_word[1], 63, 1)
#define BP_GET_LSIZE(bp) \
(BP_IS_EMBEDDED(bp) ? \
(BPE_GET_ETYPE(bp) == 0 ? BPE_GET_LSIZE(bp) : 0): \
BF64_GET_SB((bp)->blk_prop, 0, 16, SPA_MINBLOCKSHIFT, 1))
#define BP_GET_PSIZE(bp) \
(BP_IS_EMBEDDED(bp) ? 0 : \
BF64_GET_SB((bp)->blk_prop, 16, 16, SPA_MINBLOCKSHIFT, 1))
#define BP_GET_COMPRESS(bp) BF64_GET((bp)->blk_prop, 32, 7)
#define BP_GET_CHECKSUM(bp) \
(BP_IS_EMBEDDED(bp) ? 2 : \
BF64_GET((bp)->blk_prop, 40, 8))
#define BP_GET_TYPE(bp) BF64_GET((bp)->blk_prop, 48, 8)
#define BP_GET_LEVEL(bp) BF64_GET((bp)->blk_prop, 56, 5)
#define BP_GET_PROP_BIT_61(bp) BF64_GET((bp)->blk_prop, 61, 1)
#define BP_GET_DEDUP(bp) BF64_GET((bp)->blk_prop, 62, 1)
#define BP_GET_BYTEORDER(bp) (0 - BF64_GET((bp)->blk_prop, 63, 1))
#define BP_IS_EMBEDDED(bp) BF64_GET((bp)->blk_prop, 39, 1)
#define BP_PHYSICAL_BIRTH(bp) \
(BP_IS_EMBEDDED(bp) ? 0 : \
(bp)->blk_phys_birth ? (bp)->blk_phys_birth : (bp)->blk_birth)
#define BP_GET_ASIZE(bp) \
(BP_IS_EMBEDDED(bp) ? 0 : \
(DVA_GET_ASIZE(&(bp)->blk_dva[0]) + DVA_GET_ASIZE(&(bp)->blk_dva[1]) + \
DVA_GET_ASIZE(&(bp)->blk_dva[2])))
#define BP_GET_UCSIZE(bp) \
((BP_GET_LEVEL(bp) > 0 || DMU_OT_IS_METADATA(BP_GET_TYPE(bp))) ? \
BP_GET_PSIZE(bp) : BP_GET_LSIZE(bp))
#define BP_GET_NDVAS(bp) \
(BP_IS_EMBEDDED(bp) ? 0 : \
!!DVA_GET_ASIZE(&(bp)->blk_dva[0]) + \
!!DVA_GET_ASIZE(&(bp)->blk_dva[1]) + \
!!DVA_GET_ASIZE(&(bp)->blk_dva[2]))
#define BP_COUNT_GANG(bp) \
(BP_IS_EMBEDDED(bp) ? 0 : \
DVA_GET_GANG(&(bp)->blk_dva[0]) + \
DVA_GET_GANG(&(bp)->blk_dva[1]) + \
DVA_GET_GANG(&(bp)->blk_dva[2]))
#define DVA_EQUAL(dva1, dva2) \
((dva1)->dva_word[1] == (dva2)->dva_word[1] && \
(dva1)->dva_word[0] == (dva2)->dva_word[0])
#define BP_EQUAL(bp1, bp2) \
(BP_PHYSICAL_BIRTH(bp1) == BP_PHYSICAL_BIRTH(bp2) && \
DVA_EQUAL(&(bp1)->blk_dva[0], &(bp2)->blk_dva[0]) && \
DVA_EQUAL(&(bp1)->blk_dva[1], &(bp2)->blk_dva[1]) && \
DVA_EQUAL(&(bp1)->blk_dva[2], &(bp2)->blk_dva[2]))
#define ZIO_CHECKSUM_EQUAL(zc1, zc2) \
(0 == (((zc1).zc_word[0] - (zc2).zc_word[0]) | \
((zc1).zc_word[1] - (zc2).zc_word[1]) | \
((zc1).zc_word[2] - (zc2).zc_word[2]) | \
((zc1).zc_word[3] - (zc2).zc_word[3])))
#define DVA_IS_VALID(dva) (DVA_GET_ASIZE(dva) != 0)
#define BP_IDENTITY(bp) (&(bp)->blk_dva[0])
#define BP_IS_GANG(bp) DVA_GET_GANG(BP_IDENTITY(bp))
#define DVA_IS_EMPTY(dva) ((dva)->dva_word[0] == 0ULL && \
(dva)->dva_word[1] == 0ULL)
#define BP_IS_HOLE(bp) \
(!BP_IS_EMBEDDED(bp) && DVA_IS_EMPTY(BP_IDENTITY(bp)))
#define BP_IS_RAIDZ(bp) (DVA_GET_ASIZE(&(bp)->blk_dva[0]) > \
BP_GET_PSIZE(bp))
#ifdef _BIG_ENDIAN
#define ZFS_HOST_BYTEORDER (0ULL)
#else
#define ZFS_HOST_BYTEORDER (-1ULL)
#endif
#define BP_SHOULD_BYTESWAP(bp) (BP_GET_BYTEORDER(bp) != ZFS_HOST_BYTEORDER)
typedef enum zio_type {
ZIO_TYPE_NULL = 0,
ZIO_TYPE_READ,
ZIO_TYPE_WRITE,
ZIO_TYPE_FREE,
ZIO_TYPE_CLAIM,
ZIO_TYPE_IOCTL,
ZIO_TYPES
} zio_type_t;
#define BP_GET_COMPRESS_NAME(bp) \
(stringof(zfs`zio_compress_table[BP_GET_COMPRESS(bp)].ci_name))
#define BP_GET_CHECKSUM_NAME(bp) \
(stringof(zfs`zio_checksum_table[BP_GET_CHECKSUM(bp)].ci_name))
#define DMU_OT_NEWTYPE 0x80
#define DMU_OT_METADATA 0x40
#define DMU_OT_BYTESWAP_MASK 0x3f
#define DMU_OT_IS_METADATA(ot) (((ot) & DMU_OT_NEWTYPE) ? \
((ot) & DMU_OT_METADATA) : \
zfs`dmu_ot[(ot)].ot_metadata)
#define DMU_OT_BYTESWAP(ot) (((ot) & DMU_OT_NEWTYPE) ? \
((ot) & DMU_OT_BYTESWAP_MASK) : \
zfs`dmu_ot[(ot)].ot_byteswap)
#define BP_GET_TYPE_NAME(bp) ((BP_GET_TYPE(bp) & DMU_OT_NEWTYPE) ? \
stringof(zfs`dmu_ot_byteswap[DMU_OT_BYTESWAP(BP_GET_TYPE(bp))].ob_name) : \
stringof(zfs`dmu_ot[BP_GET_TYPE(bp)].ot_name))
#define PRINTF_BP(bp) \
if (BP_IS_HOLE(bp)) { \
printf("<hole> birth=%u\n", (bp)->blk_birth); \
} else if (BP_IS_EMBEDDED(bp)) { \
printf("EMBEDDED [L%u %s et=%u %s size=%xL/%xP birth=%uL\n", \
BP_GET_LEVEL(bp), \
BP_GET_TYPE_NAME(bp), \
BPE_GET_ETYPE(bp), \
BP_GET_COMPRESS_NAME(bp), \
BPE_GET_LSIZE(bp), \
BPE_GET_PSIZE(bp), \
(bp)->blk_birth); \
} else { \
printf("[L%u %s] %s %s %s %s %s ndvas=%u ", \
BP_GET_LEVEL(bp), \
BP_GET_TYPE_NAME(bp), \
BP_GET_CHECKSUM_NAME(bp), \
BP_GET_COMPRESS_NAME(bp), \
BP_GET_BYTEORDER(bp) == 0 ? "BE" : "LE", \
BP_IS_GANG(bp) ? "gang" : "contiguous", \
BP_GET_DEDUP(bp) ? "dedup" : "unique", \
BP_GET_NDVAS(bp)); \
printf("size=%xL/%xP birth=%uL/%uP fill=%u ", \
BP_GET_LSIZE(bp), \
BP_GET_PSIZE(bp), \
bp->blk_birth, \
BP_PHYSICAL_BIRTH(bp), \
bp->blk_fill); \
printf("cksum=%x:%x:%x:%x\n", \
bp->blk_cksum.zc_word[0], \
bp->blk_cksum.zc_word[1], \
bp->blk_cksum.zc_word[2], \
bp->blk_cksum.zc_word[3]); \
}
string dsname[string, uint64_t];
#if 0
dsl_dataset_name:entry
/this->ds = (zfs`dsl_dataset_t*)arg0,
this->dsid = this->ds->ds_object,
this->spaname = stringof(this->ds->ds_dir->dd_pool->dp_spa->spa_name),
strstr(dsname[this->spaname, this->dsid], "/") == NULL/
{
self->dsid = this->dsid;
self->spaname = this->spaname;
self->nameptr = args[1];
}
dsl_dataset_name:return
/self->nameptr/
{
dsname[self->spaname, self->dsid] = stringof(self->nameptr);
self->dsid = 0;
self->spaname = 0;
self->nameptr = 0;
}
dsl_dataset_sync:entry
/this->ds = (zfs`dsl_dataset_t*)arg0,
this->dsid = this->ds->ds_object,
this->spaname = stringof(this->ds->ds_dir->dd_pool->dp_spa->spa_name),
dsname[this->spaname, this->dsid] == NULL/
{
dsname[this->spaname, this->dsid] =
stringof(this->ds->ds_dir->dd_myname);
}
/*
* Note: dtrace seems to have a bug where indexing an aggregation with
* different but compatible types results in improper sorting.
* Therefore cast the uint64_t os & level to ints.
*/
#define ZIO_AGG(agg, zio) \
this->_spaname = stringof(zio->io_spa->spa_name); \
this->_pass = zio->io_spa->spa_sync_pass; \
this->_bp = zio->io_bp; \
this->_os = zio->io_bookmark.zb_objset; \
this->_os_name = dsname[this->_spaname, this->_os]; \
this->_lvl = BP_GET_LEVEL(this->_bp); \
this->_type_name = BP_GET_TYPE_NAME(this->_bp); \
@agg##s[this->_spaname, this->_pass, (int)this->_os, this->_os_name, (int)this->_lvl, this->_type_name] = count(); \
@agg##s[this->_spaname, this->_pass, -1, "", -1, "TOTAL"] = count(); \
@agg##bytes[this->_spaname, this->_pass, (int)this->_os, this->_os_name, (int)this->_lvl, this->_type_name] = sum((zio)->io_size); \
@agg##bytes[this->_spaname, this->_pass, -1, "", -1, "TOTAL"] = sum((zio)->io_size); \
#if 1
vdev_queue_pending_remove:entry
/this->zio=(zfs`zio_t*)arg1,
this->zio->io_type == ZIO_TYPE_READ && this->zio->io_bp == NULL/
{
this->spaname = stringof(this->zio->io_spa->spa_name);
this->pass = this->zio->io_spa->spa_sync_pass;
@preads[this->spaname, this->pass, -2, "", -2, "AGGREGATE"] = count();
@preadbytes[this->spaname, this->pass, -2, "", -1, "AGGREGATE"] =
sum(this->zio->io_size);
@preadbytes[this->spaname, this->pass, -1, "", -1, "TOTAL"] =
sum(this->zio->io_size);
}
vdev_queue_pending_remove:entry
/this->zio=(zfs`zio_t*)arg1,
this->zio->io_type == ZIO_TYPE_WRITE && this->zio->io_bp == NULL/
{
this->spaname = stringof(this->zio->io_spa->spa_name);
this->pass = this->zio->io_spa->spa_sync_pass;
@pwrites[this->spaname, this->pass, -2, "", -2, "AGGREGATE"] = count();
@pwritebytes[this->spaname, this->pass, -2, "", -2, "AGGREGATE"] =
sum(this->zio->io_size);
@pwritebytes[this->spaname, this->pass, -1, "", -1, "TOTAL"] =
sum(this->zio->io_size);
}
#endif
vdev_queue_pending_remove:entry
/this->zio=(zfs`zio_t*)arg1,
this->zio->io_type == ZIO_TYPE_READ && this->zio->io_bp != NULL/
{
ZIO_AGG(pread, this->zio);
}
vdev_queue_pending_remove:entry
/this->zio=(zfs`zio_t*)arg1,
this->zio->io_type == ZIO_TYPE_WRITE && this->zio->io_bp != NULL/
{
ZIO_AGG(pwrite, this->zio);
}
#if 1
vdev_queue_io_remove:entry
/this->zio=(zfs`zio_t*)arg1,
this->zio->io_type == ZIO_TYPE_READ && this->zio->io_bp == NULL/
{
this->spaname = stringof(this->zio->io_spa->spa_name);
this->pass = this->zio->io_spa->spa_sync_pass;
@lreads[this->spaname, this->pass, -2, "", -2, "PHYSICAL"] = count();
@lreadbytes[this->spaname, this->pass, -2, "", -2, "PHYSICAL"] =
sum(this->zio->io_size);
@lreadbytes[this->spaname, this->pass, -1, "", -1, "TOTAL"] =
sum(this->zio->io_size);
}
vdev_queue_io_remove:entry
/this->zio=(zfs`zio_t*)arg1,
this->zio->io_type == ZIO_TYPE_WRITE && this->zio->io_bp == NULL/
{
this->spaname = stringof(this->zio->io_spa->spa_name);
this->pass = this->zio->io_spa->spa_sync_pass;
@lwrites[this->spaname, this->pass, -2, "", -2, "PHYSICAL"] = count();
@lwritebytes[this->spaname, this->pass, -2, "", -2, "PHYSICAL"] =
sum(this->zio->io_size);
@lwritebytes[this->spaname, this->pass, -1, "", -1, "TOTAL"] =
sum(this->zio->io_size);
}
#endif
vdev_queue_io_remove:entry
/this->zio=(zfs`zio_t*)arg1, this->zio->io_type == ZIO_TYPE_READ && this->zio->io_bp != NULL/
{
ZIO_AGG(lread, this->zio);
}
vdev_queue_io_remove:entry
/this->zio=(zfs`zio_t*)arg1, this->zio->io_type == ZIO_TYPE_WRITE && this->zio->io_bp != NULL/
{
ZIO_AGG(lwrite, this->zio);
}
#pragma D option aggsortpos=0
BEGIN
{
last = timestamp;
}
#define PRINTAGGBYTES(agg) \
printf("\n\n%s KB/sec:\n", #agg); \
normalize(@agg, 1024 * this->elapsed / 1000000000); \
trunc(@agg, 20); \
printa("%@10u pool=%s pass=%u os=%5d (%15s) [L%d %s]\n", @agg); \
trunc(@agg);
#define PRINTAGG(agg) \
printf("\n\n%s ops/sec:\n", #agg); \
normalize(@agg, this->elapsed / 1000000000); \
trunc(@agg, 20); \
printa("%@10u pool=%s pass=%u os=%5d (%15s) [L%d %s]\n", @agg); \
trunc(@agg);
tick-10s
{
printf("\n\n----------------------------------------\n\n");
this->elapsed = timestamp - last;
PRINTAGG(preads)
PRINTAGG(pwrites)
PRINTAGGBYTES(preadbytes)
PRINTAGGBYTES(pwritebytes)
PRINTAGG(lreads)
PRINTAGG(lwrites)
PRINTAGGBYTES(lreadbytes)
PRINTAGGBYTES(lwritebytes)
last = timestamp;
}
#endif
zio_read:return
/pid == $target/
{
this->zio = (zio_t *)arg1;
printf("read from bookmark %u/%u/%u/%u\n",
this->zio->io_bookmark.zb_objset,
this->zio->io_bookmark.zb_object,
this->zio->io_bookmark.zb_level,
this->zio->io_bookmark.zb_blkid);
PRINTF_BP(this->zio->io_bp);
@[ustack()] = count();
}