Blame view

drivers/md/dm-dust.c 12.8 KB
e4f3fabd6   Bryan Gurney   dm: add dust target
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
  // SPDX-License-Identifier: GPL-2.0
  /*
   * Copyright (c) 2018 Red Hat, Inc.
   *
   * This is a test "dust" device, which fails reads on specified
   * sectors, emulating the behavior of a hard disk drive sending
   * a "Read Medium Error" sense.
   *
   */
  
  #include <linux/device-mapper.h>
  #include <linux/module.h>
  #include <linux/rbtree.h>
  
  #define DM_MSG_PREFIX "dust"
  
  struct badblock {
  	struct rb_node node;
  	sector_t bb;
72d7df4c8   Bryan Gurney   dm dust: add limi...
20
  	unsigned char wr_fail_cnt;
e4f3fabd6   Bryan Gurney   dm: add dust target
21
22
23
24
25
26
27
28
  };
  
  struct dust_device {
  	struct dm_dev *dev;
  	struct rb_root badblocklist;
  	unsigned long long badblock_count;
  	spinlock_t dust_lock;
  	unsigned int blksz;
08c04c84a   Bryan Gurney   dm dust: use dust...
29
  	int sect_per_block_shift;
e4f3fabd6   Bryan Gurney   dm: add dust target
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
  	unsigned int sect_per_block;
  	sector_t start;
  	bool fail_read_on_bb:1;
  	bool quiet_mode:1;
  };
  
  static struct badblock *dust_rb_search(struct rb_root *root, sector_t blk)
  {
  	struct rb_node *node = root->rb_node;
  
  	while (node) {
  		struct badblock *bblk = rb_entry(node, struct badblock, node);
  
  		if (bblk->bb > blk)
  			node = node->rb_left;
  		else if (bblk->bb < blk)
  			node = node->rb_right;
  		else
  			return bblk;
  	}
  
  	return NULL;
  }
  
  static bool dust_rb_insert(struct rb_root *root, struct badblock *new)
  {
  	struct badblock *bblk;
  	struct rb_node **link = &root->rb_node, *parent = NULL;
  	sector_t value = new->bb;
  
  	while (*link) {
  		parent = *link;
  		bblk = rb_entry(parent, struct badblock, node);
  
  		if (bblk->bb > value)
  			link = &(*link)->rb_left;
  		else if (bblk->bb < value)
  			link = &(*link)->rb_right;
  		else
  			return false;
  	}
  
  	rb_link_node(&new->node, parent, link);
  	rb_insert_color(&new->node, root);
  
  	return true;
  }
  
  static int dust_remove_block(struct dust_device *dd, unsigned long long block)
  {
  	struct badblock *bblock;
  	unsigned long flags;
  
  	spin_lock_irqsave(&dd->dust_lock, flags);
08c04c84a   Bryan Gurney   dm dust: use dust...
84
  	bblock = dust_rb_search(&dd->badblocklist, block);
e4f3fabd6   Bryan Gurney   dm: add dust target
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
  
  	if (bblock == NULL) {
  		if (!dd->quiet_mode) {
  			DMERR("%s: block %llu not found in badblocklist",
  			      __func__, block);
  		}
  		spin_unlock_irqrestore(&dd->dust_lock, flags);
  		return -EINVAL;
  	}
  
  	rb_erase(&bblock->node, &dd->badblocklist);
  	dd->badblock_count--;
  	if (!dd->quiet_mode)
  		DMINFO("%s: badblock removed at block %llu", __func__, block);
  	kfree(bblock);
  	spin_unlock_irqrestore(&dd->dust_lock, flags);
  
  	return 0;
  }
72d7df4c8   Bryan Gurney   dm dust: add limi...
104
105
  static int dust_add_block(struct dust_device *dd, unsigned long long block,
  			  unsigned char wr_fail_cnt)
