[sheepdog] [RFC PATCH 0/3] make list and rbtree more safe

MORITA Kazutaka morita.kazutaka at gmail.com
Wed Sep 25 20:12:08 CEST 2013


From: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>

This series adds a bit complexity to list and rbtree macros
definition, but makes their usage much simpler and type-safer.  With
this series,

 - list and rbtree macros can detect errors when we insert a wrong
   type entry to them.  E.g. the current code cannot detect an error
   when we add a sd_node entry to the sd_vnode tree, but this patch
   enables us to dectect it.

 - we don't need to specify a type name, a member name, nor a
   comparison function to list/rbtree macros any more.  E.g.

   [before]
      list_first_entry(head, type, member);

      list_add(&entry->member, head);

      list_for_each_entry(entry, head, member) {
      }

      rb_insert(root, entry, member, cmp_func);

      rb_erase(&entry->member, root);

   [after]
      list_first_entry(head);

      list_add(entry, head);

      list_for_each_entry(entry, head) {
      }

      rb_insert(entry, root);

      rb_erase(entry, root);

The changes with this series is not so small, but very systematic.  If
what this series tries to do looks good to the developers, I'll add a
documentation for each list/rbtree macro definition and send it as a
v2 series.

MORITA Kazutaka (3):
  make rbtree more typesafe
  add strict check in list_del and list_linked
  make list more typesafe

 dog/dog.c                     |   6 +-
 dog/dog.h                     |   4 +-
 dog/farm/farm.c               |  21 ++---
 dog/farm/object_tree.c        |  32 +++-----
 dog/node.c                    |  14 ++--
 dog/trace.c                   |  14 ++--
 dog/treeview.c                |  29 ++++---
 dog/vdi.c                     |  10 +--
 include/compiler.h            |   5 ++
 include/internal_proto.h      |   2 +
 include/list.h                | 187 +++++++++++++++++++++++++++++-------------
 include/rbtree.h              | 142 +++++++++++++++++++++-----------
 include/sheep.h               |  48 ++++++-----
 include/sockfd_cache.h        |   2 +-
 include/util.h                |   1 -
 include/work.h                |   4 +-
 lib/event.c                   |  10 ++-
 lib/logger.c                  |  12 +--
 lib/rbtree.c                  |  22 ++---
 lib/sockfd_cache.c            |  34 ++++----
 lib/util.c                    |  11 +--
 lib/work.c                    |  28 +++----
 sheep/cluster.h               |  15 ++--
 sheep/cluster/corosync.c      |  47 ++++++-----
 sheep/cluster/local.c         |   8 +-
 sheep/cluster/shepherd.c      |  23 +++---
 sheep/cluster/zookeeper.c     |  45 +++++-----
 sheep/group.c                 | 118 +++++++++++++-------------
 sheep/md.c                    |  52 ++++++------
 sheep/object_cache.c          |  43 +++++-----
 sheep/object_list_cache.c     |  37 +++++----
 sheep/ops.c                   |   9 +-
 sheep/recovery.c              |   2 +-
 sheep/request.c               |  49 +++++------
 sheep/sheep.c                 |   2 +-
 sheep/sheep_priv.h            |  43 +++++-----
 sheep/store.c                 |   2 +-
 sheep/trace/trace.c           |  17 ++--
 sheep/vdi.c                   |  33 ++++----
 sheepfs/volume.c              |  17 ++--
 shepherd/shepherd.c           |  37 +++++----
 tests/unit/dog/mock_dog.c     |   4 +-
 tests/unit/mock/mock.c        |   6 +-
 tests/unit/mock/mock.h        |   6 +-
 tests/unit/sheep/mock_group.c |   6 +-
 tests/unit/sheep/mock_sheep.c |   2 +-
 tests/unit/sheep/test_hash.c  |  41 ++++-----
 47 files changed, 726 insertions(+), 576 deletions(-)

-- 
1.8.1.2




More information about the sheepdog mailing list