2 * Copyright (C) 2001, 2002 Sistina Software (UK) Limited.
3 * Copyright (C) 2004 Red Hat, Inc. All rights reserved.
5 * This file is released under the GPL.
9 #include "dm-bio-list.h"
11 #include <linux/init.h>
12 #include <linux/module.h>
13 #include <linux/moduleparam.h>
14 #include <linux/blkpg.h>
15 #include <linux/bio.h>
16 #include <linux/buffer_head.h>
17 #include <linux/mempool.h>
18 #include <linux/slab.h>
19 #include <linux/idr.h>
20 #include <linux/hdreg.h>
21 #include <linux/blktrace_api.h>
23 static const char *_name = DM_NAME;
25 static unsigned int major = 0;
26 static unsigned int _major = 0;
29 * One of these is allocated per bio.
32 struct mapped_device *md;
36 unsigned long start_time;
40 * One of these is allocated per target within a bio. Hopefully
41 * this will be simplified out one day.
49 union map_info *dm_get_mapinfo(struct bio *bio)
51 if (bio && bio->bi_private)
52 return &((struct target_io *)bio->bi_private)->info;
57 * Bits for the md->flags field.
59 #define DMF_BLOCK_IO 0
60 #define DMF_SUSPENDED 1
63 struct mapped_device {
64 struct rw_semaphore io_lock;
65 struct semaphore suspend_lock;
71 request_queue_t *queue;
78 * A list of ios that arrived while we were suspended.
81 wait_queue_head_t wait;
82 struct bio_list deferred;
85 * The current mapping.
90 * io objects are allocated from here.
99 wait_queue_head_t eventq;
102 * freeze/thaw support require holding onto a super block
104 struct super_block *frozen_sb;
105 struct block_device *suspended_bdev;
107 /* forced geometry settings */
108 struct hd_geometry geometry;
112 static kmem_cache_t *_io_cache;
113 static kmem_cache_t *_tio_cache;
115 static struct bio_set *dm_set;
117 static int __init local_init(void)
121 dm_set = bioset_create(16, 16, 4);
125 /* allocate a slab for the dm_ios */
126 _io_cache = kmem_cache_create("dm_io",
127 sizeof(struct dm_io), 0, 0, NULL, NULL);
131 /* allocate a slab for the target ios */
132 _tio_cache = kmem_cache_create("dm_tio", sizeof(struct target_io),
135 kmem_cache_destroy(_io_cache);
140 r = register_blkdev(_major, _name);
142 kmem_cache_destroy(_tio_cache);
143 kmem_cache_destroy(_io_cache);
153 static void local_exit(void)
155 kmem_cache_destroy(_tio_cache);
156 kmem_cache_destroy(_io_cache);
160 if (unregister_blkdev(_major, _name) < 0)
161 DMERR("devfs_unregister_blkdev failed");
165 DMINFO("cleaned up");
168 int (*_inits[])(void) __initdata = {
176 void (*_exits[])(void) = {
184 static int __init dm_init(void)
186 const int count = ARRAY_SIZE(_inits);
190 for (i = 0; i < count; i++) {
205 static void __exit dm_exit(void)
207 int i = ARRAY_SIZE(_exits);
214 * Block device functions
216 static int dm_blk_open(struct inode *inode, struct file *file)
218 struct mapped_device *md;
220 md = inode->i_bdev->bd_disk->private_data;
225 static int dm_blk_close(struct inode *inode, struct file *file)
227 struct mapped_device *md;
229 md = inode->i_bdev->bd_disk->private_data;
234 static int dm_blk_getgeo(struct block_device *bdev, struct hd_geometry *geo)
236 struct mapped_device *md = bdev->bd_disk->private_data;
238 return dm_get_geometry(md, geo);
241 static inline struct dm_io *alloc_io(struct mapped_device *md)
243 return mempool_alloc(md->io_pool, GFP_NOIO);
246 static inline void free_io(struct mapped_device *md, struct dm_io *io)
248 mempool_free(io, md->io_pool);
251 static inline struct target_io *alloc_tio(struct mapped_device *md)
253 return mempool_alloc(md->tio_pool, GFP_NOIO);
256 static inline void free_tio(struct mapped_device *md, struct target_io *tio)
258 mempool_free(tio, md->tio_pool);
261 static void start_io_acct(struct dm_io *io)
263 struct mapped_device *md = io->md;
265 io->start_time = jiffies;
268 disk_round_stats(dm_disk(md));
270 dm_disk(md)->in_flight = atomic_inc_return(&md->pending);
273 static int end_io_acct(struct dm_io *io)
275 struct mapped_device *md = io->md;
276 struct bio *bio = io->bio;
277 unsigned long duration = jiffies - io->start_time;
279 int rw = bio_data_dir(bio);
282 disk_round_stats(dm_disk(md));
284 dm_disk(md)->in_flight = pending = atomic_dec_return(&md->pending);
286 disk_stat_add(dm_disk(md), ticks[rw], duration);
292 * Add the bio to the list of deferred io.
294 static int queue_io(struct mapped_device *md, struct bio *bio)
296 down_write(&md->io_lock);
298 if (!test_bit(DMF_BLOCK_IO, &md->flags)) {
299 up_write(&md->io_lock);
303 bio_list_add(&md->deferred, bio);
305 up_write(&md->io_lock);
306 return 0; /* deferred successfully */
310 * Everyone (including functions in this file), should use this
311 * function to access the md->map field, and make sure they call
312 * dm_table_put() when finished.
314 struct dm_table *dm_get_table(struct mapped_device *md)
318 read_lock(&md->map_lock);
322 read_unlock(&md->map_lock);
328 * Get the geometry associated with a dm device
330 int dm_get_geometry(struct mapped_device *md, struct hd_geometry *geo)
338 * Set the geometry of a device.
340 int dm_set_geometry(struct mapped_device *md, struct hd_geometry *geo)
342 sector_t sz = (sector_t)geo->cylinders * geo->heads * geo->sectors;
344 if (geo->start > sz) {
345 DMWARN("Start sector is beyond the geometry limits.");
354 /*-----------------------------------------------------------------
356 * A more elegant soln is in the works that uses the queue
357 * merge fn, unfortunately there are a couple of changes to
358 * the block layer that I want to make for this. So in the
359 * interests of getting something for people to use I give
360 * you this clearly demarcated crap.
361 *---------------------------------------------------------------*/
364 * Decrements the number of outstanding ios that a bio has been
365 * cloned into, completing the original io if necc.
367 static void dec_pending(struct dm_io *io, int error)
372 if (atomic_dec_and_test(&io->io_count)) {
374 /* nudge anyone waiting on suspend queue */
375 wake_up(&io->md->wait);
377 blk_add_trace_bio(io->md->queue, io->bio, BLK_TA_COMPLETE);
379 bio_endio(io->bio, io->bio->bi_size, io->error);
384 static int clone_endio(struct bio *bio, unsigned int done, int error)
387 struct target_io *tio = bio->bi_private;
388 struct dm_io *io = tio->io;
389 dm_endio_fn endio = tio->ti->type->end_io;
394 if (!bio_flagged(bio, BIO_UPTODATE) && !error)
398 r = endio(tio->ti, bio, error, &tio->info);
403 /* the target wants another shot at the io */
407 free_tio(io->md, tio);
408 dec_pending(io, error);
413 static sector_t max_io_len(struct mapped_device *md,
414 sector_t sector, struct dm_target *ti)
416 sector_t offset = sector - ti->begin;
417 sector_t len = ti->len - offset;
420 * Does the target need to split even further ?
424 boundary = ((offset + ti->split_io) & ~(ti->split_io - 1))
433 static void __map_bio(struct dm_target *ti, struct bio *clone,
434 struct target_io *tio)
442 BUG_ON(!clone->bi_size);
444 clone->bi_end_io = clone_endio;
445 clone->bi_private = tio;
448 * Map the clone. If r == 0 we don't need to do
449 * anything, the target has assumed ownership of
452 atomic_inc(&tio->io->io_count);
453 sector = clone->bi_sector;
454 r = ti->type->map(ti, clone, &tio->info);
456 /* the bio has been remapped so dispatch it */
458 blk_add_trace_remap(bdev_get_queue(clone->bi_bdev), clone,
459 tio->io->bio->bi_bdev->bd_dev, sector,
462 generic_make_request(clone);
466 /* error the io and bail out */
467 struct dm_io *io = tio->io;
468 free_tio(tio->io->md, tio);
475 struct mapped_device *md;
476 struct dm_table *map;
480 sector_t sector_count;
484 static void dm_bio_destructor(struct bio *bio)
486 bio_free(bio, dm_set);
490 * Creates a little bio that is just does part of a bvec.
492 static struct bio *split_bvec(struct bio *bio, sector_t sector,
493 unsigned short idx, unsigned int offset,
497 struct bio_vec *bv = bio->bi_io_vec + idx;
499 clone = bio_alloc_bioset(GFP_NOIO, 1, dm_set);
500 clone->bi_destructor = dm_bio_destructor;
501 *clone->bi_io_vec = *bv;
503 clone->bi_sector = sector;
504 clone->bi_bdev = bio->bi_bdev;
505 clone->bi_rw = bio->bi_rw;
507 clone->bi_size = to_bytes(len);
508 clone->bi_io_vec->bv_offset = offset;
509 clone->bi_io_vec->bv_len = clone->bi_size;
515 * Creates a bio that consists of range of complete bvecs.
517 static struct bio *clone_bio(struct bio *bio, sector_t sector,
518 unsigned short idx, unsigned short bv_count,
523 clone = bio_clone(bio, GFP_NOIO);
524 clone->bi_sector = sector;
526 clone->bi_vcnt = idx + bv_count;
527 clone->bi_size = to_bytes(len);
528 clone->bi_flags &= ~(1 << BIO_SEG_VALID);
533 static void __clone_and_map(struct clone_info *ci)
535 struct bio *clone, *bio = ci->bio;
536 struct dm_target *ti = dm_table_find_target(ci->map, ci->sector);
537 sector_t len = 0, max = max_io_len(ci->md, ci->sector, ti);
538 struct target_io *tio;
541 * Allocate a target io object.
543 tio = alloc_tio(ci->md);
546 memset(&tio->info, 0, sizeof(tio->info));
548 if (ci->sector_count <= max) {
550 * Optimise for the simple case where we can do all of
551 * the remaining io with a single clone.
553 clone = clone_bio(bio, ci->sector, ci->idx,
554 bio->bi_vcnt - ci->idx, ci->sector_count);
555 __map_bio(ti, clone, tio);
556 ci->sector_count = 0;
558 } else if (to_sector(bio->bi_io_vec[ci->idx].bv_len) <= max) {
560 * There are some bvecs that don't span targets.
561 * Do as many of these as possible.
564 sector_t remaining = max;
567 for (i = ci->idx; remaining && (i < bio->bi_vcnt); i++) {
568 bv_len = to_sector(bio->bi_io_vec[i].bv_len);
570 if (bv_len > remaining)
577 clone = clone_bio(bio, ci->sector, ci->idx, i - ci->idx, len);
578 __map_bio(ti, clone, tio);
581 ci->sector_count -= len;
586 * Handle a bvec that must be split between two or more targets.
588 struct bio_vec *bv = bio->bi_io_vec + ci->idx;
589 sector_t remaining = to_sector(bv->bv_len);
590 unsigned int offset = 0;
594 ti = dm_table_find_target(ci->map, ci->sector);
595 max = max_io_len(ci->md, ci->sector, ti);
597 tio = alloc_tio(ci->md);
600 memset(&tio->info, 0, sizeof(tio->info));
603 len = min(remaining, max);
605 clone = split_bvec(bio, ci->sector, ci->idx,
606 bv->bv_offset + offset, len);
608 __map_bio(ti, clone, tio);
611 ci->sector_count -= len;
612 offset += to_bytes(len);
613 } while (remaining -= len);
620 * Split the bio into several clones.
622 static void __split_bio(struct mapped_device *md, struct bio *bio)
624 struct clone_info ci;
626 ci.map = dm_get_table(md);
628 bio_io_error(bio, bio->bi_size);
634 ci.io = alloc_io(md);
636 atomic_set(&ci.io->io_count, 1);
639 ci.sector = bio->bi_sector;
640 ci.sector_count = bio_sectors(bio);
641 ci.idx = bio->bi_idx;
643 start_io_acct(ci.io);
644 while (ci.sector_count)
645 __clone_and_map(&ci);
647 /* drop the extra reference count */
648 dec_pending(ci.io, 0);
649 dm_table_put(ci.map);
651 /*-----------------------------------------------------------------
653 *---------------------------------------------------------------*/
656 * The request function that just remaps the bio built up by
659 static int dm_request(request_queue_t *q, struct bio *bio)
662 int rw = bio_data_dir(bio);
663 struct mapped_device *md = q->queuedata;
665 down_read(&md->io_lock);
667 disk_stat_inc(dm_disk(md), ios[rw]);
668 disk_stat_add(dm_disk(md), sectors[rw], bio_sectors(bio));
671 * If we're suspended we have to queue
674 while (test_bit(DMF_BLOCK_IO, &md->flags)) {
675 up_read(&md->io_lock);
677 if (bio_rw(bio) == READA) {
678 bio_io_error(bio, bio->bi_size);
682 r = queue_io(md, bio);
684 bio_io_error(bio, bio->bi_size);
688 return 0; /* deferred successfully */
691 * We're in a while loop, because someone could suspend
692 * before we get to the following read lock.
694 down_read(&md->io_lock);
697 __split_bio(md, bio);
698 up_read(&md->io_lock);
702 static int dm_flush_all(request_queue_t *q, struct gendisk *disk,
703 sector_t *error_sector)
705 struct mapped_device *md = q->queuedata;
706 struct dm_table *map = dm_get_table(md);
710 ret = dm_table_flush_all(map);
717 static void dm_unplug_all(request_queue_t *q)
719 struct mapped_device *md = q->queuedata;
720 struct dm_table *map = dm_get_table(md);
723 dm_table_unplug_all(map);
728 static int dm_any_congested(void *congested_data, int bdi_bits)
731 struct mapped_device *md = (struct mapped_device *) congested_data;
732 struct dm_table *map = dm_get_table(md);
734 if (!map || test_bit(DMF_BLOCK_IO, &md->flags))
737 r = dm_table_any_congested(map, bdi_bits);
743 /*-----------------------------------------------------------------
744 * An IDR is used to keep track of allocated minor numbers.
745 *---------------------------------------------------------------*/
746 static DECLARE_MUTEX(_minor_lock);
747 static DEFINE_IDR(_minor_idr);
749 static void free_minor(unsigned int minor)
752 idr_remove(&_minor_idr, minor);
757 * See if the device with a specific minor # is free.
759 static int specific_minor(struct mapped_device *md, unsigned int minor)
763 if (minor >= (1 << MINORBITS))
768 if (idr_find(&_minor_idr, minor)) {
773 r = idr_pre_get(&_minor_idr, GFP_KERNEL);
779 r = idr_get_new_above(&_minor_idr, md, minor, &m);
785 idr_remove(&_minor_idr, m);
795 static int next_free_minor(struct mapped_device *md, unsigned int *minor)
802 r = idr_pre_get(&_minor_idr, GFP_KERNEL);
808 r = idr_get_new(&_minor_idr, md, &m);
813 if (m >= (1 << MINORBITS)) {
814 idr_remove(&_minor_idr, m);
826 static struct block_device_operations dm_blk_dops;
829 * Allocate and initialise a blank device with a given minor.
831 static struct mapped_device *alloc_dev(unsigned int minor, int persistent)
834 struct mapped_device *md = kmalloc(sizeof(*md), GFP_KERNEL);
837 DMWARN("unable to allocate device, out of memory.");
841 /* get a minor number for the dev */
842 r = persistent ? specific_minor(md, minor) : next_free_minor(md, &minor);
846 memset(md, 0, sizeof(*md));
847 init_rwsem(&md->io_lock);
848 init_MUTEX(&md->suspend_lock);
849 rwlock_init(&md->map_lock);
850 atomic_set(&md->holders, 1);
851 atomic_set(&md->event_nr, 0);
853 md->queue = blk_alloc_queue(GFP_KERNEL);
857 md->queue->queuedata = md;
858 md->queue->backing_dev_info.congested_fn = dm_any_congested;
859 md->queue->backing_dev_info.congested_data = md;
860 blk_queue_make_request(md->queue, dm_request);
861 blk_queue_bounce_limit(md->queue, BLK_BOUNCE_ANY);
862 md->queue->unplug_fn = dm_unplug_all;
863 md->queue->issue_flush_fn = dm_flush_all;
865 md->io_pool = mempool_create_slab_pool(MIN_IOS, _io_cache);
869 md->tio_pool = mempool_create_slab_pool(MIN_IOS, _tio_cache);
873 md->disk = alloc_disk(1);
877 md->disk->major = _major;
878 md->disk->first_minor = minor;
879 md->disk->fops = &dm_blk_dops;
880 md->disk->queue = md->queue;
881 md->disk->private_data = md;
882 sprintf(md->disk->disk_name, "dm-%d", minor);
884 format_dev_t(md->name, MKDEV(_major, minor));
886 atomic_set(&md->pending, 0);
887 init_waitqueue_head(&md->wait);
888 init_waitqueue_head(&md->eventq);
893 mempool_destroy(md->tio_pool);
895 mempool_destroy(md->io_pool);
897 blk_cleanup_queue(md->queue);
904 static void free_dev(struct mapped_device *md)
906 unsigned int minor = md->disk->first_minor;
908 if (md->suspended_bdev) {
909 thaw_bdev(md->suspended_bdev, NULL);
910 bdput(md->suspended_bdev);
912 mempool_destroy(md->tio_pool);
913 mempool_destroy(md->io_pool);
914 del_gendisk(md->disk);
917 blk_cleanup_queue(md->queue);
922 * Bind a table to the device.
924 static void event_callback(void *context)
926 struct mapped_device *md = (struct mapped_device *) context;
928 atomic_inc(&md->event_nr);
929 wake_up(&md->eventq);
932 static void __set_size(struct mapped_device *md, sector_t size)
934 set_capacity(md->disk, size);
936 mutex_lock(&md->suspended_bdev->bd_inode->i_mutex);
937 i_size_write(md->suspended_bdev->bd_inode, (loff_t)size << SECTOR_SHIFT);
938 mutex_unlock(&md->suspended_bdev->bd_inode->i_mutex);
941 static int __bind(struct mapped_device *md, struct dm_table *t)
943 request_queue_t *q = md->queue;
946 size = dm_table_get_size(t);
949 * Wipe any geometry if the size of the table changed.
951 if (size != get_capacity(md->disk))
952 memset(&md->geometry, 0, sizeof(md->geometry));
954 __set_size(md, size);
959 dm_table_event_callback(t, event_callback, md);
961 write_lock(&md->map_lock);
963 dm_table_set_restrictions(t, q);
964 write_unlock(&md->map_lock);
969 static void __unbind(struct mapped_device *md)
971 struct dm_table *map = md->map;
976 dm_table_event_callback(map, NULL, NULL);
977 write_lock(&md->map_lock);
979 write_unlock(&md->map_lock);
984 * Constructor for a new device.
986 static int create_aux(unsigned int minor, int persistent,
987 struct mapped_device **result)
989 struct mapped_device *md;
991 md = alloc_dev(minor, persistent);
999 int dm_create(struct mapped_device **result)
1001 return create_aux(0, 0, result);
1004 int dm_create_with_minor(unsigned int minor, struct mapped_device **result)
1006 return create_aux(minor, 1, result);
1009 static struct mapped_device *dm_find_md(dev_t dev)
1011 struct mapped_device *md;
1012 unsigned minor = MINOR(dev);
1014 if (MAJOR(dev) != _major || minor >= (1 << MINORBITS))
1019 md = idr_find(&_minor_idr, minor);
1020 if (!md || (dm_disk(md)->first_minor != minor))
1028 struct mapped_device *dm_get_md(dev_t dev)
1030 struct mapped_device *md = dm_find_md(dev);
1038 void *dm_get_mdptr(struct mapped_device *md)
1040 return md->interface_ptr;
1043 void dm_set_mdptr(struct mapped_device *md, void *ptr)
1045 md->interface_ptr = ptr;
1048 void dm_get(struct mapped_device *md)
1050 atomic_inc(&md->holders);
1053 void dm_put(struct mapped_device *md)
1055 struct dm_table *map;
1057 if (atomic_dec_and_test(&md->holders)) {
1058 map = dm_get_table(md);
1059 if (!dm_suspended(md)) {
1060 dm_table_presuspend_targets(map);
1061 dm_table_postsuspend_targets(map);
1070 * Process the deferred bios
1072 static void __flush_deferred_io(struct mapped_device *md, struct bio *c)
1085 * Swap in a new table (destroying old one).
1087 int dm_swap_table(struct mapped_device *md, struct dm_table *table)
1091 down(&md->suspend_lock);
1093 /* device must be suspended */
1094 if (!dm_suspended(md))
1098 r = __bind(md, table);
1101 up(&md->suspend_lock);
1106 * Functions to lock and unlock any filesystem running on the
1109 static int lock_fs(struct mapped_device *md)
1113 WARN_ON(md->frozen_sb);
1115 md->frozen_sb = freeze_bdev(md->suspended_bdev);
1116 if (IS_ERR(md->frozen_sb)) {
1117 r = PTR_ERR(md->frozen_sb);
1118 md->frozen_sb = NULL;
1122 set_bit(DMF_FROZEN, &md->flags);
1124 /* don't bdput right now, we don't want the bdev
1125 * to go away while it is locked.
1130 static void unlock_fs(struct mapped_device *md)
1132 if (!test_bit(DMF_FROZEN, &md->flags))
1135 thaw_bdev(md->suspended_bdev, md->frozen_sb);
1136 md->frozen_sb = NULL;
1137 clear_bit(DMF_FROZEN, &md->flags);
1141 * We need to be able to change a mapping table under a mounted
1142 * filesystem. For example we might want to move some data in
1143 * the background. Before the table can be swapped with
1144 * dm_bind_table, dm_suspend must be called to flush any in
1145 * flight bios and ensure that any further io gets deferred.
1147 int dm_suspend(struct mapped_device *md, int do_lockfs)
1149 struct dm_table *map = NULL;
1150 DECLARE_WAITQUEUE(wait, current);
1154 down(&md->suspend_lock);
1156 if (dm_suspended(md))
1159 map = dm_get_table(md);
1161 /* This does not get reverted if there's an error later. */
1162 dm_table_presuspend_targets(map);
1164 md->suspended_bdev = bdget_disk(md->disk, 0);
1165 if (!md->suspended_bdev) {
1166 DMWARN("bdget failed in dm_suspend");
1171 /* Flush I/O to the device. */
1179 * First we set the BLOCK_IO flag so no more ios will be mapped.
1181 down_write(&md->io_lock);
1182 set_bit(DMF_BLOCK_IO, &md->flags);
1184 add_wait_queue(&md->wait, &wait);
1185 up_write(&md->io_lock);
1189 dm_table_unplug_all(map);
1192 * Then we wait for the already mapped ios to
1196 set_current_state(TASK_INTERRUPTIBLE);
1198 if (!atomic_read(&md->pending) || signal_pending(current))
1203 set_current_state(TASK_RUNNING);
1205 down_write(&md->io_lock);
1206 remove_wait_queue(&md->wait, &wait);
1208 /* were we interrupted ? */
1210 if (atomic_read(&md->pending)) {
1211 clear_bit(DMF_BLOCK_IO, &md->flags);
1212 def = bio_list_get(&md->deferred);
1213 __flush_deferred_io(md, def);
1214 up_write(&md->io_lock);
1218 up_write(&md->io_lock);
1220 dm_table_postsuspend_targets(map);
1222 set_bit(DMF_SUSPENDED, &md->flags);
1227 if (r && md->suspended_bdev) {
1228 bdput(md->suspended_bdev);
1229 md->suspended_bdev = NULL;
1233 up(&md->suspend_lock);
1237 int dm_resume(struct mapped_device *md)
1241 struct dm_table *map = NULL;
1243 down(&md->suspend_lock);
1244 if (!dm_suspended(md))
1247 map = dm_get_table(md);
1248 if (!map || !dm_table_get_size(map))
1251 dm_table_resume_targets(map);
1253 down_write(&md->io_lock);
1254 clear_bit(DMF_BLOCK_IO, &md->flags);
1256 def = bio_list_get(&md->deferred);
1257 __flush_deferred_io(md, def);
1258 up_write(&md->io_lock);
1262 bdput(md->suspended_bdev);
1263 md->suspended_bdev = NULL;
1265 clear_bit(DMF_SUSPENDED, &md->flags);
1267 dm_table_unplug_all(map);
1273 up(&md->suspend_lock);
1278 /*-----------------------------------------------------------------
1279 * Event notification.
1280 *---------------------------------------------------------------*/
1281 uint32_t dm_get_event_nr(struct mapped_device *md)
1283 return atomic_read(&md->event_nr);
1286 int dm_wait_event(struct mapped_device *md, int event_nr)
1288 return wait_event_interruptible(md->eventq,
1289 (event_nr != atomic_read(&md->event_nr)));
1293 * The gendisk is only valid as long as you have a reference
1296 struct gendisk *dm_disk(struct mapped_device *md)
1301 int dm_suspended(struct mapped_device *md)
1303 return test_bit(DMF_SUSPENDED, &md->flags);
1306 static struct block_device_operations dm_blk_dops = {
1307 .open = dm_blk_open,
1308 .release = dm_blk_close,
1309 .getgeo = dm_blk_getgeo,
1310 .owner = THIS_MODULE
1313 EXPORT_SYMBOL(dm_get_mapinfo);
1318 module_init(dm_init);
1319 module_exit(dm_exit);
1321 module_param(major, uint, 0);
1322 MODULE_PARM_DESC(major, "The major number of the device mapper");
1323 MODULE_DESCRIPTION(DM_NAME " driver");
1324 MODULE_AUTHOR("Joe Thornber <dm-devel@redhat.com>");
1325 MODULE_LICENSE("GPL");