Commit 7a671a1c authored by Zhong Jinghua's avatar Zhong Jinghua Committed by Li Nan
Browse files

block: call blk_get_queue earlier in __device_add_disk



hulk inclusion
category: bugfix
bugzilla: 188733

----------------------------------------

When adding a disk, first obtain the reference count of the request_queue,
and release the reference count when error handling, which will make it
easier for the driver to add error handling.

Signed-off-by: default avatarZhong Jinghua <zhongjinghua@huawei.com>
Signed-off-by: default avatarLi Nan <linan122@huawei.com>
parent a3163431
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -777,6 +777,11 @@ static int __device_add_disk(struct device *parent, struct gendisk *disk,
	dev_t devt;
	int retval;

	/*
	 * Take an extra ref on queue which will be put on disk_release()
	 * so that it sticks around as long as @disk is there.
	 */
	WARN_ON_ONCE(!blk_get_queue(disk->queue));
	/*
	 * The disk queue should now be all set with enough information about
	 * the device for the elevator code to pick an adequate default
@@ -884,12 +889,6 @@ static int __device_add_disk(struct device *parent, struct gendisk *disk,
			goto out_del_bdi_sysfs_link;
	}

	/*
	 * Take an extra ref on queue which will be put on disk_release()
	 * so that it sticks around as long as @disk is there.
	 */
	WARN_ON_ONCE(!blk_get_queue(disk->queue));

	disk_add_events(disk);

	/* Make sure the first partition scan will be proceed */