aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/ceph/osdmap.h3
-rw-r--r--include/linux/ceph/rados.h4
-rw-r--r--net/ceph/debugfs.c5
-rw-r--r--net/ceph/osdmap.c47
4 files changed, 57 insertions, 2 deletions
diff --git a/include/linux/ceph/osdmap.h b/include/linux/ceph/osdmap.h
index db4fb6322aae..6e030cb3c9ca 100644
--- a/include/linux/ceph/osdmap.h
+++ b/include/linux/ceph/osdmap.h
@@ -88,6 +88,8 @@ struct ceph_osdmap {
88 struct rb_root pg_temp; 88 struct rb_root pg_temp;
89 struct rb_root primary_temp; 89 struct rb_root primary_temp;
90 90
91 u32 *osd_primary_affinity;
92
91 struct rb_root pg_pools; 93 struct rb_root pg_pools;
92 u32 pool_max; 94 u32 pool_max;
93 95
@@ -134,6 +136,7 @@ static inline bool ceph_osdmap_flag(struct ceph_osdmap *map, int flag)
134} 136}
135 137
136extern char *ceph_osdmap_state_str(char *str, int len, int state); 138extern char *ceph_osdmap_state_str(char *str, int len, int state);
139extern u32 ceph_get_primary_affinity(struct ceph_osdmap *map, int osd);
137 140
138static inline struct ceph_entity_addr *ceph_osd_addr(struct ceph_osdmap *map, 141static inline struct ceph_entity_addr *ceph_osd_addr(struct ceph_osdmap *map,
139 int osd) 142 int osd)
diff --git a/include/linux/ceph/rados.h b/include/linux/ceph/rados.h
index 2caabef8d369..bb6f40c9cb0f 100644
--- a/include/linux/ceph/rados.h
+++ b/include/linux/ceph/rados.h
@@ -133,6 +133,10 @@ extern const char *ceph_osd_state_name(int s);
133#define CEPH_OSD_IN 0x10000 133#define CEPH_OSD_IN 0x10000
134#define CEPH_OSD_OUT 0 134#define CEPH_OSD_OUT 0
135 135
136/* osd primary-affinity. fixed point value: 0x10000 == baseline */
137#define CEPH_OSD_MAX_PRIMARY_AFFINITY 0x10000
138#define CEPH_OSD_DEFAULT_PRIMARY_AFFINITY 0x10000
139
136 140
137/* 141/*
138 * osd map flag bits 142 * osd map flag bits
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 */