at present, libscf supports transactions at the property
group level, via scf_transaction_create (3SCF) and friends.
for the NWAM project, we would like to support transactions that
may span multiple property groups, and would like to be able
to load/commit an entire SMF instance if possible (to support
renaming of instances representing datalinks or IP interfaces).
at present, we're getting by with a combination of the
following mechanisms, but maybe there's a better/simpler
approach we haven't thought of?

1: we use fcntl(2)-based lockfiles to protect multiple
consumers from colliding during commit (a system-wide
mechanism is needed, since the consumers may be
different processes, e.g. nwamcfg vs the NWAM GUI).

2: we always load from a dedicated snapshot (the "nwam"
snapshot), which is taken after a successful commit, and as
such represents completely committed data for the instance.

3: on loading data for the instance, we store the
"scf_propertygroup_t *", and use it at commit time. this
ensures that if the propertygroup has been touched since
load time, the scf_transaction_commit (3SCF) action will fail,
returning 0. this allows us to avoid lost updates - if the
editing snapshot has been updated since load, the
commit action will fail for the property group in question.

4: if commit succeeds, we refresh the instance and take
the "nwam" snapshot, since we now have a new
"last good config".

these mechanisms combine to ensure that loaded data
has always been fully commited (since the dedicated
"nwam" snapshot is only taken after all property groups
have been committed), that multiple commits cannot collide
(via fcntl  locking), and that we do not experience lost
updates (via the use of the property group handle which we
store at load time and reuse at commit).

however it all seems like a bit of a hodge-podge,
and maybe there's a better way to tackle all of this.
it occurs to me that if it were possible to atomically
roll back the editing snapshot as a whole to a
previously-taken,  "last good config" snapshot,
instance-level transactions would be a cinch, but i
don't know if that is feasible. any advice or suggestions
would be greatly appreciated. thanks!

alan

Reply via email to