/*
* Event handling.
*/
- uint32_t event_nr;
+ atomic_t event_nr;
wait_queue_head_t eventq;
/*
static kmem_cache_t *_io_cache;
static kmem_cache_t *_tio_cache;
-static __init int local_init(void)
+static int __init local_init(void)
{
int r;
struct dm_io *io = tio->io;
free_tio(tio->io->md, tio);
dec_pending(io, -EIO);
+ bio_put(clone);
}
}
return r;
}
+static struct block_device_operations dm_blk_dops;
+
/*
* Allocate and initialise a blank device with a given minor.
*/
init_rwsem(&md->lock);
rwlock_init(&md->map_lock);
atomic_set(&md->holders, 1);
+ atomic_set(&md->event_nr, 0);
md->queue = blk_alloc_queue(GFP_KERNEL);
if (!md->queue)
{
struct mapped_device *md = (struct mapped_device *) context;
- down_write(&md->lock);
- md->event_nr++;
+ atomic_inc(&md->event_nr);;
wake_up(&md->eventq);
- up_write(&md->lock);
}
static void __set_size(struct gendisk *disk, sector_t size)
*---------------------------------------------------------------*/
uint32_t dm_get_event_nr(struct mapped_device *md)
{
- uint32_t r;
-
- down_read(&md->lock);
- r = md->event_nr;
- up_read(&md->lock);
-
- return r;
+ return atomic_read(&md->event_nr);
}
-int dm_add_wait_queue(struct mapped_device *md, wait_queue_t *wq,
- uint32_t event_nr)
+int dm_wait_event(struct mapped_device *md, int event_nr)
{
- down_write(&md->lock);
- if (event_nr != md->event_nr) {
- up_write(&md->lock);
- return 1;
- }
-
- add_wait_queue(&md->eventq, wq);
- up_write(&md->lock);
-
- return 0;
-}
-
-void dm_remove_wait_queue(struct mapped_device *md, wait_queue_t *wq)
-{
- down_write(&md->lock);
- remove_wait_queue(&md->eventq, wq);
- up_write(&md->lock);
+ return wait_event_interruptible(md->eventq,
+ (event_nr != atomic_read(&md->event_nr)));
}
/*
return test_bit(DMF_SUSPENDED, &md->flags);
}
-struct block_device_operations dm_blk_dops = {
+static struct block_device_operations dm_blk_dops = {
.open = dm_blk_open,
.release = dm_blk_close,
.owner = THIS_MODULE