2 * Copyright (C) 2012 Red Hat, Inc.
4 * Author: Mikulas Patocka <mpatocka@redhat.com>
6 * Based on Chromium dm-verity driver (C) 2011 The Chromium OS Authors
8 * This file is released under the GPLv2.
10 * In the file "/sys/module/dm_verity/parameters/prefetch_cluster" you can set
11 * default prefetch value. Data are read in "prefetch_cluster" chunks from the
12 * hash device. Setting this greatly improves performance when data and hash
13 * are on the same disk on different partitions on devices with poor random
19 #include <linux/module.h>
20 #include <linux/device-mapper.h>
21 #include <crypto/hash.h>
23 #define DM_MSG_PREFIX "verity"
25 #define DM_VERITY_IO_VEC_INLINE 16
26 #define DM_VERITY_MEMPOOL_SIZE 4
27 #define DM_VERITY_DEFAULT_PREFETCH_SIZE 262144
29 #define DM_VERITY_MAX_LEVELS 63
31 static unsigned dm_verity_prefetch_cluster
= DM_VERITY_DEFAULT_PREFETCH_SIZE
;
33 module_param_named(prefetch_cluster
, dm_verity_prefetch_cluster
, uint
, S_IRUGO
| S_IWUSR
);
36 struct dm_dev
*data_dev
;
37 struct dm_dev
*hash_dev
;
39 struct dm_bufio_client
*bufio
;
41 struct crypto_shash
*tfm
;
42 u8
*root_digest
; /* digest of the root block */
43 u8
*salt
; /* salt: its size is salt_size */
45 sector_t data_start
; /* data offset in 512-byte sectors */
46 sector_t hash_start
; /* hash start in blocks */
47 sector_t data_blocks
; /* the number of data blocks */
48 sector_t hash_blocks
; /* the number of hash blocks */
49 unsigned char data_dev_block_bits
; /* log2(data blocksize) */
50 unsigned char hash_dev_block_bits
; /* log2(hash blocksize) */
51 unsigned char hash_per_block_bits
; /* log2(hashes in hash block) */
52 unsigned char levels
; /* the number of tree levels */
53 unsigned char version
;
54 unsigned digest_size
; /* digest size for the current hash algorithm */
55 unsigned shash_descsize
;/* the size of temporary space for crypto */
56 int hash_failed
; /* set to 1 if hash of any block failed */
58 mempool_t
*vec_mempool
; /* mempool of bio vector */
60 struct workqueue_struct
*verify_wq
;
62 /* starting blocks for each tree level. 0 is the lowest level. */
63 sector_t hash_level_block
[DM_VERITY_MAX_LEVELS
];
69 /* original values of bio->bi_end_io and bio->bi_private */
70 bio_end_io_t
*orig_bi_end_io
;
71 void *orig_bi_private
;
76 /* saved bio vector */
77 struct bio_vec
*io_vec
;
80 struct work_struct work
;
82 /* A space for short vectors; longer vectors are allocated separately. */
83 struct bio_vec io_vec_inline
[DM_VERITY_IO_VEC_INLINE
];
86 * Three variably-size fields follow this struct:
88 * u8 hash_desc[v->shash_descsize];
89 * u8 real_digest[v->digest_size];
90 * u8 want_digest[v->digest_size];
92 * To access them use: io_hash_desc(), io_real_digest() and io_want_digest().
96 static struct shash_desc
*io_hash_desc(struct dm_verity
*v
, struct dm_verity_io
*io
)
98 return (struct shash_desc
*)(io
+ 1);
101 static u8
*io_real_digest(struct dm_verity
*v
, struct dm_verity_io
*io
)
103 return (u8
*)(io
+ 1) + v
->shash_descsize
;
106 static u8
*io_want_digest(struct dm_verity
*v
, struct dm_verity_io
*io
)
108 return (u8
*)(io
+ 1) + v
->shash_descsize
+ v
->digest_size
;
112 * Auxiliary structure appended to each dm-bufio buffer. If the value
113 * hash_verified is nonzero, hash of the block has been verified.
115 * The variable hash_verified is set to 0 when allocating the buffer, then
116 * it can be changed to 1 and it is never reset to 0 again.
118 * There is no lock around this value, a race condition can at worst cause
119 * that multiple processes verify the hash of the same buffer simultaneously
120 * and write 1 to hash_verified simultaneously.
121 * This condition is harmless, so we don't need locking.
128 * Initialize struct buffer_aux for a freshly created buffer.
130 static void dm_bufio_alloc_callback(struct dm_buffer
*buf
)
132 struct buffer_aux
*aux
= dm_bufio_get_aux_data(buf
);
134 aux
->hash_verified
= 0;
138 * Translate input sector number to the sector number on the target device.
140 static sector_t
verity_map_sector(struct dm_verity
*v
, sector_t bi_sector
)
142 return v
->data_start
+ dm_target_offset(v
->ti
, bi_sector
);
146 * Return hash position of a specified block at a specified tree level
147 * (0 is the lowest level).
148 * The lowest "hash_per_block_bits"-bits of the result denote hash position
149 * inside a hash block. The remaining bits denote location of the hash block.
151 static sector_t
verity_position_at_level(struct dm_verity
*v
, sector_t block
,
154 return block
>> (level
* v
->hash_per_block_bits
);
157 static void verity_hash_at_level(struct dm_verity
*v
, sector_t block
, int level
,
158 sector_t
*hash_block
, unsigned *offset
)
160 sector_t position
= verity_position_at_level(v
, block
, level
);
163 *hash_block
= v
->hash_level_block
[level
] + (position
>> v
->hash_per_block_bits
);
168 idx
= position
& ((1 << v
->hash_per_block_bits
) - 1);
170 *offset
= idx
* v
->digest_size
;
172 *offset
= idx
<< (v
->hash_dev_block_bits
- v
->hash_per_block_bits
);
176 * Verify hash of a metadata block pertaining to the specified data block
177 * ("block" argument) at a specified level ("level" argument).
179 * On successful return, io_want_digest(v, io) contains the hash value for
180 * a lower tree level or for the data block (if we're at the lowest leve).
182 * If "skip_unverified" is true, unverified buffer is skipped and 1 is returned.
183 * If "skip_unverified" is false, unverified buffer is hashed and verified
184 * against current value of io_want_digest(v, io).
186 static int verity_verify_level(struct dm_verity_io
*io
, sector_t block
,
187 int level
, bool skip_unverified
)
189 struct dm_verity
*v
= io
->v
;
190 struct dm_buffer
*buf
;
191 struct buffer_aux
*aux
;
197 verity_hash_at_level(v
, block
, level
, &hash_block
, &offset
);
199 data
= dm_bufio_read(v
->bufio
, hash_block
, &buf
);
200 if (unlikely(IS_ERR(data
)))
201 return PTR_ERR(data
);
203 aux
= dm_bufio_get_aux_data(buf
);
205 if (!aux
->hash_verified
) {
206 struct shash_desc
*desc
;
209 if (skip_unverified
) {
214 desc
= io_hash_desc(v
, io
);
216 desc
->flags
= CRYPTO_TFM_REQ_MAY_SLEEP
;
217 r
= crypto_shash_init(desc
);
219 DMERR("crypto_shash_init failed: %d", r
);
223 if (likely(v
->version
>= 1)) {
224 r
= crypto_shash_update(desc
, v
->salt
, v
->salt_size
);
226 DMERR("crypto_shash_update failed: %d", r
);
231 r
= crypto_shash_update(desc
, data
, 1 << v
->hash_dev_block_bits
);
233 DMERR("crypto_shash_update failed: %d", r
);
238 r
= crypto_shash_update(desc
, v
->salt
, v
->salt_size
);
240 DMERR("crypto_shash_update failed: %d", r
);
245 result
= io_real_digest(v
, io
);
246 r
= crypto_shash_final(desc
, result
);
248 DMERR("crypto_shash_final failed: %d", r
);
251 if (unlikely(memcmp(result
, io_want_digest(v
, io
), v
->digest_size
))) {
252 DMERR_LIMIT("metadata block %llu is corrupted",
253 (unsigned long long)hash_block
);
258 aux
->hash_verified
= 1;
263 memcpy(io_want_digest(v
, io
), data
, v
->digest_size
);
265 dm_bufio_release(buf
);
269 dm_bufio_release(buf
);
275 * Verify one "dm_verity_io" structure.
277 static int verity_verify_io(struct dm_verity_io
*io
)
279 struct dm_verity
*v
= io
->v
;
282 unsigned vector
= 0, offset
= 0;
284 for (b
= 0; b
< io
->n_blocks
; b
++) {
285 struct shash_desc
*desc
;
290 if (likely(v
->levels
)) {
292 * First, we try to get the requested hash for
293 * the current block. If the hash block itself is
294 * verified, zero is returned. If it isn't, this
295 * function returns 0 and we fall back to whole
296 * chain verification.
298 int r
= verity_verify_level(io
, io
->block
+ b
, 0, true);
300 goto test_block_hash
;
305 memcpy(io_want_digest(v
, io
), v
->root_digest
, v
->digest_size
);
307 for (i
= v
->levels
- 1; i
>= 0; i
--) {
308 int r
= verity_verify_level(io
, io
->block
+ b
, i
, false);
314 desc
= io_hash_desc(v
, io
);
316 desc
->flags
= CRYPTO_TFM_REQ_MAY_SLEEP
;
317 r
= crypto_shash_init(desc
);
319 DMERR("crypto_shash_init failed: %d", r
);
323 if (likely(v
->version
>= 1)) {
324 r
= crypto_shash_update(desc
, v
->salt
, v
->salt_size
);
326 DMERR("crypto_shash_update failed: %d", r
);
331 todo
= 1 << v
->data_dev_block_bits
;
337 BUG_ON(vector
>= io
->io_vec_size
);
338 bv
= &io
->io_vec
[vector
];
339 page
= kmap_atomic(bv
->bv_page
);
340 len
= bv
->bv_len
- offset
;
341 if (likely(len
>= todo
))
343 r
= crypto_shash_update(desc
,
344 page
+ bv
->bv_offset
+ offset
, len
);
347 DMERR("crypto_shash_update failed: %d", r
);
351 if (likely(offset
== bv
->bv_len
)) {
359 r
= crypto_shash_update(desc
, v
->salt
, v
->salt_size
);
361 DMERR("crypto_shash_update failed: %d", r
);
366 result
= io_real_digest(v
, io
);
367 r
= crypto_shash_final(desc
, result
);
369 DMERR("crypto_shash_final failed: %d", r
);
372 if (unlikely(memcmp(result
, io_want_digest(v
, io
), v
->digest_size
))) {
373 DMERR_LIMIT("data block %llu is corrupted",
374 (unsigned long long)(io
->block
+ b
));
379 BUG_ON(vector
!= io
->io_vec_size
);
386 * End one "io" structure with a given error.
388 static void verity_finish_io(struct dm_verity_io
*io
, int error
)
390 struct dm_verity
*v
= io
->v
;
391 struct bio
*bio
= dm_bio_from_per_bio_data(io
, v
->ti
->per_bio_data_size
);
393 bio
->bi_end_io
= io
->orig_bi_end_io
;
394 bio
->bi_private
= io
->orig_bi_private
;
396 if (io
->io_vec
!= io
->io_vec_inline
)
397 mempool_free(io
->io_vec
, v
->vec_mempool
);
399 bio_endio(bio
, error
);
402 static void verity_work(struct work_struct
*w
)
404 struct dm_verity_io
*io
= container_of(w
, struct dm_verity_io
, work
);
406 verity_finish_io(io
, verity_verify_io(io
));
409 static void verity_end_io(struct bio
*bio
, int error
)
411 struct dm_verity_io
*io
= bio
->bi_private
;
414 verity_finish_io(io
, error
);
418 INIT_WORK(&io
->work
, verity_work
);
419 queue_work(io
->v
->verify_wq
, &io
->work
);
423 * Prefetch buffers for the specified io.
424 * The root buffer is not prefetched, it is assumed that it will be cached
427 static void verity_prefetch_io(struct dm_verity
*v
, struct dm_verity_io
*io
)
431 for (i
= v
->levels
- 2; i
>= 0; i
--) {
432 sector_t hash_block_start
;
433 sector_t hash_block_end
;
434 verity_hash_at_level(v
, io
->block
, i
, &hash_block_start
, NULL
);
435 verity_hash_at_level(v
, io
->block
+ io
->n_blocks
- 1, i
, &hash_block_end
, NULL
);
437 unsigned cluster
= ACCESS_ONCE(dm_verity_prefetch_cluster
);
439 cluster
>>= v
->data_dev_block_bits
;
440 if (unlikely(!cluster
))
441 goto no_prefetch_cluster
;
443 if (unlikely(cluster
& (cluster
- 1)))
444 cluster
= 1 << (fls(cluster
) - 1);
446 hash_block_start
&= ~(sector_t
)(cluster
- 1);
447 hash_block_end
|= cluster
- 1;
448 if (unlikely(hash_block_end
>= v
->hash_blocks
))
449 hash_block_end
= v
->hash_blocks
- 1;
452 dm_bufio_prefetch(v
->bufio
, hash_block_start
,
453 hash_block_end
- hash_block_start
+ 1);
458 * Bio map function. It allocates dm_verity_io structure and bio vector and
459 * fills them. Then it issues prefetches and the I/O.
461 static int verity_map(struct dm_target
*ti
, struct bio
*bio
)
463 struct dm_verity
*v
= ti
->private;
464 struct dm_verity_io
*io
;
466 bio
->bi_bdev
= v
->data_dev
->bdev
;
467 bio
->bi_sector
= verity_map_sector(v
, bio
->bi_sector
);
469 if (((unsigned)bio
->bi_sector
| bio_sectors(bio
)) &
470 ((1 << (v
->data_dev_block_bits
- SECTOR_SHIFT
)) - 1)) {
471 DMERR_LIMIT("unaligned io");
475 if ((bio
->bi_sector
+ bio_sectors(bio
)) >>
476 (v
->data_dev_block_bits
- SECTOR_SHIFT
) > v
->data_blocks
) {
477 DMERR_LIMIT("io out of range");
481 if (bio_data_dir(bio
) == WRITE
)
484 io
= dm_per_bio_data(bio
, ti
->per_bio_data_size
);
486 io
->orig_bi_end_io
= bio
->bi_end_io
;
487 io
->orig_bi_private
= bio
->bi_private
;
488 io
->block
= bio
->bi_sector
>> (v
->data_dev_block_bits
- SECTOR_SHIFT
);
489 io
->n_blocks
= bio
->bi_size
>> v
->data_dev_block_bits
;
491 bio
->bi_end_io
= verity_end_io
;
492 bio
->bi_private
= io
;
493 io
->io_vec_size
= bio
->bi_vcnt
- bio
->bi_idx
;
494 if (io
->io_vec_size
< DM_VERITY_IO_VEC_INLINE
)
495 io
->io_vec
= io
->io_vec_inline
;
497 io
->io_vec
= mempool_alloc(v
->vec_mempool
, GFP_NOIO
);
498 memcpy(io
->io_vec
, bio_iovec(bio
),
499 io
->io_vec_size
* sizeof(struct bio_vec
));
501 verity_prefetch_io(v
, io
);
503 generic_make_request(bio
);
505 return DM_MAPIO_SUBMITTED
;
509 * Status: V (valid) or C (corruption found)
511 static void verity_status(struct dm_target
*ti
, status_type_t type
,
512 unsigned status_flags
, char *result
, unsigned maxlen
)
514 struct dm_verity
*v
= ti
->private;
519 case STATUSTYPE_INFO
:
520 DMEMIT("%c", v
->hash_failed
? 'C' : 'V');
522 case STATUSTYPE_TABLE
:
523 DMEMIT("%u %s %s %u %u %llu %llu %s ",
527 1 << v
->data_dev_block_bits
,
528 1 << v
->hash_dev_block_bits
,
529 (unsigned long long)v
->data_blocks
,
530 (unsigned long long)v
->hash_start
,
533 for (x
= 0; x
< v
->digest_size
; x
++)
534 DMEMIT("%02x", v
->root_digest
[x
]);
539 for (x
= 0; x
< v
->salt_size
; x
++)
540 DMEMIT("%02x", v
->salt
[x
]);
545 static int verity_ioctl(struct dm_target
*ti
, unsigned cmd
,
548 struct dm_verity
*v
= ti
->private;
552 ti
->len
!= i_size_read(v
->data_dev
->bdev
->bd_inode
) >> SECTOR_SHIFT
)
553 r
= scsi_verify_blk_ioctl(NULL
, cmd
);
555 return r
? : __blkdev_driver_ioctl(v
->data_dev
->bdev
, v
->data_dev
->mode
,
559 static int verity_merge(struct dm_target
*ti
, struct bvec_merge_data
*bvm
,
560 struct bio_vec
*biovec
, int max_size
)
562 struct dm_verity
*v
= ti
->private;
563 struct request_queue
*q
= bdev_get_queue(v
->data_dev
->bdev
);
565 if (!q
->merge_bvec_fn
)
568 bvm
->bi_bdev
= v
->data_dev
->bdev
;
569 bvm
->bi_sector
= verity_map_sector(v
, bvm
->bi_sector
);
571 return min(max_size
, q
->merge_bvec_fn(q
, bvm
, biovec
));
574 static int verity_iterate_devices(struct dm_target
*ti
,
575 iterate_devices_callout_fn fn
, void *data
)
577 struct dm_verity
*v
= ti
->private;
579 return fn(ti
, v
->data_dev
, v
->data_start
, ti
->len
, data
);
582 static void verity_io_hints(struct dm_target
*ti
, struct queue_limits
*limits
)
584 struct dm_verity
*v
= ti
->private;
586 if (limits
->logical_block_size
< 1 << v
->data_dev_block_bits
)
587 limits
->logical_block_size
= 1 << v
->data_dev_block_bits
;
589 if (limits
->physical_block_size
< 1 << v
->data_dev_block_bits
)
590 limits
->physical_block_size
= 1 << v
->data_dev_block_bits
;
592 blk_limits_io_min(limits
, limits
->logical_block_size
);
595 static void verity_dtr(struct dm_target
*ti
)
597 struct dm_verity
*v
= ti
->private;
600 destroy_workqueue(v
->verify_wq
);
603 mempool_destroy(v
->vec_mempool
);
606 dm_bufio_client_destroy(v
->bufio
);
609 kfree(v
->root_digest
);
612 crypto_free_shash(v
->tfm
);
617 dm_put_device(ti
, v
->hash_dev
);
620 dm_put_device(ti
, v
->data_dev
);
627 * <version> The current format is version 1.
628 * Vsn 0 is compatible with original Chromium OS releases.
633 * <the number of data blocks>
637 * <salt> Hex string or "-" if no salt.
639 static int verity_ctr(struct dm_target
*ti
, unsigned argc
, char **argv
)
643 unsigned long long num_ll
;
646 sector_t hash_position
;
649 v
= kzalloc(sizeof(struct dm_verity
), GFP_KERNEL
);
651 ti
->error
= "Cannot allocate verity structure";
657 if ((dm_table_get_mode(ti
->table
) & ~FMODE_READ
)) {
658 ti
->error
= "Device must be readonly";
664 ti
->error
= "Invalid argument count: exactly 10 arguments required";
669 if (sscanf(argv
[0], "%d%c", &num
, &dummy
) != 1 ||
670 num
< 0 || num
> 1) {
671 ti
->error
= "Invalid version";
677 r
= dm_get_device(ti
, argv
[1], FMODE_READ
, &v
->data_dev
);
679 ti
->error
= "Data device lookup failed";
683 r
= dm_get_device(ti
, argv
[2], FMODE_READ
, &v
->hash_dev
);
685 ti
->error
= "Data device lookup failed";
689 if (sscanf(argv
[3], "%u%c", &num
, &dummy
) != 1 ||
690 !num
|| (num
& (num
- 1)) ||
691 num
< bdev_logical_block_size(v
->data_dev
->bdev
) ||
693 ti
->error
= "Invalid data device block size";
697 v
->data_dev_block_bits
= ffs(num
) - 1;
699 if (sscanf(argv
[4], "%u%c", &num
, &dummy
) != 1 ||
700 !num
|| (num
& (num
- 1)) ||
701 num
< bdev_logical_block_size(v
->hash_dev
->bdev
) ||
703 ti
->error
= "Invalid hash device block size";
707 v
->hash_dev_block_bits
= ffs(num
) - 1;
709 if (sscanf(argv
[5], "%llu%c", &num_ll
, &dummy
) != 1 ||
710 (sector_t
)(num_ll
<< (v
->data_dev_block_bits
- SECTOR_SHIFT
))
711 >> (v
->data_dev_block_bits
- SECTOR_SHIFT
) != num_ll
) {
712 ti
->error
= "Invalid data blocks";
716 v
->data_blocks
= num_ll
;
718 if (ti
->len
> (v
->data_blocks
<< (v
->data_dev_block_bits
- SECTOR_SHIFT
))) {
719 ti
->error
= "Data device is too small";
724 if (sscanf(argv
[6], "%llu%c", &num_ll
, &dummy
) != 1 ||
725 (sector_t
)(num_ll
<< (v
->hash_dev_block_bits
- SECTOR_SHIFT
))
726 >> (v
->hash_dev_block_bits
- SECTOR_SHIFT
) != num_ll
) {
727 ti
->error
= "Invalid hash start";
731 v
->hash_start
= num_ll
;
733 v
->alg_name
= kstrdup(argv
[7], GFP_KERNEL
);
735 ti
->error
= "Cannot allocate algorithm name";
740 v
->tfm
= crypto_alloc_shash(v
->alg_name
, 0, 0);
741 if (IS_ERR(v
->tfm
)) {
742 ti
->error
= "Cannot initialize hash function";
747 v
->digest_size
= crypto_shash_digestsize(v
->tfm
);
748 if ((1 << v
->hash_dev_block_bits
) < v
->digest_size
* 2) {
749 ti
->error
= "Digest size too big";
754 sizeof(struct shash_desc
) + crypto_shash_descsize(v
->tfm
);
756 v
->root_digest
= kmalloc(v
->digest_size
, GFP_KERNEL
);
757 if (!v
->root_digest
) {
758 ti
->error
= "Cannot allocate root digest";
762 if (strlen(argv
[8]) != v
->digest_size
* 2 ||
763 hex2bin(v
->root_digest
, argv
[8], v
->digest_size
)) {
764 ti
->error
= "Invalid root digest";
769 if (strcmp(argv
[9], "-")) {
770 v
->salt_size
= strlen(argv
[9]) / 2;
771 v
->salt
= kmalloc(v
->salt_size
, GFP_KERNEL
);
773 ti
->error
= "Cannot allocate salt";
777 if (strlen(argv
[9]) != v
->salt_size
* 2 ||
778 hex2bin(v
->salt
, argv
[9], v
->salt_size
)) {
779 ti
->error
= "Invalid salt";
785 v
->hash_per_block_bits
=
786 fls((1 << v
->hash_dev_block_bits
) / v
->digest_size
) - 1;
790 while (v
->hash_per_block_bits
* v
->levels
< 64 &&
791 (unsigned long long)(v
->data_blocks
- 1) >>
792 (v
->hash_per_block_bits
* v
->levels
))
795 if (v
->levels
> DM_VERITY_MAX_LEVELS
) {
796 ti
->error
= "Too many tree levels";
801 hash_position
= v
->hash_start
;
802 for (i
= v
->levels
- 1; i
>= 0; i
--) {
804 v
->hash_level_block
[i
] = hash_position
;
805 s
= verity_position_at_level(v
, v
->data_blocks
, i
);
806 s
= (s
>> v
->hash_per_block_bits
) +
807 !!(s
& ((1 << v
->hash_per_block_bits
) - 1));
808 if (hash_position
+ s
< hash_position
) {
809 ti
->error
= "Hash device offset overflow";
815 v
->hash_blocks
= hash_position
;
817 v
->bufio
= dm_bufio_client_create(v
->hash_dev
->bdev
,
818 1 << v
->hash_dev_block_bits
, 1, sizeof(struct buffer_aux
),
819 dm_bufio_alloc_callback
, NULL
);
820 if (IS_ERR(v
->bufio
)) {
821 ti
->error
= "Cannot initialize dm-bufio";
822 r
= PTR_ERR(v
->bufio
);
827 if (dm_bufio_get_device_size(v
->bufio
) < v
->hash_blocks
) {
828 ti
->error
= "Hash device is too small";
833 ti
->per_bio_data_size
= roundup(sizeof(struct dm_verity_io
) + v
->shash_descsize
+ v
->digest_size
* 2, __alignof__(struct dm_verity_io
));
835 v
->vec_mempool
= mempool_create_kmalloc_pool(DM_VERITY_MEMPOOL_SIZE
,
836 BIO_MAX_PAGES
* sizeof(struct bio_vec
));
837 if (!v
->vec_mempool
) {
838 ti
->error
= "Cannot allocate vector mempool";
843 /* WQ_UNBOUND greatly improves performance when running on ramdisk */
844 v
->verify_wq
= alloc_workqueue("kverityd", WQ_CPU_INTENSIVE
| WQ_MEM_RECLAIM
| WQ_UNBOUND
, num_online_cpus());
846 ti
->error
= "Cannot allocate workqueue";
859 static struct target_type verity_target
= {
861 .version
= {1, 1, 1},
862 .module
= THIS_MODULE
,
866 .status
= verity_status
,
867 .ioctl
= verity_ioctl
,
868 .merge
= verity_merge
,
869 .iterate_devices
= verity_iterate_devices
,
870 .io_hints
= verity_io_hints
,
873 static int __init
dm_verity_init(void)
877 r
= dm_register_target(&verity_target
);
879 DMERR("register failed %d", r
);
884 static void __exit
dm_verity_exit(void)
886 dm_unregister_target(&verity_target
);
889 module_init(dm_verity_init
);
890 module_exit(dm_verity_exit
);
892 MODULE_AUTHOR("Mikulas Patocka <mpatocka@redhat.com>");
893 MODULE_AUTHOR("Mandeep Baines <msb@chromium.org>");
894 MODULE_AUTHOR("Will Drewry <wad@chromium.org>");
895 MODULE_DESCRIPTION(DM_NAME
" target for transparent disk integrity checking");
896 MODULE_LICENSE("GPL");