e4f3fabd6   Bryan Gurney   dm: add dust target
106
107
108
109
110
111
112
113
114
115
116
117
  {
  	struct badblock *bblock;
  	unsigned long flags;
  
  	bblock = kmalloc(sizeof(*bblock), GFP_KERNEL);
  	if (bblock == NULL) {
  		if (!dd->quiet_mode)
  			DMERR("%s: badblock allocation failed", __func__);
  		return -ENOMEM;
  	}
  
  	spin_lock_irqsave(&dd->dust_lock, flags);
08c04c84a   Bryan Gurney   dm dust: use dust...
118
  	bblock->bb = block;
72d7df4c8   Bryan Gurney   dm dust: add limi...
119
  	bblock->wr_fail_cnt = wr_fail_cnt;
e4f3fabd6   Bryan Gurney   dm: add dust target
120
121
122
123
124
125
126
127
128
129
130
  	if (!dust_rb_insert(&dd->badblocklist, bblock)) {
  		if (!dd->quiet_mode) {
  			DMERR("%s: block %llu already in badblocklist",
  			      __func__, block);
  		}
  		spin_unlock_irqrestore(&dd->dust_lock, flags);
  		kfree(bblock);
  		return -EINVAL;
  	}
  
  	dd->badblock_count++;
72d7df4c8   Bryan Gurney   dm dust: add limi...
131
132
133
134
  	if (!dd->quiet_mode) {
  		DMINFO("%s: badblock added at block %llu with write fail count %hhu",
  		       __func__, block, wr_fail_cnt);
  	}
e4f3fabd6   Bryan Gurney   dm: add dust target
135
136
137
138
139
140
141
142
143
144
145
  	spin_unlock_irqrestore(&dd->dust_lock, flags);
  
  	return 0;
  }
  
  static int dust_query_block(struct dust_device *dd, unsigned long long block)
  {
  	struct badblock *bblock;
  	unsigned long flags;
  
  	spin_lock_irqsave(&dd->dust_lock, flags);
08c04c84a   Bryan Gurney   dm dust: use dust...
146
  	bblock = dust_rb_search(&dd->badblocklist, block);
e4f3fabd6   Bryan Gurney   dm: add dust target
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
  	if (bblock != NULL)
  		DMINFO("%s: block %llu found in badblocklist", __func__, block);
  	else
  		DMINFO("%s: block %llu not found in badblocklist", __func__, block);
  	spin_unlock_irqrestore(&dd->dust_lock, flags);
  
  	return 0;
  }
  
  static int __dust_map_read(struct dust_device *dd, sector_t thisblock)
  {
  	struct badblock *bblk = dust_rb_search(&dd->badblocklist, thisblock);
  
  	if (bblk)
  		return DM_MAPIO_KILL;
  
  	return DM_MAPIO_REMAPPED;
  }
  
  static int dust_map_read(struct dust_device *dd, sector_t thisblock,
  			 bool fail_read_on_bb)
  {
  	unsigned long flags;
cc7a7fb3b   Bryan Gurney   dm dust: change r...
170
  	int r = DM_MAPIO_REMAPPED;
e4f3fabd6   Bryan Gurney   dm: add dust target
171
172
  
  	if (fail_read_on_bb) {
08c04c84a   Bryan Gurney   dm dust: use dust...
173
  		thisblock >>= dd->sect_per_block_shift;
e4f3fabd6   Bryan Gurney   dm: add dust target
174
  		spin_lock_irqsave(&dd->dust_lock, flags);
cc7a7fb3b   Bryan Gurney   dm dust: change r...
175
  		r = __dust_map_read(dd, thisblock);
e4f3fabd6   Bryan Gurney   dm: add dust target
176
177
  		spin_unlock_irqrestore(&dd->dust_lock, flags);
  	}
cc7a7fb3b   Bryan Gurney   dm dust: change r...
178
  	return r;
e4f3fabd6   Bryan Gurney   dm: add dust target
179
  }
72d7df4c8   Bryan Gurney   dm dust: add limi...
180
  static int __dust_map_write(struct dust_device *dd, sector_t thisblock)
