aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ceph
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ceph')
-rw-r--r--fs/ceph/mdsmap.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/fs/ceph/mdsmap.c b/fs/ceph/mdsmap.c
index 0d3c9240c61b..9278dec9e940 100644
--- a/fs/ceph/mdsmap.c
+++ b/fs/ceph/mdsmap.c
@@ -20,7 +20,10 @@ int ceph_mdsmap_get_random_mds(struct ceph_mdsmap *m)
20{ 20{
21 int n = 0; 21 int n = 0;
22 int i; 22 int i;
23 char r; 23
24 /* special case for one mds */
25 if (1 == m->m_max_mds && m->m_info[0].state > 0)
26 return 0;
24 27
25 /* count */ 28 /* count */
26 for (i = 0; i < m->m_max_mds; i++) 29 for (i = 0; i < m->m_max_mds; i++)
@@ -30,8 +33,7 @@ int ceph_mdsmap_get_random_mds(struct ceph_mdsmap *m)
30 return -1; 33 return -1;
31 34
32 /* pick */ 35 /* pick */
33 get_random_bytes(&r, 1); 36 n = prandom_u32() % n;
34 n = r % n;
35 i = 0; 37 i = 0;
36 for (i = 0; n > 0; i++, n--) 38 for (i = 0; n > 0; i++, n--)
37 while (m->m_info[i].state <= 0) 39 while (m->m_info[i].state <= 0)