diff options
Diffstat (limited to 'block/blktrace.c')
-rw-r--r-- | block/blktrace.c | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/block/blktrace.c b/block/blktrace.c index eb9651ccb241..85049a7e7a17 100644 --- a/block/blktrace.c +++ b/block/blktrace.c | |||
@@ -111,23 +111,9 @@ static int act_log_check(struct blk_trace *bt, u32 what, sector_t sector, | |||
111 | */ | 111 | */ |
112 | static u32 ddir_act[2] __read_mostly = { BLK_TC_ACT(BLK_TC_READ), BLK_TC_ACT(BLK_TC_WRITE) }; | 112 | static u32 ddir_act[2] __read_mostly = { BLK_TC_ACT(BLK_TC_READ), BLK_TC_ACT(BLK_TC_WRITE) }; |
113 | 113 | ||
114 | /* | 114 | /* The ilog2() calls fall out because they're constant */ |
115 | * Bio action bits of interest | 115 | #define MASK_TC_BIT(rw, __name) ( (rw & (1 << BIO_RW_ ## __name)) << \ |
116 | */ | 116 | (ilog2(BLK_TC_ ## __name) + BLK_TC_SHIFT - BIO_RW_ ## __name) ) |
117 | static u32 bio_act[9] __read_mostly = { 0, BLK_TC_ACT(BLK_TC_BARRIER), BLK_TC_ACT(BLK_TC_SYNC), 0, BLK_TC_ACT(BLK_TC_AHEAD), 0, 0, 0, BLK_TC_ACT(BLK_TC_META) }; | ||
118 | |||
119 | /* | ||
120 | * More could be added as needed, taking care to increment the decrementer | ||
121 | * to get correct indexing | ||
122 | */ | ||
123 | #define trace_barrier_bit(rw) \ | ||
124 | (((rw) & (1 << BIO_RW_BARRIER)) >> (BIO_RW_BARRIER - 0)) | ||
125 | #define trace_sync_bit(rw) \ | ||
126 | (((rw) & (1 << BIO_RW_SYNC)) >> (BIO_RW_SYNC - 1)) | ||
127 | #define trace_ahead_bit(rw) \ | ||
128 | (((rw) & (1 << BIO_RW_AHEAD)) << (2 - BIO_RW_AHEAD)) | ||
129 | #define trace_meta_bit(rw) \ | ||
130 | (((rw) & (1 << BIO_RW_META)) >> (BIO_RW_META - 3)) | ||
131 | 117 | ||
132 | /* | 118 | /* |
133 | * The worker for the various blk_add_trace*() types. Fills out a | 119 | * The worker for the various blk_add_trace*() types. Fills out a |
@@ -147,10 +133,11 @@ void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes, | |||
147 | return; | 133 | return; |
148 | 134 | ||
149 | what |= ddir_act[rw & WRITE]; | 135 | what |= ddir_act[rw & WRITE]; |
150 | what |= bio_act[trace_barrier_bit(rw)]; | 136 | what |= MASK_TC_BIT(rw, BARRIER); |
151 | what |= bio_act[trace_sync_bit(rw)]; | 137 | what |= MASK_TC_BIT(rw, SYNC); |
152 | what |= bio_act[trace_ahead_bit(rw)]; | 138 | what |= MASK_TC_BIT(rw, AHEAD); |
153 | what |= bio_act[trace_meta_bit(rw)]; | 139 | what |= MASK_TC_BIT(rw, META); |
140 | what |= MASK_TC_BIT(rw, DISCARD); | ||
154 | 141 | ||
155 | pid = tsk->pid; | 142 | pid = tsk->pid; |
156 | if (unlikely(act_log_check(bt, what, sector, pid))) | 143 | if (unlikely(act_log_check(bt, what, sector, pid))) |
@@ -382,7 +369,8 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev, | |||
382 | if (!buts->buf_size || !buts->buf_nr) | 369 | if (!buts->buf_size || !buts->buf_nr) |
383 | return -EINVAL; | 370 | return -EINVAL; |
384 | 371 | ||
385 | strcpy(buts->name, name); | 372 | strncpy(buts->name, name, BLKTRACE_BDEV_SIZE); |
373 | buts->name[BLKTRACE_BDEV_SIZE - 1] = '\0'; | ||
386 | 374 | ||
387 | /* | 375 | /* |
388 | * some device names have larger paths - convert the slashes | 376 | * some device names have larger paths - convert the slashes |