1 /* 2 BAREOS® - Backup Archiving REcovery Open Sourced 3 4 Copyright (C) 2000-2008 Free Software Foundation Europe e.V. 5 Copyright (C) 2011-2016 Planets Communications B.V. 6 Copyright (C) 2013-2019 Bareos GmbH & Co. KG 7 8 This program is Free Software; you can redistribute it and/or 9 modify it under the terms of version three of the GNU Affero General Public 10 License as published by the Free Software Foundation and included 11 in the file LICENSE. 12 13 This program is distributed in the hope that it will be useful, but 14 WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 Affero General Public License for more details. 17 18 You should have received a copy of the GNU Affero General Public License 19 along with this program; if not, write to the Free Software 20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 21 02110-1301, USA. 22 */ 23 /* 24 * Kern Sibbald, December MM 25 */ 26 /** 27 * @file 28 * Includes specific to the Director 29 */ 30 #ifndef BAREOS_DIRD_DIRD_H_ 31 #define BAREOS_DIRD_DIRD_H_ 32 #include "dird/dird_conf.h" 33 #include "include/bareos.h" 34 #include "lib/connection_pool.h" 35 #include "lib/runscript.h" 36 #include "stored/bsr.h" 37 #include "ndmp/smc.h" 38 39 #define DIRECTOR_DAEMON 1 40 41 #include "cats/cats.h" 42 #include "dir_plugins.h" 43 44 #include "dird/bsr.h" 45 #include "include/jcr.h" 46 #include "jobq.h" 47 #include "ua.h" 48 49 class dlist; 50 51 namespace directordaemon { 52 53 /* Used in ua_prune.c and ua_purge.c */ 54 55 struct s_count_ctx { 56 int count{}; 57 }; 58 59 #define MAX_DEL_LIST_LEN 2000000 60 61 struct del_ctx { 62 JobId_t* JobId{nullptr}; /**< array of JobIds */ 63 char* PurgedFiles{nullptr}; /**< Array of PurgedFile flags */ 64 int num_ids{0}; /**< ids stored */ 65 int max_ids{0}; /**< size of array */ 66 int num_del{0}; /**< number deleted */ 67 int tot_ids{0}; /**< total to process */ 68 }; 69 70 /* Flags for FindNextVolumeForAppend() */ 71 enum : bool 72 { 73 fnv_create_vol = true, 74 fnv_no_create_vol = false, 75 fnv_prune = true, 76 fnv_no_prune = false 77 }; 78 79 enum e_enabled_val 80 { 81 VOL_NOT_ENABLED = 0, 82 VOL_ENABLED = 1, 83 VOL_ARCHIVED = 2 84 }; 85 86 enum e_prtmsg 87 { 88 DISPLAY_ERROR, 89 NO_DISPLAY 90 }; 91 92 enum e_pool_op 93 { 94 POOL_OP_UPDATE, 95 POOL_OP_CREATE 96 }; 97 98 enum e_move_op 99 { 100 VOLUME_IMPORT, 101 VOLUME_EXPORT, 102 VOLUME_MOVE 103 }; 104 105 enum e_slot_flag 106 { 107 can_import = 0x01, 108 can_export = 0x02, 109 by_oper = 0x04, 110 by_mte = 0x08 111 }; 112 113 typedef enum 114 { 115 VOL_LIST_ALL, 116 VOL_LIST_PARTIAL 117 } vol_list_type; 118 119 enum class slot_type_t 120 { 121 kSlotTypeUnknown, 122 kSlotTypeDrive, 123 kSlotTypeStorage, 124 kSlotTypeImport, /**< Import/export slot */ 125 kSlotTypePicker /**< Robotics */ 126 }; 127 128 enum class slot_status_t 129 { 130 kSlotStatusUnknown, 131 kSlotStatusEmpty, 132 kSlotStatusFull 133 }; 134 135 enum s_mapping_type 136 { 137 LOGICAL_TO_PHYSICAL, 138 PHYSICAL_TO_LOGICAL 139 }; 140 141 /* 142 * Slot list definition 143 */ 144 /* clang-format off */ 145 struct vol_list_t { 146 dlink link; /**< Link for list */ 147 slot_number_t element_address = kInvalidSlotNumber; /**< scsi element address */ 148 slot_flags_t flags = 0; /**< Slot specific flags see e_slot_flag enum */ 149 slot_type_t slot_type = slot_type_t::kSlotTypeUnknown; 150 slot_status_t slot_status = slot_status_t::kSlotStatusUnknown; 151 slot_number_t bareos_slot_number = kInvalidSlotNumber; /**< Drive number when 152 kSlotTypeDrive or actual slot number */ 153 slot_number_t currently_loaded_slot_number = kInvalidSlotNumber; /**< Volume loaded in drive when 154 kSlotTypeDrive */ 155 char* VolName = nullptr; /**< Actual Volume Name */ 156 }; 157 /* clang-format on */ 158 159 struct changer_vol_list_t { 160 int16_t reference_count{}; /**< Number of references to this vol_list */ 161 vol_list_type type{}; /**< Type of vol_list see vol_list_type enum */ 162 utime_t timestamp{}; /**< When was this vol_list created */ 163 dlist* contents{}; /**< Contents of autochanger */ 164 }; 165 166 /* 167 * Mapping from logical to physical storage address 168 */ 169 struct storage_mapping_t { 170 dlink link{}; /**< Link for list */ 171 slot_type_t slot_type{slot_type_t::kSlotTypeUnknown}; /**< See slot_type_* */ 172 slot_number_t element_address{}; /**< scsi element address */ 173 slot_number_t Slot{}; /**< Drive number when kSlotTypeDrive 174 or actual slot number */ 175 }; 176 177 #if HAVE_NDMP 178 struct ndmp_deviceinfo_t { 179 std::string device; 180 std::string model; 181 JobId_t JobIdUsingDevice{}; 182 }; 183 #endif 184 185 struct RuntimeStorageStatus { 186 RuntimeStorageStatus() = default; 187 ~RuntimeStorageStatus() = default; 188 189 int32_t NumConcurrentJobs = 0; /**< Number of concurrent jobs running */ 190 int32_t NumConcurrentReadJobs = 0; /**< Number of jobs reading */ 191 drive_number_t drives = {0}; /**< Number of drives in autochanger */ 192 slot_number_t slots = {0}; /**< Number of slots in autochanger */ 193 pthread_mutex_t changer_lock = PTHREAD_MUTEX_INITIALIZER; /**< Any access to 194 the autochanger is controlled by this lock */ 195 unsigned char smc_ident[32] = {0}; /**< smc ident info = changer name */ 196 changer_vol_list_t* vol_list = nullptr; /**< Cached content of autochanger */ 197 pthread_mutex_t ndmp_deviceinfo_lock = 198 PTHREAD_MUTEX_INITIALIZER; /**< Any access to the list devices is 199 controlled by this lock */ 200 #if HAVE_NDMP 201 struct smc_element_address_assignment storage_mapping = {0}; 202 std::list<ndmp_deviceinfo_t> ndmp_deviceinfo; 203 #endif 204 }; 205 206 struct runtime_client_status_t { 207 int32_t NumConcurrentJobs{}; /**< Number of concurrent jobs running */ 208 }; 209 210 struct runtime_job_status_t { 211 int32_t NumConcurrentJobs{}; /**< Number of concurrent jobs running */ 212 }; 213 214 #define INDEX_DRIVE_OFFSET 0 215 #define INDEX_MAX_DRIVES 100 216 #define INDEX_SLOT_OFFSET 100 217 218 #define FD_VERSION_1 1 219 #define FD_VERSION_2 2 220 #define FD_VERSION_3 3 221 #define FD_VERSION_4 4 222 #define FD_VERSION_5 5 223 #define FD_VERSION_51 51 224 #define FD_VERSION_52 52 225 #define FD_VERSION_53 53 226 #define FD_VERSION_54 54 227 228 bool DoReloadConfig(); 229 230 } /* namespace directordaemon */ 231 232 #endif // BAREOS_DIRD_DIRD_H_ 233