e4f3fabd6   Bryan Gurney   dm: add dust target
181
182
  {
  	struct badblock *bblk = dust_rb_search(&dd->badblocklist, thisblock);
72d7df4c8   Bryan Gurney   dm dust: add limi...
183
184
185
186
  	if (bblk && bblk->wr_fail_cnt > 0) {
  		bblk->wr_fail_cnt--;
  		return DM_MAPIO_KILL;
  	}
e4f3fabd6   Bryan Gurney   dm: add dust target
187
188
189
190
191
192
193
194
195
196
  	if (bblk) {
  		rb_erase(&bblk->node, &dd->badblocklist);
  		dd->badblock_count--;
  		kfree(bblk);
  		if (!dd->quiet_mode) {
  			sector_div(thisblock, dd->sect_per_block);
  			DMINFO("block %llu removed from badblocklist by write",
  			       (unsigned long long)thisblock);
  		}
  	}
72d7df4c8   Bryan Gurney   dm dust: add limi...
197
198
  
  	return DM_MAPIO_REMAPPED;
e4f3fabd6   Bryan Gurney   dm: add dust target
199
200
201
202
203
204
  }
  
  static int dust_map_write(struct dust_device *dd, sector_t thisblock,
  			  bool fail_read_on_bb)
  {
  	unsigned long flags;
88e7cafdc   Bryan Gurney   dm dust: change r...
205
  	int r = DM_MAPIO_REMAPPED;
e4f3fabd6   Bryan Gurney   dm: add dust target
206
207
  
  	if (fail_read_on_bb) {
08c04c84a   Bryan Gurney   dm dust: use dust...
208
  		thisblock >>= dd->sect_per_block_shift;
e4f3fabd6   Bryan Gurney   dm: add dust target
209
  		spin_lock_irqsave(&dd->dust_lock, flags);
88e7cafdc   Bryan Gurney   dm dust: change r...
210
  		r = __dust_map_write(dd, thisblock);
e4f3fabd6   Bryan Gurney   dm: add dust target
211
212
  		spin_unlock_irqrestore(&dd->dust_lock, flags);
  	}
88e7cafdc   Bryan Gurney   dm dust: change r...
213
  	return r;
e4f3fabd6   Bryan Gurney   dm: add dust target
214
215
216
217
218
  }
  
  static int dust_map(struct dm_target *ti, struct bio *bio)
  {
  	struct dust_device *dd = ti->private;
cc7a7fb3b   Bryan Gurney   dm dust: change r...
219
  	int r;
e4f3fabd6   Bryan Gurney   dm: add dust target
220
221
222
223
224
  
  	bio_set_dev(bio, dd->dev->bdev);
  	bio->bi_iter.bi_sector = dd->start + dm_target_offset(ti, bio->bi_iter.bi_sector);
  
  	if (bio_data_dir(bio) == READ)
cc7a7fb3b   Bryan Gurney   dm dust: change r...
225
  		r = dust_map_read(dd, bio->bi_iter.bi_sector, dd->fail_read_on_bb);
e4f3fabd6   Bryan Gurney   dm: add dust target
226
  	else
cc7a7fb3b   Bryan Gurney   dm dust: change r...
227
  		r = dust_map_write(dd, bio->bi_iter.bi_sector, dd->fail_read_on_bb);
e4f3fabd6   Bryan Gurney   dm: add dust target
228

cc7a7fb3b   Bryan Gurney   dm dust: change r...
229
  	return r;
e4f3fabd6   Bryan Gurney   dm: add dust target
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
  }
  
  static bool __dust_clear_badblocks(struct rb_root *tree,
  				   unsigned long long count)
  {
  	struct rb_node *node = NULL, *nnode = NULL;
  
  	nnode = rb_first(tree);
  	if (nnode == NULL) {
  		BUG_ON(count != 0);
  		return false;
  	}
  
  	while (nnode) {
  		node = nnode;
  		nnode = rb_next(node);
  		rb_erase(node, tree);
  		count--;
  		kfree(node);
  	}
  	BUG_ON(count != 0);
  	BUG_ON(tree->rb_node != NULL);
  
  	return true;
  }
  
  static int dust_clear_badblocks(struct dust_device *dd)
  {
  	unsigned long flags;
  	struct rb_root badblocklist;
  	unsigned long long badblock_count;
  
  	spin_lock_irqsave(&dd->dust_lock, flags);
  	badblocklist = dd->badblocklist;
  	badblock_count = dd->badblock_count;
  	dd->badblocklist = RB_ROOT;
  	dd->badblock_count = 0;
  	spin_unlock_irqrestore(&dd->dust_lock, flags);
  
  	if (!__dust_clear_badblocks(&badblocklist, badblock_count))
  		DMINFO("%s: no badblocks found", __func__);
  	else
  		DMINFO("%s: badblocks cleared", __func__);
  
  	return 0;
  }
  
  /*
   * Target parameters:
   *
   * <device_path> <offset> <blksz>
   *
   * device_path: path to the block device
   * offset: offset to data area from start of device_path
   * blksz: block size (minimum 512, maximum 1073741824, must be a power of 2)
   */
  static int dust_ctr(struct dm_target *ti, unsigned int argc, char **argv)
  {
  	struct dust_device *dd;
  	unsigned long long tmp;
  	char dummy;
  	unsigned int blksz;
  	unsigned int sect_per_block;
  	sector_t DUST_MAX_BLKSZ_SECTORS = 2097152;
  	sector_t max_block_sectors = min(ti->len, DUST_MAX_BLKSZ_SECTORS);
  
  	if (argc != 3) {
  		ti->error = "Invalid argument count";
  		return -EINVAL;
  	}
  
  	if (kstrtouint(argv[2], 10, &blksz) || !blksz) {
  		ti->error = "Invalid block size parameter";
  		return -EINVAL;
  	}
  
  	if (blksz < 512) {
  		ti->error = "Block size must be at least 512";
  		return -EINVAL;
  	}
  
  	if (!is_power_of_2(blksz)) {
  		ti->error = "Block size must be a power of 2";
  		return -EINVAL;
  	}
  
  	if (to_sector(blksz) > max_block_sectors) {
  		ti->error = "Block size is too large";
  		return -EINVAL;
  	}
  
  	sect_per_block = (blksz >> SECTOR_SHIFT);
  
  	if (sscanf(argv[1], "%llu%c", &tmp, &dummy) != 1 || tmp != (sector_t)tmp) {
  		ti->error = "Invalid device offset sector";
  		return -EINVAL;
  	}
  
  	dd = kzalloc(sizeof(struct dust_device), GFP_KERNEL);
  	if (dd == NULL) {
  		ti->error = "Cannot allocate context";
  		return -ENOMEM;
  	}
  
  	if (dm_get_device(ti, argv[0], dm_table_get_mode(ti->table), &dd->dev)) {
  		ti->error = "Device lookup failed";
  		kfree(dd);
  		return -EINVAL;
  	}
  
  	dd->sect_per_block = sect_per_block;
  	dd->blksz = blksz;
  	dd->start = tmp;
08c04c84a   Bryan Gurney   dm dust: use dust...
343
  	dd->sect_per_block_shift = __ffs(sect_per_block);
e4f3fabd6   Bryan Gurney   dm: add dust target
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
  	/*
  	 * Whether to fail a read on a "bad" block.
  	 * Defaults to false; enabled later by message.
  	 */
  	dd->fail_read_on_bb = false;
  
  	/*
  	 * Initialize bad block list rbtree.
  	 */
  	dd->badblocklist = RB_ROOT;
  	dd->badblock_count = 0;
  	spin_lock_init(&dd->dust_lock);
  
  	dd->quiet_mode = false;
  
  	BUG_ON(dm_set_target_max_io_len(ti, dd->sect_per_block) != 0);
  
  	ti->num_discard_bios = 1;
  	ti->num_flush_bios = 1;
  	ti->private = dd;
  
  	return 0;
  }
  
  static void dust_dtr(struct dm_target *ti)
  {
  	struct dust_device *dd = ti->private;
  
  	__dust_clear_badblocks(&dd->badblocklist, dd->badblock_count);
  	dm_put_device(ti, dd->dev);
  	kfree(dd);
  }
  
  static int dust_message(struct dm_target *ti, unsigned int argc, char **argv,
  			char *result_buf, unsigned int maxlen)
  {
  	struct dust_device *dd = ti->private;
  	sector_t size = i_size_read(dd->dev->bdev->bd_inode) >> SECTOR_SHIFT;
  	bool invalid_msg = false;
6ec1be501   Bryan Gurney   dm dust: change r...
383
  	int r = -EINVAL;
e4f3fabd6   Bryan Gurney   dm: add dust target
384
  	unsigned long long tmp, block;
72d7df4c8   Bryan Gurney   dm dust: add limi...
385
386
  	unsigned char wr_fail_cnt;
  	unsigned int tmp_ui;
e4f3fabd6   Bryan Gurney   dm: add dust target
387
388
389
390
391
392
393
394
395
396
397
  	unsigned long flags;
  	char dummy;
  
  	if (argc == 1) {
  		if (!strcasecmp(argv[0], "addbadblock") ||
  		    !strcasecmp(argv[0], "removebadblock") ||
  		    !strcasecmp(argv[0], "queryblock")) {
  			DMERR("%s requires an additional argument", argv[0]);
  		} else if (!strcasecmp(argv[0], "disable")) {
  			DMINFO("disabling read failures on bad sectors");
  			dd->fail_read_on_bb = false;
6ec1be501   Bryan Gurney   dm dust: change r...
398
  			r = 0;
e4f3fabd6   Bryan Gurney   dm: add dust target
399
400
401
  		} else if (!strcasecmp(argv[0], "enable")) {
  			DMINFO("enabling read failures on bad sectors");
  			dd->fail_read_on_bb = true;
6ec1be501   Bryan Gurney   dm dust: change r...
402
  			r = 0;
e4f3fabd6   Bryan Gurney   dm: add dust target
403
404
405
406
407
  		} else if (!strcasecmp(argv[0], "countbadblocks")) {
  			spin_lock_irqsave(&dd->dust_lock, flags);
  			DMINFO("countbadblocks: %llu badblock(s) found",
  			       dd->badblock_count);
  			spin_unlock_irqrestore(&dd->dust_lock, flags);
6ec1be501   Bryan Gurney   dm dust: change r...
408
  			r = 0;
e4f3fabd6   Bryan Gurney   dm: add dust target
409
  		} else if (!strcasecmp(argv[0], "clearbadblocks")) {
6ec1be501   Bryan Gurney   dm dust: change r...
410
  			r = dust_clear_badblocks(dd);
e4f3fabd6   Bryan Gurney   dm: add dust target
411
412
413
414
415
  		} else if (!strcasecmp(argv[0], "quiet")) {
  			if (!dd->quiet_mode)
  				dd->quiet_mode = true;
  			else
  				dd->quiet_mode = false;
6ec1be501   Bryan Gurney   dm dust: change r...
416
  			r = 0;
e4f3fabd6   Bryan Gurney   dm: add dust target
417
418
419
420
421
  		} else {
  			invalid_msg = true;
  		}
  	} else if (argc == 2) {
  		if (sscanf(argv[1], "%llu%c", &tmp, &dummy) != 1)
6ec1be501   Bryan Gurney   dm dust: change r...
422
  			return r;
e4f3fabd6   Bryan Gurney   dm: add dust target
423
424
425
  
  		block = tmp;
  		sector_div(size, dd->sect_per_block);
cacddeab5   Colin Ian King   dm dust: remove r...
426
  		if (block > size) {
e4f3fabd6   Bryan Gurney   dm: add dust target
427
  			DMERR("selected block value out of range");
6ec1be501   Bryan Gurney   dm dust: change r...
428
  			return r;
e4f3fabd6   Bryan Gurney   dm: add dust target
429
430
431
  		}
  
  		if (!strcasecmp(argv[0], "addbadblock"))
72d7df4c8   Bryan Gurney   dm dust: add limi...
432
  			r = dust_add_block(dd, block, 0);
e4f3fabd6   Bryan Gurney   dm: add dust target
433
  		else if (!strcasecmp(argv[0], "removebadblock"))
6ec1be501   Bryan Gurney   dm dust: change r...
434
  			r = dust_remove_block(dd, block);
e4f3fabd6   Bryan Gurney   dm: add dust target
435
  		else if (!strcasecmp(argv[0], "queryblock"))
6ec1be501   Bryan Gurney   dm dust: change r...
436
  			r = dust_query_block(dd, block);
e4f3fabd6   Bryan Gurney   dm: add dust target
437
438
  		else
  			invalid_msg = true;
72d7df4c8   Bryan Gurney   dm dust: add limi...
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
  	} else if (argc == 3) {
  		if (sscanf(argv[1], "%llu%c", &tmp, &dummy) != 1)
  			return r;
  
  		if (sscanf(argv[2], "%u%c", &tmp_ui, &dummy) != 1)
  			return r;
  
  		block = tmp;
  		if (tmp_ui > 255) {
  			DMERR("selected write fail count out of range");
  			return r;
  		}
  		wr_fail_cnt = tmp_ui;
  		sector_div(size, dd->sect_per_block);
  		if (block > size) {
  			DMERR("selected block value out of range");
  			return r;
  		}
  
  		if (!strcasecmp(argv[0], "addbadblock"))
  			r = dust_add_block(dd, block, wr_fail_cnt);
  		else
  			invalid_msg = true;
e4f3fabd6   Bryan Gurney   dm: add dust target
462
463
464
465
466
  	} else
  		DMERR("invalid number of arguments '%d'", argc);
  
  	if (invalid_msg)
  		DMERR("unrecognized message '%s' received", argv[0]);
6ec1be501   Bryan Gurney   dm dust: change r...
467
  	return r;
e4f3fabd6   Bryan Gurney   dm: add dust target
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
  }
  
  static void dust_status(struct dm_target *ti, status_type_t type,
  			unsigned int status_flags, char *result, unsigned int maxlen)
  {
  	struct dust_device *dd = ti->private;
  	unsigned int sz = 0;
  
  	switch (type) {
  	case STATUSTYPE_INFO:
  		DMEMIT("%s %s %s", dd->dev->name,
  		       dd->fail_read_on_bb ? "fail_read_on_bad_block" : "bypass",
  		       dd->quiet_mode ? "quiet" : "verbose");
  		break;
  
  	case STATUSTYPE_TABLE:
  		DMEMIT("%s %llu %u", dd->dev->name,
  		       (unsigned long long)dd->start, dd->blksz);
  		break;
  	}
  }
  
  static int dust_prepare_ioctl(struct dm_target *ti, struct block_device **bdev)
  {
  	struct dust_device *dd = ti->private;
  	struct dm_dev *dev = dd->dev;
  
  	*bdev = dev->bdev;
  
  	/*
  	 * Only pass ioctls through if the device sizes match exactly.
  	 */
  	if (dd->start ||
  	    ti->len != i_size_read(dev->bdev->bd_inode) >> SECTOR_SHIFT)
  		return 1;
  
  	return 0;
  }
  
  static int dust_iterate_devices(struct dm_target *ti, iterate_devices_callout_fn fn,
  				void *data)
  {
  	struct dust_device *dd = ti->private;
  
  	return fn(ti, dd->dev, dd->start, ti->len, data);
  }
  
  static struct target_type dust_target = {
  	.name = "dust",
  	.version = {1, 0, 0},
  	.module = THIS_MODULE,
  	.ctr = dust_ctr,
  	.dtr = dust_dtr,
  	.iterate_devices = dust_iterate_devices,
  	.map = dust_map,
  	.message = dust_message,
  	.status = dust_status,
  	.prepare_ioctl = dust_prepare_ioctl,
  };
