Commit 8ac5ad30 authored by Mike Hibler's avatar Mike Hibler

Pass PERSIST=1 when the blockstore is persistent.

This is a bit hacky as noted in the comment:

               * XXX we only put out the PERSIST flag if it is set.
               * Since the client-side is stupid-picky about unknown
               * attributes, this will cause an older client to fail
               * when the attribute is passed. Believe it or not,
               * that is a good thing! This will cause an older
               * client to fail if presented with a persistent
               * blockstore. If it did not fail, the client would
               * proceed to unconditionally create a filesystem on
               * the blockstore, wiping out what was previously
               * there.
parent 6177887d
...@@ -254,7 +254,7 @@ typedef struct { ...@@ -254,7 +254,7 @@ typedef struct {
static int iptonodeid(struct in_addr, tmcdreq_t *, char*); static int iptonodeid(struct in_addr, tmcdreq_t *, char*);
static int checkdbredirect(tmcdreq_t *); static int checkdbredirect(tmcdreq_t *);
static int sendstoreconf(int sock, int tcp, tmcdreq_t *reqp, char *bscmd, static int sendstoreconf(int sock, int tcp, tmcdreq_t *reqp, char *bscmd,
char *vname); char *vname, int dopersist);
#ifdef EVENTSYS #ifdef EVENTSYS
int myevent_send(address_tuple_t address); int myevent_send(address_tuple_t address);
...@@ -4235,7 +4235,7 @@ COMMAND_PROTOTYPE(dostorageconfig) ...@@ -4235,7 +4235,7 @@ COMMAND_PROTOTYPE(dostorageconfig)
OUTPUT(buf, sizeof(buf), OUTPUT(buf, sizeof(buf),
"CMD=EXPORT IDX=%d VOLNAME=%s", "CMD=EXPORT IDX=%d VOLNAME=%s",
cmdidx++, vname); cmdidx++, vname);
rv = sendstoreconf(sock, tcp, reqp, buf, vname); rv = sendstoreconf(sock, tcp, reqp, buf, vname, 0);
mysql_free_result(res); mysql_free_result(res);
return rv; return rv;
...@@ -4357,7 +4357,7 @@ COMMAND_PROTOTYPE(dostorageconfig) ...@@ -4357,7 +4357,7 @@ COMMAND_PROTOTYPE(dostorageconfig)
OUTPUT(buf, sizeof(buf), OUTPUT(buf, sizeof(buf),
"CMD=SLICE IDX=%d VOLNAME=%s VOLSIZE=%d", "CMD=SLICE IDX=%d VOLNAME=%s VOLSIZE=%d",
cmdidx++, vname, volsize); cmdidx++, vname, volsize);
sendstoreconf(sock, tcp, reqp, buf, vname); sendstoreconf(sock, tcp, reqp, buf, vname, 0);
} }
mysql_free_result(res); mysql_free_result(res);
...@@ -4428,7 +4428,7 @@ COMMAND_PROTOTYPE(dostorageconfig) ...@@ -4428,7 +4428,7 @@ COMMAND_PROTOTYPE(dostorageconfig)
OUTPUT(buf, sizeof(buf), OUTPUT(buf, sizeof(buf),
"CMD=ELEMENT IDX=%d HOSTID=%s VOLNAME=%s VOLSIZE=%d", "CMD=ELEMENT IDX=%d HOSTID=%s VOLNAME=%s VOLSIZE=%d",
cmdidx++, hostid, vname, volsize); cmdidx++, hostid, vname, volsize);
sendstoreconf(sock, tcp, reqp, buf, vname); sendstoreconf(sock, tcp, reqp, buf, vname, 1);
} }
mysql_free_result(res); mysql_free_result(res);
...@@ -4438,7 +4438,8 @@ COMMAND_PROTOTYPE(dostorageconfig) ...@@ -4438,7 +4438,8 @@ COMMAND_PROTOTYPE(dostorageconfig)
/* Helper function for "dostorageconfig" */ /* Helper function for "dostorageconfig" */
static int static int
sendstoreconf(int sock, int tcp, tmcdreq_t *reqp, char *bscmd, char *vname) sendstoreconf(int sock, int tcp, tmcdreq_t *reqp, char *bscmd, char *vname,
int dopersist)
{ {
MYSQL_RES *res; MYSQL_RES *res;
MYSQL_ROW row; MYSQL_ROW row;
...@@ -4446,7 +4447,7 @@ sendstoreconf(int sock, int tcp, tmcdreq_t *reqp, char *bscmd, char *vname) ...@@ -4446,7 +4447,7 @@ sendstoreconf(int sock, int tcp, tmcdreq_t *reqp, char *bscmd, char *vname)
char *bufp, *ebufp = &buf[sizeof(buf)]; char *bufp, *ebufp = &buf[sizeof(buf)];
char iqn[BS_IQN_MAXSIZE]; char iqn[BS_IQN_MAXSIZE];
char *mynodeid; char *mynodeid;
char *class, *protocol, *placement, *mountpoint; char *class, *protocol, *placement, *mountpoint, *lease;
int nrows, nattrs; int nrows, nattrs;
/* Remember the nodeid we care about up front. */ /* Remember the nodeid we care about up front. */
...@@ -4467,7 +4468,7 @@ sendstoreconf(int sock, int tcp, tmcdreq_t *reqp, char *bscmd, char *vname) ...@@ -4467,7 +4468,7 @@ sendstoreconf(int sock, int tcp, tmcdreq_t *reqp, char *bscmd, char *vname)
/* Find out what type of blockstore we are dealing with and /* Find out what type of blockstore we are dealing with and
grab some additional attributes. */ grab some additional attributes. */
nrows = nattrs = (int) mysql_num_rows(res); nrows = nattrs = (int) mysql_num_rows(res);
class = protocol = placement = mountpoint = "\0"; class = protocol = placement = mountpoint = lease = "\0";
while (nrows--) { while (nrows--) {
char *key, *val; char *key, *val;
row = mysql_fetch_row(res); row = mysql_fetch_row(res);
...@@ -4481,6 +4482,8 @@ sendstoreconf(int sock, int tcp, tmcdreq_t *reqp, char *bscmd, char *vname) ...@@ -4481,6 +4482,8 @@ sendstoreconf(int sock, int tcp, tmcdreq_t *reqp, char *bscmd, char *vname)
placement = val; placement = val;
} else if (strcmp(key,"mountpoint") == 0) { } else if (strcmp(key,"mountpoint") == 0) {
mountpoint = val; mountpoint = val;
} else if (strcmp(key,"lease") == 0) {
lease = val;
} }
} }
...@@ -4507,6 +4510,22 @@ sendstoreconf(int sock, int tcp, tmcdreq_t *reqp, char *bscmd, char *vname) ...@@ -4507,6 +4510,22 @@ sendstoreconf(int sock, int tcp, tmcdreq_t *reqp, char *bscmd, char *vname)
mountpoint); mountpoint);
} }
/*
* XXX we only put out the PERSIST flag if it is set.
* Since the client-side is stupid-picky about unknown
* attributes, this will cause an older client to fail
* when the attribute is passed. Believe it or not,
* that is a good thing! This will cause an older
* client to fail if presented with a persistent
* blockstore. If it did not fail, the client would
* proceed to unconditionally create a filesystem on
* the blockstore, wiping out what was previously
* there.
*/
if (dopersist && strlen(lease) && atoi(lease) != 0) {
bufp += OUTPUT(bufp, ebufp-bufp, " PERSIST=1");
}
bufp += OUTPUT(bufp, ebufp-bufp, "\n"); bufp += OUTPUT(bufp, ebufp-bufp, "\n");
client_writeback(sock, buf, strlen(buf), tcp); client_writeback(sock, buf, strlen(buf), tcp);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment