CEPH filesystem development
 help / color / mirror / Atom feed
From: Alex Elder <elder@ieee.org>
To: Ilya Dryomov <ilya.dryomov@inktank.com>, ceph-devel@vger.kernel.org
Subject: Re: [PATCH 21/33] libceph: primary_affinity infrastructure
Date: Thu, 27 Mar 2014 15:26:42 -0500	[thread overview]
Message-ID: <53348982.9010707@ieee.org> (raw)
In-Reply-To: <1395944299-21970-22-git-send-email-ilya.dryomov@inktank.com>

On 03/27/2014 01:18 PM, Ilya Dryomov wrote:
> 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.

One comment about some constant definitions, but
this looks good.

Reviewed-by: Alex Elder <elder@linaro.org>

> Signed-off-by: Ilya Dryomov <ilya.dryomov@inktank.com>
> ---
>  include/linux/ceph/osdmap.h |    3 +++
>  include/linux/ceph/rados.h  |    4 ++++
>  net/ceph/debugfs.c          |    5 +++--
>  net/ceph/osdmap.c           |   47 +++++++++++++++++++++++++++++++++++++++++++
>  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 {
>  	struct rb_root pg_temp;
>  	struct rb_root primary_temp;
>  
> +	u32 *osd_primary_affinity;
> +
>  	struct rb_root pg_pools;
>  	u32 pool_max;
>  
> @@ -134,6 +136,7 @@ static inline bool ceph_osdmap_flag(struct ceph_osdmap *map, int flag)
>  }
>  
>  extern char *ceph_osdmap_state_str(char *str, int len, int state);
> +extern u32 ceph_get_primary_affinity(struct ceph_osdmap *map, int osd);
>  
>  static inline struct ceph_entity_addr *ceph_osd_addr(struct ceph_osdmap *map,
>  						     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);
>  #define CEPH_OSD_IN  0x10000
>  #define CEPH_OSD_OUT 0
>  
> +/* osd primary-affinity.  fixed point value: 0x10000 == baseline */
> +#define CEPH_OSD_MAX_PRIMARY_AFFINITY 0x10000
> +#define CEPH_OSD_DEFAULT_PRIMARY_AFFINITY 0x10000
> +

It seems like these definitions may also belong in a
common header file.  However I know that in some cases
it's necessary to impose limits in the kernel where
none is enforced in user space.

>  /*
>   * 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)
>  		int state = map->osd_state[i];
>  		char sb[64];
>  
> -		seq_printf(s, "osd%d\t%s\t%3d%%\t(%s)\n",
> +		seq_printf(s, "osd%d\t%s\t%3d%%\t(%s)\t%3d%%\n",
>  			   i, ceph_pr_addr(&addr->in_addr),
>  			   ((map->osd_weight[i]*100) >> 16),
> -			   ceph_osdmap_state_str(sb, sizeof(sb), state));
> +			   ceph_osdmap_state_str(sb, sizeof(sb), state),
> +			   ((ceph_get_primary_affinity(map, i)*100) >> 16));
>  	}
>  	for (n = rb_first(&map->pg_temp); n; n = rb_next(n)) {
>  		struct ceph_pg_mapping *pg =
> diff --git a/net/ceph/osdmap.c b/net/ceph/osdmap.c
> index 0ca7f36e88b4..538b8dd341e8 100644
> --- a/net/ceph/osdmap.c
> +++ b/net/ceph/osdmap.c
> @@ -649,6 +649,7 @@ void ceph_osdmap_destroy(struct ceph_osdmap *map)
>  	kfree(map->osd_state);
>  	kfree(map->osd_weight);
>  	kfree(map->osd_addr);
> +	kfree(map->osd_primary_affinity);
>  	kfree(map);
>  }
>  
> @@ -685,6 +686,20 @@ static int osdmap_set_max_osd(struct ceph_osdmap *map, int max)
>  	map->osd_weight = weight;
>  	map->osd_addr = addr;
>  
> +	if (map->osd_primary_affinity) {
> +		u32 *affinity;
> +
> +		affinity = krealloc(map->osd_primary_affinity,
> +				    max*sizeof(*affinity), GFP_NOFS);
> +		if (!affinity)
> +			return -ENOMEM;
> +
> +		for (i = map->max_osd; i < max; i++)
> +			affinity[i] = CEPH_OSD_DEFAULT_PRIMARY_AFFINITY;
> +
> +		map->osd_primary_affinity = affinity;
> +	}
> +
>  	map->max_osd = max;
>  
>  	return 0;
> @@ -912,6 +927,38 @@ static int decode_new_primary_temp(void **p, void *end,
>  	return __decode_primary_temp(p, end, map, true);
>  }
>  
> +u32 ceph_get_primary_affinity(struct ceph_osdmap *map, int osd)
> +{
> +	BUG_ON(osd >= map->max_osd);
> +
> +	if (!map->osd_primary_affinity)
> +		return CEPH_OSD_DEFAULT_PRIMARY_AFFINITY;
> +
> +	return map->osd_primary_affinity[osd];
> +}
> +
> +static int set_primary_affinity(struct ceph_osdmap *map, int osd, u32 aff)
> +{
> +	BUG_ON(osd >= map->max_osd);
> +
> +	if (!map->osd_primary_affinity) {
> +		int i;
> +
> +		map->osd_primary_affinity = kmalloc(map->max_osd*sizeof(u32),
> +						    GFP_NOFS);
> +		if (!map->osd_primary_affinity)
> +			return -ENOMEM;
> +
> +		for (i = 0; i < map->max_osd; i++)
> +			map->osd_primary_affinity[i] =
> +			    CEPH_OSD_DEFAULT_PRIMARY_AFFINITY;
> +	}
> +
> +	map->osd_primary_affinity[osd] = aff;
> +
> +	return 0;
> +}
> +
>  /*
>   * decode a full map.
>   */
> 


  reply	other threads:[~2014-03-27 20:26 UTC|newest]

