Re: [PATCH] ceph: code cleanup for getting random mds

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Mar 11, 2018 at 11:42 AM, Chengguang Xu <cgxu519@xxxxxxx> wrote:
> The code to verify having one mds is redundant,
> and if there is only one active mds should return
> immediately.
>
> Signed-off-by: Chengguang Xu <cgxu519@xxxxxxx>
> ---
>  fs/ceph/mdsmap.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/fs/ceph/mdsmap.c b/fs/ceph/mdsmap.c
> index 44e53ab..1e4f07a 100644
> --- a/fs/ceph/mdsmap.c
> +++ b/fs/ceph/mdsmap.c
> @@ -22,10 +22,6 @@ int ceph_mdsmap_get_random_mds(struct ceph_mdsmap *m)
>         int n = 0;
>         int i;
>
> -       /* special case for one mds */
> -       if (1 == m->m_num_mds && m->m_info[0].state > 0)
> -               return 0;
> -
>         /* count */
>         for (i = 0; i < m->m_num_mds; i++)
>                 if (m->m_info[i].state > 0)
> @@ -33,6 +29,9 @@ int ceph_mdsmap_get_random_mds(struct ceph_mdsmap *m)
>         if (n == 0)
>                 return -1;
>
> +       if (n == 1)
> +               return i;
> +

This change is wrong. For example:

m_num_mds is 2, m_info[0].state > 0, m_info[1].state < 0. this patch
make the function return 2


>         /* pick */
>         n = prandom_u32() % n;
>         i = 0;
> --
> 1.8.3.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [CEPH Users]     [Ceph Large]     [Information on CEPH]     [Linux BTRFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux