Extend bls with number of retries when specifying incorrect Volume.
* Returns: false if failed for any reason
* true if successful
*/
-bool acquire_device_for_read(DCR *dcr)
+bool acquire_device_for_read(DCR *dcr, uint32_t retry_count)
{
DEVICE *dev;
JCR *jcr = dcr->jcr;
bool try_autochanger = true;
int i;
int vol_label_status;
- int retry = 0;
+ uint32_t retry = 0;
Enter(rdbglvl);
dev = dcr->dev;
for ( ;; ) {
/* If not polling limit retries */
- if (!dev->poll && retry++ > 10) {
+ if (!dev->poll && retry++ >= retry_count) {
break;
}
dev->clear_labeled(); /* force reread of label */
enable_backup_privileges(NULL, 1);
- jcr = setup_jcr("bextract", devname, bsr, VolumeName, SD_READ, true/*read dedup data*/);
+ jcr = setup_jcr("bextract", devname, bsr, VolumeName, SD_READ, true/*read dedup data*/, 10/*retry count*/);
if (!jcr) {
exit(1);
}
static JCR *jcr;
static SESSION_LABEL sessrec;
static uint32_t num_files = 0;
+static uint32_t retry_count = 10;
static ATTR *attr;
static CONFIG *config;
" -j list jobs\n"
" -k list blocks\n"
" (no j or k option) list saved files\n"
+" -n number of times user is aked to provide correct volume\n"
" -L dump label\n"
" -p proceed inspite of errors\n"
" -V specify Volume names (separated by |)\n"
ff = init_find_files();
- while ((ch = getopt(argc, argv, "b:c:d:e:i:jkLpvV:?EDF:")) != -1) {
+ while ((ch = getopt(argc, argv, "b:c:d:e:i:n:jkLpvV:?EDF:")) != -1) {
switch (ch) {
case 'b':
bsrName = optarg;
list_blocks = true;
break;
+ case 'n':
+ retry_count = atoi(optarg);
+ break;
case 'L':
dump_label = true;
break;
if (bsrName) {
bsr = parse_bsr(NULL, bsrName);
}
- jcr = setup_jcr("bls", argv[i], bsr, VolumeName, SD_READ);
+ jcr = setup_jcr("bls", argv[i], bsr, VolumeName, SD_READ, false/*read dedup data*/, retry_count);
if (!jcr) {
exit(1);
}
/* Forward referenced functions */
static DCR *setup_to_access_device(JCR *jcr, char *dev_name,
- const char *VolumeName, bool writing, bool read_dedup_data);
+ const char *VolumeName, bool writing, bool read_dedup_data, uint32_t retry_count=10);
static DEVRES *find_device_res(char *device_name, bool writing);
static void my_free_jcr(JCR *jcr);
* tools (e.g. bls, bextract, bscan, ...)
*/
JCR *setup_jcr(const char *name, char *dev_name, BSR *bsr,
- const char *VolumeName, bool writing, bool read_dedup_data)
+ const char *VolumeName, bool writing, bool read_dedup_data, uint32_t retry_count)
{
DCR *dcr;
JCR *jcr = new_jcr(sizeof(JCR), my_free_jcr);
init_autochangers();
create_volume_lists();
- dcr = setup_to_access_device(jcr, dev_name, VolumeName, writing, read_dedup_data);
+ dcr = setup_to_access_device(jcr, dev_name, VolumeName, writing, read_dedup_data, retry_count);
if (!dcr) {
return NULL;
}
* the caller will do it.
*/
static DCR *setup_to_access_device(JCR *jcr, char *dev_name,
- const char *VolumeName, bool writing, bool read_dedup_data)
+ const char *VolumeName, bool writing, bool read_dedup_data, uint32_t retry_count)
{
DEVICE *dev;
char *p;
if (!writing) { /* read only access? */
Dmsg0(100, "Acquire device for read\n");
- if (!acquire_device_for_read(dcr)) {
+ if (!acquire_device_for_read(dcr, retry_count)) {
return NULL;
}
jcr->read_dcr = dcr;
/* From acquire.c */
DCR *acquire_device_for_append(DCR *dcr);
-bool acquire_device_for_read(DCR *dcr);
+bool acquire_device_for_read(DCR *dcr, uint32_t retry_count=10);
bool release_device(DCR *dcr);
bool clean_device(DCR *dcr);
DCR *new_dcr(JCR *jcr, DCR *dcr, DEVICE *dev, bool writing=true);
void setup_me();
void print_ls_output(const char *fname, const char *link, int type, struct stat *statp);
JCR *setup_jcr(const char *name, char *dev_name, BSR *bsr,
- const char *VolumeName, bool writing, bool read_dedup_data=true);
+ const char *VolumeName, bool writing, bool read_dedup_data=true, uint32_t retry_count=10);
void display_tape_error_status(JCR *jcr, DEVICE *dev);