[sheepdog] [PATCH v2 0/4] improve reference counting of data structures

Hitoshi Mitake mitake.hitoshi at lab.ntt.co.jp
Tue Jul 9 09:41:59 CEST 2013


Current sheep uses raw int and uatomic_{inc,dec} for reference
counting of data structures. This is not a good practice because we
can simply increment or decrement with ++ or -- operators of C because
these counters has a type of int. It causes typical multithreading
programming errors.

This patch implements a new data structures, refcnt_t, for reference
counting. refcnt_t can be used for structs which can be get or put by
multiple threads. This leverage compiler support for detecting bad
operations and manipulated safely than previous reference counters
whose types are raw integer.

And in the last patch of this series, one bug is removed which is
found by this feature.

v2:
 - stop let treeview.c and shadow_file.c include logger.h
 - eliminate main_refcnt_t

Hitoshi Mitake (4):
  util: solve cyclic dependency of util.h and logger.h
  util: introduce a new data type refcnt_t for reference counting
  sheep: use refcnt_t in object cache
  sheep: initialize reference count of local request

 include/logger.h     |    6 ++++
 include/sheep.h      |    3 +-
 include/util.h       |   75 ++++++++++++++++++++++++++++++++++++++++----------
 sheep/group.c        |   10 +++----
 sheep/object_cache.c |    8 +++---
 sheep/request.c      |   18 ++++++------
 sheep/sheep_priv.h   |    4 +--
 sheep/vdi.c          |    2 +-
 8 files changed, 90 insertions(+), 36 deletions(-)

-- 
1.7.10.4




More information about the sheepdog mailing list