Commit c14f2880 authored by Alexander Viro's avatar Alexander Viro Committed by James Bottomley

[PATCH] z2ram

	* switched to private queues
	* set ->queue
	* cleaned up
parent 624a75e8
...@@ -73,55 +73,36 @@ static spinlock_t z2ram_lock = SPIN_LOCK_UNLOCKED; ...@@ -73,55 +73,36 @@ static spinlock_t z2ram_lock = SPIN_LOCK_UNLOCKED;
static struct block_device_operations z2_fops; static struct block_device_operations z2_fops;
static struct gendisk *z2ram_gendisk; static struct gendisk *z2ram_gendisk;
static void static void do_z2_request(request_queue_t *q)
do_z2_request( request_queue_t * q )
{ {
u_long start, len, addr, size; u_long start, len, addr, size;
while ( TRUE ) while (!blk_queue_empty(q)) {
{ struct request *req = elv_next_request(q);
if (blk_queue_empty(QUEUE)) unsigned long start = req->sector << 9;
return; unsigned long len = req->current_nr_sectors << 9;
start = CURRENT->sector << 9; if (start + len > z2ram_size) {
len = CURRENT->current_nr_sectors << 9; printk( KERN_ERR DEVICE_NAME ": bad access: block=%lu, count=%u\n",
req->sector, req->current_nr_sectors);
if ( ( start + len ) > z2ram_size ) end_request(req, 0);
{ continue;
printk( KERN_ERR DEVICE_NAME ": bad access: block=%lu, count=%u\n", }
CURRENT->sector, while (len) {
CURRENT->current_nr_sectors); unsigned long addr = start & Z2RAM_CHUNKMASK;
end_request(CURRENT, FALSE); unsigned long size = Z2RAM_CHUNKSIZE - addr;
continue; if (len < size)
} size = len;
addr += z2ram_map[ start >> Z2RAM_CHUNKSHIFT ];
if ( ( rq_data_dir(CURRENT) != READ ) && ( rq_data_dir(CURRENT) != WRITE ) ) if (rq_data_dir(req) == READ)
{ memcpy(req->buffer, (char *)addr, size);
printk( KERN_ERR DEVICE_NAME ": bad command: %ld\n", rq_data_dir(CURRENT) ); else
end_request(CURRENT, FALSE); memcpy((char *)addr, req->buffer, size);
continue; start += size;
} len -= size;
}
while ( len ) end_request(req, 1);
{
addr = start & Z2RAM_CHUNKMASK;
size = Z2RAM_CHUNKSIZE - addr;
if ( len < size )
size = len;
addr += z2ram_map[ start >> Z2RAM_CHUNKSHIFT ];
if ( rq_data_dir(CURRENT) == READ )
memcpy( CURRENT->buffer, (char *)addr, size );
else
memcpy( (char *)addr, CURRENT->buffer, size );
start += size;
len -= size;
} }
end_request(CURRENT, TRUE);
}
} }
static void static void
...@@ -351,6 +332,8 @@ static struct gendisk *z2_find(dev_t dev, int *part, void *data) ...@@ -351,6 +332,8 @@ static struct gendisk *z2_find(dev_t dev, int *part, void *data)
return get_disk(z2ram_gendisk); return get_disk(z2ram_gendisk);
} }
static struct request_queue z2_queue;
int __init int __init
z2_init( void ) z2_init( void )
{ {
...@@ -374,7 +357,8 @@ z2_init( void ) ...@@ -374,7 +357,8 @@ z2_init( void )
z2ram_gendisk->fops = &z2_fops; z2ram_gendisk->fops = &z2_fops;
sprintf(z2ram_gendisk->disk_name, "z2ram"); sprintf(z2ram_gendisk->disk_name, "z2ram");
blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), do_z2_request, &z2ram_lock); blk_init_queue(&z2_queue, do_z2_request, &z2ram_lock);
z2ram_gendisk->queue = &z2_queue;
add_disk(z2ram_gendisk); add_disk(z2ram_gendisk);
blk_register_region(MKDEV(MAJOR_NR, 0), Z2MINOR_COUNT, THIS_MODULE, blk_register_region(MKDEV(MAJOR_NR, 0), Z2MINOR_COUNT, THIS_MODULE,
z2_find, NULL, NULL); z2_find, NULL, NULL);
...@@ -410,7 +394,7 @@ cleanup_module( void ) ...@@ -410,7 +394,7 @@ cleanup_module( void )
del_gendisk(z2ram_gendisk); del_gendisk(z2ram_gendisk);
put_disk(z2ram_gendisk); put_disk(z2ram_gendisk);
blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR)); blk_cleanup_queue(&z2_queue);
if ( current_device != -1 ) if ( current_device != -1 )
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment