Skip to content

Commit

Permalink
NDMP: merged NDMP multidrive support
Browse files Browse the repository at this point in the history
This commit merges the current NDMP multidrive support
branch into bareos 18.
  • Loading branch information
pstorz committed Jan 4, 2019
1 parent f3e9084 commit 3d26757
Show file tree
Hide file tree
Showing 27 changed files with 1,601 additions and 919 deletions.
1 change: 1 addition & 0 deletions core/src/dird/CMakeLists.txt
Expand Up @@ -30,6 +30,7 @@ set(DIRD_OBJECTS_SRCS admin.cc archive.cc authenticate.cc authenticate_console.c
ndmp_dma_generic.cc
ndmp_dma_restore_common.cc ndmp_dma_restore_NDMP_BAREOS.cc ndmp_dma_restore_NDMP_NATIVE.cc
ndmp_fhdb_common.cc ndmp_fhdb_helpers.cc
ndmp_slot2elemaddr.cc
ndmp_fhdb_mem.cc ndmp_fhdb_lmdb.cc ndmp_ndmmedia_db_helpers.cc
newvol.cc next_vol.cc quota.cc socket_server.cc recycle.cc restore.cc
run_conf.cc sd_cmds.cc scheduler.cc stats.cc storage.cc ua.cc ua_acl.cc ua_audit.cc
Expand Down
1 change: 1 addition & 0 deletions core/src/dird/backup.cc
Expand Up @@ -45,6 +45,7 @@
#include "dird/msgchan.h"
#include "dird/quota.h"
#include "dird/sd_cmds.h"
#include "ndmp/smc.h"
#include "dird/storage.h"

#include "cats/sql.h"
Expand Down
67 changes: 51 additions & 16 deletions core/src/dird/dird.h
Expand Up @@ -109,16 +109,16 @@ typedef enum {
typedef enum {
slot_type_unknown, /**< Unknown slot type */
slot_type_drive, /**< Drive slot */
slot_type_normal, /**< Normal slot */
slot_type_storage, /**< Storage slot */
slot_type_import, /**< Import/export slot */
slot_type_picker /**< Robotics */
} slot_type;
} slot_type_t;

typedef enum {
slot_content_unknown, /**< Slot content is unknown */
slot_content_empty, /**< Slot is empty */
slot_content_full /**< Slot is full */
} slot_content;
slot_status_unknown, /**< Slot content is unknown */
slot_status_empty, /**< Slot is empty */
slot_status_full /**< Slot is full */
} slot_status_t;

