diff options
author | Andrew Tridgell <tridge@samba.org> | 2007-05-04 22:18:00 +1000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2007-05-04 22:18:00 +1000 |
commit | fccc585f5a4ba70675899a3e1dce91a867534c86 (patch) | |
tree | a56ae76261d403ee6b46ed57fdd390c1e2bcea56 /ctdb/lib/tdb | |
parent | ed3e8477856bb29c968d79791dfd351e8df0e13e (diff) | |
download | samba-fccc585f5a4ba70675899a3e1dce91a867534c86.tar.gz samba-fccc585f5a4ba70675899a3e1dce91a867534c86.tar.xz samba-fccc585f5a4ba70675899a3e1dce91a867534c86.zip |
added seqnum propogation code to ctdb
(This used to be ctdb commit be2572b1b09eaaa1ea6a726d60f16996f9407d13)
Diffstat (limited to 'ctdb/lib/tdb')
-rw-r--r-- | ctdb/lib/tdb/common/tdb.c | 25 | ||||
-rw-r--r-- | ctdb/lib/tdb/include/tdb.h | 1 |
2 files changed, 20 insertions, 6 deletions
diff --git a/ctdb/lib/tdb/common/tdb.c b/ctdb/lib/tdb/common/tdb.c index c8c874d536..70d050e7e6 100644 --- a/ctdb/lib/tdb/common/tdb.c +++ b/ctdb/lib/tdb/common/tdb.c @@ -31,10 +31,10 @@ TDB_DATA tdb_null; /* - increment the tdb sequence number if the tdb has been opened using + non-blocking increment of the tdb sequence number if the tdb has been opened using the TDB_SEQNUM flag */ -static void tdb_increment_seqnum(struct tdb_context *tdb) +void tdb_increment_seqnum_nonblock(struct tdb_context *tdb) { tdb_off_t seqnum=0; @@ -42,16 +42,29 @@ static void tdb_increment_seqnum(struct tdb_context *tdb) return; } - if (tdb_brlock(tdb, TDB_SEQNUM_OFS, F_WRLCK, F_SETLKW, 1, 1) != 0) { - return; - } - /* we ignore errors from this, as we have no sane way of dealing with them. */ tdb_ofs_read(tdb, TDB_SEQNUM_OFS, &seqnum); seqnum++; tdb_ofs_write(tdb, TDB_SEQNUM_OFS, &seqnum); +} + +/* + increment the tdb sequence number if the tdb has been opened using + the TDB_SEQNUM flag +*/ +static void tdb_increment_seqnum(struct tdb_context *tdb) +{ + if (!(tdb->flags & TDB_SEQNUM)) { + return; + } + + if (tdb_brlock(tdb, TDB_SEQNUM_OFS, F_WRLCK, F_SETLKW, 1, 1) != 0) { + return; + } + + tdb_increment_seqnum_nonblock(tdb); tdb_brlock(tdb, TDB_SEQNUM_OFS, F_UNLCK, F_SETLKW, 1, 1); } diff --git a/ctdb/lib/tdb/include/tdb.h b/ctdb/lib/tdb/include/tdb.h index 3d7826f74b..b3f6a840b9 100644 --- a/ctdb/lib/tdb/include/tdb.h +++ b/ctdb/lib/tdb/include/tdb.h @@ -132,6 +132,7 @@ int tdb_hash_size(struct tdb_context *tdb); size_t tdb_map_size(struct tdb_context *tdb); int tdb_get_flags(struct tdb_context *tdb); void tdb_enable_seqnum(struct tdb_context *tdb); +void tdb_increment_seqnum_nonblock(struct tdb_context *tdb); /* Low level locking functions: use with care */ int tdb_chainlock(struct tdb_context *tdb, TDB_DATA key); |