tabled: fix objid when less than 500
PATCH 1/2 tabled: fix objid when less than 500
When we start over an empty directory, we start with ID 1 in memory and assume that eventually it will be written out and all will be ok. Unfortunately, it's wrong. If tabled is interrupted before it created 500 objects, the counter is not written and so objects get confused. So, force-write the new counter.
I also roll an API change to objid_xxx that I carried for a while. It permits the objid_xxx to be used where tabled.h is not included, for example in tdbadm.
Signed-off-by Pete Zaitcev <[email protected]>
--- include/tdb.h | 4 ++ server/object.c | 2 - server/server.c | 2 - server/tabled.h | 3 -- server/util.c | 67 ++++++++++++++++++++++++++-------------------- 5 files changed, 45 insertions(+), 33 deletions(-)
commit 9b0a6c22661095962b3b562a5d9f24d914d0b1e9
Author: Master <[email protected]> Date: Thu Oct 22 22:27:07 2009 -0600
Fix objid and incorporate small API change.
include/tdb.h +4 -0
@@ -122,4 +122,8 @@ extern int tdb_up(struct tabledb *tdb, unsigned int open_flags);extern void tdb_down (struct tabledb *tdb);extern void tdb_fini (struct tabledb *tdb); +/* util.c */ +uint64_t objid_next (uint64_t *state,struct tabledb *tdbp); +int objid_init (uint64_t *state,struct tabledb *tdbp); +#endif /* __TDB_H__ */
server/object.c +1 -1
@@ -773,7 +773,7 @@ bool object_put_body(struct client *cli, const char *user, const char *bucket,return cli_err (cli, InternalError); } - objid =objid_next (); + objid =objid_next (&tabled_srv.object_count, &tdb); rc =open_chunks (&cli->out_ch, &tabled_srv.all_stor, cli, objid, content_len);
server/server.c +1 -1
@@ -1690,7 +1690,7 @@ static void tdb_state_process(enum st_tdb new_state)if (tdb_up (&tdb, db_flags))return ; -if (objid_init ()) { +if (objid_init (&tabled_srv.object_count, &tdb)) {tdb_down (&tdb);return ; }
server/tabled.h +0 -3
@@ -295,9 +295,6 @@ extern void md5str(const unsigned char *digest, char *outstr);extern void req_sign (struct http_req *req,const char *bucket,const char *key,char *b64hmac_out); -uint64_t objid_next (void ); -int objid_init (void ); -/* server.c */ extern int debugging;extern struct server tabled_srv;
server/util.c +39 -28
118 lines not on this page · raw message