enum s_mapping_type {
LOGICAL_TO_PHYSICAL,
Expand All @@ -130,12 +130,12 @@ enum s_mapping_type {
*/
struct vol_list_t {
dlink link; /**< Link for list */
slot_number_t Index; /**< Unique index */
slot_flags_t Flags; /**< Slot specific flags see e_slot_flag enum */
slot_type Type; /**< See slot_type_* */
slot_content Content; /**< See slot_content_* */
slot_number_t Slot; /**< Drive number when slot_type_drive or actual slot number */
slot_number_t Loaded; /**< Volume loaded in drive when slot_type_drive */
slot_number_t element_address ; /**< scsi element address */
slot_flags_t flags; /**< Slot specific flags see e_slot_flag enum */
slot_type_t slot_type; /**< See slot_type_* */
slot_status_t slot_status; /**< See slot_status_* */
slot_number_t bareos_slot_number; /**< Drive number when slot_type_drive or actual slot number */
slot_number_t currently_loaded_slot_number; /**< Volume loaded in drive when slot_type_drive */
char *VolName; /**< Actual Volume Name */
};

Expand All @@ -151,19 +151,54 @@ struct changer_vol_list_t {
*/
struct storage_mapping_t {
dlink link; /**< Link for list */
slot_type Type; /**< See slot_type_* */
slot_number_t Index; /**< Unique index */
slot_type_t slot_type; /**< See slot_type_* */
slot_number_t element_address;/**< scsi element address */
slot_number_t Slot; /**< Drive number when slot_type_drive or actual slot number */
};



#if HAVE_NDMP
/**
* same as smc_element_address_assignment
* from ndmp/smc.h
* TODO: check if original definition can be used
*/
struct smc_element_address_assignment {

unsigned mte_addr; /* media transport element */
unsigned mte_count;

unsigned se_addr; /* storage element */
unsigned se_count;

unsigned iee_addr; /* import/export element */
unsigned iee_count;

unsigned dte_addr; /* data transfer element */
unsigned dte_count;

};

struct ndmp_deviceinfo_t {
std::string device;
std::string model;
JobId_t JobIdUsingDevice;
};
#endif


struct runtime_storage_status_t {
int32_t NumConcurrentJobs; /**< Number of concurrent jobs running */
int32_t NumConcurrentReadJobs; /**< Number of jobs reading */
drive_number_t drives; /**< Number of drives in autochanger */
slot_number_t slots; /**< Number of slots in autochanger */
dlist *storage_mappings; /**< Mappings from logical to physical storage address */
changer_vol_list_t *vol_list; /**< Cached content of autochanger */
pthread_mutex_t changer_lock; /**< Any access to the autochanger is controlled by this lock */
unsigned char smc_ident[32]; /**< smc ident info = changer name */
smc_element_address_assignment storage_mapping;/**< smc element assignment */
changer_vol_list_t *vol_list; /**< Cached content of autochanger */
std::list<ndmp_deviceinfo_t> *ndmp_deviceinfo; /**< NDMP device info for devices in this Storage */
pthread_mutex_t ndmp_deviceinfo_lock; /**< Any access to the list devices is controlled by this lock */
};

struct runtime_client_status_t {
Expand Down
8 changes: 7 additions & 1 deletion core/src/dird/dird_conf.cc
Expand Up @@ -2486,6 +2486,12 @@ static bool UpdateResourcePointer(int type, ResourceItem *items)

Emsg1(M_ERROR_TERM, 0, _("pthread_mutex_init: ERR=%s\n"), be.bstrerror(status));
}
if ((status = pthread_mutex_init(&res->res_store.rss->ndmp_deviceinfo_lock, NULL)) != 0) {
BErrNo be;

Emsg1(M_ERROR_TERM, 0, _("pthread_mutex_init: ERR=%s\n"), be.bstrerror(status));
}

}
break;
case R_JOBDEFS:
Expand Down Expand Up @@ -4094,7 +4100,6 @@ static void FreeResource(CommonResourceHeader *sres, int type)
if (res->res_store.ndmp_changer_device) { free(res->res_store.ndmp_changer_device); }
if (res->res_store.device) { delete res->res_store.device; }
if (res->res_store.rss) {
if (res->res_store.rss->storage_mappings) { delete res->res_store.rss->storage_mappings; }
if (res->res_store.rss->vol_list) {
if (res->res_store.rss->vol_list->contents) {
vol_list_t *vl;
Expand All @@ -4108,6 +4113,7 @@ static void FreeResource(CommonResourceHeader *sres, int type)
free(res->res_store.rss->vol_list);
}
pthread_mutex_destroy(&res->res_store.rss->changer_lock);
pthread_mutex_destroy(&res->res_store.rss->ndmp_deviceinfo_lock);
free(res->res_store.rss);
}
if (res->res_store.tls_cert_.allowed_certificate_common_names_) {
Expand Down
6 changes: 1 addition & 5 deletions core/src/dird/ndmp_dma_backup_NDMP_BAREOS.cc
Expand Up @@ -201,11 +201,7 @@ bool DoNdmpBackup(JobControlRecord *jcr)
bool retval = false;
int NdmpLoglevel;

if (jcr->res.client->ndmp_loglevel > me->ndmp_loglevel) {
NdmpLoglevel = jcr->res.client->ndmp_loglevel;
} else {
NdmpLoglevel = me->ndmp_loglevel;
}
NdmpLoglevel = std::max(jcr->res.client->ndmp_loglevel, me->ndmp_loglevel);

/*
* Print Job Start message
Expand Down

0 comments on commit 3d26757

Please sign in to comment.