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

Hitoshi Mitake mitake.hitoshi at gmail.com
Wed Jul 10 16:08:14 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.

v3:
 - remove redundant assert()s
 - rename the prefix refcnt_ -> refcount_

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 various data structures
  sheep: initialize reference count of local request

 include/logger.h     |    6 ++++
 include/sheep.h      |    3 +-
 include/util.h       |   69 +++++++++++++++++++++++++++++++++++++++-----------
 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, 82 insertions(+), 38 deletions(-)

-- 
1.7.5.1




More information about the sheepdog mailing list