Commit b647ad02 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

drbd: convert to blk_alloc_disk/blk_cleanup_disk

Convert the drbd driver to use the blk_alloc_disk and blk_cleanup_disk
helpers to simplify gendisk and request_queue allocation.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarHannes Reinecke <hare@suse.de>
Reviewed-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
Link: https://lore.kernel.org/r/20210521055116.1053587-8-hch@lst.deSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 7f9b348c
...@@ -2231,8 +2231,7 @@ void drbd_destroy_device(struct kref *kref) ...@@ -2231,8 +2231,7 @@ void drbd_destroy_device(struct kref *kref)
if (device->bitmap) /* should no longer be there. */ if (device->bitmap) /* should no longer be there. */
drbd_bm_cleanup(device); drbd_bm_cleanup(device);
__free_page(device->md_io.page); __free_page(device->md_io.page);
put_disk(device->vdisk); blk_cleanup_disk(device->vdisk);
blk_cleanup_queue(device->rq_queue);
kfree(device->rs_plan_s); kfree(device->rs_plan_s);
/* not for_each_connection(connection, resource): /* not for_each_connection(connection, resource):
...@@ -2701,7 +2700,6 @@ enum drbd_ret_code drbd_create_device(struct drbd_config_context *adm_ctx, unsig ...@@ -2701,7 +2700,6 @@ enum drbd_ret_code drbd_create_device(struct drbd_config_context *adm_ctx, unsig
struct drbd_device *device; struct drbd_device *device;
struct drbd_peer_device *peer_device, *tmp_peer_device; struct drbd_peer_device *peer_device, *tmp_peer_device;
struct gendisk *disk; struct gendisk *disk;
struct request_queue *q;
int id; int id;
int vnr = adm_ctx->volume; int vnr = adm_ctx->volume;
enum drbd_ret_code err = ERR_NOMEM; enum drbd_ret_code err = ERR_NOMEM;
...@@ -2723,29 +2721,26 @@ enum drbd_ret_code drbd_create_device(struct drbd_config_context *adm_ctx, unsig ...@@ -2723,29 +2721,26 @@ enum drbd_ret_code drbd_create_device(struct drbd_config_context *adm_ctx, unsig
drbd_init_set_defaults(device); drbd_init_set_defaults(device);
q = blk_alloc_queue(NUMA_NO_NODE); disk = blk_alloc_disk(NUMA_NO_NODE);
if (!q)
goto out_no_q;
device->rq_queue = q;
disk = alloc_disk(1);
if (!disk) if (!disk)
goto out_no_disk; goto out_no_disk;
device->vdisk = disk; device->vdisk = disk;
device->rq_queue = disk->queue;
set_disk_ro(disk, true); set_disk_ro(disk, true);
disk->queue = q;
disk->major = DRBD_MAJOR; disk->major = DRBD_MAJOR;
disk->first_minor = minor; disk->first_minor = minor;
disk->minors = 1;
disk->fops = &drbd_ops; disk->fops = &drbd_ops;
sprintf(disk->disk_name, "drbd%d", minor); sprintf(disk->disk_name, "drbd%d", minor);
disk->private_data = device; disk->private_data = device;
blk_queue_write_cache(q, true, true); blk_queue_write_cache(disk->queue, true, true);
/* Setting the max_hw_sectors to an odd value of 8kibyte here /* Setting the max_hw_sectors to an odd value of 8kibyte here
This triggers a max_bio_size message upon first attach or connect */ This triggers a max_bio_size message upon first attach or connect */
blk_queue_max_hw_sectors(q, DRBD_MAX_BIO_SIZE_SAFE >> 8); blk_queue_max_hw_sectors(disk->queue, DRBD_MAX_BIO_SIZE_SAFE >> 8);
device->md_io.page = alloc_page(GFP_KERNEL); device->md_io.page = alloc_page(GFP_KERNEL);
if (!device->md_io.page) if (!device->md_io.page)
...@@ -2834,10 +2829,8 @@ enum drbd_ret_code drbd_create_device(struct drbd_config_context *adm_ctx, unsig ...@@ -2834,10 +2829,8 @@ enum drbd_ret_code drbd_create_device(struct drbd_config_context *adm_ctx, unsig
out_no_bitmap: out_no_bitmap:
__free_page(device->md_io.page); __free_page(device->md_io.page);
out_no_io_page: out_no_io_page:
put_disk(disk); blk_cleanup_disk(disk);
out_no_disk: out_no_disk:
blk_cleanup_queue(q);
out_no_q:
kref_put(&resource->kref, drbd_destroy_resource); kref_put(&resource->kref, drbd_destroy_resource);
kfree(device); kfree(device);
return err; return err;
......
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