[Patch 1/2] tabled: second step to data redundancy

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We continue to advance towards redundant data. To that end this patch
retires 3 FIXMEs and, sadly, adds one.

We also throw an improvement to "Good Socket, but ..." message.
It's caused by a harmless bug in Chunk on which we want to keep tabs.

Signed-off-by: Pete Zaitcev <zaitcev@xxxxxxxxxx>

diff -urp -X dontdiff tabled/server/object.c tabled-m/server/object.c
--- tabled/server/object.c	2009-09-29 09:18:25.070156921 -0600
+++ tabled-m/server/object.c	2009-09-30 19:26:33.338814552 -0600
@@ -124,25 +124,34 @@ bool object_del_acls(DB_TXN *txn, const 
 	return true;
 }
 
-static int object_unlink(struct db_obj_ent *obj)
+static void object_unlink(struct db_obj_ent *obj)
 {
 	struct db_obj_addr *addr;
+	int i;
 	struct storage_node *stnode;
+	int rc;
 
 	if (GUINT32_FROM_LE(obj->flags) & DB_OBJ_INLINE)
-		return 0;
-	/*
-	 * FIXME Iterate over all of NIDs when redundancy is added;
-	 * use nid to locate node in all_stor.
-	 */
+		return;
 	addr = &obj->d.a;
 
-	if (list_empty(&tabled_srv.all_stor))
-		return -EIO;
-	stnode = list_entry(tabled_srv.all_stor.next,
-			    struct storage_node, all_link);
+	for (i = 0; i < MAXWAY; i++) {
+		uint32_t nid;
 
-	return stor_obj_del(stnode, GUINT64_FROM_LE(addr->oid));
+		nid = GUINT32_FROM_LE(addr->nidv[i]);
+		if (!nid)
+			continue;
+		stnode = stor_node_by_nid(nid);
+		if (!stnode)
+			continue;
+
+		rc = stor_obj_del(stnode, GUINT64_FROM_LE(addr->oid));
+		if (rc)
+			applog(LOG_ERR,
+			       "object data(%llX) unlink failed on nid %u",
+			       (unsigned long long) GUINT64_FROM_LE(addr->oid),
+			       nid);
+	}
 }
 
 bool object_del(struct client *cli, const char *user,
@@ -204,9 +213,7 @@ bool object_del(struct client *cli, cons
 		return cli_err(cli, InternalError);
 	}
 
-	if (object_unlink(&obje) < 0)
-		applog(LOG_ERR, "object data(%llX) unlink failed",
-		       (unsigned long long) cli->in_objid);
+	object_unlink(&obje);
 	if (asprintf(&hdr,
 "HTTP/%d.%d 204 x\r\n"
 "Content-Length: 0\r\n"
@@ -311,6 +318,7 @@ static bool object_put_end(struct client
 	struct list_head *pos, *tmp;
 	int nok;
 	enum errcode err = InternalError;
+	struct db_obj_addr obj_addr;
 	struct db_obj_ent *obj;
 	struct db_obj_key *obj_key;
 	struct db_obj_ent oldobj;
@@ -331,6 +339,8 @@ static bool object_put_end(struct client
 	else
 		cli->state = evt_dispose;
 
+	memset(&obj_addr, 0, sizeof(struct db_obj_addr));
+	obj_addr.oid = GUINT64_TO_LE(cli->out_objid);
 	nok = 0;
 	list_for_each_safe(pos, tmp, &cli->out_ch) {
 		struct open_chunk *ochunk;
@@ -349,6 +359,7 @@ static bool object_put_end(struct client
 					applog(LOG_DEBUG, "STORED %llX, size -",
 					       (unsigned long long) cli->out_objid);
 			}
+			obj_addr.nidv[nok] = GUINT32_TO_LE(ochunk->node->id);
 			nok++;
 		}
 		stor_close(ochunk);
@@ -435,8 +446,7 @@ static bool object_put_end(struct client
 	/* encode object header */
 	obj->size = cli->out_size;
 	obj->mtime = (uint64_t)time(NULL) * 1000000;
-	obj->d.a.nidv[0] = GUINT32_TO_LE(1);		/* FIXME */
-	obj->d.a.oid = GUINT64_TO_LE(cli->out_objid);
+	memcpy(&obj->d.a, &obj_addr, sizeof(struct db_obj_addr));
 	strncpy(obj->bucket, cli->out_bucket, sizeof(obj->bucket));
 	strncpy(obj->owner, cli->out_user, sizeof(obj->owner));
 	strncpy(obj->md5, md5, sizeof(obj->md5));
@@ -480,10 +490,8 @@ static bool object_put_end(struct client
 	/* now that all database manipulation has been a success,
 	 * we can remove the old object (overwritten) data.
 	 */
-	if (delobj && object_unlink(&oldobj) < 0) {
-		applog(LOG_ERR, "object data(%llX) orphaned",
-		       (unsigned long long) GUINT64_FROM_LE(oldobj.d.a.oid));
-	}
+	if (delobj)
+		object_unlink(&oldobj);
 
 	free(cli->out_bucket);
 	free(cli->out_key);
@@ -724,6 +732,8 @@ static int open_chunks(struct list_head 
 
 	n = 0;
 	list_for_each_entry(stnode, slist, all_link) {
+		if (n >= MAXWAY)
+			break;
 		if (!stnode->up)
 			continue;
 		ochunk = open_chunk1(stnode, objid, content_len);
@@ -1034,17 +1044,9 @@ static bool object_get_more(struct clien
 }
 
 /* callback from the chunkd side: some data is available */
-static void object_get_event(struct open_chunk *cep)
+static void object_get_event(struct open_chunk *ochunk)
 {
-	struct client *cli;
-	unsigned char *p;
-
-	/* FIXME what's the name of this ideom? parentof()? */
-	p = (unsigned char *)cep;
-	p -= ((unsigned long) &((struct client *)0)->in_ce);  /* offsetof */
-	cli = (struct client *) p;
-
-	object_get_poke(cli);
+	object_get_poke(ochunk->cli);
 }
 
 bool object_get_body(struct client *cli, const char *user, const char *bucket,
@@ -1148,12 +1150,21 @@ bool object_get_body(struct client *cli,
 
 	cli->in_objid = GUINT64_FROM_LE(obj->d.a.oid);
 
-	if (list_empty(&tabled_srv.all_stor)) {
-		applog(LOG_ERR, "No chunk nodes");
-		goto err_out_str;
+	for (i = 0; i < MAXWAY; i++ ) {
+		uint32_t nid;
+
+		nid = GUINT32_FROM_LE(obj->d.a.nidv[0]);
+		if (!nid)
+			continue;
+		stnode = stor_node_by_nid(nid);
+		if (stnode)		/* FIXME temporarily 1-way */
+			break;
+
+		applog(LOG_ERR, "No chunk node nid %u for oid %llX",
+		       nid, cli->in_objid);
 	}
-	stnode = list_entry(tabled_srv.all_stor.next,
-			    struct storage_node, all_link);
+	if (!stnode)
+		goto err_out_str;
 
 	rc = stor_open(&cli->in_ce, stnode);
 	if (rc < 0) {
@@ -1169,6 +1180,7 @@ bool object_get_body(struct client *cli,
 		       (unsigned long long) cli->in_objid, stnode->id, rc);
 		goto err_out_str;
 	}
+	cli->in_ce.cli = cli;
 
 	hdr = req_hdr(&cli->req, "if-unmodified-since");
 	if (hdr) {
diff -urp -X dontdiff tabled/server/storage.c tabled-m/server/storage.c
--- tabled/server/storage.c	2009-09-30 19:11:04.854874868 -0600
+++ tabled-m/server/storage.c	2009-09-30 19:26:33.341815126 -0600
@@ -342,7 +342,7 @@ bool stor_obj_test(struct open_chunk *ce
 	return true;
 }
 
-static struct storage_node *stor_node_by_nid(uint32_t nid)
+struct storage_node *stor_node_by_nid(uint32_t nid)
 {
 	struct storage_node *sn;
 
diff -urp -X dontdiff tabled/server/storparse.c tabled-m/server/storparse.c
--- tabled/server/storparse.c	2009-08-29 13:03:09.129481061 -0600
+++ tabled-m/server/storparse.c	2009-09-30 19:26:33.343813430 -0600
@@ -102,16 +102,19 @@ static void cfg_elm_end_storage(struct c
 
 	/* FIXME Chunkd with SSL needs certs, or else it's security theater. */
 	if (cc->stor_encrypt) {
-		applog(LOG_WARNING, "%s: Good Socket, but "
+		applog(LOG_WARNING, "%s: Good Socket (%s,%s), but "
 		       "SSL access to Chunk is not supported yet",
-		       cc->fname);
+		       cc->fname,
+		       cc->stor_host, cc->stor_port);
 		goto end;
 	}
 
 	if (cc->stor_ok) {
-		applog(LOG_WARNING, "%s: Good Socket, but "
-		       "multihomed Chunk is not supported yet",
-		       cc->fname);
+		applog(LOG_WARNING, "%s: Good Socket (%s,%s), but "
+		       "multihomed Chunk is not supported yet, using (%s,%s)",
+		       cc->fname,
+		       cc->stor_host, cc->stor_port,
+		       cc->stor_ok_host, cc->stor_ok_port);
 		goto end;
 	}
 
diff -urp -X dontdiff tabled/server/tabled.h tabled-m/server/tabled.h
--- tabled/server/tabled.h	2009-09-29 09:18:25.075156919 -0600
+++ tabled-m/server/tabled.h	2009-09-30 19:26:33.346784216 -0600
@@ -333,6 +333,7 @@ extern bool stor_put_end(struct open_chu
 extern ssize_t stor_get_buf(struct open_chunk *cep, void *data, size_t len);
 extern int stor_obj_del(struct storage_node *stn, uint64_t key);
 extern bool stor_obj_test(struct open_chunk *cep, uint64_t key);
+extern struct storage_node *stor_node_by_nid(uint32_t nid);
 extern void stor_add_node(uint32_t nid, const char *hostname,
 			  const char *portstr, struct geo *locp);
 extern int stor_node_check(struct storage_node *stn);
--
To unsubscribe from this list: send the line "unsubscribe hail-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Fedora Clound]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux