Skip to content

Commit

Permalink
Merge branch 'bareos-15.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco van Wieringen committed Apr 18, 2016
2 parents 963c634 + b1976e8 commit 5cdbf0b
Show file tree
Hide file tree
Showing 11 changed files with 20,044 additions and 84 deletions.
6 changes: 4 additions & 2 deletions src/dird/Makefile.in
Expand Up @@ -22,6 +22,8 @@ GETTEXT_LIBS = @LIBINTL@
CAP_LIBS = @CAP_LIBS@
NDMP_LIBS = @NDMP_LIBS@
DB_LIBS=@DB_LIBS@
LMDB_LIBS=@LMDB_LIBS@

OPENSSL_LIBS_NONSHARED = @OPENSSL_LIBS_NONSHARED@
GNUTLS_LIBS_NONSHARED = @GNUTLS_LIBS_NONSHARED@

Expand All @@ -47,7 +49,7 @@ DBCHKOBJS = $(DBCHKSRCS:.c=.o)
TSTFNDSRCS = testfind.c dird_conf.c ua_acl.c ua_audit.c run_conf.c inc_conf.c
TSTFNDOBJS = $(TSTFNDSRCS:.c=.o)

INCLUDES += -I$(srcdir) -I$(basedir) -I$(basedir)/include
INCLUDES += -I$(srcdir) -I$(basedir) -I$(basedir)/include -I$(basedir)/lmdb -I$(basedir)/ndmp

JANSSON_CPPFLAGS = @JANSSON_INC@

Expand Down Expand Up @@ -79,7 +81,7 @@ bareos-dir: Makefile $(SVROBJS) \
$(LIBTOOL_LINK) $(CXX) $(WLDFLAGS) $(LDFLAGS) -L../lib -L../cats -L../findlib -o $@ $(SVROBJS) \
$(NDMP_LIBS) -lbareosfind -lbareossql -lbareoscats -lbareoscfg -lbareos -lm $(DLIB) \
$(DB_LIBS) $(LIBS) $(WRAPLIBS) $(GETTEXT_LIBS) $(CAP_LIBS) \
$(OPENSSL_LIBS_NONSHARED) $(GNUTLS_LIBS_NONSHARED)
$(OPENSSL_LIBS_NONSHARED) $(GNUTLS_LIBS_NONSHARED) $(LMDB_LIBS)

bareos-dbcheck: Makefile $(DBCHKOBJS) \
../lib/libbareos$(DEFAULT_ARCHIVE_TYPE) \
Expand Down
84 changes: 50 additions & 34 deletions src/dird/jobq.c
Expand Up @@ -3,7 +3,7 @@
Copyright (C) 2003-2011 Free Software Foundation Europe e.V.
Copyright (C) 2011-2012 Planets Communications B.V.
Copyright (C) 2013-2013 Bareos GmbH & Co. KG
Copyright (C) 2013-2016 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
Expand Down Expand Up @@ -41,22 +41,24 @@
#include "bareos.h"
#include "dird.h"

extern JCR *jobs;
static pthread_mutex_t rstore_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t wstore_mutex = PTHREAD_MUTEX_INITIALIZER;

/* Forward referenced functions */
extern "C" void *jobq_server(void *arg);
extern "C" void *sched_wait(void *arg);

static int start_server(jobq_t *jq);
static int start_server(jobq_t *jq);
static bool acquire_resources(JCR *jcr);
static bool reschedule_job(JCR *jcr, jobq_t *jq, jobq_item_t *je);
static bool inc_write_store(JCR *jcr);
static void dec_write_store(JCR *jcr);

/*
* Initialize a job queue
*
* Returns: 0 on success
* errno on failure
* Returns: 0 on success
* errno on failure
*/
int jobq_init(jobq_t *jq, int threads, void *(*engine)(void *arg))
{
Expand Down Expand Up @@ -91,10 +93,14 @@ int jobq_init(jobq_t *jq, int threads, void *(*engine)(void *arg))
jq->idle_workers = 0; /* no idle threads */
jq->engine = engine; /* routine to run */
jq->valid = JOBQ_VALID;
/* Initialize the job queues */

/*
* Initialize the job queues
*/
jq->waiting_jobs = New(dlist(item, &item->link));
jq->running_jobs = New(dlist(item, &item->link));
jq->ready_jobs = New(dlist(item, &item->link));

return 0;
}

Expand Down Expand Up @@ -795,8 +801,6 @@ static bool reschedule_job(JCR *jcr, jobq_t *jq, jobq_item_t *je)
*/
static bool acquire_resources(JCR *jcr)
{
bool skip_this_jcr = false;

/*
* Set that we didn't acquire any resourse locks yet.
*/
Expand Down Expand Up @@ -839,8 +843,8 @@ static bool acquire_resources(JCR *jcr)
*/
if (jcr->res.rstore && jcr->res.rstore == jcr->res.wstore) { /* possible deadlock */
Jmsg(jcr, M_FATAL, 0, _("Job canceled. Attempt to read and write same device.\n"
" Read storage \"%s\" (From %s) -- Write storage \"%s\" (From %s)\n"),
jcr->res.rstore->name(), jcr->res.rstore_source, jcr->res.wstore->name(), jcr->res.wstore_source);
" Read storage \"%s\" (From %s) -- Write storage \"%s\" (From %s)\n"),
jcr->res.rstore->name(), jcr->res.rstore_source, jcr->res.wstore->name(), jcr->res.wstore_source);
jcr->setJobStatus(JS_Canceled);

return false;
Expand All @@ -849,33 +853,24 @@ static bool acquire_resources(JCR *jcr)

if (!jcr->IgnoreStorageConcurrency) {
if (jcr->res.rstore) {
Dmsg1(200, "Rstore=%s\n", jcr->res.rstore->name());
if (!inc_read_store(jcr)) {
Dmsg1(200, "Fail rncj=%d\n", jcr->res.rstore->NumConcurrentJobs);
Dmsg2(200, "Fail to acquire Rstore=%s rncj=%d\n",
jcr->res.rstore->name(), jcr->res.rstore->NumConcurrentJobs);
jcr->setJobStatus(JS_WaitStoreRes);

return false;
}
}

if (jcr->res.wstore) {
Dmsg1(200, "Wstore=%s\n", jcr->res.wstore->name());
if (jcr->res.wstore->NumConcurrentJobs < jcr->res.wstore->MaxConcurrentJobs) {
jcr->res.wstore->NumConcurrentJobs++;
Dmsg1(200, "Inc wncj=%d\n", jcr->res.wstore->NumConcurrentJobs);
} else if (jcr->res.rstore) {
if (!inc_write_store(jcr)) {
Dmsg2(200, "Fail to acquire Wstore=%s wncj=%d\n",
jcr->res.wstore->name(), jcr->res.wstore->NumConcurrentJobs);
dec_read_store(jcr);
skip_this_jcr = true;
} else {
Dmsg1(200, "Fail wncj=%d\n", jcr->res.wstore->NumConcurrentJobs);
skip_this_jcr = true;
}
}

if (skip_this_jcr) {
jcr->setJobStatus(JS_WaitStoreRes);
jcr->setJobStatus(JS_WaitStoreRes);

return false;
return false;
}
}
}

Expand Down Expand Up @@ -925,23 +920,24 @@ static bool acquire_resources(JCR *jcr)
return true;
}

static pthread_mutex_t rstore_mutex = PTHREAD_MUTEX_INITIALIZER;

/*
* Note: inc_read_store() and dec_read_store() are
* called from select_next_rstore() in src/dird/job.c
* called from select_next_rstore() in src/dird/job.c
*/
bool inc_read_store(JCR *jcr)
{
P(rstore_mutex);
if (jcr->res.rstore->NumConcurrentJobs < jcr->res.rstore->MaxConcurrentJobs) {
jcr->res.rstore->NumConcurrentReadJobs++;
jcr->res.rstore->NumConcurrentJobs++;
Dmsg1(200, "Inc rncj=%d\n", jcr->res.rstore->NumConcurrentJobs);
Dmsg2(200, "Inc Rstore=%s rncj=%d\n",
jcr->res.rstore->name(), jcr->res.rstore->NumConcurrentJobs);
V(rstore_mutex);

return true;
}
V(rstore_mutex);

return false;
}

Expand All @@ -951,18 +947,38 @@ void dec_read_store(JCR *jcr)
P(rstore_mutex);
jcr->res.rstore->NumConcurrentReadJobs--; /* back out rstore */
jcr->res.rstore->NumConcurrentJobs--; /* back out rstore */
Dmsg1(200, "Dec rncj=%d\n", jcr->res.rstore->NumConcurrentJobs);
V(rstore_mutex);
Dmsg2(200, "Dec Rstore=%s rncj=%d\n",
jcr->res.rstore->name(), jcr->res.rstore->NumConcurrentJobs);
ASSERT(jcr->res.rstore->NumConcurrentReadJobs >= 0);
ASSERT(jcr->res.rstore->NumConcurrentJobs >= 0);
V(rstore_mutex);
}
}

static bool inc_write_store(JCR *jcr)
{
P(wstore_mutex);
if (jcr->res.wstore->NumConcurrentJobs < jcr->res.wstore->MaxConcurrentJobs) {
jcr->res.wstore->NumConcurrentJobs++;
Dmsg2(200, "Inc Wstore=%s wncj=%d\n",
jcr->res.wstore->name(), jcr->res.wstore->NumConcurrentJobs);
V(wstore_mutex);

return true;
}
V(wstore_mutex);

return false;
}

static void dec_write_store(JCR *jcr)
{
if (jcr->res.wstore) {
P(wstore_mutex);
jcr->res.wstore->NumConcurrentJobs--;
Dmsg1(200, "Dec wncj=%d\n", jcr->res.wstore->NumConcurrentJobs);
Dmsg2(200, "Dec Wstore=%s wncj=%d\n",
jcr->res.wstore->name(), jcr->res.wstore->NumConcurrentJobs);
ASSERT(jcr->res.wstore->NumConcurrentJobs >= 0);
V(wstore_mutex);
}
}
12 changes: 12 additions & 0 deletions src/dird/ndmp_dma_backup.c
Expand Up @@ -46,17 +46,29 @@ static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
*/
static inline void register_callback_hooks(struct ndmlog *ixlog)
{
#ifdef HAVE_LMDB
ndmp_fhdb_lmdb_register(ixlog);
#else
ndmp_fhdb_mem_register(ixlog);
#endif
}

static inline void unregister_callback_hooks(struct ndmlog *ixlog)
{
#ifdef HAVE_LMDB
ndmp_fhdb_lmdb_unregister(ixlog);
#else
ndmp_fhdb_mem_unregister(ixlog);
#endif
}

static inline void process_fhdb(struct ndmlog *ixlog)
{
#ifdef HAVE_LMDB
ndmp_fhdb_lmdb_process_db(ixlog);
#else
ndmp_fhdb_mem_process_db(ixlog);
#endif
}

static inline int native_to_ndmp_level(JCR *jcr, char *filesystem)
Expand Down
13 changes: 13 additions & 0 deletions src/dird/ndmp_fhdb_helpers.c
Expand Up @@ -76,6 +76,19 @@ void ndmp_convert_fstat(ndmp9_file_stat *fstat, int32_t FileIndex,
*/
memset(&statp, 0, sizeof(statp));

Dmsg11(100, "ftype:%d mtime:%lu atime:%lu ctime:%lu uid:%lu gid:%lu mode:%lu size:%llu links:%lu node:%llu fh_info:%llu \n",
fstat->ftype,
fstat->mtime.value,
fstat->atime.value,
fstat->ctime.value,
fstat->uid.value,
fstat->gid.value,
fstat->mode.value,
fstat->size.value,
fstat->links.value,
fstat->node.value,
fstat->fh_info.value);

/*
* If we got a valid mode of the file fill the UNIX stat struct.
*/
Expand Down

0 comments on commit 5cdbf0b

Please sign in to comment.