mirror of
https://github.com/samba-team/samba.git
synced 2025-01-12 09:18:10 +03:00
ldb_tdb: Replace tdb transaction code with generic key value ones
Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
parent
e33fb2c633
commit
448101a3fd
@ -415,7 +415,7 @@ int ltdb_cache_load(struct ldb_module *module)
|
||||
/* possibly initialise the baseinfo */
|
||||
if (r == LDB_ERR_NO_SUCH_OBJECT) {
|
||||
|
||||
if (tdb_transaction_start(ltdb->tdb) != 0) {
|
||||
if (ltdb->kv_ops->begin_write(ltdb) != 0) {
|
||||
goto failed;
|
||||
}
|
||||
|
||||
@ -423,7 +423,9 @@ int ltdb_cache_load(struct ldb_module *module)
|
||||
looking for the record again. */
|
||||
ltdb_baseinfo_init(module);
|
||||
|
||||
tdb_transaction_commit(ltdb->tdb);
|
||||
if (ltdb->kv_ops->finish_write(ltdb) != 0) {
|
||||
goto failed;
|
||||
}
|
||||
|
||||
if (ltdb_search_dn1(module, baseinfo_dn, baseinfo, 0) != LDB_SUCCESS) {
|
||||
goto failed;
|
||||
|
@ -1401,6 +1401,26 @@ static int ltdb_rename(struct ltdb_context *ctx)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int ltdb_tdb_transaction_start(struct ltdb_private *ltdb)
|
||||
{
|
||||
return tdb_transaction_start(ltdb->tdb);
|
||||
}
|
||||
|
||||
static int ltdb_tdb_transaction_cancel(struct ltdb_private *ltdb)
|
||||
{
|
||||
return tdb_transaction_cancel(ltdb->tdb);
|
||||
}
|
||||
|
||||
static int ltdb_tdb_transaction_prepare_commit(struct ltdb_private *ltdb)
|
||||
{
|
||||
return tdb_transaction_prepare_commit(ltdb->tdb);
|
||||
}
|
||||
|
||||
static int ltdb_tdb_transaction_commit(struct ltdb_private *ltdb)
|
||||
{
|
||||
return tdb_transaction_commit(ltdb->tdb);
|
||||
}
|
||||
|
||||
static int ltdb_start_trans(struct ldb_module *module)
|
||||
{
|
||||
void *data = ldb_module_get_private(module);
|
||||
@ -1411,7 +1431,7 @@ static int ltdb_start_trans(struct ldb_module *module)
|
||||
return LDB_ERR_UNWILLING_TO_PERFORM;
|
||||
}
|
||||
|
||||
if (tdb_transaction_start(ltdb->tdb) != 0) {
|
||||
if (ltdb->kv_ops->begin_write(ltdb) != 0) {
|
||||
return ltdb->kv_ops->error(ltdb);
|
||||
}
|
||||
|
||||
@ -1434,13 +1454,13 @@ static int ltdb_prepare_commit(struct ldb_module *module)
|
||||
|
||||
ret = ltdb_index_transaction_commit(module);
|
||||
if (ret != LDB_SUCCESS) {
|
||||
tdb_transaction_cancel(ltdb->tdb);
|
||||
ltdb->kv_ops->abort_write(ltdb);
|
||||
ltdb->in_transaction--;
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (tdb_transaction_prepare_commit(ltdb->tdb) != 0) {
|
||||
ret = ltdb_err_map(tdb_error(ltdb->tdb));
|
||||
if (ltdb->kv_ops->prepare_write(ltdb) != 0) {
|
||||
ret = ltdb->kv_ops->error(ltdb);
|
||||
ltdb->in_transaction--;
|
||||
ldb_debug_set(ldb_module_get_ctx(module),
|
||||
LDB_DEBUG_FATAL,
|
||||
@ -1472,7 +1492,7 @@ static int ltdb_end_trans(struct ldb_module *module)
|
||||
ltdb->in_transaction--;
|
||||
ltdb->prepared_commit = false;
|
||||
|
||||
if (tdb_transaction_commit(ltdb->tdb) != 0) {
|
||||
if (ltdb->kv_ops->finish_write(ltdb) != 0) {
|
||||
ret = ltdb->kv_ops->error(ltdb);
|
||||
ldb_asprintf_errstring(ldb_module_get_ctx(module),
|
||||
"Failure during tdb_transaction_commit(): %s -> %s",
|
||||
@ -1492,11 +1512,11 @@ static int ltdb_del_trans(struct ldb_module *module)
|
||||
ltdb->in_transaction--;
|
||||
|
||||
if (ltdb_index_transaction_cancel(module) != 0) {
|
||||
tdb_transaction_cancel(ltdb->tdb);
|
||||
ltdb->kv_ops->abort_write(ltdb);
|
||||
return ltdb->kv_ops->error(ltdb);
|
||||
}
|
||||
|
||||
tdb_transaction_cancel(ltdb->tdb);
|
||||
ltdb->kv_ops->abort_write(ltdb);
|
||||
return LDB_SUCCESS;
|
||||
}
|
||||
|
||||
@ -1696,6 +1716,10 @@ static const struct kv_db_ops key_value_ops = {
|
||||
.delete = ltdb_tdb_delete,
|
||||
.lock_read = ltdb_lock_read,
|
||||
.unlock_read = ltdb_unlock_read,
|
||||
.begin_write = ltdb_tdb_transaction_start,
|
||||
.prepare_write = ltdb_tdb_transaction_prepare_commit,
|
||||
.finish_write = ltdb_tdb_transaction_commit,
|
||||
.abort_write = ltdb_tdb_transaction_cancel,
|
||||
.error = ltdb_error,
|
||||
.name = ltdb_tdb_name,
|
||||
};
|
||||
|
@ -10,6 +10,10 @@ struct kv_db_ops {
|
||||
int (*delete)(struct ltdb_private *ltdb, TDB_DATA key);
|
||||
int (*lock_read)(struct ldb_module *);
|
||||
int (*unlock_read)(struct ldb_module *);
|
||||
int (*begin_write)(struct ltdb_private *);
|
||||
int (*prepare_write)(struct ltdb_private *);
|
||||
int (*abort_write)(struct ltdb_private *);
|
||||
int (*finish_write)(struct ltdb_private *);
|
||||
int (*error)(struct ltdb_private *ltdb);
|
||||
const char * (*name)(struct ltdb_private *ltdb);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user