/* * Copyright (C) 2001, 2002 Sistina Software (UK) Limited. * Copyright (C) 2004 Red Hat, Inc. All rights reserved. * * This file is released under the GPL. */#include"dm.h"#include"dm-bio-list.h"#include<linux/init.h>#include<linux/module.h>#include<linux/mutex.h>#include<linux/moduleparam.h>#include<linux/blkpg.h>#include<linux/bio.h>#include<linux/buffer_head.h>#include<linux/mempool.h>#include<linux/slab.h>#include<linux/idr.h>#include<linux/hdreg.h>#include<linux/blktrace_api.h>staticconstchar*_name=DM_NAME;staticunsignedintmajor=0;staticunsignedint_major=0;staticDEFINE_SPINLOCK(_minor_lock);/* * One of these is allocated per bio. */structdm_io{structmapped_device*md;interror;structbio*bio;atomic_tio_count;unsignedlongstart_time;};/* * One of these is allocated per target within a bio. Hopefully * this will be simplified out one day. */structtarget_io{structdm_io*io;structdm_target*ti;unionmap_infoinfo;};unionmap_info*dm_get_mapinfo(structbio*bio){if(bio&&bio->bi_private)return&((structtarget_io*)bio->bi_private)->info;returnNULL;}#define MINOR_ALLOCED ((void *)-1)/* * Bits for the md->flags field. */#define DMF_BLOCK_IO 0#define DMF_SUSPENDED 1#define DMF_FROZEN 2#define DMF_FREEING 3structmapped_device{structrw_semaphoreio_lock;structsemaphoresuspend_lock;rwlock_tmap_lock;atomic_tholders;unsignedlongflags;request_queue_t*queue;structgendisk*disk;charname[16];void*interface_ptr;/* * A list of ios that arrived while we were suspended. */atomic_tpending;wait_queue_head_twait;structbio_listdeferred;/* * The current mapping. */structdm_table*map;/* * io objects are allocated from here. */mempool_t*io_pool;