diff options
| -rw-r--r-- | block/blk-mq-debugfs.c | 145 | ||||
| -rw-r--r-- | block/blk-mq-debugfs.h | 36 |
2 files changed, 49 insertions, 132 deletions
diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c index 6aea0ebc3a73..2489ddbb21db 100644 --- a/block/blk-mq-debugfs.c +++ b/block/blk-mq-debugfs.c | |||
| @@ -821,38 +821,28 @@ static const struct blk_mq_debugfs_attr blk_mq_debugfs_ctx_attrs[] = { | |||
| 821 | {}, | 821 | {}, |
| 822 | }; | 822 | }; |
| 823 | 823 | ||
| 824 | static bool debugfs_create_files(struct dentry *parent, void *data, | 824 | static void debugfs_create_files(struct dentry *parent, void *data, |
| 825 | const struct blk_mq_debugfs_attr *attr) | 825 | const struct blk_mq_debugfs_attr *attr) |
| 826 | { | 826 | { |
| 827 | if (IS_ERR_OR_NULL(parent)) | 827 | if (IS_ERR_OR_NULL(parent)) |
| 828 | return false; | 828 | return; |
| 829 | 829 | ||
| 830 | d_inode(parent)->i_private = data; | 830 | d_inode(parent)->i_private = data; |
| 831 | 831 | ||
| 832 | for (; attr->name; attr++) { | 832 | for (; attr->name; attr++) |
| 833 | if (!debugfs_create_file(attr->name, attr->mode, parent, | 833 | debugfs_create_file(attr->name, attr->mode, parent, |
| 834 | (void *)attr, &blk_mq_debugfs_fops)) | 834 | (void *)attr, &blk_mq_debugfs_fops); |
| 835 | return false; | ||
| 836 | } | ||
| 837 | return true; | ||
| 838 | } | 835 | } |
| 839 | 836 | ||
| 840 | int blk_mq_debugfs_register(struct request_queue *q) | 837 | void blk_mq_debugfs_register(struct request_queue *q) |
| 841 | { | 838 | { |
| 842 | struct blk_mq_hw_ctx *hctx; | 839 | struct blk_mq_hw_ctx *hctx; |
| 843 | int i; | 840 | int i; |
| 844 | 841 | ||
| 845 | if (!blk_debugfs_root) | ||
| 846 | return -ENOENT; | ||
| 847 | |||
| 848 | q->debugfs_dir = debugfs_create_dir(kobject_name(q->kobj.parent), | 842 | q->debugfs_dir = debugfs_create_dir(kobject_name(q->kobj.parent), |
| 849 | blk_debugfs_root); | 843 | blk_debugfs_root); |
| 850 | if (!q->debugfs_dir) | ||
| 851 | return -ENOMEM; | ||
| 852 | 844 | ||
| 853 | if (!debugfs_create_files(q->debugfs_dir, q, | 845 | debugfs_create_files(q->debugfs_dir, q, blk_mq_debugfs_queue_attrs); |
| 854 | blk_mq_debugfs_queue_attrs)) | ||
| 855 | goto err; | ||
| 856 | 846 | ||
| 857 | /* | 847 | /* |
| 858 | * blk_mq_init_sched() attempted to do this already, but q->debugfs_dir | 848 | * blk_mq_init_sched() attempted to do this already, but q->debugfs_dir |
| @@ -864,11 +854,10 @@ int blk_mq_debugfs_register(struct request_queue *q) | |||
| 864 | 854 | ||
| 865 | /* Similarly, blk_mq_init_hctx() couldn't do this previously. */ | 855 | /* Similarly, blk_mq_init_hctx() couldn't do this previously. */ |
| 866 | queue_for_each_hw_ctx(q, hctx, i) { | 856 | queue_for_each_hw_ctx(q, hctx, i) { |
| 867 | if (!hctx->debugfs_dir && blk_mq_debugfs_register_hctx(q, hctx)) | 857 | if (!hctx->debugfs_dir) |
| 868 | goto err; | 858 | blk_mq_debugfs_register_hctx(q, hctx); |
| 869 | if (q->elevator && !hctx->sched_debugfs_dir && | 859 | if (q->elevator && !hctx->sched_debugfs_dir) |
| 870 | blk_mq_debugfs_register_sched_hctx(q, hctx)) | 860 | blk_mq_debugfs_register_sched_hctx(q, hctx); |
| 871 | goto err; | ||
| 872 | } | 861 | } |
| 873 | 862 | ||
| 874 | if (q->rq_qos) { | 863 | if (q->rq_qos) { |
| @@ -879,12 +868,6 @@ int blk_mq_debugfs_register(struct request_queue *q) | |||
| 879 | rqos = rqos->next; | 868 | rqos = rqos->next; |
| 880 | } | 869 | } |
| 881 | } | 870 | } |
| 882 | |||
| 883 | return 0; | ||
| 884 | |||
| 885 | err: | ||
| 886 | blk_mq_debugfs_unregister(q); | ||
| 887 | return -ENOMEM; | ||
| 888 | } | 871 | } |
| 889 | 872 | ||
| 890 | void blk_mq_debugfs_unregister(struct request_queue *q) | 873 | void blk_mq_debugfs_unregister(struct request_queue *q) |
| @@ -894,52 +877,32 @@ void blk_mq_debugfs_unregister(struct request_queue *q) | |||
| 894 | q->debugfs_dir = NULL; | 877 | q->debugfs_dir = NULL; |
| 895 | } | 878 | } |
| 896 | 879 | ||
| 897 | static int blk_mq_debugfs_register_ctx(struct blk_mq_hw_ctx *hctx, | 880 | static void blk_mq_debugfs_register_ctx(struct blk_mq_hw_ctx *hctx, |
| 898 | struct blk_mq_ctx *ctx) | 881 | struct blk_mq_ctx *ctx) |
| 899 | { | 882 | { |
| 900 | struct dentry *ctx_dir; | 883 | struct dentry *ctx_dir; |
| 901 | char name[20]; | 884 | char name[20]; |
| 902 | 885 | ||
| 903 | snprintf(name, sizeof(name), "cpu%u", ctx->cpu); | 886 | snprintf(name, sizeof(name), "cpu%u", ctx->cpu); |
| 904 | ctx_dir = debugfs_create_dir(name, hctx->debugfs_dir); | 887 | ctx_dir = debugfs_create_dir(name, hctx->debugfs_dir); |
| 905 | if (!ctx_dir) | ||
| 906 | return -ENOMEM; | ||
| 907 | 888 | ||
| 908 | if (!debugfs_create_files(ctx_dir, ctx, blk_mq_debugfs_ctx_attrs)) | 889 | debugfs_create_files(ctx_dir, ctx, blk_mq_debugfs_ctx_attrs); |
| 909 | return -ENOMEM; | ||
| 910 | |||
| 911 | return 0; | ||
| 912 | } | 890 | } |
| 913 | 891 | ||
| 914 | int blk_mq_debugfs_register_hctx(struct request_queue *q, | 892 | void blk_mq_debugfs_register_hctx(struct request_queue *q, |
| 915 | struct blk_mq_hw_ctx *hctx) | 893 | struct blk_mq_hw_ctx *hctx) |
| 916 | { | 894 | { |
| 917 | struct blk_mq_ctx *ctx; | 895 | struct blk_mq_ctx *ctx; |
| 918 | char name[20]; | 896 | char name[20]; |
| 919 | int i; | 897 | int i; |
| 920 | 898 | ||
| 921 | if (!q->debugfs_dir) | ||
| 922 | return -ENOENT; | ||
| 923 | |||
| 924 | snprintf(name, sizeof(name), "hctx%u", hctx->queue_num); | 899 | snprintf(name, sizeof(name), "hctx%u", hctx->queue_num); |
| 925 | hctx->debugfs_dir = debugfs_create_dir(name, q->debugfs_dir); | 900 | hctx->debugfs_dir = debugfs_create_dir(name, q->debugfs_dir); |
| 926 | if (!hctx->debugfs_dir) | ||
| 927 | return -ENOMEM; | ||
| 928 | |||
| 929 | if (!debugfs_create_files(hctx->debugfs_dir, hctx, | ||
| 930 | blk_mq_debugfs_hctx_attrs)) | ||
| 931 | goto err; | ||
| 932 | |||
| 933 | hctx_for_each_ctx(hctx, ctx, i) { | ||
| 934 | if (blk_mq_debugfs_register_ctx(hctx, ctx)) | ||
| 935 | goto err; | ||
| 936 | } | ||
| 937 | 901 | ||
| 938 | return 0; | 902 | debugfs_create_files(hctx->debugfs_dir, hctx, blk_mq_debugfs_hctx_attrs); |
| 939 | 903 | ||
| 940 | err: | 904 | hctx_for_each_ctx(hctx, ctx, i) |
| 941 | blk_mq_debugfs_unregister_hctx(hctx); | 905 | blk_mq_debugfs_register_ctx(hctx, ctx); |
| 942 | return -ENOMEM; | ||
| 943 | } | 906 | } |
| 944 | 907 | ||
| 945 | void blk_mq_debugfs_unregister_hctx(struct blk_mq_hw_ctx *hctx) | 908 | void blk_mq_debugfs_unregister_hctx(struct blk_mq_hw_ctx *hctx) |
| @@ -949,17 +912,13 @@ void blk_mq_debugfs_unregister_hctx(struct blk_mq_hw_ctx *hctx) | |||
| 949 | hctx->debugfs_dir = NULL; | 912 | hctx->debugfs_dir = NULL; |
| 950 | } | 913 | } |
| 951 | 914 | ||
| 952 | int blk_mq_debugfs_register_hctxs(struct request_queue *q) | 915 | void blk_mq_debugfs_register_hctxs(struct request_queue *q) |
| 953 | { | 916 | { |
| 954 | struct blk_mq_hw_ctx *hctx; | 917 | struct blk_mq_hw_ctx *hctx; |
| 955 | int i; | 918 | int i; |
| 956 | 919 | ||
| 957 | queue_for_each_hw_ctx(q, hctx, i) { | 920 | queue_for_each_hw_ctx(q, hctx, i) |
| 958 | if (blk_mq_debugfs_register_hctx(q, hctx)) | 921 | blk_mq_debugfs_register_hctx(q, hctx); |
| 959 | return -ENOMEM; | ||
| 960 | } | ||
| 961 | |||
| 962 | return 0; | ||
| 963 | } | 922 | } |
| 964 | 923 | ||
| 965 | void blk_mq_debugfs_unregister_hctxs(struct request_queue *q) | 924 | void blk_mq_debugfs_unregister_hctxs(struct request_queue *q) |
| @@ -971,29 +930,16 @@ void blk_mq_debugfs_unregister_hctxs(struct request_queue *q) | |||
| 971 | blk_mq_debugfs_unregister_hctx(hctx); | 930 | blk_mq_debugfs_unregister_hctx(hctx); |
| 972 | } | 931 | } |
| 973 | 932 | ||
| 974 | int blk_mq_debugfs_register_sched(struct request_queue *q) | 933 | void blk_mq_debugfs_register_sched(struct request_queue *q) |
| 975 | { | 934 | { |
| 976 | struct elevator_type *e = q->elevator->type; | 935 | struct elevator_type *e = q->elevator->type; |
| 977 | 936 | ||
| 978 | if (!q->debugfs_dir) | ||
| 979 | return -ENOENT; | ||
| 980 | |||
| 981 | if (!e->queue_debugfs_attrs) | 937 | if (!e->queue_debugfs_attrs) |
| 982 | return 0; | 938 | return; |
| 983 | 939 | ||
| 984 | q->sched_debugfs_dir = debugfs_create_dir("sched", q->debugfs_dir); | 940 | q->sched_debugfs_dir = debugfs_create_dir("sched", q->debugfs_dir); |
| 985 | if (!q->sched_debugfs_dir) | ||
| 986 | return -ENOMEM; | ||
| 987 | 941 | ||
| 988 | if (!debugfs_create_files(q->sched_debugfs_dir, q, | 942 | debugfs_create_files(q->sched_debugfs_dir, q, e->queue_debugfs_attrs); |
| 989 | e->queue_debugfs_attrs)) | ||
| 990 | goto err; | ||
| 991 | |||
| 992 | return 0; | ||
| 993 | |||
| 994 | err: | ||
| 995 | blk_mq_debugfs_unregister_sched(q); | ||
| 996 | return -ENOMEM; | ||
| 997 | } | 943 | } |
| 998 | 944 | ||
| 999 | void blk_mq_debugfs_unregister_sched(struct request_queue *q) | 945 | void blk_mq_debugfs_unregister_sched(struct request_queue *q) |
| @@ -1008,36 +954,22 @@ void blk_mq_debugfs_unregister_rqos(struct rq_qos *rqos) | |||
| 1008 | rqos->debugfs_dir = NULL; | 954 | rqos->debugfs_dir = NULL; |
| 1009 | } | 955 | } |
| 1010 | 956 | ||
| 1011 | int blk_mq_debugfs_register_rqos(struct rq_qos *rqos) | 957 | void blk_mq_debugfs_register_rqos(struct rq_qos *rqos) |
| 1012 | { | 958 | { |
| 1013 | struct request_queue *q = rqos->q; | 959 | struct request_queue *q = rqos->q; |
| 1014 | const char *dir_name = rq_qos_id_to_name(rqos->id); | 960 | const char *dir_name = rq_qos_id_to_name(rqos->id); |
| 1015 | 961 | ||
| 1016 | if (!q->debugfs_dir) | ||
| 1017 | return -ENOENT; | ||
| 1018 | |||
| 1019 | if (rqos->debugfs_dir || !rqos->ops->debugfs_attrs) | 962 | if (rqos->debugfs_dir || !rqos->ops->debugfs_attrs) |
| 1020 | return 0; | 963 | return; |
| 1021 | 964 | ||
| 1022 | if (!q->rqos_debugfs_dir) { | 965 | if (!q->rqos_debugfs_dir) |
| 1023 | q->rqos_debugfs_dir = debugfs_create_dir("rqos", | 966 | q->rqos_debugfs_dir = debugfs_create_dir("rqos", |
| 1024 | q->debugfs_dir); | 967 | q->debugfs_dir); |
| 1025 | if (!q->rqos_debugfs_dir) | ||
| 1026 | return -ENOMEM; | ||
| 1027 | } | ||
| 1028 | 968 | ||
| 1029 | rqos->debugfs_dir = debugfs_create_dir(dir_name, | 969 | rqos->debugfs_dir = debugfs_create_dir(dir_name, |
| 1030 | rqos->q->rqos_debugfs_dir); | 970 | rqos->q->rqos_debugfs_dir); |
| 1031 | if (!rqos->debugfs_dir) | ||
| 1032 | return -ENOMEM; | ||
| 1033 | 971 | ||
| 1034 | if (!debugfs_create_files(rqos->debugfs_dir, rqos, | 972 | debugfs_create_files(rqos->debugfs_dir, rqos, rqos->ops->debugfs_attrs); |
| 1035 | rqos->ops->debugfs_attrs)) | ||
| 1036 | goto err; | ||
| 1037 | return 0; | ||
| 1038 | err: | ||
| 1039 | blk_mq_debugfs_unregister_rqos(rqos); | ||
| 1040 | return -ENOMEM; | ||
| 1041 | } | 973 | } |
| 1042 | 974 | ||
| 1043 | void blk_mq_debugfs_unregister_queue_rqos(struct request_queue *q) | 975 | void blk_mq_debugfs_unregister_queue_rqos(struct request_queue *q) |
| @@ -1046,27 +978,18 @@ void blk_mq_debugfs_unregister_queue_rqos(struct request_queue *q) | |||
| 1046 | q->rqos_debugfs_dir = NULL; | 978 | q->rqos_debugfs_dir = NULL; |
| 1047 | } | 979 | } |
| 1048 | 980 | ||
| 1049 | int blk_mq_debugfs_register_sched_hctx(struct request_queue *q, | 981 | void blk_mq_debugfs_register_sched_hctx(struct request_queue *q, |
| 1050 | struct blk_mq_hw_ctx *hctx) | 982 | struct blk_mq_hw_ctx *hctx) |
| 1051 | { | 983 | { |
| 1052 | struct elevator_type *e = q->elevator->type; | 984 | struct elevator_type *e = q->elevator->type; |
| 1053 | 985 | ||
| 1054 | if (!hctx->debugfs_dir) | ||
| 1055 | return -ENOENT; | ||
| 1056 | |||
| 1057 | if (!e->hctx_debugfs_attrs) | 986 | if (!e->hctx_debugfs_attrs) |
| 1058 | return 0; | 987 | return; |
| 1059 | 988 | ||
| 1060 | hctx->sched_debugfs_dir = debugfs_create_dir("sched", | 989 | hctx->sched_debugfs_dir = debugfs_create_dir("sched", |
| 1061 | hctx->debugfs_dir); | 990 | hctx->debugfs_dir); |
| 1062 | if (!hctx->sched_debugfs_dir) | 991 | debugfs_create_files(hctx->sched_debugfs_dir, hctx, |
| 1063 | return -ENOMEM; | 992 | e->hctx_debugfs_attrs); |
| 1064 | |||
| 1065 | if (!debugfs_create_files(hctx->sched_debugfs_dir, hctx, | ||
| 1066 | e->hctx_debugfs_attrs)) | ||
| 1067 | return -ENOMEM; | ||
| 1068 | |||
| 1069 | return 0; | ||
| 1070 | } | 993 | } |
| 1071 | 994 | ||
| 1072 | void blk_mq_debugfs_unregister_sched_hctx(struct blk_mq_hw_ctx *hctx) | 995 | void blk_mq_debugfs_unregister_sched_hctx(struct blk_mq_hw_ctx *hctx) |
diff --git a/block/blk-mq-debugfs.h b/block/blk-mq-debugfs.h index 8c9012a578c1..a68aa6041a10 100644 --- a/block/blk-mq-debugfs.h +++ b/block/blk-mq-debugfs.h | |||
| @@ -18,74 +18,68 @@ struct blk_mq_debugfs_attr { | |||
| 18 | int __blk_mq_debugfs_rq_show(struct seq_file *m, struct request *rq); | 18 | int __blk_mq_debugfs_rq_show(struct seq_file *m, struct request *rq); |
| 19 | int blk_mq_debugfs_rq_show(struct seq_file *m, void *v); | 19 | int blk_mq_debugfs_rq_show(struct seq_file *m, void *v); |
| 20 | 20 | ||
| 21 | int blk_mq_debugfs_register(struct request_queue *q); | 21 | void blk_mq_debugfs_register(struct request_queue *q); |
| 22 | void blk_mq_debugfs_unregister(struct request_queue *q); | 22 | void blk_mq_debugfs_unregister(struct request_queue *q); |
| 23 | int blk_mq_debugfs_register_hctx(struct request_queue *q, | 23 | void blk_mq_debugfs_register_hctx(struct request_queue *q, |
| 24 | struct blk_mq_hw_ctx *hctx); | 24 | struct blk_mq_hw_ctx *hctx); |
| 25 | void blk_mq_debugfs_unregister_hctx(struct blk_mq_hw_ctx *hctx); | 25 | void blk_mq_debugfs_unregister_hctx(struct blk_mq_hw_ctx *hctx); |
| 26 | int blk_mq_debugfs_register_hctxs(struct request_queue *q); | 26 | void blk_mq_debugfs_register_hctxs(struct request_queue *q); |
| 27 | void blk_mq_debugfs_unregister_hctxs(struct request_queue *q); | 27 | void blk_mq_debugfs_unregister_hctxs(struct request_queue *q); |
| 28 | 28 | ||
| 29 | int blk_mq_debugfs_register_sched(struct request_queue *q); | 29 | void blk_mq_debugfs_register_sched(struct request_queue *q); |
| 30 | void blk_mq_debugfs_unregister_sched(struct request_queue *q); | 30 | void blk_mq_debugfs_unregister_sched(struct request_queue *q); |
| 31 | int blk_mq_debugfs_register_sched_hctx(struct request_queue *q, | 31 | void blk_mq_debugfs_register_sched_hctx(struct request_queue *q, |
| 32 | struct blk_mq_hw_ctx *hctx); | 32 | struct blk_mq_hw_ctx *hctx); |
| 33 | void blk_mq_debugfs_unregister_sched_hctx(struct blk_mq_hw_ctx *hctx); | 33 | void blk_mq_debugfs_unregister_sched_hctx(struct blk_mq_hw_ctx *hctx); |
| 34 | 34 | ||
| 35 | int blk_mq_debugfs_register_rqos(struct rq_qos *rqos); | 35 | void blk_mq_debugfs_register_rqos(struct rq_qos *rqos); |
| 36 | void blk_mq_debugfs_unregister_rqos(struct rq_qos *rqos); | 36 | void blk_mq_debugfs_unregister_rqos(struct rq_qos *rqos); |
| 37 | void blk_mq_debugfs_unregister_queue_rqos(struct request_queue *q); | 37 | void blk_mq_debugfs_unregister_queue_rqos(struct request_queue *q); |
| 38 | #else | 38 | #else |
| 39 | static inline int blk_mq_debugfs_register(struct request_queue *q) | 39 | static inline void blk_mq_debugfs_register(struct request_queue *q) |
| 40 | { | 40 | { |
| 41 | return 0; | ||
| 42 | } | 41 | } |
| 43 | 42 | ||
| 44 | static inline void blk_mq_debugfs_unregister(struct request_queue *q) | 43 | static inline void blk_mq_debugfs_unregister(struct request_queue *q) |
| 45 | { | 44 | { |
| 46 | } | 45 | } |
| 47 | 46 | ||
| 48 | static inline int blk_mq_debugfs_register_hctx(struct request_queue *q, | 47 | static inline void blk_mq_debugfs_register_hctx(struct request_queue *q, |
| 49 | struct blk_mq_hw_ctx *hctx) | 48 | struct blk_mq_hw_ctx *hctx) |
| 50 | { | 49 | { |
| 51 | return 0; | ||
| 52 | } | 50 | } |
| 53 | 51 | ||
| 54 | static inline void blk_mq_debugfs_unregister_hctx(struct blk_mq_hw_ctx *hctx) | 52 | static inline void blk_mq_debugfs_unregister_hctx(struct blk_mq_hw_ctx *hctx) |
| 55 | { | 53 | { |
| 56 | } | 54 | } |
| 57 | 55 | ||
| 58 | static inline int blk_mq_debugfs_register_hctxs(struct request_queue *q) | 56 | static inline void blk_mq_debugfs_register_hctxs(struct request_queue *q) |
| 59 | { | 57 | { |
| 60 | return 0; | ||
| 61 | } | 58 | } |
| 62 | 59 | ||
| 63 | static inline void blk_mq_debugfs_unregister_hctxs(struct request_queue *q) | 60 | static inline void blk_mq_debugfs_unregister_hctxs(struct request_queue *q) |
| 64 | { | 61 | { |
| 65 | } | 62 | } |
| 66 | 63 | ||
| 67 | static inline int blk_mq_debugfs_register_sched(struct request_queue *q) | 64 | static inline void blk_mq_debugfs_register_sched(struct request_queue *q) |
| 68 | { | 65 | { |
| 69 | return 0; | ||
| 70 | } | 66 | } |
| 71 | 67 | ||
| 72 | static inline void blk_mq_debugfs_unregister_sched(struct request_queue *q) | 68 | static inline void blk_mq_debugfs_unregister_sched(struct request_queue *q) |
| 73 | { | 69 | { |
| 74 | } | 70 | } |
| 75 | 71 | ||
| 76 | static inline int blk_mq_debugfs_register_sched_hctx(struct request_queue *q, | 72 | static inline void blk_mq_debugfs_register_sched_hctx(struct request_queue *q, |
| 77 | struct blk_mq_hw_ctx *hctx) | 73 | struct blk_mq_hw_ctx *hctx) |
| 78 | { | 74 | { |
| 79 | return 0; | ||
| 80 | } | 75 | } |
| 81 | 76 | ||
| 82 | static inline void blk_mq_debugfs_unregister_sched_hctx(struct blk_mq_hw_ctx *hctx) | 77 | static inline void blk_mq_debugfs_unregister_sched_hctx(struct blk_mq_hw_ctx *hctx) |
| 83 | { | 78 | { |
| 84 | } | 79 | } |
| 85 | 80 | ||
| 86 | static inline int blk_mq_debugfs_register_rqos(struct rq_qos *rqos) | 81 | static inline void blk_mq_debugfs_register_rqos(struct rq_qos *rqos) |
| 87 | { | 82 | { |
| 88 | return 0; | ||
| 89 | } | 83 | } |
| 90 | 84 | ||
| 91 | static inline void blk_mq_debugfs_unregister_rqos(struct rq_qos *rqos) | 85 | static inline void blk_mq_debugfs_unregister_rqos(struct rq_qos *rqos) |
