[sheepdog] [PATCH v5 1/2] lib: move sockfd cache from sheep to lib

Liu Yuan namei.unix at gmail.com
Mon Jul 29 10:40:40 CEST 2013


On Sat, Jul 27, 2013 at 10:57:34PM +0900, Hitoshi Mitake wrote:
> From: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
> 
> On some subcommands, collie also issues lots of request to sheeps. So
> collie can enjoy sockfd caching. For this purpose, this patch moves
> sockfd from sheep to lib and generalize the interfaces of sockfd.
> 
> This patch doesn't change anything related to IO NIC in sockfd
> cache. Because collie can know address and port of IO NIC so
> potentially use them.
> 
> Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
> ---
> 
> v5:
>  - make the workqueue for cachefd growth an internal thing in
>    lib/sockfd_cache.c
>  - remove revalidate_node(), because this relies on the assumption of
>    sheep
>  - better naming of functions. do_sockfd_cache_{get, put}() ->
>    sockfd_cache_{get, put}_long()
> 
>  include/Makefile.am           |    3 +-
>  include/internal_proto.h      |    2 +
>  include/sockfd_cache.h        |   23 ++
>  lib/Makefile.am               |    2 +-
>  {sheep => lib}/sockfd_cache.c |  157 +++++--------
>  sheep/gateway.c               |   10 +-
>  sheep/group.c                 |    2 +-
>  sheep/sheep.c                 |    9 +-
>  sheep/sheep_priv.h            |   12 +-
>  sheep/sockfd_cache.c          |  509 +----------------------------------------
>  10 files changed, 108 insertions(+), 621 deletions(-)
>  create mode 100644 include/sockfd_cache.h
>  copy {sheep => lib}/sockfd_cache.c (83%)
> 
> diff --git a/include/Makefile.am b/include/Makefile.am
> index 0acb76e..4d0c229 100644
> --- a/include/Makefile.am
> +++ b/include/Makefile.am
> @@ -2,4 +2,5 @@ MAINTAINERCLEANFILES    = Makefile.in config.h.in
>  
>  noinst_HEADERS          = bitops.h event.h logger.h sheepdog_proto.h util.h \
>  			  list.h net.h sheep.h exits.h strbuf.h rbtree.h \
> -			  sha1.h option.h internal_proto.h shepherd.h work.h
> +			  sha1.h option.h internal_proto.h shepherd.h work.h \
> +			  sockfd_cache.h
> diff --git a/include/internal_proto.h b/include/internal_proto.h
> index 0463eae..0061007 100644
> --- a/include/internal_proto.h
> +++ b/include/internal_proto.h
> @@ -20,6 +20,8 @@
>  #include <stdint.h>
>  #include <netinet/in.h>
>  
> +#include "sheepdog_proto.h"
> +
>  #define SD_SHEEP_PROTO_VER 0x08
>  
>  #define SD_DEFAULT_COPIES 3
> diff --git a/include/sockfd_cache.h b/include/sockfd_cache.h
> new file mode 100644
> index 0000000..a724cdd
> --- /dev/null
> +++ b/include/sockfd_cache.h
> @@ -0,0 +1,23 @@
> +#ifndef SOCKFD_CACHE_H
> +#define SOCKFD_CACHE_H
> +
> +#include "internal_proto.h"
> +#include "work.h"
> +
> +struct sockfd *sockfd_cache_get(const struct node_id *nid);
> +void do_sockfd_cache_put(const struct node_id *nid, int idx);

Forget to remove it?

Thanks
Yuan



More information about the sheepdog mailing list