Thread overview: 77+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-27 18:17 [PATCH 00/33] OSDMAP_ENC, primary_temp, PRIMARY_AFFINITY Ilya Dryomov
2014-03-27 18:17 ` [PATCH 01/33] libceph: refer to osdmap directly in osdmap_show() Ilya Dryomov
2014-03-27 19:09   ` Alex Elder
2014-03-27 18:17 ` [PATCH 02/33] libceph: do not prefix osd lines with \t in debugfs output Ilya Dryomov
2014-03-27 19:10   ` Alex Elder
2014-03-27 18:17 ` [PATCH 03/33] libceph: dump pg_temp mappings to debugfs Ilya Dryomov
2014-03-27 19:11   ` Alex Elder
2014-03-27 18:17 ` [PATCH 04/33] libceph: dump osdmap and enhance output on decode errors Ilya Dryomov
2014-03-27 19:15   ` Alex Elder
2014-03-27 18:17 ` [PATCH 05/33] libceph: split osdmap allocation and decode steps Ilya Dryomov
2014-03-27 19:18   ` Alex Elder
2014-03-27 18:17 ` [PATCH 06/33] libceph: fixup error handling in osdmap_decode() Ilya Dryomov
2014-03-27 19:25   ` Alex Elder
2014-03-28 14:56     ` Ilya Dryomov
2014-03-28 16:22       ` Alex Elder
2014-03-27 18:17 ` [PATCH 07/33] libceph: safely decode max_osd value " Ilya Dryomov
2014-03-27 19:27   ` Alex Elder
2014-03-27 18:17 ` [PATCH 08/33] libceph: assert length of osdmap osd arrays Ilya Dryomov
2014-03-27 19:30   ` Alex Elder
2014-03-28 14:57     ` Ilya Dryomov
2014-03-27 18:17 ` [PATCH 09/33] libceph: fix crush_decode() call site in osdmap_decode() Ilya Dryomov
2014-03-27 19:45   ` Alex Elder
2014-03-28 14:57     ` Ilya Dryomov
2014-03-27 18:17 ` [PATCH 10/33] libceph: fixup error handling in osdmap_apply_incremental() Ilya Dryomov
2014-03-27 19:49   ` Alex Elder
2014-03-28 14:58     ` Ilya Dryomov
2014-03-27 18:17 ` [PATCH 11/33] libceph: nuke bogus encoding version check " Ilya Dryomov
2014-03-27 19:50   ` Alex Elder
2014-03-27 18:17 ` [PATCH 12/33] libceph: fix and clarify ceph_decode_need() sizes Ilya Dryomov
2014-03-27 19:53   ` Alex Elder
2014-03-27 18:17 ` [PATCH 13/33] libceph: rename __decode_pool{,_names}() to decode_pool{,_names}() Ilya Dryomov
2014-03-27 19:54   ` Alex Elder
2014-03-27 18:18 ` [PATCH 14/33] libceph: introduce decode{,_new}_pools() and switch to them Ilya Dryomov
2014-03-27 19:56   ` Alex Elder
2014-03-27 18:18 ` [PATCH 15/33] libceph: switch osdmap_set_max_osd() to krealloc() Ilya Dryomov
2014-03-27 19:59   ` Alex Elder
2014-03-27 18:18 ` [PATCH 16/33] libceph: introduce decode{,_new}_pg_temp() and switch to them Ilya Dryomov
2014-03-27 20:05   ` Alex Elder
2014-03-27 18:18 ` [PATCH 17/33] libceph: introduce get_osdmap_client_data_v() Ilya Dryomov
2014-03-27 20:17   ` Alex Elder
2014-03-28 14:59     ` Ilya Dryomov
2014-03-27 18:18 ` [PATCH 18/33] libceph: generalize ceph_pg_mapping Ilya Dryomov
2014-03-27 18:18 ` [PATCH 19/33] libceph: primary_temp infrastructure Ilya Dryomov
2014-03-27 20:21   ` Alex Elder
2014-03-27 18:18 ` [PATCH 20/33] libceph: primary_temp decode bits Ilya Dryomov
2014-03-27 20:23   ` Alex Elder
2014-03-27 18:18 ` [PATCH 21/33] libceph: primary_affinity infrastructure Ilya Dryomov
2014-03-27 20:26   ` Alex Elder [this message]
2014-03-28 15:01     ` Ilya Dryomov
2014-03-27 18:18 ` [PATCH 22/33] libceph: primary_affinity decode bits Ilya Dryomov
2014-03-27 20:31   ` Alex Elder
2014-03-28 15:01     ` Ilya Dryomov
2014-03-27 18:18 ` [PATCH 23/33] libceph: enable OSDMAP_ENC feature bit Ilya Dryomov
2014-03-27 20:32   ` Alex Elder
2014-03-28 15:01     ` Ilya Dryomov
2014-03-27 18:18 ` [PATCH 24/33] libceph: ceph_osd_{exists,is_up,is_down}(osd) definitions Ilya Dryomov
2014-03-27 20:33   ` Alex Elder
2014-03-27 18:18 ` [PATCH 25/33] libceph: ceph_can_shift_osds(pool) and pool type defines Ilya Dryomov
2014-03-27 20:34   ` Alex Elder
2014-03-27 18:18 ` [PATCH 26/33] libceph: introduce pg_to_raw_osds() and raw_to_up_osds() helpers Ilya Dryomov
2014-03-27 20:36   ` Alex Elder
2014-03-27 18:18 ` [PATCH 27/33] libceph: introduce apply_temps() helper Ilya Dryomov
2014-03-27 20:41   ` Alex Elder
2014-03-27 18:18 ` [PATCH 28/33] libceph: switch ceph_calc_pg_acting() to new helpers Ilya Dryomov
2014-03-27 20:49   ` Alex Elder
2014-03-28 15:02     ` Ilya Dryomov
2014-03-27 18:18 ` [PATCH 29/33] libceph: return primary from ceph_calc_pg_acting() Ilya Dryomov
2014-03-27 20:50   ` Alex Elder
2014-03-27 18:18 ` [PATCH 30/33] libceph: add support for primary_temp mappings Ilya Dryomov
2014-03-27 20:51   ` Alex Elder
2014-03-27 18:18 ` [PATCH 31/33] libceph: add support for osd primary affinity Ilya Dryomov
2014-03-27 20:59   ` Alex Elder
2014-03-28 15:03     ` Ilya Dryomov
2014-03-27 18:18 ` [PATCH 32/33] libceph: redo ceph_calc_pg_primary() in terms of ceph_calc_pg_acting() Ilya Dryomov
2014-03-27 21:04   ` Alex Elder
2014-03-27 18:18 ` [PATCH 33/33] libceph: enable PRIMARY_AFFINITY feature bit Ilya Dryomov
2014-03-27 21:04   ` Alex Elder

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53348982.9010707@ieee.org \
    --to=elder@ieee.org \
    --cc=ceph-devel@vger.kernel.org \
    --cc=ilya.dryomov@inktank.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox