diff options
Diffstat (limited to 'block/blk-cgroup.c')
-rw-r--r-- | block/blk-cgroup.c | 54 |
1 files changed, 40 insertions, 14 deletions
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index 61553670735d..8f630cec906e 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c | |||
@@ -869,60 +869,86 @@ unsigned int blkcg_get_weight(struct blkio_cgroup *blkcg, | |||
869 | dev_t dev) | 869 | dev_t dev) |
870 | { | 870 | { |
871 | struct blkio_policy_node *pn; | 871 | struct blkio_policy_node *pn; |
872 | unsigned long flags; | ||
873 | unsigned int weight; | ||
874 | |||
875 | spin_lock_irqsave(&blkcg->lock, flags); | ||
872 | 876 | ||
873 | pn = blkio_policy_search_node(blkcg, dev, BLKIO_POLICY_PROP, | 877 | pn = blkio_policy_search_node(blkcg, dev, BLKIO_POLICY_PROP, |
874 | BLKIO_PROP_weight_device); | 878 | BLKIO_PROP_weight_device); |
875 | if (pn) | 879 | if (pn) |
876 | return pn->val.weight; | 880 | weight = pn->val.weight; |
877 | else | 881 | else |
878 | return blkcg->weight; | 882 | weight = blkcg->weight; |
883 | |||
884 | spin_unlock_irqrestore(&blkcg->lock, flags); | ||
885 | |||
886 | return weight; | ||
879 | } | 887 | } |
880 | EXPORT_SYMBOL_GPL(blkcg_get_weight); | 888 | EXPORT_SYMBOL_GPL(blkcg_get_weight); |
881 | 889 | ||
882 | uint64_t blkcg_get_read_bps(struct blkio_cgroup *blkcg, dev_t dev) | 890 | uint64_t blkcg_get_read_bps(struct blkio_cgroup *blkcg, dev_t dev) |
883 | { | 891 | { |
884 | struct blkio_policy_node *pn; | 892 | struct blkio_policy_node *pn; |
893 | unsigned long flags; | ||
894 | uint64_t bps = -1; | ||
885 | 895 | ||
896 | spin_lock_irqsave(&blkcg->lock, flags); | ||
886 | pn = blkio_policy_search_node(blkcg, dev, BLKIO_POLICY_THROTL, | 897 | pn = blkio_policy_search_node(blkcg, dev, BLKIO_POLICY_THROTL, |
887 | BLKIO_THROTL_read_bps_device); | 898 | BLKIO_THROTL_read_bps_device); |
888 | if (pn) | 899 | if (pn) |
889 | return pn->val.bps; | 900 | bps = pn->val.bps; |
890 | else | 901 | spin_unlock_irqrestore(&blkcg->lock, flags); |
891 | return -1; | 902 | |
903 | return bps; | ||
892 | } | 904 | } |
893 | 905 | ||
894 | uint64_t blkcg_get_write_bps(struct blkio_cgroup *blkcg, dev_t dev) | 906 | uint64_t blkcg_get_write_bps(struct blkio_cgroup *blkcg, dev_t dev) |
895 | { | 907 | { |
896 | struct blkio_policy_node *pn; | 908 | struct blkio_policy_node *pn; |
909 | unsigned long flags; | ||
910 | uint64_t bps = -1; | ||
911 | |||
912 | spin_lock_irqsave(&blkcg->lock, flags); | ||
897 | pn = blkio_policy_search_node(blkcg, dev, BLKIO_POLICY_THROTL, | 913 | pn = blkio_policy_search_node(blkcg, dev, BLKIO_POLICY_THROTL, |
898 | BLKIO_THROTL_write_bps_device); | 914 | BLKIO_THROTL_write_bps_device); |
899 | if (pn) | 915 | if (pn) |
900 | return pn->val.bps; | 916 | bps = pn->val.bps; |
901 | else | 917 | spin_unlock_irqrestore(&blkcg->lock, flags); |
902 | return -1; | 918 | |
919 | return bps; | ||
903 | } | 920 | } |
904 | 921 | ||
905 | unsigned int blkcg_get_read_iops(struct blkio_cgroup *blkcg, dev_t dev) | 922 | unsigned int blkcg_get_read_iops(struct blkio_cgroup *blkcg, dev_t dev) |
906 | { | 923 | { |
907 | struct blkio_policy_node *pn; | 924 | struct blkio_policy_node *pn; |
925 | unsigned long flags; | ||
926 | unsigned int iops = -1; | ||
908 | 927 | ||
928 | spin_lock_irqsave(&blkcg->lock, flags); | ||
909 | pn = blkio_policy_search_node(blkcg, dev, BLKIO_POLICY_THROTL, | 929 | pn = blkio_policy_search_node(blkcg, dev, BLKIO_POLICY_THROTL, |
910 | BLKIO_THROTL_read_iops_device); | 930 | BLKIO_THROTL_read_iops_device); |
911 | if (pn) | 931 | if (pn) |
912 | return pn->val.iops; | 932 | iops = pn->val.iops; |
913 | else | 933 | spin_unlock_irqrestore(&blkcg->lock, flags); |
914 | return -1; | 934 | |
935 | return iops; | ||
915 | } | 936 | } |
916 | 937 | ||
917 | unsigned int blkcg_get_write_iops(struct blkio_cgroup *blkcg, dev_t dev) | 938 | unsigned int blkcg_get_write_iops(struct blkio_cgroup *blkcg, dev_t dev) |
918 | { | 939 | { |
919 | struct blkio_policy_node *pn; | 940 | struct blkio_policy_node *pn; |
941 | unsigned long flags; | ||
942 | unsigned int iops = -1; | ||
943 | |||
944 | spin_lock_irqsave(&blkcg->lock, flags); | ||
920 | pn = blkio_policy_search_node(blkcg, dev, BLKIO_POLICY_THROTL, | 945 | pn = blkio_policy_search_node(blkcg, dev, BLKIO_POLICY_THROTL, |
921 | BLKIO_THROTL_write_iops_device); | 946 | BLKIO_THROTL_write_iops_device); |
922 | if (pn) | 947 | if (pn) |
923 | return pn->val.iops; | 948 | iops = pn->val.iops; |
924 | else | 949 | spin_unlock_irqrestore(&blkcg->lock, flags); |
925 | return -1; | 950 | |
951 | return iops; | ||
926 | } | 952 | } |
927 | 953 | ||
928 | /* Checks whether user asked for deleting a policy rule */ | 954 | /* Checks whether user asked for deleting a policy rule */ |