[sheepdog] [PATCH v4 0/4] improve reference counting of data structures
Hitoshi Mitake
mitake.hitoshi at lab.ntt.co.jp
Thu Jul 11 03:48:09 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.
v4:
- introduce compiler.h for solving the cyclic dependency of util.h
and logger.h
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/compiler.h | 20 ++++++++++++++++++++
include/logger.h | 8 +++++++-
include/sheep.h | 3 ++-
include/strbuf.h | 1 +
include/util.h | 40 +++++++++++++++++++++++++++++++++-------
lib/strbuf.c | 1 +
sheep/group.c | 10 +++-------
sheep/object_cache.c | 8 ++++----
sheep/request.c | 18 ++++++++++--------
sheep/sheep_priv.h | 4 ++--
sheep/vdi.c | 2 +-
11 files changed, 84 insertions(+), 31 deletions(-)
create mode 100644 include/compiler.h
--
1.7.10.4
More information about the sheepdog
mailing list