aboutsummaryrefslogtreecommitdiffstats
path: root/net/ceph
diff options
context:
space:
mode:
authorIlya Dryomov <ilya.dryomov@inktank.com>2014-03-21 13:05:30 -0400
committerSage Weil <sage@inktank.com>2014-04-05 00:08:02 -0400
commit2cfa34f2d67a36e292cbe6e4c1e60d212b7ba4d1 (patch)
tree63ab56e96104a41d950d97b3f6d18e248151325f /net/ceph
parentd286de796aab9e306e674c6d23c4f3c1f55e394c (diff)
libceph: primary_affinity infrastructure
Add primary_affinity infrastructure. primary_affinity values are stored in an max_osd-sized array, hanging off ceph_osdmap, similar to a osd_weight array. Introduce {get,set}_primary_affinity() helpers, primarily to return CEPH_OSD_DEFAULT_PRIMARY_AFFINITY when no affinity has been set and to abstract out osd_primary_affinity array allocation and initialization. Signed-off-by: Ilya Dryomov <ilya.dryomov@inktank.com> Reviewed-by: Alex Elder <elder@linaro.org>
Diffstat (limited to 'net/ceph')
-rw-r--r--net/ceph/debugfs.c5
-rw-r--r--net/ceph/osdmap.c47
2 files changed, 50 insertions, 2 deletions
diff --git a/net/ceph/debugfs.c b/net/ceph/debugfs.c
index 612bf55e6a8b..34453a2b4b4d 100644
--- a/net/ceph/debugfs.c
+++ b/net/ceph/debugfs.c
@@ -77,10 +77,11 @@ static int osdmap_show(struct seq_file *s, void *p)
77 int state = map->osd_state[i]; 77 int state = map->osd_state[i];
78 char sb[64]; 78 char sb[64];
79 79
80 seq_printf(s, "osd%d\t%s\t%3d%%\t(%s)\n", 80 seq_printf(s, "osd%d\t%s\t%3d%%\t(%s)\t%3d%%\n",
81 i, ceph_pr_addr(&addr->in_addr), 81 i, ceph_pr_addr(&addr->in_addr),
82 ((map->osd_weight[i]*100) >> 16), 82 ((map->osd_weight[i]*100) >> 16),
83 ceph_osdmap_state_str(sb, sizeof(sb), state)); 83 ceph_osdmap_state_str(sb, sizeof(sb), state),
84 ((ceph_get_primary_affinity(map, i)*100) >> 16));
84 } 85 }
85 for (n = rb_first(&map->pg_temp); n; n = rb_next(n)) { 86 for (n = rb_first(&map->pg_temp); n; n = rb_next(n)) {
86 struct ceph_pg_mapping *pg = 87 struct ceph_pg_mapping *pg =
diff --git a/net/ceph/osdmap.c b/net/ceph/osdmap.c
index c2d793d3d98d..0ac129388e07 100644
--- a/net/ceph/osdmap.c
+++ b/net/ceph/osdmap.c
@@ -649,6 +649,7 @@ void ceph_osdmap_destroy(struct ceph_osdmap *map)
649 kfree(map->osd_state); 649 kfree(map->osd_state);
650 kfree(map->osd_weight); 650 kfree(map->osd_weight);
651 kfree(map->osd_addr); 651 kfree(map->osd_addr);
652 kfree(map->osd_primary_affinity);
652 kfree(map); 653 kfree(map);
653} 654}
654 655
@@ -685,6 +686,20 @@ static int osdmap_set_max_osd(struct ceph_osdmap *map, int max)
685 map->osd_weight = weight; 686 map->osd_weight = weight;
686 map->osd_addr = addr; 687 map->osd_addr = addr;
687 688
689 if (map->osd_primary_affinity) {
690 u32 *affinity;
691
692 affinity = krealloc(map->osd_primary_affinity,
693 max*sizeof(*affinity), GFP_NOFS);
694 if (!affinity)
695 return -ENOMEM;
696
697 for (i = map->max_osd; i < max; i++)
698 affinity[i] = CEPH_OSD_DEFAULT_PRIMARY_AFFINITY;
699
700 map->osd_primary_affinity = affinity;
701 }
702
688 map->max_osd = max; 703 map->max_osd = max;
689 704
690 return 0; 705 return 0;
@@ -912,6 +927,38 @@ static int decode_new_primary_temp(void **p, void *end,
912 return __decode_primary_temp(p, end, map, true); 927 return __decode_primary_temp(p, end, map, true);
913} 928}
914 929
930u32 ceph_get_primary_affinity(struct ceph_osdmap *map, int osd)
931{
932 BUG_ON(osd >= map->max_osd);
933
934 if (!map->osd_primary_affinity)
935 return CEPH_OSD_DEFAULT_PRIMARY_AFFINITY;
936
937 return map->osd_primary_affinity[osd];
938}
939
940static int set_primary_affinity(struct ceph_osdmap *map, int osd, u32 aff)
941{
942 BUG_ON(osd >= map->max_osd);
943
944 if (!map->osd_primary_affinity) {
945 int i;
946
947 map->osd_primary_affinity = kmalloc(map->max_osd*sizeof(u32),
948 GFP_NOFS);
949 if (!map->osd_primary_affinity)
950 return -ENOMEM;
951
952 for (i = 0; i < map->max_osd; i++)
953 map->osd_primary_affinity[i] =
954 CEPH_OSD_DEFAULT_PRIMARY_AFFINITY;
955 }
956
957 map->osd_primary_affinity[osd] = aff;
958
959 return 0;
960}
961
915/* 962/*
916 * decode a full map. 963 * decode a full map.
917 */ 964 */