mirror of https://gitee.com/openkylin/linux.git
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: Christoph Hellwig <hch@lst.de> Reviewed-by: Hannes Reinecke <hare@suse.de> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org> Link: https://lore.kernel.org/r/20210521055116.1053587-8-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
7f9b348cb5
commit
b647ad0248
|
@ -2231,8 +2231,7 @@ void drbd_destroy_device(struct kref *kref)
|
|||
if (device->bitmap) /* should no longer be there. */
|
||||
drbd_bm_cleanup(device);
|
||||
__free_page(device->md_io.page);
|
||||
put_disk(device->vdisk);
|
||||
blk_cleanup_queue(device->rq_queue);
|
||||
blk_cleanup_disk(device->vdisk);
|
||||
kfree(device->rs_plan_s);
|
||||
|
||||
/* not for_each_connection(connection, resource):
|
||||
|
@ -2701,7 +2700,6 @@ enum drbd_ret_code drbd_create_device(struct drbd_config_context *adm_ctx, unsig
|
|||
struct drbd_device *device;
|
||||
struct drbd_peer_device *peer_device, *tmp_peer_device;
|
||||
struct gendisk *disk;
|
||||
struct request_queue *q;
|
||||
int id;
|
||||
int vnr = adm_ctx->volume;
|
||||
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
|
|||
|
||||
drbd_init_set_defaults(device);
|
||||
|
||||
q = blk_alloc_queue(NUMA_NO_NODE);
|
||||
if (!q)
|
||||
goto out_no_q;
|
||||
device->rq_queue = q;
|
||||
|
||||
disk = alloc_disk(1);
|
||||
disk = blk_alloc_disk(NUMA_NO_NODE);
|
||||
if (!disk)
|
||||
goto out_no_disk;
|
||||
|
||||
device->vdisk = disk;
|
||||
device->rq_queue = disk->queue;
|
||||
|
||||
set_disk_ro(disk, true);
|
||||
|
||||
disk->queue = q;
|
||||
disk->major = DRBD_MAJOR;
|
||||
disk->first_minor = minor;
|
||||
disk->minors = 1;
|
||||
disk->fops = &drbd_ops;
|
||||
sprintf(disk->disk_name, "drbd%d", minor);
|
||||
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
|
||||
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);
|
||||
if (!device->md_io.page)
|
||||
|
@ -2834,10 +2829,8 @@ enum drbd_ret_code drbd_create_device(struct drbd_config_context *adm_ctx, unsig
|
|||
out_no_bitmap:
|
||||
__free_page(device->md_io.page);
|
||||
out_no_io_page:
|
||||
put_disk(disk);
|
||||
blk_cleanup_disk(disk);
|
||||
out_no_disk:
|
||||
blk_cleanup_queue(q);
|
||||
out_no_q:
|
||||
kref_put(&resource->kref, drbd_destroy_resource);
|
||||
kfree(device);
|
||||
return err;
|
||||
|
|
Loading…
Reference in New Issue