diff options
author | Michael Adam <obnox@samba.org> | 2010-12-22 14:16:07 +0100 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2011-03-31 18:10:22 +0200 |
commit | 3a3c118a7edf679d6b545df035fd8d51b00e0830 (patch) | |
tree | 7b046f55487a2f0185bc985701364a9a4eceb361 /source3 | |
parent | 0e240bd6a96f1270509bd12e7b083bef7d55e99f (diff) | |
download | samba-3a3c118a7edf679d6b545df035fd8d51b00e0830.tar.gz samba-3a3c118a7edf679d6b545df035fd8d51b00e0830.tar.bz2 samba-3a3c118a7edf679d6b545df035fd8d51b00e0830.zip |
s3:dbwrap_ctdb: in ctdb_delete, send a SCHEDULE_FOR_DELETION control to local ctdbd
This way, the record will be scheduled for fast vacuuming.
This is sent with the NOREPLY flag, so ctd should not sent
a reply packet and samba does not expect one. Hence, it
is not important for the success of the db_ctdb_delete command
whether or not the ctdbd we are running against supports the
SCHEDULE_FOR_DELETION control.
Diffstat (limited to 'source3')
-rw-r--r-- | source3/lib/dbwrap_ctdb.c | 57 |
1 files changed, 56 insertions, 1 deletions
diff --git a/source3/lib/dbwrap_ctdb.c b/source3/lib/dbwrap_ctdb.c index 2d543905d6..f9a7dd6a6f 100644 --- a/source3/lib/dbwrap_ctdb.c +++ b/source3/lib/dbwrap_ctdb.c @@ -909,9 +909,56 @@ static NTSTATUS db_ctdb_store(struct db_record *rec, TDB_DATA data, int flag) +#ifdef CTDB_CONTROL_SCHEDULE_FOR_DELETION +static NTSTATUS db_ctdb_send_schedule_for_deletion(struct db_record *rec) +{ + NTSTATUS status; + struct ctdb_control_schedule_for_deletion *dd; + TDB_DATA indata; + int cstatus; + struct db_ctdb_rec *crec = talloc_get_type_abort( + rec->private_data, struct db_ctdb_rec); + + indata.dsize = offsetof(struct ctdb_control_schedule_for_deletion, key) + rec->key.dsize; + indata.dptr = talloc_zero_array(crec, uint8_t, indata.dsize); + if (indata.dptr == NULL) { + DEBUG(0, (__location__ " talloc failed!\n")); + return NT_STATUS_NO_MEMORY; + } + + dd = (struct ctdb_control_schedule_for_deletion *)(void *)indata.dptr; + dd->db_id = crec->ctdb_ctx->db_id; + dd->hdr = crec->header; + dd->keylen = rec->key.dsize; + memcpy(dd->key, rec->key.dptr, rec->key.dsize); + + status = ctdbd_control_local(messaging_ctdbd_connection(), + CTDB_CONTROL_SCHEDULE_FOR_DELETION, + crec->ctdb_ctx->db_id, + CTDB_CTRL_FLAG_NOREPLY, /* flags */ + indata, + NULL, /* outdata */ + NULL, /* errmsg */ + &cstatus); + talloc_free(indata.dptr); + + if (!NT_STATUS_IS_OK(status) || cstatus != 0) { + DEBUG(1, (__location__ " Error sending local control " + "SCHEDULE_FOR_DELETION: %s, cstatus = %d\n", + nt_errstr(status), cstatus)); + if (NT_STATUS_IS_OK(status)) { + status = NT_STATUS_UNSUCCESSFUL; + } + } + + return status; +} +#endif + static NTSTATUS db_ctdb_delete(struct db_record *rec) { TDB_DATA data; + NTSTATUS status; /* * We have to store the header with empty data. TODO: Fix the @@ -920,8 +967,16 @@ static NTSTATUS db_ctdb_delete(struct db_record *rec) ZERO_STRUCT(data); - return db_ctdb_store(rec, data, 0); + status = db_ctdb_store(rec, data, 0); + if (!NT_STATUS_IS_OK(status)) { + return status; + } +#ifdef CTDB_CONTROL_SCHEDULE_FOR_DELETION + status = db_ctdb_send_schedule_for_deletion(rec); +#endif + + return status; } static int db_ctdb_record_destr(struct db_record* data) |