blk-sysfs.c (0f69288253e9fc7c495047720e523b9f1aba5712) blk-sysfs.c (20f01f163203666010ee1560852590a0c0572726)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Functions related to sysfs handling
4 */
5#include <linux/kernel.h>
6#include <linux/slab.h>
7#include <linux/module.h>
8#include <linux/bio.h>

--- 866 unchanged lines hidden (view full) ---

875 goto put_dev;
876
877 if (q->elevator) {
878 ret = elv_register_queue(q, false);
879 if (ret)
880 goto put_dev;
881 }
882
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Functions related to sysfs handling
4 */
5#include <linux/kernel.h>
6#include <linux/slab.h>
7#include <linux/module.h>
8#include <linux/bio.h>

--- 866 unchanged lines hidden (view full) ---

875 goto put_dev;
876
877 if (q->elevator) {
878 ret = elv_register_queue(q, false);
879 if (ret)
880 goto put_dev;
881 }
882
883 ret = blk_crypto_sysfs_register(q);
884 if (ret)
885 goto put_dev;
886
883 blk_queue_flag_set(QUEUE_FLAG_REGISTERED, q);
884 wbt_enable_default(q);
885 blk_throtl_register_queue(q);
886
887 /* Now everything is ready and send out KOBJ_ADD uevent */
888 kobject_uevent(&q->kobj, KOBJ_ADD);
889 if (q->elevator)
890 kobject_uevent(&q->elevator->kobj, KOBJ_ADD);

--- 14 unchanged lines hidden (view full) ---

905 if (!blk_queue_init_done(q)) {
906 blk_queue_flag_set(QUEUE_FLAG_INIT_DONE, q);
907 percpu_ref_switch_to_percpu(&q->q_usage_counter);
908 }
909
910 return ret;
911
912put_dev:
887 blk_queue_flag_set(QUEUE_FLAG_REGISTERED, q);
888 wbt_enable_default(q);
889 blk_throtl_register_queue(q);
890
891 /* Now everything is ready and send out KOBJ_ADD uevent */
892 kobject_uevent(&q->kobj, KOBJ_ADD);
893 if (q->elevator)
894 kobject_uevent(&q->elevator->kobj, KOBJ_ADD);

--- 14 unchanged lines hidden (view full) ---

909 if (!blk_queue_init_done(q)) {
910 blk_queue_flag_set(QUEUE_FLAG_INIT_DONE, q);
911 percpu_ref_switch_to_percpu(&q->q_usage_counter);
912 }
913
914 return ret;
915
916put_dev:
917 elv_unregister_queue(q);
913 disk_unregister_independent_access_ranges(disk);
914 mutex_unlock(&q->sysfs_lock);
915 mutex_unlock(&q->sysfs_dir_lock);
916 kobject_del(&q->kobj);
917 blk_trace_remove_sysfs(dev);
918 kobject_put(&dev->kobj);
919
920 return ret;

--- 28 unchanged lines hidden (view full) ---

949
950 mutex_lock(&q->sysfs_dir_lock);
951 /*
952 * Remove the sysfs attributes before unregistering the queue data
953 * structures that can be modified through sysfs.
954 */
955 if (queue_is_mq(q))
956 blk_mq_unregister_dev(disk_to_dev(disk), q);
918 disk_unregister_independent_access_ranges(disk);
919 mutex_unlock(&q->sysfs_lock);
920 mutex_unlock(&q->sysfs_dir_lock);
921 kobject_del(&q->kobj);
922 blk_trace_remove_sysfs(dev);
923 kobject_put(&dev->kobj);
924
925 return ret;

--- 28 unchanged lines hidden (view full) ---

954
955 mutex_lock(&q->sysfs_dir_lock);
956 /*
957 * Remove the sysfs attributes before unregistering the queue data
958 * structures that can be modified through sysfs.
959 */
960 if (queue_is_mq(q))
961 blk_mq_unregister_dev(disk_to_dev(disk), q);
962 blk_crypto_sysfs_unregister(q);
957 blk_trace_remove_sysfs(disk_to_dev(disk));
958
959 mutex_lock(&q->sysfs_lock);
960 elv_unregister_queue(q);
961 disk_unregister_independent_access_ranges(disk);
962 mutex_unlock(&q->sysfs_lock);
963
964 /* Now that we've deleted all child objects, we can delete the queue. */
965 kobject_uevent(&q->kobj, KOBJ_REMOVE);
966 kobject_del(&q->kobj);
967
968 mutex_unlock(&q->sysfs_dir_lock);
969
970 kobject_put(&disk_to_dev(disk)->kobj);
971}
963 blk_trace_remove_sysfs(disk_to_dev(disk));
964
965 mutex_lock(&q->sysfs_lock);
966 elv_unregister_queue(q);
967 disk_unregister_independent_access_ranges(disk);
968 mutex_unlock(&q->sysfs_lock);
969
970 /* Now that we've deleted all child objects, we can delete the queue. */
971 kobject_uevent(&q->kobj, KOBJ_REMOVE);
972 kobject_del(&q->kobj);
973
974 mutex_unlock(&q->sysfs_dir_lock);
975
976 kobject_put(&disk_to_dev(disk)->kobj);
977}