9ccce5a0f   YueHaibing   dm dust: Make dm_...
527
  static int __init dm_dust_init(void)
e4f3fabd6   Bryan Gurney   dm: add dust target
528
  {
6ec1be501   Bryan Gurney   dm dust: change r...
529
  	int r = dm_register_target(&dust_target);
e4f3fabd6   Bryan Gurney   dm: add dust target
530

6ec1be501   Bryan Gurney   dm dust: change r...
531
532
  	if (r < 0)
  		DMERR("dm_register_target failed %d", r);
e4f3fabd6   Bryan Gurney   dm: add dust target
533

6ec1be501   Bryan Gurney   dm dust: change r...
534
  	return r;
e4f3fabd6   Bryan Gurney   dm: add dust target
535
  }
9ccce5a0f   YueHaibing   dm dust: Make dm_...
536
  static void __exit dm_dust_exit(void)
e4f3fabd6   Bryan Gurney   dm: add dust target
537
538
539
540
541
542
543
544
545
546
  {
  	dm_unregister_target(&dust_target);
  }
  
  module_init(dm_dust_init);
  module_exit(dm_dust_exit);
  
  MODULE_DESCRIPTION(DM_NAME " dust test target");
  MODULE_AUTHOR("Bryan Gurney <dm-devel@redhat.com>");
  MODULE_LICENSE("GPL");