git: carp: Lock MPSAFE, step 10 of 11
Sepherosa Ziehau
sephe at crater.dragonflybsd.org
Tue Apr 10 06:29:03 PDT 2012
commit bb05f5cdc30aad020abec4b2b54773a045f4ac27
Author: Sepherosa Ziehau <sephe at dragonflybsd.org>
Date: Mon Apr 9 21:06:57 2012 +0800
carp: Lock MPSAFE, step 10 of 11
Make carp_softc.sc_carpdev and ifnet.if_carp accessing and updating
lockless MPSAFE.
carp_softc.sc_carpdev:
- Reader of the sc_carpdev will cache the value in temporary variable
and use the cached value instead of always accessing sc_carpdev,
which may be inconsistent due to change of sc_carpdev.
ifnet.if_carp
- if_carp is a pointer to the carp_softc container list, while the list
only contains pointer to carp_softc
- Reader of if_carp will cache the value in temporary variable and use
the cached value instead of always accessing if_carp, which may be
inconsistent due to if_carp updating.
- Updating of the if_carp is done in the following way:
ocif = ifp->if_carp;
ncif = cif_copy(ocif);
cif_modify(ncif);
ifp->if_carp = ncif;
netmsg_service_sync();
/* when we reach here all users of old if_carp (ocif) are done */
cif_free(ocif)
Summary of changes:
sys/net/if_ethersubr.c | 27 +++--
sys/netinet/ip_carp.c | 279 +++++++++++++++++++++++++++++++++++-------------
sys/netinet/ip_carp.h | 1 -
3 files changed, 222 insertions(+), 85 deletions(-)
http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/bb05f5cdc30aad020abec4b2b54773a045f4ac27
--
DragonFly BSD source repository
More information about the Commits
mailing list