General:
+Changes to 1.37.21:
+- Implement attribute caching to put Signature into database
+ at the same time as the file attributes thus eliminating a
+ number of database accesses.
+- Correct a reservation problem.
+- Implement full Dir Storage use.
+- Reduce a bit of TLS #ifdeffing.
+
Changes to 1.37.20:
04Jun05
- Minor changes
*
* Version $Id$
*/
-
/*
Copyright (C) 2000-2005 Kern Sibbald
This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
+ modify it under the terms of the GNU General Public License
+ version 2 as ammended with additional clauses defined in the
+ file LICENSE in the main source directory.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public
- License along with this program; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- MA 02111-1307, USA.
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ the file LICENSE for additional details.
*/
* subroutines.
* S Q L I T E
*/
-typedef struct s_db {
+struct B_DB {
BQUEUE bq; /* queue control */
brwlock_t lock; /* transaction lock */
struct sqlite *db;
POOLMEM *esc_name; /* Escaped file/path name */
int fnl; /* file name length */
int pnl; /* path name length */
-} B_DB;
+};
/*
* subroutines.
* S Q L I T E
*/
-typedef struct s_db {
+struct B_DB {
BQUEUE bq; /* queue control */
brwlock_t lock; /* transaction lock */
struct sqlite3 *db;
POOLMEM *esc_name; /* Escaped file/path name */
int fnl; /* file name length */
int pnl; /* path name length */
-} B_DB;
+};
/*
* Conversion of sqlite 2 names to sqlite3
*
* M Y S Q L
*/
-typedef struct s_db {
+struct B_DB {
BQUEUE bq; /* queue control */
brwlock_t lock; /* transaction lock */
MYSQL mysql;
POOLMEM *esc_name; /* Escaped file/path name */
int fnl; /* file name length */
int pnl; /* path name length */
-} B_DB;
+};
#define DB_STATUS int
*
* P O S T G R E S Q L
*/
-typedef struct s_db {
+struct B_DB {
BQUEUE bq; /* queue control */
brwlock_t lock; /* transaction lock */
PGconn *db;
POOLMEM *esc_name; /* Escaped file/path name */
int fnl; /* file name length */
int pnl; /* path name length */
-} B_DB;
+};
void my_postgresql_free_result(B_DB *mdb);
POSTGRESQL_ROW my_postgresql_fetch_row (B_DB *mdb);
/* This is the REAL definition for using the
* Bacula internal DB
*/
-typedef struct s_db {
+struct B_DB {
BQUEUE bq; /* queue control */
/* pthread_mutex_t mutex; */ /* single thread lock */
brwlock_t lock; /* transaction lock */
POOLMEM *cached_path;
int cached_path_len; /* length of cached path */
uint32_t cached_path_id;
-} B_DB;
+};
#endif /* HAVE_SQLITE3 */
#endif /* HAVE_MYSQL */
/* This is a "dummy" definition for use outside of sql.c
*/
-typedef struct s_db {
+struct B_DB {
int dummy; /* for SunOS compiler */
-} B_DB;
+};
#endif /* __SQL_C */
if (!jcr->attr) {
jcr->attr = get_pool_memory(PM_FNAME);
}
+ if (!jcr->ar) {
+ jcr->ar = (ATTR_DBR *)malloc(sizeof(ATTR_DBR));
+ }
+
#ifdef HAVE_SQLITE
if (!mdb->allow_transactions) {
return;
if (!mdb) {
return;
}
-#ifdef xxx
+
if (jcr && jcr->cached_attribute) {
- if (!db_create_file_attributes_record(jcr, jcr->db, &jcr->ar)) {
+ Dmsg0(400, "Flush last cached attribute.\n");
+ if (!db_create_file_attributes_record(jcr, mdb, jcr->ar)) {
Jmsg1(jcr, M_FATAL, 0, _("Attribute create error. %s"), db_strerror(jcr->db));
}
jcr->cached_attribute = false;
}
-#endif
+
#ifdef HAVE_SQLITE
if (!mdb->allow_transactions) {
return;
*/
if (!(ar->Stream == STREAM_UNIX_ATTRIBUTES ||
ar->Stream == STREAM_UNIX_ATTRIBUTES_EX)) {
- Mmsg0(&mdb->errmsg, _("Attempt to put non-attributes into catalog\n"));
+ Mmsg1(&mdb->errmsg, _("Attempt to put non-attributes into catalog. Stream=%d\n"),
+ ar->Stream);
Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg);
goto bail_out;
}
*
* Version $Id$
*/
-
/*
Copyright (C) 2000-2005 Kern Sibbald
This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
+ modify it under the terms of the GNU General Public License
+ version 2 as ammended with additional clauses defined in the
+ file LICENSE in the main source directory.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public
- License along with this program; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- MA 02111-1307, USA.
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ the file LICENSE for additional details.
*/
return false;
}
/*
- * Now start a Storage daemon message thread
+ * Now start a Storage daemon message thread. Note,
+ * this thread is used to provide the catalog services
+ * for the backup job, including inserting the attributes
+ * into the catalog. See catalog_update() in catreq.c
*/
if (!start_storage_daemon_message_thread(jcr)) {
return false;
store->SDDport = store->SDport;
}
-#ifdef HAVE_TLS
/* TLS Requirement */
if (store->tls_enable) {
if (store->tls_require) {
tls_need = BNET_TLS_OK;
}
}
-#endif
bnet_fsend(fd, storaddr, store->address, store->SDDport,
tls_need);
* Version $Id$
*/
/*
- Copyright (C) 2000-2005 Kern Sibbald
+ Copyright (C) 2001-2005 Kern Sibbald
This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
+ modify it under the terms of the GNU General Public License
+ version 2 as ammended with additional clauses defined in the
+ file LICENSE in the main source directory.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public
- License along with this program; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- MA 02111-1307, USA.
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ the file LICENSE for additional details.
*/
char *p;
int len;
char *fname, *attr;
- ATTR_DBR *ar = &jcr->ar;
+ ATTR_DBR *ar = NULL;
if (!jcr->pool->catalog_files) {
- return;
+ return; /* user disabled cataloging */
}
+ /* Start transaction allocates jcr->attr and jcr->ar if needed */
db_start_transaction(jcr, jcr->db); /* start transaction if not already open */
- jcr->attr = check_pool_memory_size(jcr->attr, bs->msglen);
- memcpy(jcr->attr, bs->msg, bs->msglen);
- p = jcr->attr;
+ ar = jcr->ar;
+
+ /* Start by scanning directly in the message buffer to get Stream
+ * there may be a cached attr so we cannot yet write into
+ * jcr->attr or jcr->ar
+ */
+ p = bs->msg;
skip_nonspaces(&p); /* UpdCat */
skip_spaces(&p);
skip_nonspaces(&p); /* Job=nnn */
VolSessionId, VolSessionTime, FileIndex, Stream, data_len);
if (Stream == STREAM_UNIX_ATTRIBUTES || Stream == STREAM_UNIX_ATTRIBUTES_EX) {
+ if (jcr->cached_attribute) {
+ Dmsg2(400, "Cached attr. Stream=%d fname=%s\n", ar->Stream, ar->fname);
+ if (!db_create_file_attributes_record(jcr, jcr->db, ar)) {
+ Jmsg1(jcr, M_FATAL, 0, _("Attribute create error. %s"), db_strerror(jcr->db));
+ }
+ }
+ /* Any cached attr is flushed so we can reuse jcr->attr and jcr->ar */
+ jcr->attr = check_pool_memory_size(jcr->attr, bs->msglen);
+ memcpy(jcr->attr, bs->msg, bs->msglen);
+ p = jcr->attr - bs->msg + p; /* point p into jcr->attr */
skip_nonspaces(&p); /* skip FileIndex */
skip_spaces(&p);
skip_nonspaces(&p); /* skip FileType */
ar->JobId = jcr->JobId;
ar->Sig = NULL;
ar->SigType = 0;
+ jcr->cached_attribute = true;
Dmsg2(400, "dird<filed: stream=%d %s\n", Stream, fname);
Dmsg1(400, "dird<filed: attr=%s\n", attr);
+#ifdef xxx
if (!db_create_file_attributes_record(jcr, jcr->db, ar)) {
Jmsg1(jcr, M_FATAL, 0, _("Attribute create error. %s"), db_strerror(jcr->db));
}
+#endif
} else if (Stream == STREAM_MD5_SIGNATURE || Stream == STREAM_SHA1_SIGNATURE) {
fname = p;
if (ar->FileIndex != FileIndex) {
}
bin_to_base64(SIGbuf, fname, len);
Dmsg3(400, "SIGlen=%d SIG=%s type=%d\n", strlen(SIGbuf), SIGbuf, Stream);
- if (!db_add_SIG_to_file_record(jcr, jcr->db, ar->FileId, SIGbuf, type)) {
- Jmsg(jcr, M_ERROR, 0, _("Catalog error updating MD5/SHA1. %s"),
- db_strerror(jcr->db));
+ if (jcr->cached_attribute) {
+ ar->Sig = SIGbuf;
+ ar->SigType = type;
+ Dmsg2(400, "Cached attr with SIG. Stream=%d fname=%s\n", ar->Stream, ar->fname);
+ if (!db_create_file_attributes_record(jcr, jcr->db, ar)) {
+ Jmsg1(jcr, M_FATAL, 0, _("Attribute create error. %s"), db_strerror(jcr->db));
+ }
+ jcr->cached_attribute = false;
+ } else {
+ if (!db_add_SIG_to_file_record(jcr, jcr->db, ar->FileId, SIGbuf, type)) {
+ Jmsg(jcr, M_ERROR, 0, _("Catalog error updating MD5/SHA1. %s"),
+ db_strerror(jcr->db));
+ }
}
}
}
{"spoolattributes",store_yesno, ITEM(res_job.SpoolAttributes), 1, ITEM_DEFAULT, 0},
{"spooldata", store_yesno, ITEM(res_job.spool_data), 1, ITEM_DEFAULT, 0},
{"rerunfailedlevels", store_yesno, ITEM(res_job.rerun_failed_levels), 1, ITEM_DEFAULT, 0},
- {"newvolumeeachjob", store_yesno, ITEM(res_job.NewVolEachJob), 1, ITEM_DEFAULT, 0},
+ {"prefermountedvolumes", store_yesno, ITEM(res_job.PreferMountedVolumes), 1, ITEM_DEFAULT, 1},
{"runbeforejob", store_str, ITEM(res_job.RunBeforeJob), 0, 0, 0},
{"runafterjob", store_str, ITEM(res_job.RunAfterJob), 0, 0, 0},
{"runafterfailedjob", store_str, ITEM(res_job.RunAfterFailedJob), 0, 0, 0},
uint32_t MaxConcurrentJobs; /* Max concurrent jobs for whole director */
utime_t FDConnectTimeout; /* timeout for connect in seconds */
utime_t SDConnectTimeout; /* timeout in seconds */
-#ifdef HAVE_TLS
int tls_enable; /* Enable TLS */
- int tls_require; /* Require TLS */
+ int tls_require; /* Require TLS */
int tls_verify_peer; /* TLS Verify Client Certificate */
char *tls_ca_certfile; /* TLS CA Certificate File */
char *tls_ca_certdir; /* TLS CA Certificate Directory */
alist *tls_allowed_cns; /* TLS Allowed Clients */
TLS_CONTEXT *tls_ctx; /* Shared TLS Context */
-#endif /* HAVE_TLS */
};
/*
RES hdr;
char *password; /* UA server password */
alist *ACL_lists[Num_ACL]; /* pointers to ACLs */
-#ifdef HAVE_TLS
- int tls_enable; /* Enable TLS */
- int tls_require; /* Require TLS */
+ int tls_enable; /* Enable TLS */
+ int tls_require; /* Require TLS */
int tls_verify_peer; /* TLS Verify Client Certificate */
char *tls_ca_certfile; /* TLS CA Certificate File */
char *tls_ca_certdir; /* TLS CA Certificate Directory */
alist *tls_allowed_cns; /* TLS Allowed Clients */
TLS_CONTEXT *tls_ctx; /* Shared TLS Context */
-#endif /* HAVE_TLS */
};
CAT *catalog; /* Catalog resource */
uint32_t MaxConcurrentJobs; /* Maximume concurrent jobs */
uint32_t NumConcurrentJobs; /* number of concurrent jobs running */
-#ifdef HAVE_TLS
int tls_enable; /* Enable TLS */
- int tls_require; /* Require TLS */
+ int tls_require; /* Require TLS */
char *tls_ca_certfile; /* TLS CA Certificate File */
char *tls_ca_certdir; /* TLS CA Certificate Directory */
char *tls_certfile; /* TLS Client Certificate File */
char *tls_keyfile; /* TLS Client Key File */
TLS_CONTEXT *tls_ctx; /* Shared TLS Context */
-#endif /* HAVE_TLS */
};
/*
int autochanger; /* set if autochanger */
uint32_t MaxConcurrentJobs; /* Maximume concurrent jobs */
uint32_t NumConcurrentJobs; /* number of concurrent jobs running */
-#ifdef HAVE_TLS
int tls_enable; /* Enable TLS */
- int tls_require; /* Require TLS */
+ int tls_require; /* Require TLS */
char *tls_ca_certfile; /* TLS CA Certificate File */
char *tls_ca_certdir; /* TLS CA Certificate Directory */
char *tls_certfile; /* TLS Client Certificate File */
char *tls_keyfile; /* TLS Client Key File */
TLS_CONTEXT *tls_ctx; /* Shared TLS Context */
-#endif /* HAVE_TLS */
int64_t StorageId; /* Set from Storage DB record */
int SpoolAttributes; /* Set to spool attributes in SD */
int spool_data; /* Set to spool data in SD */
int rerun_failed_levels; /* Upgrade to rerun failed levels */
- int NewVolEachJob; /* Mount new volume each Job */
+ int PreferMountedVolumes; /* Prefer vols mounted rather than new one */
uint32_t MaxConcurrentJobs; /* Maximume concurrent jobs */
int RescheduleOnError; /* Set to reschedule on error */
int RescheduleTimes; /* Number of times to reschedule job */
pthread_cond_destroy(&jcr->term_wait);
jcr->term_wait_inited = false;
}
+ if (jcr->attr) {
+ free_pool_memory(jcr->attr);
+ jcr->attr = NULL;
+ }
+ if (jcr->ar) {
+ free(jcr->ar);
+ jcr->ar = NULL;
+ }
}
/*
*
* Basic tasks done here:
* Open a message channel with the Storage daemon
- * to authenticate ourself and to pass the JobId.
+ * to authenticate ourself and to pass the JobId.
* Create a thread to interact with the Storage daemon
- * who returns a job status and requests Catalog services, etc.
+ * who returns a job status and requests Catalog services, etc.
*
* Version $Id$
*/
Copyright (C) 2000-2005 Kern Sibbald
This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
+ modify it under the terms of the GNU General Public License
+ version 2 as ammended with additional clauses defined in the
+ file LICENSE in the main source directory.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public
- License along with this program; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- MA 02111-1307, USA.
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ the file LICENSE for additional details.
*/
/* Commands sent to Storage daemon */
static char jobcmd[] = "JobId=%d job=%s job_name=%s client_name=%s "
"type=%d level=%d FileSet=%s NoAttr=%d SpoolAttr=%d FileSetMD5=%s "
- "SpoolData=%d WritePartAfterJob=%d NewVol=%d\n";
+ "SpoolData=%d WritePartAfterJob=%d PreferMountedVols=%d\n";
static char use_storage[] = "use storage=%s media_type=%s pool_name=%s "
"pool_type=%s append=%d copy=%d stripe=%d\n";
static char use_device[] = "use device=%s\n";
/* Storage Daemon requests */
static char Job_start[] = "3010 Job %127s start\n";
-static char Job_end[] =
+static char Job_end[] =
"3099 Job %127s end JobStatus=%d JobFiles=%d JobBytes=%" lld "\n";
/* Forward referenced functions */
* and perform authentication.
*/
bool connect_to_storage_daemon(JCR *jcr, int retry_interval,
- int max_retry_time, int verbose)
+ int max_retry_time, int verbose)
{
BSOCK *sd;
STORE *store;
if (jcr->store_bsock) {
- return true; /* already connected */
+ return true; /* already connected */
}
store = (STORE *)jcr->storage->first();
store->SDport);
sd = bnet_connect(jcr, retry_interval, max_retry_time,
_("Storage daemon"), store->address,
- NULL, store->SDport, verbose);
+ NULL, store->SDport, verbose);
if (sd == NULL) {
return false;
}
- sd->res = (RES *)store; /* save pointer to other end */
+ sd->res = (RES *)store; /* save pointer to other end */
jcr->store_bsock = sd;
if (!authenticate_storage_daemon(jcr, store)) {
bstrncpy(jcr->fileset->MD5, "**Dummy**", sizeof(jcr->fileset->MD5));
}
bnet_fsend(sd, jobcmd, jcr->JobId, jcr->Job, jcr->job->hdr.name,
- jcr->client->hdr.name, jcr->JobType, jcr->JobLevel,
- jcr->fileset->hdr.name, !jcr->pool->catalog_files,
- jcr->job->SpoolAttributes, jcr->fileset->MD5, jcr->spool_data,
- jcr->write_part_after_job, jcr->job->NewVolEachJob);
+ jcr->client->hdr.name, jcr->JobType, jcr->JobLevel,
+ jcr->fileset->hdr.name, !jcr->pool->catalog_files,
+ jcr->job->SpoolAttributes, jcr->fileset->MD5, jcr->spool_data,
+ jcr->write_part_after_job, jcr->job->PreferMountedVolumes);
Dmsg1(100, ">stored: %s\n", sd->msg);
unbash_spaces(jcr->job->hdr.name);
unbash_spaces(jcr->client->hdr.name);
if (bget_dirmsg(sd) > 0) {
Dmsg1(100, "<stored: %s", sd->msg);
if (sscanf(sd->msg, OKjob, &jcr->VolSessionId,
- &jcr->VolSessionTime, &auth_key) != 3) {
+ &jcr->VolSessionTime, &auth_key) != 3) {
Dmsg1(100, "BadJob=%s\n", sd->msg);
Jmsg(jcr, M_FATAL, 0, _("Storage daemon rejected Job command: %s\n"), sd->msg);
- return 0;
+ return 0;
} else {
- jcr->sd_auth_key = bstrdup(auth_key);
+ jcr->sd_auth_key = bstrdup(auth_key);
Dmsg1(150, "sd_auth_key=%s\n", jcr->sd_auth_key);
}
} else {
Jmsg(jcr, M_FATAL, 0, _("<stored: bad response to Job command: %s\n"),
- bnet_strerror(sd));
+ bnet_strerror(sd));
return 0;
}
*
* Note, the outer loop is not yet implemented.
*/
-// foreach_alist(storage, store) {
- storage = (STORE *)store->first();
+ foreach_alist(storage, store) {
+// storage = (STORE *)store->first();
pm_strcpy(store_name, storage->hdr.name);
bash_spaces(store_name);
pm_strcpy(media_type, storage->media_type);
bash_spaces(media_type);
bnet_fsend(sd, use_storage, store_name.c_str(), media_type.c_str(),
- pool_name.c_str(), pool_type.c_str(), append, copy, stripe);
+ pool_name.c_str(), pool_type.c_str(), append, copy, stripe);
DEVICE *dev;
/* Loop over alternative storage Devices until one is OK */
foreach_alist(dev, storage->device) {
- pm_strcpy(device_name, dev->hdr.name);
- bash_spaces(device_name);
- bnet_fsend(sd, use_device, device_name.c_str());
+ pm_strcpy(device_name, dev->hdr.name);
+ bash_spaces(device_name);
+ bnet_fsend(sd, use_device, device_name.c_str());
Dmsg1(100, ">stored: %s", sd->msg);
}
- bnet_sig(sd, BNET_EOD); /* end of Devices */
- bnet_sig(sd, BNET_EOD); /* end of Storages */
+ bnet_sig(sd, BNET_EOD); /* end of Devices */
+ bnet_sig(sd, BNET_EOD); /* end of Storages */
if (bget_dirmsg(sd) > 0) {
Dmsg1(100, "<stored: %s", sd->msg);
- /* ****FIXME**** save actual device name */
- ok = sscanf(sd->msg, OK_device, device_name.c_str()) == 1;
+ /* ****FIXME**** save actual device name */
+ ok = sscanf(sd->msg, OK_device, device_name.c_str()) == 1;
} else {
- POOL_MEM err_msg;
- pm_strcpy(err_msg, sd->msg); /* save message */
- Jmsg(jcr, M_WARNING, 0, _("\n"
+ POOL_MEM err_msg;
+ pm_strcpy(err_msg, sd->msg); /* save message */
+ Jmsg(jcr, M_FATAL, 0, _("\n"
" Storage daemon didn't accept Device \"%s\" because:\n %s"),
- device_name.c_str(), err_msg.c_str()/* sd->msg */);
+ device_name.c_str(), err_msg.c_str()/* sd->msg */);
}
-// if (!ok) {
-// break;
-// }
-// }
+ break;
+ }
if (ok) {
ok = bnet_fsend(sd, "run");
Dmsg1(100, ">stored: %s\n", sd->msg);
pthread_t thid;
P(jcr->mutex);
- jcr->use_count++; /* mark in use by msg thread */
+ jcr->use_count++; /* mark in use by msg thread */
jcr->sd_msg_thread_done = false;
jcr->SD_msg_chan = 0;
V(jcr->mutex);
{
JCR *jcr = (JCR *)arg;
Dmsg0(200, "End msg_thread\n");
- db_end_transaction(jcr, jcr->db); /* terminate any open transaction */
+ db_end_transaction(jcr, jcr->db); /* terminate any open transaction */
P(jcr->mutex);
jcr->sd_msg_thread_done = true;
pthread_cond_broadcast(&jcr->term_wait); /* wakeup any waiting threads */
jcr->SD_msg_chan = 0;
V(jcr->mutex);
- free_jcr(jcr); /* release jcr */
+ free_jcr(jcr); /* release jcr */
}
/*
while ((stat=bget_dirmsg(sd)) >= 0) {
Dmsg1(200, "<stored: %s", sd->msg);
if (sscanf(sd->msg, Job_start, &Job) == 1) {
- continue;
+ continue;
}
if (sscanf(sd->msg, Job_end, &Job, &JobStatus, &JobFiles,
- &JobBytes) == 4) {
- jcr->SDJobStatus = JobStatus; /* termination status */
- jcr->SDJobFiles = JobFiles;
- jcr->SDJobBytes = JobBytes;
- break;
+ &JobBytes) == 4) {
+ jcr->SDJobStatus = JobStatus; /* termination status */
+ jcr->SDJobFiles = JobFiles;
+ jcr->SDJobBytes = JobBytes;
+ break;
}
}
if (is_bnet_error(sd)) {
jcr->SDJobStatus = JS_ErrorTerminated;
}
- pthread_cleanup_pop(1); /* remove and execute the handler */
+ pthread_cleanup_pop(1); /* remove and execute the handler */
return NULL;
}
Dmsg0(300, "I'm waiting for message thread termination.\n");
pthread_cond_timedwait(&jcr->term_wait, &jcr->mutex, &timeout);
if (job_canceled(jcr)) {
- cancel_count++;
+ cancel_count++;
}
/* Give SD 30 seconds to clean up after cancel */
if (cancel_count == 3) {
- break;
+ break;
}
}
V(jcr->mutex);
for (i=0; i < MAX_TRIES; i++) {
if (!connect_to_storage_daemon(jcr, 10, 30, 1)) {
Dmsg0(000, "Failed connecting to SD.\n");
- continue;
+ continue;
}
LockRes();
foreach_res(dev, R_DEVICE) {
- if (!update_device_res(jcr, dev)) {
+ if (!update_device_res(jcr, dev)) {
Dmsg1(900, "Error updating device=%s\n", dev->hdr.name);
- } else {
+ } else {
Dmsg1(900, "Updated Device=%s\n", dev->hdr.name);
- }
+ }
}
UnlockRes();
bnet_close(jcr->store_bsock);
/* Forward referenced structures */
class JCR;
struct FF_PKT;
+struct B_DB;
+struct ATTR_DBR;
typedef void (JCR_free_HANDLER)(JCR *jcr);
bool cached_attribute; /* set if attribute is cached */
POOLMEM *attr; /* Attribute string from SD */
+ B_DB *db; /* database pointer */
+ ATTR_DBR *ar; /* DB attribute record */
/* Daemon specific part of JCR */
/* This should be empty in the library */
volatile int SDJobStatus; /* Storage Job Status */
volatile int FDJobStatus; /* File daemon Job Status */
uint32_t ExpectedFiles; /* Expected restore files */
- B_DB *db; /* database pointer */
uint32_t MediaId; /* DB record IDs associated with this job */
uint32_t PoolId; /* Pool record id */
FileId_t FileId; /* Last file id inserted */
bool needs_sd; /* set if SD needed by Job */
bool cloned; /* set if cloned */
bool unlink_bsr; /* Unlink bsr file created */
- ATTR_DBR ar; /* DB attribute record */
#endif /* DIRECTOR_DAEMON */
int CurVol; /* Current Volume count */
DIRRES* director; /* Director resource */
bool write_part_after_job; /* Set to write part after job */
- bool NewVolEachJob; /* Allow using new volume */
+ bool PreferMountedVols; /* Prefer mounted vols rather than new */
uint32_t FileId; /* Last file id inserted */
JCR *jcr = dcr->jcr;
DEVICE *dev = dcr->dev;
- /*
- * If we reserved the device, we must decrement the
- * number of writers.
- */
if (dcr->reserved_device) {
lock_device(dev);
- dev->num_writers--;
+ dev->reserved_device--;
+ Dmsg1(200, "=========== Dec reserve=%d\n", dev->reserved_device);
+ dcr->reserved_device = false;
if (dev->num_writers < 0) {
Jmsg1(dcr->jcr, M_ERROR, 0, _("Hey! num_writers=%d!!!!\n"), dev->num_writers);
dev->num_writers = 0;
- dcr->reserved_device = false;
}
unlock_device(dev);
}
if (dcr->reserved_device) {
dev->reserved_device--;
+ Dmsg1(200, "============ Dec reserve=%d\n", dev->reserved_device);
dcr->reserved_device = false;
}
/* if device is reserved, job never started, so release the reserve here */
if (dcr->reserved_device) {
dev->reserved_device--;
+ Dmsg1(200, "========= Dec reserve=%d\n", dev->reserved_device);
dcr->reserved_device = false;
}
DEVICE *dev = dcr->dev;
- Dmsg0(10, "Start append data.\n");
+ Dmsg0(100, "Start append data.\n");
memset(&rec, 0, sizeof(rec));
Copyright (C) 2000-2005 Kern Sibbald
This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
+ modify it under the terms of the GNU General Public License
+ version 2 as ammended with additional clauses defined in the
+ file LICENSE in the main source directory.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public
- License along with this program; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- MA 02111-1307, USA.
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ the file LICENSE for additional details.
*/
int is_open() const { return state & ST_OPENED; }
int is_offline() const { return state & ST_OFFLINE; }
int is_labeled() const { return state & ST_LABEL; }
- int is_busy() const; /* either reading or writing */
+ int is_busy() const { return state & ST_READ || num_writers || reserved_device; }
int at_eof() const { return state & ST_EOF; }
int at_eot() const { return state & ST_EOT; }
int at_weot() const { return state & ST_WEOT; }
};
/* Note, these return int not bool! */
-inline int DEVICE::is_busy() const { return state & ST_READ || num_writers || reserved_device; }
inline const char *DEVICE::strerror() const { return errmsg; }
inline const char *DEVICE::archive_name() const { return dev_name; }
inline const char *DEVICE::print_name() const { return prt_name; }
/* Requests from the Director daemon */
static char jobcmd[] = "JobId=%d job=%127s job_name=%127s client_name=%127s "
"type=%d level=%d FileSet=%127s NoAttr=%d SpoolAttr=%d FileSetMD5=%127s "
- "SpoolData=%d WritePartAfterJob=%d NewVol=%d\n";
+ "SpoolData=%d WritePartAfterJob=%d PreferMountedVols=%d\n";
/* Responses sent to Director daemon */
BSOCK *dir = jcr->dir_bsock;
POOL_MEM job_name, client_name, job, fileset_name, fileset_md5;
int JobType, level, spool_attributes, no_attributes, spool_data;
- int write_part_after_job, NewVol;
+ int write_part_after_job, PreferMountedVols;
JCR *ojcr;
client_name.c_str(),
&JobType, &level, fileset_name.c_str(), &no_attributes,
&spool_attributes, fileset_md5.c_str(), &spool_data,
- &write_part_after_job, &NewVol) != 13) {
+ &write_part_after_job, &PreferMountedVols) != 13) {
pm_strcpy(jcr->errmsg, dir->msg);
bnet_fsend(dir, BAD_job, jcr->errmsg);
Dmsg1(100, ">dird: %s\n", dir->msg);
jcr->write_part_after_job = write_part_after_job;
jcr->fileset_md5 = get_pool_memory(PM_NAME);
pm_strcpy(jcr->fileset_md5, fileset_md5);
- jcr->NewVolEachJob = NewVol;
+ jcr->PreferMountedVols = PreferMountedVols;
jcr->authenticated = false;
/* */
#undef VERSION
-#define VERSION "1.37.20"
+#define VERSION "1.37.21"
#define BDATE "04 June 2005"
#define LSMDATE "04Jun05"