]> Pileus Git - ~andy/linux/blobdiff - fs/ceph/mdsmap.c
Merge branch 'kconfig' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild
[~andy/linux] / fs / ceph / mdsmap.c
index 0d3c9240c61bc80031f85a94ba462809b1d7249a..9278dec9e9400aa222c6e73fcaa144405644c056 100644 (file)
@@ -20,7 +20,10 @@ int ceph_mdsmap_get_random_mds(struct ceph_mdsmap *m)
 {
        int n = 0;
        int i;
-       char r;
+
+       /* special case for one mds */
+       if (1 == m->m_max_mds && m->m_info[0].state > 0)
+               return 0;
 
        /* count */
        for (i = 0; i < m->m_max_mds; i++)
@@ -30,8 +33,7 @@ int ceph_mdsmap_get_random_mds(struct ceph_mdsmap *m)
                return -1;
 
        /* pick */
-       get_random_bytes(&r, 1);
-       n = r % n;
+       n = prandom_u32() % n;
        i = 0;
        for (i = 0; n > 0; i++, n--)
                while (m->m_info[i].state <= 0)