From: Kern Sibbald Date: Sat, 17 Jan 2004 16:27:38 +0000 (+0000) Subject: Add maximum network buffer size directive X-Git-Tag: Release-1.34.0~158 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=5b543208c74dcc644456d01d4efd13195160d1ad;p=bacula%2Fbacula Add maximum network buffer size directive git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1015 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/kernstodo b/bacula/kernstodo index 9727a4b2bc..fe59a6b282 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -1,5 +1,5 @@ Kern's ToDo List - 13 January 2004 + 17 January 2004 Documentation to do: (any release a little bit at a time) - Document running a test version. @@ -58,16 +58,7 @@ For 1.33 Testing/Documentation: - Document Pool keyword for restore. For 1.33 -- Implement alist processing for ACLs from Console. - Finish code passing files=nnn to restore start. -- Add Console usr permissions -- do by adding regex filters for - jobs, clients, storage, ... -- Put max network buffer size on a directive. -- Why does "mark cygwin" take so long!!!!!!!! -- When a file is set for restore, walk back up the chain of - directories, setting them to be restored. -- Figure out a way to set restore on a directory without recursively - decending. (recurse off?). - Add level to estimate command. - Check time/dates printed during restore when using Win32 API. - Volume "add"ed to Pool gets recycled in first use. VolBytes=0 @@ -1118,3 +1109,13 @@ Done: (see kernsdone for more) - Something is not right in last block of fill command. - Add FileSet to command line arguments for restore. - Enhance time and size scanning routines. +- Add Console usr permissions -- do by adding filters for + jobs, clients, storage, ... +- Put max network buffer size on a directive. +- Why does "mark cygwin" take so long!!!!!!!! +- Implement alist processing for ACLs from Console. +- When a file is set for restore, walk back up the chain of + directories, setting them to be restored. +- Figure out a way to set restore on a directory without recursively + decending. (recurse off?). + diff --git a/bacula/src/baconfig.h b/bacula/src/baconfig.h index 95205cfb5c..90a2248fbb 100644 --- a/bacula/src/baconfig.h +++ b/bacula/src/baconfig.h @@ -95,10 +95,9 @@ #endif /* - * Maximum number of bytes that you can push into a - * socket. + * Default network buffer size */ -#define MAX_NETWORK_BUFFER_SIZE (32 * 1024) +#define DEFAULT_NETWORK_BUFFER_SIZE (32 * 1024) /* * Stream definitions. Once defined these must NEVER diff --git a/bacula/src/filed/authenticate.c b/bacula/src/filed/authenticate.c index ac4867c134..f3d8e9f434 100644 --- a/bacula/src/filed/authenticate.c +++ b/bacula/src/filed/authenticate.c @@ -61,10 +61,9 @@ static int authenticate(int rcode, BSOCK *bs) bs->who, bs->msg); return 0; } - director = NULL; unbash_spaces(dirname); LockRes(); - while ((director=(DIRRES *)GetNextRes(rcode, (RES *)director))) { + foreach_res(director, R_DIRECTOR) { if (strcmp(director->hdr.name, dirname) == 0) break; } diff --git a/bacula/src/filed/backup.c b/bacula/src/filed/backup.c index 68c475df97..eb9302156d 100644 --- a/bacula/src/filed/backup.c +++ b/bacula/src/filed/backup.c @@ -55,7 +55,16 @@ int blast_data_to_storage_daemon(JCR *jcr, char *addr) Dmsg1(110, "bfiled: opened data connection %d to stored\n", sd->fd); - if (!bnet_set_buffer_size(sd, MAX_NETWORK_BUFFER_SIZE, BNET_SETBUF_WRITE)) { + LockRes(); + CLIENT *client = (CLIENT *)GetNextRes(R_CLIENT, NULL); + UnlockRes(); + uint32_t buf_size; + if (client) { + buf_size = client->max_network_buffer_size; + } else { + buf_size = 0; /* use default */ + } + if (!bnet_set_buffer_size(sd, buf_size, BNET_SETBUF_WRITE)) { set_jcr_job_status(jcr, JS_ErrorTerminated); return 0; } diff --git a/bacula/src/filed/filed_conf.c b/bacula/src/filed/filed_conf.c index fcc3e53ca7..022d7ba6cb 100644 --- a/bacula/src/filed/filed_conf.c +++ b/bacula/src/filed/filed_conf.c @@ -8,14 +8,14 @@ * 1. The generic lexical scanner in lib/lex.c and lib/lex.h * * 2. The generic config scanner in lib/parse_config.c and - * lib/parse_config.h. - * These files contain the parser code, some utility - * routines, and the common store routines (name, int, - * string). + * lib/parse_config.h. + * These files contain the parser code, some utility + * routines, and the common store routines (name, int, + * string). * * 3. The daemon specific file, which contains the Resource - * definitions as well as any specific store routines - * for the resource records. + * definitions as well as any specific store routines + * for the resource records. * * Kern Sibbald, September MM * @@ -83,6 +83,7 @@ static struct res_items cli_items[] = { {"messages", store_res, ITEM(res_client.messages), R_MSGS, 0, 0}, {"heartbeatinterval", store_time, ITEM(res_client.heartbeat_interval), 0, ITEM_DEFAULT, 0}, {"sdconnecttimeout", store_time,ITEM(res_client.SDConnectTimeout), 0, ITEM_DEFAULT, 60 * 30}, + {"maximumnetworkbuffersize", store_pint, ITEM(res_client.max_network_buffer_size), 0, 0, 0}, {NULL, NULL, NULL, 0, 0, 0} }; @@ -108,7 +109,7 @@ struct s_res resources[] = { {"filedaemon", cli_items, R_CLIENT, NULL}, {"client", cli_items, R_CLIENT, NULL}, /* alias for filedaemon */ {"messages", msgs_items, R_MSGS, NULL}, - {NULL, NULL, 0, NULL} + {NULL, NULL, 0, NULL} }; @@ -122,26 +123,26 @@ void dump_resource(int type, RES *reshdr, void sendit(void *sock, char *fmt, ... sendit(sock, "No record for %d %s\n", type, res_to_str(type)); return; } - if (type < 0) { /* no recursion */ + if (type < 0) { /* no recursion */ type = - type; recurse = 0; } switch (type) { case R_DIRECTOR: sendit(sock, "Director: name=%s password=%s\n", reshdr->name, - res->res_dir.password); - break; + res->res_dir.password); + break; case R_CLIENT: sendit(sock, "Client: name=%s FDport=%d\n", reshdr->name, - res->res_client.FDport); - break; + res->res_client.FDport); + break; case R_MSGS: sendit(sock, "Messages: name=%s\n", res->res_msgs.hdr.name); - if (res->res_msgs.mail_cmd) + if (res->res_msgs.mail_cmd) sendit(sock, " mailcmd=%s\n", res->res_msgs.mail_cmd); - if (res->res_msgs.operator_cmd) + if (res->res_msgs.operator_cmd) sendit(sock, " opcmd=%s\n", res->res_msgs.operator_cmd); - break; + break; default: sendit(sock, "Unknown resource type %d\n", type); } @@ -179,35 +180,35 @@ void free_resource(int type) switch (type) { case R_DIRECTOR: - if (res->res_dir.password) { - free(res->res_dir.password); - } - if (res->res_dir.address) { - free(res->res_dir.address); - } - break; + if (res->res_dir.password) { + free(res->res_dir.password); + } + if (res->res_dir.address) { + free(res->res_dir.address); + } + break; case R_CLIENT: - if (res->res_client.working_directory) { - free(res->res_client.working_directory); - } - if (res->res_client.pid_directory) { - free(res->res_client.pid_directory); - } - if (res->res_client.subsys_directory) { - free(res->res_client.subsys_directory); - } - if (res->res_client.FDaddr) { - free(res->res_client.FDaddr); - } - break; + if (res->res_client.working_directory) { + free(res->res_client.working_directory); + } + if (res->res_client.pid_directory) { + free(res->res_client.pid_directory); + } + if (res->res_client.subsys_directory) { + free(res->res_client.subsys_directory); + } + if (res->res_client.FDaddr) { + free(res->res_client.FDaddr); + } + break; case R_MSGS: - if (res->res_msgs.mail_cmd) - free(res->res_msgs.mail_cmd); - if (res->res_msgs.operator_cmd) - free(res->res_msgs.operator_cmd); - free_msgs_res((MSGS *)res); /* free message resource */ - res = NULL; - break; + if (res->res_msgs.mail_cmd) + free(res->res_msgs.mail_cmd); + if (res->res_msgs.operator_cmd) + free(res->res_msgs.operator_cmd); + free_msgs_res((MSGS *)res); /* free message resource */ + res = NULL; + break; default: printf("Unknown resource type %d\n", type); } @@ -237,10 +238,10 @@ void save_resource(int type, struct res_items *items, int pass) */ for (i=0; items[i].name; i++) { if (items[i].flags & ITEM_REQUIRED) { - if (!bit_is_set(i, res_all.res_dir.hdr.item_present)) { + if (!bit_is_set(i, res_all.res_dir.hdr.item_present)) { Emsg2(M_ABORT, 0, _("%s item is required in %s resource, but not found.\n"), - items[i].name, resources[rindex]); - } + items[i].name, resources[rindex]); + } } } @@ -251,33 +252,33 @@ void save_resource(int type, struct res_items *items, int pass) */ if (pass == 2) { switch (type) { - /* Resources not containing a resource */ - case R_MSGS: - case R_DIRECTOR: - break; + /* Resources not containing a resource */ + case R_MSGS: + case R_DIRECTOR: + break; - /* Resources containing another resource */ - case R_CLIENT: - if ((res = (URES *)GetResWithName(R_CLIENT, res_all.res_dir.hdr.name)) == NULL) { + /* Resources containing another resource */ + case R_CLIENT: + if ((res = (URES *)GetResWithName(R_CLIENT, res_all.res_dir.hdr.name)) == NULL) { Emsg1(M_ABORT, 0, "Cannot find Client resource %s\n", res_all.res_dir.hdr.name); - } - res->res_client.messages = res_all.res_client.messages; - break; - default: + } + res->res_client.messages = res_all.res_client.messages; + break; + default: Emsg1(M_ERROR, 0, _("Unknown resource type %d\n"), type); - error = 1; - break; + error = 1; + break; } /* Note, the resoure name was already saved during pass 1, * so here, we can just release it. */ if (res_all.res_dir.hdr.name) { - free(res_all.res_dir.hdr.name); - res_all.res_dir.hdr.name = NULL; + free(res_all.res_dir.hdr.name); + res_all.res_dir.hdr.name = NULL; } if (res_all.res_dir.hdr.desc) { - free(res_all.res_dir.hdr.desc); - res_all.res_dir.hdr.desc = NULL; + free(res_all.res_dir.hdr.desc); + res_all.res_dir.hdr.desc = NULL; } return; } @@ -285,39 +286,39 @@ void save_resource(int type, struct res_items *items, int pass) /* The following code is only executed on pass 1 */ switch (type) { case R_DIRECTOR: - size = sizeof(DIRRES); - break; + size = sizeof(DIRRES); + break; case R_CLIENT: - size = sizeof(CLIENT); - break; + size = sizeof(CLIENT); + break; case R_MSGS: - size = sizeof(MSGS); - break; + size = sizeof(MSGS); + break; default: printf(_("Unknown resource type %d\n"), type); - error = 1; - size = 1; - break; + error = 1; + size = 1; + break; } /* Common */ if (!error) { res = (URES *)malloc(size); memcpy(res, &res_all, size); if (!resources[rindex].res_head) { - resources[rindex].res_head = (RES *)res; /* store first entry */ + resources[rindex].res_head = (RES *)res; /* store first entry */ } else { - RES *next; - /* Add new res to end of chain */ - for (next=resources[rindex].res_head; next->next; next=next->next) { - if (strcmp(next->name, res->res_dir.hdr.name) == 0) { - Emsg2(M_ERROR_TERM, 0, + RES *next; + /* Add new res to end of chain */ + for (next=resources[rindex].res_head; next->next; next=next->next) { + if (strcmp(next->name, res->res_dir.hdr.name) == 0) { + Emsg2(M_ERROR_TERM, 0, _("Attempt to define second %s resource named \"%s\" is not permitted.\n"), - resources[rindex].name, res->res_dir.hdr.name); - } - } - next->next = (RES *)res; + resources[rindex].name, res->res_dir.hdr.name); + } + } + next->next = (RES *)res; Dmsg2(90, "Inserting %s res: %s\n", res_to_str(type), - res->res_dir.hdr.name); + res->res_dir.hdr.name); } } } diff --git a/bacula/src/filed/filed_conf.h b/bacula/src/filed/filed_conf.h index 08f0035133..47e3d637a0 100644 --- a/bacula/src/filed/filed_conf.h +++ b/bacula/src/filed/filed_conf.h @@ -65,6 +65,7 @@ struct CLIENT { int MaxConcurrentJobs; utime_t heartbeat_interval; /* Interval to send heartbeats to Dir */ utime_t SDConnectTimeout; /* timeout in seconds */ + uint32_t max_network_buffer_size; /* max network buf size */ }; diff --git a/bacula/src/filed/restore.c b/bacula/src/filed/restore.c index eb4afe2686..8b536647cb 100644 --- a/bacula/src/filed/restore.c +++ b/bacula/src/filed/restore.c @@ -67,7 +67,16 @@ void do_restore(JCR *jcr) sd = jcr->store_bsock; set_jcr_job_status(jcr, JS_Running); - if (!bnet_set_buffer_size(sd, MAX_NETWORK_BUFFER_SIZE, BNET_SETBUF_READ)) { + LockRes(); + CLIENT *client = (CLIENT *)GetNextRes(R_CLIENT, NULL); + UnlockRes(); + uint32_t buf_size; + if (client) { + buf_size = client->max_network_buffer_size; + } else { + buf_size = 0; /* use default */ + } + if (!bnet_set_buffer_size(sd, buf_size, BNET_SETBUF_WRITE)) { set_jcr_job_status(jcr, JS_ErrorTerminated); return; } diff --git a/bacula/src/filed/verify.c b/bacula/src/filed/verify.c index cf414d6320..2957cfc9f2 100644 --- a/bacula/src/filed/verify.c +++ b/bacula/src/filed/verify.c @@ -39,9 +39,10 @@ static int verify_file(FF_PKT *ff_pkt, void *my_pkt); void do_verify(JCR *jcr) { set_jcr_job_status(jcr, JS_Running); - jcr->buf_size = MAX_NETWORK_BUFFER_SIZE; + jcr->buf_size = DEFAULT_NETWORK_BUFFER_SIZE; if ((jcr->big_buf = (char *) malloc(jcr->buf_size)) == NULL) { - Jmsg1(jcr, M_ABORT, 0, _("Cannot malloc %d network read buffer\n"), MAX_NETWORK_BUFFER_SIZE); + Jmsg1(jcr, M_ABORT, 0, _("Cannot malloc %d network read buffer\n"), + DEFAULT_NETWORK_BUFFER_SIZE); } set_find_options((FF_PKT *)jcr->ff, jcr->incremental, jcr->mtime, jcr->mtime_only); Dmsg0(10, "Start find files\n"); diff --git a/bacula/src/filed/verify_vol.c b/bacula/src/filed/verify_vol.c index 0fc907a9bc..49e2e6b65e 100644 --- a/bacula/src/filed/verify_vol.c +++ b/bacula/src/filed/verify_vol.c @@ -60,7 +60,16 @@ void do_verify_volume(JCR *jcr) dir = jcr->dir_bsock; set_jcr_job_status(jcr, JS_Running); - if (!bnet_set_buffer_size(sd, MAX_NETWORK_BUFFER_SIZE, BNET_SETBUF_READ)) { + LockRes(); + CLIENT *client = (CLIENT *)GetNextRes(R_CLIENT, NULL); + UnlockRes(); + uint32_t buf_size; + if (client) { + buf_size = client->max_network_buffer_size; + } else { + buf_size = 0; /* use default */ + } + if (!bnet_set_buffer_size(sd, buf_size, BNET_SETBUF_WRITE)) { set_jcr_job_status(jcr, JS_FatalError); return; } diff --git a/bacula/src/lib/bnet.c b/bacula/src/lib/bnet.c index 9ff0ec2312..76350d7d30 100644 --- a/bacula/src/lib/bnet.c +++ b/bacula/src/lib/bnet.c @@ -272,9 +272,9 @@ bnet_suppress_error_messages(BSOCK *bsock, int flag) /* - * Transmit spooled data now + * Transmit spooled data now to a BSOCK */ -int bnet_despool(BSOCK *bsock) +int bnet_despool_to_bsock(BSOCK *bsock) { int32_t pktsiz; size_t nbytes; @@ -712,7 +712,7 @@ again: */ int bnet_set_buffer_size(BSOCK *bs, uint32_t size, int rw) { - uint32_t dbuf_size; + uint32_t dbuf_size, start_size; #if defined(IP_TOS) && defined(IPTOS_THROUGHPUT) int opt; @@ -720,7 +720,12 @@ int bnet_set_buffer_size(BSOCK *bs, uint32_t size, int rw) setsockopt(bs->fd, IPPROTO_IP, IP_TOS, (sockopt_val_t)&opt, sizeof(opt)); #endif - dbuf_size = size; + if (size != 0) { + dbuf_size = size; + } else { + dbuf_size = DEFAULT_NETWORK_BUFFER_SIZE; + } + start_size = dbuf_size; if ((bs->msg = realloc_pool_memory(bs->msg, dbuf_size+100)) == NULL) { Jmsg0(bs->jcr, M_FATAL, 0, _("Could not malloc BSOCK data buffer\n")); return 0; @@ -732,14 +737,20 @@ int bnet_set_buffer_size(BSOCK *bs, uint32_t size, int rw) dbuf_size -= TAPE_BSIZE; } Dmsg1(200, "set network buffer size=%d\n", dbuf_size); - if (dbuf_size != MAX_NETWORK_BUFFER_SIZE) + if (dbuf_size != start_size) { Jmsg1(bs->jcr, M_WARNING, 0, _("Warning network buffer = %d bytes not max size.\n"), dbuf_size); + } if (dbuf_size % TAPE_BSIZE != 0) { Jmsg1(bs->jcr, M_ABORT, 0, _("Network buffer size %d not multiple of tape block size.\n"), dbuf_size); } } - dbuf_size = size; + if (size != 0) { + dbuf_size = size; + } else { + dbuf_size = DEFAULT_NETWORK_BUFFER_SIZE; + } + start_size = dbuf_size; if (rw & BNET_SETBUF_WRITE) { while ((dbuf_size > TAPE_BSIZE) && (setsockopt(bs->fd, SOL_SOCKET, SO_SNDBUF, (sockopt_val_t)&dbuf_size, sizeof(dbuf_size)) < 0)) { @@ -747,8 +758,9 @@ int bnet_set_buffer_size(BSOCK *bs, uint32_t size, int rw) dbuf_size -= TAPE_BSIZE; } Dmsg1(200, "set network buffer size=%d\n", dbuf_size); - if (dbuf_size != MAX_NETWORK_BUFFER_SIZE) + if (dbuf_size != start_size) { Jmsg1(bs->jcr, M_WARNING, 0, _("Warning network buffer = %d bytes not max size.\n"), dbuf_size); + } if (dbuf_size % TAPE_BSIZE != 0) { Jmsg1(bs->jcr, M_ABORT, 0, _("Network buffer size %d not multiple of tape block size.\n"), dbuf_size); diff --git a/bacula/src/lib/bsock.h b/bacula/src/lib/bsock.h index ad0da87d22..49af7fbc53 100644 --- a/bacula/src/lib/bsock.h +++ b/bacula/src/lib/bsock.h @@ -32,48 +32,48 @@ */ struct BSOCK { - uint64_t read_seqno; /* read sequence number */ - uint32_t in_msg_no; /* input message number */ - uint32_t out_msg_no; /* output message number */ - int fd; /* socket file descriptor */ - int32_t msglen; /* message length */ - int b_errno; /* bsock errno */ - int port; /* desired port */ - volatile bool errors: 1; /* set if errors on socket */ + uint64_t read_seqno; /* read sequence number */ + uint32_t in_msg_no; /* input message number */ + uint32_t out_msg_no; /* output message number */ + int fd; /* socket file descriptor */ + int32_t msglen; /* message length */ + int b_errno; /* bsock errno */ + int port; /* desired port */ + volatile bool errors: 1; /* set if errors on socket */ volatile bool suppress_error_msgs: 1; /* set to suppress error messages */ - volatile bool timed_out: 1; /* timed out in read/write */ + volatile bool timed_out: 1; /* timed out in read/write */ volatile bool terminated: 1; /* set when BNET_TERMINATE arrives */ - bool duped: 1; /* set if duped BSOCK */ - bool spool: 1; /* set for spooling */ + bool duped: 1; /* set if duped BSOCK */ + bool spool: 1; /* set for spooling */ volatile time_t timer_start; /* time started read/write */ - volatile time_t timeout; /* timeout BSOCK after this interval */ - POOLMEM *msg; /* message pool buffer */ - char *who; /* Name of daemon to which we are talking */ - char *host; /* Host name/IP */ - POOLMEM *errmsg; /* edited error message (to be implemented) */ - RES *res; /* Resource to which we are connected */ - BSOCK *next; /* next BSOCK if duped */ - FILE *spool_fd; /* spooling file */ - JCR *jcr; /* jcr or NULL for error msgs */ + volatile time_t timeout; /* timeout BSOCK after this interval */ + POOLMEM *msg; /* message pool buffer */ + char *who; /* Name of daemon to which we are talking */ + char *host; /* Host name/IP */ + POOLMEM *errmsg; /* edited error message (to be implemented) */ + RES *res; /* Resource to which we are connected */ + BSOCK *next; /* next BSOCK if duped */ + FILE *spool_fd; /* spooling file */ + JCR *jcr; /* jcr or NULL for error msgs */ struct sockaddr_in client_addr; /* client's IP address */ -}; +}; /* Signal definitions for use in bnet_sig() */ enum { - BNET_EOD = -1, /* End of data stream, new data may follow */ - BNET_EOD_POLL = -2, /* End of data and poll all in one */ - BNET_STATUS = -3, /* Send full status */ - BNET_TERMINATE = -4, /* Conversation terminated, doing close() */ + BNET_EOD = -1, /* End of data stream, new data may follow */ + BNET_EOD_POLL = -2, /* End of data and poll all in one */ + BNET_STATUS = -3, /* Send full status */ + BNET_TERMINATE = -4, /* Conversation terminated, doing close() */ BNET_POLL = -5, /* Poll request, I'm hanging on a read */ - BNET_HEARTBEAT = -6, /* Heartbeat Response requested */ - BNET_HB_RESPONSE = -7, /* Only response permited to HB */ - BNET_PROMPT = -8, /* Prompt for UA */ - BNET_BTIME = -9, /* Send UTC btime */ - BNET_BREAK = -10 /* Stop current command -- ctl-c */ + BNET_HEARTBEAT = -6, /* Heartbeat Response requested */ + BNET_HB_RESPONSE = -7, /* Only response permited to HB */ + BNET_PROMPT = -8, /* Prompt for UA */ + BNET_BTIME = -9, /* Send UTC btime */ + BNET_BREAK = -10 /* Stop current command -- ctl-c */ }; -#define BNET_SETBUF_READ 1 /* Arg for bnet_set_buffer_size */ -#define BNET_SETBUF_WRITE 2 /* Arg for bnet_set_buffer_size */ +#define BNET_SETBUF_READ 1 /* Arg for bnet_set_buffer_size */ +#define BNET_SETBUF_WRITE 2 /* Arg for bnet_set_buffer_size */ /* Return status from bnet_recv() */ #define BNET_SIGNAL -1 @@ -81,25 +81,25 @@ enum { #define BNET_ERROR -3 /* SSL enabling values */ -#define BNET_SSL_NONE 0 /* cannot do SSL */ -#define BNET_SSL_OK 1 /* can do, but not required on my end */ -#define BNET_SSL_REQUIRED 2 /* SSL is required */ +#define BNET_SSL_NONE 0 /* cannot do SSL */ +#define BNET_SSL_OK 1 /* can do, but not required on my end */ +#define BNET_SSL_REQUIRED 2 /* SSL is required */ /* * This is the structure of the in memory BPKT */ typedef struct s_bpkt { - char *id; /* String identifier or name of field */ - uint8_t type; /* field type */ - uint32_t len; /* field length for string, name, bytes */ - void *value; /* pointer to value */ + char *id; /* String identifier or name of field */ + uint8_t type; /* field type */ + uint32_t len; /* field length for string, name, bytes */ + void *value; /* pointer to value */ } BPKT; /* * These are the data types that can be sent. * For all values other than string, the storage space * is assumed to be allocated in the receiving packet. - * For BP_STRING if the *value is non-zero, it is a + * For BP_STRING if the *value is non-zero, it is a * pointer to a POOLMEM buffer, and the Memory Pool * routines will be used to assure that the length is * adequate. NOTE!!! This pointer will be changed @@ -107,13 +107,13 @@ typedef struct s_bpkt { * does). If the pointer is NULL, a POOLMEM * buffer will be allocated. */ -#define BP_EOF 0 /* end of file */ -#define BP_CHAR 1 /* Character */ -#define BP_INT32 1 /* 32 bit integer */ -#define BP_UINT32 3 /* Unsigned 32 bit integer */ -#define BP_INT64 4 /* 64 bit integer */ -#define BP_STRING 5 /* string */ -#define BP_NAME 6 /* Name string -- limited length */ -#define BP_BYTES 7 /* Binary bytes */ -#define BP_FLOAT32 8 /* 32 bit floating point */ -#define BP_FLOAT64 9 /* 64 bit floating point */ +#define BP_EOF 0 /* end of file */ +#define BP_CHAR 1 /* Character */ +#define BP_INT32 1 /* 32 bit integer */ +#define BP_UINT32 3 /* Unsigned 32 bit integer */ +#define BP_INT64 4 /* 64 bit integer */ +#define BP_STRING 5 /* string */ +#define BP_NAME 6 /* Name string -- limited length */ +#define BP_BYTES 7 /* Binary bytes */ +#define BP_FLOAT32 8 /* 32 bit floating point */ +#define BP_FLOAT64 9 /* 64 bit floating point */ diff --git a/bacula/src/lib/protos.h b/bacula/src/lib/protos.h index 128db706a3..6dce67f578 100644 --- a/bacula/src/lib/protos.h +++ b/bacula/src/lib/protos.h @@ -80,7 +80,7 @@ char * bnet_strerror (BSOCK *bsock); char * bnet_sig_to_ascii (BSOCK *bsock); int bnet_wait_data (BSOCK *bsock, int sec); int bnet_wait_data_intr (BSOCK *bsock, int sec); -int bnet_despool (BSOCK *bsock); +int bnet_despool_to_bsock (BSOCK *bsock); int is_bnet_stop (BSOCK *bsock); int is_bnet_error (BSOCK *bsock); void bnet_suppress_error_messages(BSOCK *bsock, int flag); diff --git a/bacula/src/stored/append.c b/bacula/src/stored/append.c index 4b7a0c010c..6d42130636 100644 --- a/bacula/src/stored/append.c +++ b/bacula/src/stored/append.c @@ -32,7 +32,7 @@ static char OK_data[] = "3000 OK data\n"; /* Forward referenced functions */ -static bool is_spooled(JCR *jcr); +static bool are_attributes_spooled(JCR *jcr); static int begin_attribute_spool(JCR *jcr); static int discard_attribute_spool(JCR *jcr); static int commit_attribute_spool(JCR *jcr); @@ -61,7 +61,7 @@ int do_append_data(JCR *jcr) ds = fd_sock; - if (!bnet_set_buffer_size(ds, MAX_NETWORK_BUFFER_SIZE, BNET_SETBUF_WRITE)) { + if (!bnet_set_buffer_size(ds, dev->device->max_network_buffer_size, BNET_SETBUF_WRITE)) { set_jcr_job_status(jcr, JS_ErrorTerminated); Jmsg(jcr, M_FATAL, 0, _("Unable to set network buffer size.\n")); discard_attribute_spool(jcr); @@ -211,7 +211,7 @@ int do_append_data(JCR *jcr) if (stream == STREAM_UNIX_ATTRIBUTES || stream == STREAM_MD5_SIGNATURE || stream == STREAM_UNIX_ATTRIBUTES_EX || stream == STREAM_SHA1_SIGNATURE) { if (!jcr->no_attributes) { - if (is_spooled(jcr)) { + if (are_attributes_spooled(jcr)) { jcr->dir_bsock->spool = 1; } Dmsg0(200, "Send attributes.\n"); @@ -277,7 +277,7 @@ int do_append_data(JCR *jcr) return ok ? 1 : 0; } -static bool is_spooled(JCR *jcr) +static bool are_attributes_spooled(JCR *jcr) { return jcr->spool_attributes && jcr->dir_bsock->spool_fd; } @@ -292,7 +292,7 @@ static int begin_attribute_spool(JCR *jcr) static int discard_attribute_spool(JCR *jcr) { - if (is_spooled(jcr)) { + if (are_attributes_spooled(jcr)) { return close_spool_file(jcr, jcr->dir_bsock); } return 1; @@ -300,8 +300,8 @@ static int discard_attribute_spool(JCR *jcr) static int commit_attribute_spool(JCR *jcr) { - if (is_spooled(jcr)) { - bnet_despool(jcr->dir_bsock); + if (are_attributes_spooled(jcr)) { + bnet_despool_to_bsock(jcr->dir_bsock); return close_spool_file(jcr, jcr->dir_bsock); } return 1; diff --git a/bacula/src/stored/read.c b/bacula/src/stored/read.c index d2268133eb..1285e5a0d7 100644 --- a/bacula/src/stored/read.c +++ b/bacula/src/stored/read.c @@ -56,7 +56,7 @@ int do_read_data(JCR *jcr) bnet_fsend(fd, OK_data); Dmsg1(10, "bstored>filed: %s\n", fd->msg); - if (!bnet_set_buffer_size(fd, MAX_NETWORK_BUFFER_SIZE, BNET_SETBUF_READ)) { + if (!bnet_set_buffer_size(fd, dev->device->max_network_buffer_size, BNET_SETBUF_WRITE)) { return 0; } diff --git a/bacula/src/stored/stored_conf.c b/bacula/src/stored/stored_conf.c index 14541d328b..eb2ede2a41 100644 --- a/bacula/src/stored/stored_conf.c +++ b/bacula/src/stored/stored_conf.c @@ -105,6 +105,7 @@ static struct res_items dev_items[] = { {"maximumchangerwait", store_pint, ITEM(res_dev.max_changer_wait), 0, ITEM_DEFAULT, 5 * 60}, {"maximumopenwait", store_pint, ITEM(res_dev.max_open_wait), 0, ITEM_DEFAULT, 5 * 60}, {"maximumopenvolumes", store_pint, ITEM(res_dev.max_open_vols), 0, ITEM_DEFAULT, 1}, + {"maximumnetworkbuffersize", store_pint, ITEM(res_dev.max_network_buffer_size), 0, 0, 0}, {"volumepollinterval", store_time, ITEM(res_dev.vol_poll_interval), 0, 0, 0}, {"offlineonunmount", store_yesno, ITEM(res_dev.cap_bits), CAP_OFFLINEUNMOUNT, ITEM_DEFAULT, 0}, {"maximumrewindwait", store_pint, ITEM(res_dev.max_rewind_wait), 0, ITEM_DEFAULT, 5 * 60}, @@ -129,7 +130,7 @@ struct s_res resources[] = { {"storage", store_items, R_STORAGE, NULL}, {"device", dev_items, R_DEVICE, NULL}, {"messages", msgs_items, R_MSGS, NULL}, - {NULL, NULL, 0, NULL} + {NULL, NULL, 0, NULL} }; @@ -145,7 +146,7 @@ void dump_resource(int type, RES *reshdr, void sendit(void *sock, char *fmt, ... return; } sendit(sock, "dump_resource type=%d\n", type); - if (type < 0) { /* no recursion */ + if (type < 0) { /* no recursion */ type = - type; recurse = 0; } @@ -155,22 +156,22 @@ void dump_resource(int type, RES *reshdr, void sendit(void *sock, char *fmt, ... break; case R_STORAGE: sendit(sock, "Storage: name=%s SDaddr=%s SDport=%d SDDport=%d HB=%s\n", - res->res_store.hdr.name, NPRT(res->res_store.SDaddr), - res->res_store.SDport, res->res_store.SDDport, - edit_utime(res->res_store.heartbeat_interval, buf)); + res->res_store.hdr.name, NPRT(res->res_store.SDaddr), + res->res_store.SDport, res->res_store.SDDport, + edit_utime(res->res_store.heartbeat_interval, buf)); break; case R_DEVICE: sendit(sock, "Device: name=%s MediaType=%s Device=%s\n", - res->res_dev.hdr.name, - res->res_dev.media_type, res->res_dev.device_name); + res->res_dev.hdr.name, + res->res_dev.media_type, res->res_dev.device_name); sendit(sock, " rew_wait=%d min_bs=%d max_bs=%d\n", - res->res_dev.max_rewind_wait, res->res_dev.min_block_size, - res->res_dev.max_block_size); + res->res_dev.max_rewind_wait, res->res_dev.min_block_size, + res->res_dev.max_block_size); sendit(sock, " max_jobs=%d max_files=%" lld " max_size=%" lld "\n", - res->res_dev.max_volume_jobs, res->res_dev.max_volume_files, - res->res_dev.max_volume_size); + res->res_dev.max_volume_jobs, res->res_dev.max_volume_files, + res->res_dev.max_volume_size); sendit(sock, " max_file_size=%" lld " capacity=%" lld "\n", - res->res_dev.max_file_size, res->res_dev.volume_capacity); + res->res_dev.max_file_size, res->res_dev.volume_capacity); strcpy(buf, " "); if (res->res_dev.cap_bits & CAP_EOF) { bstrncat(buf, "CAP_EOF ", sizeof(buf)); @@ -255,57 +256,57 @@ void free_resource(int type) switch (type) { case R_DIRECTOR: - if (res->res_dir.password) { - free(res->res_dir.password); - } - if (res->res_dir.address) { - free(res->res_dir.address); - } - break; + if (res->res_dir.password) { + free(res->res_dir.password); + } + if (res->res_dir.address) { + free(res->res_dir.address); + } + break; case R_STORAGE: - if (res->res_store.address) { /* ***FIXME*** deprecated */ - free(res->res_store.address); - } - if (res->res_store.SDaddr) { - free(res->res_store.SDaddr); - } - if (res->res_store.working_directory) { - free(res->res_store.working_directory); - } - if (res->res_store.pid_directory) { - free(res->res_store.pid_directory); - } - if (res->res_store.subsys_directory) { - free(res->res_store.subsys_directory); - } - break; + if (res->res_store.address) { /* ***FIXME*** deprecated */ + free(res->res_store.address); + } + if (res->res_store.SDaddr) { + free(res->res_store.SDaddr); + } + if (res->res_store.working_directory) { + free(res->res_store.working_directory); + } + if (res->res_store.pid_directory) { + free(res->res_store.pid_directory); + } + if (res->res_store.subsys_directory) { + free(res->res_store.subsys_directory); + } + break; case R_DEVICE: - if (res->res_dev.media_type) { - free(res->res_dev.media_type); - } - if (res->res_dev.device_name) { - free(res->res_dev.device_name); - } - if (res->res_dev.changer_name) { - free(res->res_dev.changer_name); - } - if (res->res_dev.changer_command) { - free(res->res_dev.changer_command); - } - break; + if (res->res_dev.media_type) { + free(res->res_dev.media_type); + } + if (res->res_dev.device_name) { + free(res->res_dev.device_name); + } + if (res->res_dev.changer_name) { + free(res->res_dev.changer_name); + } + if (res->res_dev.changer_command) { + free(res->res_dev.changer_command); + } + break; case R_MSGS: - if (res->res_msgs.mail_cmd) { - free(res->res_msgs.mail_cmd); - } - if (res->res_msgs.operator_cmd) { - free(res->res_msgs.operator_cmd); - } - free_msgs_res((MSGS *)res); /* free message resource */ - res = NULL; - break; + if (res->res_msgs.mail_cmd) { + free(res->res_msgs.mail_cmd); + } + if (res->res_msgs.operator_cmd) { + free(res->res_msgs.operator_cmd); + } + free_msgs_res((MSGS *)res); /* free message resource */ + res = NULL; + break; default: Dmsg1(0, "Unknown resource type %d\n", type); - break; + break; } /* Common stuff again -- free the resource, recurse to next one */ if (res) { @@ -333,10 +334,10 @@ void save_resource(int type, struct res_items *items, int pass) */ for (i=0; items[i].name; i++) { if (items[i].flags & ITEM_REQUIRED) { - if (!bit_is_set(i, res_all.res_dir.hdr.item_present)) { + if (!bit_is_set(i, res_all.res_dir.hdr.item_present)) { Emsg2(M_ABORT, 0, _("%s item is required in %s resource, but not found.\n"), - items[i].name, resources[rindex]); - } + items[i].name, resources[rindex]); + } } /* If this triggers, take a look at lib/parse_conf.h */ if (i >= MAX_RES_ITEMS) { @@ -351,33 +352,33 @@ void save_resource(int type, struct res_items *items, int pass) */ if (pass == 2) { switch (type) { - /* Resources not containing a resource */ - case R_DIRECTOR: - case R_DEVICE: - case R_MSGS: - break; - - /* Resources containing a resource */ - case R_STORAGE: - if ((res = (URES *)GetResWithName(R_STORAGE, res_all.res_dir.hdr.name)) == NULL) { + /* Resources not containing a resource */ + case R_DIRECTOR: + case R_DEVICE: + case R_MSGS: + break; + + /* Resources containing a resource */ + case R_STORAGE: + if ((res = (URES *)GetResWithName(R_STORAGE, res_all.res_dir.hdr.name)) == NULL) { Emsg1(M_ABORT, 0, "Cannot find Storage resource %s\n", res_all.res_dir.hdr.name); - } - res->res_store.messages = res_all.res_store.messages; - break; - default: + } + res->res_store.messages = res_all.res_store.messages; + break; + default: printf("Unknown resource type %d\n", type); - error = 1; - break; + error = 1; + break; } if (res_all.res_dir.hdr.name) { - free(res_all.res_dir.hdr.name); - res_all.res_dir.hdr.name = NULL; + free(res_all.res_dir.hdr.name); + res_all.res_dir.hdr.name = NULL; } if (res_all.res_dir.hdr.desc) { - free(res_all.res_dir.hdr.desc); - res_all.res_dir.hdr.desc = NULL; + free(res_all.res_dir.hdr.desc); + res_all.res_dir.hdr.desc = NULL; } return; } @@ -385,42 +386,42 @@ void save_resource(int type, struct res_items *items, int pass) /* The following code is only executed on pass 1 */ switch (type) { case R_DIRECTOR: - size = sizeof(DIRRES); - break; + size = sizeof(DIRRES); + break; case R_STORAGE: - size = sizeof(STORES); - break; + size = sizeof(STORES); + break; case R_DEVICE: - size = sizeof(DEVRES); - break; + size = sizeof(DEVRES); + break; case R_MSGS: - size = sizeof(MSGS); - break; + size = sizeof(MSGS); + break; default: printf("Unknown resource type %d\n", type); - error = 1; - size = 1; - break; + error = 1; + size = 1; + break; } /* Common */ if (!error) { res = (URES *)malloc(size); memcpy(res, &res_all, size); if (!resources[rindex].res_head) { - resources[rindex].res_head = (RES *)res; /* store first entry */ + resources[rindex].res_head = (RES *)res; /* store first entry */ } else { - RES *next; - /* Add new res to end of chain */ - for (next=resources[rindex].res_head; next->next; next=next->next) { - if (strcmp(next->name, res->res_dir.hdr.name) == 0) { - Emsg2(M_ERROR_TERM, 0, + RES *next; + /* Add new res to end of chain */ + for (next=resources[rindex].res_head; next->next; next=next->next) { + if (strcmp(next->name, res->res_dir.hdr.name) == 0) { + Emsg2(M_ERROR_TERM, 0, _("Attempt to define second %s resource named \"%s\" is not permitted.\n"), - resources[rindex].name, res->res_dir.hdr.name); - } - } - next->next = (RES *)res; + resources[rindex].name, res->res_dir.hdr.name); + } + } + next->next = (RES *)res; Dmsg2(90, "Inserting %s res: %s\n", res_to_str(type), - res->res_dir.hdr.name); + res->res_dir.hdr.name); } } } diff --git a/bacula/src/stored/stored_conf.h b/bacula/src/stored/stored_conf.h index 65438b93bd..05a9c6d325 100644 --- a/bacula/src/stored/stored_conf.h +++ b/bacula/src/stored/stored_conf.h @@ -23,72 +23,73 @@ */ -#define R_FIRST 3001 +#define R_FIRST 3001 -#define R_DIRECTOR 3001 -#define R_STORAGE 3002 -#define R_DEVICE 3003 -#define R_MSGS 3004 +#define R_DIRECTOR 3001 +#define R_STORAGE 3002 +#define R_DEVICE 3003 +#define R_MSGS 3004 -#define R_LAST R_MSGS +#define R_LAST R_MSGS -#define R_NAME 3020 -#define R_ADDRESS 3021 -#define R_PASSWORD 3022 -#define R_TYPE 3023 -#define R_BACKUP 3024 +#define R_NAME 3020 +#define R_ADDRESS 3021 +#define R_PASSWORD 3022 +#define R_TYPE 3023 +#define R_BACKUP 3024 /* Definition of the contents of each Resource */ struct DIRRES { - RES hdr; + RES hdr; - char *password; /* Director password */ - char *address; /* Director IP address or zero */ - int enable_ssl; /* Use SSL with this Director */ + char *password; /* Director password */ + char *address; /* Director IP address or zero */ + int enable_ssl; /* Use SSL with this Director */ }; /* Storage daemon "global" definitions */ struct s_res_store { - RES hdr; + RES hdr; - char *address; /* deprecated */ - char *SDaddr; /* bind address */ - int SDport; /* Where we listen for Directors */ + char *address; /* deprecated */ + char *SDaddr; /* bind address */ + int SDport; /* Where we listen for Directors */ int SDDport; /* "Data" port where we listen for File daemons */ - char *working_directory; /* working directory for checkpoints */ + char *working_directory; /* working directory for checkpoints */ char *pid_directory; char *subsys_directory; - int require_ssl; /* Require SSL on all connections */ + int require_ssl; /* Require SSL on all connections */ uint32_t max_concurrent_jobs; /* maximum concurrent jobs to run */ - MSGS *messages; /* Daemon message handler */ - utime_t heartbeat_interval; /* Interval to send hb to FD */ + MSGS *messages; /* Daemon message handler */ + utime_t heartbeat_interval; /* Interval to send hb to FD */ }; typedef struct s_res_store STORES; /* Device specific definitions */ struct DEVRES { - RES hdr; - - char *media_type; /* User assigned media type */ - char *device_name; /* Archive device name */ - char *changer_name; /* Changer device name */ - char *changer_command; /* Changer command -- external program */ - uint32_t cap_bits; /* Capabilities of this device */ - uint32_t max_changer_wait; /* Changer timeout */ - uint32_t max_rewind_wait; /* maximum secs to wait for rewind */ - uint32_t max_open_wait; /* maximum secs to wait for open */ - uint32_t max_open_vols; /* maximum simultaneous open volumes */ - uint32_t min_block_size; /* min block size */ - uint32_t max_block_size; /* max block size */ - uint32_t max_volume_jobs; /* max jobs to put on one volume */ - utime_t vol_poll_interval; /* interval between polling volume during mount */ - int64_t max_volume_files; /* max files to put on one volume */ - int64_t max_volume_size; /* max bytes to put on one volume */ - int64_t max_file_size; /* max file size in bytes */ - int64_t volume_capacity; /* advisory capacity */ - DEVICE *dev; /* Pointer to phyical dev -- set at runtime */ + RES hdr; + + char *media_type; /* User assigned media type */ + char *device_name; /* Archive device name */ + char *changer_name; /* Changer device name */ + char *changer_command; /* Changer command -- external program */ + uint32_t cap_bits; /* Capabilities of this device */ + uint32_t max_changer_wait; /* Changer timeout */ + uint32_t max_rewind_wait; /* maximum secs to wait for rewind */ + uint32_t max_open_wait; /* maximum secs to wait for open */ + uint32_t max_open_vols; /* maximum simultaneous open volumes */ + uint32_t min_block_size; /* min block size */ + uint32_t max_block_size; /* max block size */ + uint32_t max_volume_jobs; /* max jobs to put on one volume */ + uint32_t max_network_buffer_size; /* max network buf size */ + utime_t vol_poll_interval; /* interval between polling volume during mount */ + int64_t max_volume_files; /* max files to put on one volume */ + int64_t max_volume_size; /* max bytes to put on one volume */ + int64_t max_file_size; /* max file size in bytes */ + int64_t volume_capacity; /* advisory capacity */ + DEVICE *dev; /* Pointer to phyical dev -- set at runtime */ }; union URES { @@ -96,5 +97,5 @@ union URES { STORES res_store; DEVRES res_dev; MSGS res_msgs; - RES hdr; + RES hdr; };