|
@@ -1061,19 +1061,19 @@ static struct attribute_group zram_disk_attr_group = {
|
|
|
|
|
|
static int create_device(struct zram *zram, int device_id)
|
|
static int create_device(struct zram *zram, int device_id)
|
|
{
|
|
{
|
|
|
|
+ struct request_queue *queue;
|
|
int ret = -ENOMEM;
|
|
int ret = -ENOMEM;
|
|
|
|
|
|
init_rwsem(&zram->init_lock);
|
|
init_rwsem(&zram->init_lock);
|
|
|
|
|
|
- zram->queue = blk_alloc_queue(GFP_KERNEL);
|
|
|
|
- if (!zram->queue) {
|
|
|
|
|
|
+ queue = blk_alloc_queue(GFP_KERNEL);
|
|
|
|
+ if (!queue) {
|
|
pr_err("Error allocating disk queue for device %d\n",
|
|
pr_err("Error allocating disk queue for device %d\n",
|
|
device_id);
|
|
device_id);
|
|
goto out;
|
|
goto out;
|
|
}
|
|
}
|
|
|
|
|
|
- blk_queue_make_request(zram->queue, zram_make_request);
|
|
|
|
- zram->queue->queuedata = zram;
|
|
|
|
|
|
+ blk_queue_make_request(queue, zram_make_request);
|
|
|
|
|
|
/* gendisk structure */
|
|
/* gendisk structure */
|
|
zram->disk = alloc_disk(1);
|
|
zram->disk = alloc_disk(1);
|
|
@@ -1086,7 +1086,8 @@ static int create_device(struct zram *zram, int device_id)
|
|
zram->disk->major = zram_major;
|
|
zram->disk->major = zram_major;
|
|
zram->disk->first_minor = device_id;
|
|
zram->disk->first_minor = device_id;
|
|
zram->disk->fops = &zram_devops;
|
|
zram->disk->fops = &zram_devops;
|
|
- zram->disk->queue = zram->queue;
|
|
|
|
|
|
+ zram->disk->queue = queue;
|
|
|
|
+ zram->disk->queue->queuedata = zram;
|
|
zram->disk->private_data = zram;
|
|
zram->disk->private_data = zram;
|
|
snprintf(zram->disk->disk_name, 16, "zram%d", device_id);
|
|
snprintf(zram->disk->disk_name, 16, "zram%d", device_id);
|
|
|
|
|
|
@@ -1137,7 +1138,7 @@ out_free_disk:
|
|
del_gendisk(zram->disk);
|
|
del_gendisk(zram->disk);
|
|
put_disk(zram->disk);
|
|
put_disk(zram->disk);
|
|
out_free_queue:
|
|
out_free_queue:
|
|
- blk_cleanup_queue(zram->queue);
|
|
|
|
|
|
+ blk_cleanup_queue(queue);
|
|
out:
|
|
out:
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
@@ -1158,10 +1159,9 @@ static void destroy_devices(unsigned int nr)
|
|
|
|
|
|
zram_reset_device(zram);
|
|
zram_reset_device(zram);
|
|
|
|
|
|
|
|
+ blk_cleanup_queue(zram->disk->queue);
|
|
del_gendisk(zram->disk);
|
|
del_gendisk(zram->disk);
|
|
put_disk(zram->disk);
|
|
put_disk(zram->disk);
|
|
-
|
|
|
|
- blk_cleanup_queue(zram->queue);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
kfree(zram_devices);
|
|
kfree(zram_devices);
|