projects
/
fio.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
t/verify-state: one more printf type fix
[fio.git]
/
server.c
diff --git
a/server.c
b/server.c
index 379ea90b631752c0258d52b2dcd30d276d3ac200..a593a73f436de6a13634238948e6f7e7bfda5f2d 100644
(file)
--- a/
server.c
+++ b/
server.c
@@
-151,11
+151,13
@@
static int __sk_out_drop(struct sk_out *sk_out)
int refs;
sk_lock(sk_out);
int refs;
sk_lock(sk_out);
+ assert(sk_out->refs != 0);
refs = --sk_out->refs;
sk_unlock(sk_out);
if (!refs) {
sk_out_free(sk_out);
refs = --sk_out->refs;
sk_unlock(sk_out);
if (!refs) {
sk_out_free(sk_out);
+ pthread_setspecific(sk_out_key, NULL);
return 0;
}
}
return 0;
}
}
@@
-168,8
+170,7
@@
void sk_out_drop(void)
struct sk_out *sk_out;
sk_out = pthread_getspecific(sk_out_key);
struct sk_out *sk_out;
sk_out = pthread_getspecific(sk_out_key);
- if (!__sk_out_drop(sk_out))
- pthread_setspecific(sk_out_key, NULL);
+ __sk_out_drop(sk_out);
}
static void __fio_init_net_cmd(struct fio_net_cmd *cmd, uint16_t opcode,
}
static void __fio_init_net_cmd(struct fio_net_cmd *cmd, uint16_t opcode,
@@
-757,6
+758,8
@@
static int handle_run_cmd(struct sk_out *sk_out, struct flist_head *job_list,
pid_t pid;
int ret;
pid_t pid;
int ret;
+ sk_out_assign(sk_out);
+
fio_time_init();
set_genesis_time();
fio_time_init();
set_genesis_time();
@@
-768,6
+771,7
@@
static int handle_run_cmd(struct sk_out *sk_out, struct flist_head *job_list,
ret = fio_backend(sk_out);
free_threads_shm();
ret = fio_backend(sk_out);
free_threads_shm();
+ sk_out_drop();
_exit(ret);
}
_exit(ret);
}
@@
-1072,26
+1076,24
@@
static void finish_entry(struct sk_entry *entry)
sfree(entry);
}
sfree(entry);
}
-static void entry_set_flags
_tag
(struct sk_entry *entry, struct flist_head *list,
-
unsigned int *flags, uint64_t *tag
)
+static void entry_set_flags(struct sk_entry *entry, struct flist_head *list,
+
unsigned int *flags
)
{
if (!flist_empty(list))
*flags = FIO_NET_CMD_F_MORE;
else
*flags = 0;
{
if (!flist_empty(list))
*flags = FIO_NET_CMD_F_MORE;
else
*flags = 0;
-
- *tag = entry->tag;
}
static int send_vec_entry(struct sk_out *sk_out, struct sk_entry *first)
{
unsigned int flags;
}
static int send_vec_entry(struct sk_out *sk_out, struct sk_entry *first)
{
unsigned int flags;
- uint64_t tag;
int ret;
int ret;
- entry_set_flags
_tag(first, &first->next, &flags, &tag
);
+ entry_set_flags
(first, &first->next, &flags
);
- ret = fio_send_cmd_ext_pdu(sk_out->sk, first->opcode, first->buf, first->size, tag, flags);
+ ret = fio_send_cmd_ext_pdu(sk_out->sk, first->opcode, first->buf,
+ first->size, first->tag, flags);
while (!flist_empty(&first->next)) {
struct sk_entry *next;
while (!flist_empty(&first->next)) {
struct sk_entry *next;
@@
-1099,9
+1101,10
@@
static int send_vec_entry(struct sk_out *sk_out, struct sk_entry *first)
next = flist_first_entry(&first->next, struct sk_entry, list);
flist_del_init(&next->list);
next = flist_first_entry(&first->next, struct sk_entry, list);
flist_del_init(&next->list);
- entry_set_flags
_tag(next, &first->next, &flags, &tag
);
+ entry_set_flags
(next, &first->next, &flags
);
- ret += fio_send_cmd_ext_pdu(sk_out->sk, next->opcode, next->buf, next->size, tag, flags);
+ ret += fio_send_cmd_ext_pdu(sk_out->sk, next->opcode, next->buf,
+ next->size, next->tag, flags);
finish_entry(next);
}
finish_entry(next);
}
@@
-1117,10
+1120,8
@@
static int handle_sk_entry(struct sk_out *sk_out, struct sk_entry *entry)
if (entry->flags & SK_F_VEC)
ret = send_vec_entry(sk_out, entry);
else if (entry->flags & SK_F_SIMPLE) {
if (entry->flags & SK_F_VEC)
ret = send_vec_entry(sk_out, entry);
else if (entry->flags & SK_F_SIMPLE) {
- uint64_t tag = entry->tag;
-
- ret = fio_net_send_simple_cmd(sk_out->sk, entry->opcode, tag,
- NULL);
+ ret = fio_net_send_simple_cmd(sk_out->sk, entry->opcode,
+ entry->tag, NULL);
} else {
ret = fio_net_send_cmd(sk_out->sk, entry->opcode, entry->buf,
entry->size, &entry->tag, NULL);
} else {
ret = fio_net_send_cmd(sk_out->sk, entry->opcode, entry->buf,
entry->size, &entry->tag, NULL);
@@
-1798,13
+1799,14
@@
int fio_server_get_verify_state(const char *name, int threadnumber,
struct cmd_reply *rep;
uint64_t tag;
void *data;
struct cmd_reply *rep;
uint64_t tag;
void *data;
+ int ret;
dprint(FD_NET, "server: request verify state\n");
rep = smalloc(sizeof(*rep));
if (!rep) {
log_err("fio: smalloc pool too small\n");
dprint(FD_NET, "server: request verify state\n");
rep = smalloc(sizeof(*rep));
if (!rep) {
log_err("fio: smalloc pool too small\n");
- return
1
;
+ return
ENOMEM
;
}
__fio_mutex_init(&rep->lock, FIO_MUTEX_LOCKED);
}
__fio_mutex_init(&rep->lock, FIO_MUTEX_LOCKED);
@@
-1822,17
+1824,19
@@
int fio_server_get_verify_state(const char *name, int threadnumber,
*/
if (fio_mutex_down_timeout(&rep->lock, 10000)) {
log_err("fio: timed out waiting for reply\n");
*/
if (fio_mutex_down_timeout(&rep->lock, 10000)) {
log_err("fio: timed out waiting for reply\n");
+ ret = ETIMEDOUT;
goto fail;
}
if (rep->error) {
goto fail;
}
if (rep->error) {
- log_err("fio: failure on receiving state file: %s\n",
- strerror(rep->error));
+ log_err("fio: failure on receiving state file %s: %s\n",
+ out.path, strerror(rep->error));
+ ret = rep->error;
fail:
*datap = NULL;
sfree(rep);
fio_net_queue_quit();
fail:
*datap = NULL;
sfree(rep);
fio_net_queue_quit();
- return
1
;
+ return
ret
;
}
/*
}
/*
@@
-1840,12
+1844,15
@@
fail:
* the header, and the thread_io_list checksum
*/
s = rep->data + sizeof(struct verify_state_hdr);
* the header, and the thread_io_list checksum
*/
s = rep->data + sizeof(struct verify_state_hdr);
- if (verify_state_hdr(rep->data, s, version))
+ if (verify_state_hdr(rep->data, s, version)) {
+ ret = EILSEQ;
goto fail;
goto fail;
+ }
/*
* Don't need the header from now, copy just the thread_io_list
*/
/*
* Don't need the header from now, copy just the thread_io_list
*/
+ ret = 0;
rep->size -= sizeof(struct verify_state_hdr);
data = malloc(rep->size);
memcpy(data, s, rep->size);
rep->size -= sizeof(struct verify_state_hdr);
data = malloc(rep->size);
memcpy(data, s, rep->size);
@@
-1854,7
+1861,7
@@
fail:
sfree(rep->data);
__fio_mutex_remove(&rep->lock);
sfree(rep);
sfree(rep->data);
__fio_mutex_remove(&rep->lock);
sfree(rep);
- return
0
;
+ return
ret
;
}
static int fio_init_server_ip(void)
}
static int fio_init_server_ip(void)
@@
-2179,16
+2186,25
@@
static void set_sig_handlers(void)
sigaction(SIGINT, &act, NULL);
}
sigaction(SIGINT, &act, NULL);
}
-
static int fio_server
(void)
+
void fio_server_destroy_sk_key
(void)
{
{
- int sk, ret;
+ pthread_key_delete(sk_out_key);
+}
+int fio_server_create_sk_key(void)
+{
if (pthread_key_create(&sk_out_key, NULL)) {
log_err("fio: can't create sk_out backend key\n");
if (pthread_key_create(&sk_out_key, NULL)) {
log_err("fio: can't create sk_out backend key\n");
- return
-
1;
+ return 1;
}
pthread_setspecific(sk_out_key, NULL);
}
pthread_setspecific(sk_out_key, NULL);
+ return 0;
+}
+
+static int fio_server(void)
+{
+ int sk, ret;
dprint(FD_NET, "starting server\n");
dprint(FD_NET, "starting server\n");