From 1bf3065ec3bd9c1d65a14ee98b6e42bf7077ba16 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Wed, 16 Apr 2008 07:29:09 +0000 Subject: [PATCH] kes Experiment with allowing multiple read jobs. kes Move final volume swapping code to DCR method and call it from acquire_for_read(). kes When wrong volume is mounted during read, unload_autochanger. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@6830 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/dird/jobq.c | 21 +++----------- bacula/src/stored/acquire.c | 3 ++ bacula/src/stored/dev.h | 1 + bacula/src/stored/mount.c | 58 +++++++++++++++++++++---------------- bacula/src/version.h | 4 +-- bacula/technotes-2.3 | 5 ++++ 6 files changed, 48 insertions(+), 44 deletions(-) diff --git a/bacula/src/dird/jobq.c b/bacula/src/dird/jobq.c index f9f91515a8..26a3316d6e 100644 --- a/bacula/src/dird/jobq.c +++ b/bacula/src/dird/jobq.c @@ -684,18 +684,10 @@ static bool acquire_resources(JCR *jcr) } if (jcr->rstore) { Dmsg1(200, "Rstore=%s\n", jcr->rstore->name()); - if (jcr->rstore->NumConcurrentReadJobs == 0 && - jcr->rstore->NumConcurrentJobs < jcr->rstore->MaxConcurrentJobs) { - /* Simple case, first job */ - jcr->rstore->NumConcurrentReadJobs = 1; + if (jcr->rstore->NumConcurrentJobs < jcr->rstore->MaxConcurrentJobs) { + jcr->rstore->NumConcurrentReadJobs++; jcr->rstore->NumConcurrentJobs++; - Dmsg0(200, "Set rncj=1\n"); - /* We can do this only if multi-drive autochanger */ -// } else if (jcr->rstore->NumConcurrentJobs < jcr->rstore->MaxConcurrentJobs -// && jcr->rstore->NumConcurrentReadJobs < jcr->rstore->MaxConcurrentReadJobs) { -// jcr->rstore->NumConcurrentReadJobs++; -// jcr->rstore->NumConcurrentJobs++; -// Dmsg1(200, "Inc rncj=%d\n", jcr->rstore->NumConcurrentJobs); + Dmsg1(200, "Inc rncj=%d\n", jcr->rstore->NumConcurrentJobs); } else { Dmsg1(200, "Fail rncj=%d\n", jcr->rstore->NumConcurrentJobs); set_jcr_job_status(jcr, JS_WaitStoreRes); @@ -705,12 +697,7 @@ static bool acquire_resources(JCR *jcr) if (jcr->wstore) { Dmsg1(200, "Wstore=%s\n", jcr->wstore->name()); - if (jcr->wstore->NumConcurrentJobs == 0 && - jcr->wstore->NumConcurrentJobs < jcr->wstore->MaxConcurrentJobs) { - /* Simple case, first job */ - jcr->wstore->NumConcurrentJobs = 1; - Dmsg0(200, "Set wncj=1\n"); - } else if (jcr->wstore->NumConcurrentJobs < jcr->wstore->MaxConcurrentJobs) { + if (jcr->wstore->NumConcurrentJobs < jcr->wstore->MaxConcurrentJobs) { jcr->wstore->NumConcurrentJobs++; Dmsg1(200, "Inc wncj=%d\n", jcr->wstore->NumConcurrentJobs); } else if (jcr->rstore) { diff --git a/bacula/src/stored/acquire.c b/bacula/src/stored/acquire.c index 16d77130ae..5733a4b803 100644 --- a/bacula/src/stored/acquire.c +++ b/bacula/src/stored/acquire.c @@ -192,6 +192,8 @@ bool acquire_device_for_read(DCR *dcr) goto get_out; /* error return */ } + dcr->do_swapping(); + autoload_device(dcr, 0, NULL); /* @@ -236,6 +238,7 @@ bool acquire_device_for_read(DCR *dcr) } else { bstrncpy(dev->BadVolName, dev->VolHdr.VolumeName, sizeof(dev->BadVolName)); } + unload_autochanger(dcr, -1); /* Fall through */ default: Jmsg1(jcr, M_WARNING, 0, "%s", jcr->errmsg); diff --git a/bacula/src/stored/dev.h b/bacula/src/stored/dev.h index a8f7bdf84e..619460ef1d 100644 --- a/bacula/src/stored/dev.h +++ b/bacula/src/stored/dev.h @@ -533,6 +533,7 @@ public: bool is_eod_valid(); int check_volume_label(bool &ask, bool &autochanger); void release_volume(); + void do_swapping(); }; /* diff --git a/bacula/src/stored/mount.c b/bacula/src/stored/mount.c index 38db3c7e15..5b22b3fa6c 100644 --- a/bacula/src/stored/mount.c +++ b/bacula/src/stored/mount.c @@ -102,34 +102,12 @@ mount_next_vol: goto bail_out; } recycle = false; + if (dev->must_unload()) { - Dmsg0(150, "mount_next_volume release=1\n"); - unload_autochanger(dcr, -1); - release_volume(); - dev->clear_unload(); ask = true; /* ask operator to mount tape */ } - /* - * See if we are asked to swap the Volume from another device - * if so, unload the other device here, and attach the - * volume to our drive. - */ - if (dev->swap_dev) { - Dmsg1(100, "Swap unloading %s\n", dev->swap_dev->print_name()); - if (dev->swap_dev->must_unload()) { - unload_dev(dcr, dev->swap_dev); - } - if (dev->vol) { - dev->vol->clear_swapping(); - dev->vol->set_in_use(); - dev->VolHdr.VolumeName[0] = 0; /* don't yet have right Volume */ - } - dev->swap_dev = NULL; - } - if (dev->must_load()) { - dev->clear_load(); - dev->clear_volhdr(); /* force "load" */ - } + do_swapping(); + if (!is_suitable_volume_mounted()) { bool have_vol = false; /* Do we have a candidate volume? */ @@ -492,6 +470,36 @@ bool DCR::is_suitable_volume_mounted() return dir_get_volume_info(this, GET_VOL_INFO_FOR_WRITE); } +void DCR::do_swapping() +{ + if (dev->must_unload()) { + Dmsg0(150, "mount_next_volume release=1\n"); + unload_autochanger(this, -1); + release_volume(); + dev->clear_unload(); + } + /* + * See if we are asked to swap the Volume from another device + * if so, unload the other device here, and attach the + * volume to our drive. + */ + if (dev->swap_dev) { + Dmsg1(100, "Swap unloading %s\n", dev->swap_dev->print_name()); + if (dev->swap_dev->must_unload()) { + unload_dev(this, dev->swap_dev); + } + if (dev->vol) { + dev->vol->clear_swapping(); + dev->vol->set_in_use(); + dev->VolHdr.VolumeName[0] = 0; /* don't yet have right Volume */ + } + dev->swap_dev = NULL; + } + if (dev->must_load()) { + dev->clear_load(); + dev->clear_volhdr(); /* force "load" */ + } +} /* diff --git a/bacula/src/version.h b/bacula/src/version.h index 8f1be54b82..938d63051a 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -4,8 +4,8 @@ #undef VERSION #define VERSION "2.3.18" -#define BDATE "12 April 2008" -#define LSMDATE "12Apr08" +#define BDATE "16 April 2008" +#define LSMDATE "16Apr08" #define PROG_COPYRIGHT "Copyright (C) %d-2008 Free Software Foundation Europe e.V.\n" #define BYEAR "2008" /* year for copyright messages in progs */ diff --git a/bacula/technotes-2.3 b/bacula/technotes-2.3 index e10616080b..6940c2f8d8 100644 --- a/bacula/technotes-2.3 +++ b/bacula/technotes-2.3 @@ -24,6 +24,11 @@ Add long term statistics job table General: +16Apr08 +kes Experiment with allowing multiple read jobs. +kes Move final volume swapping code to DCR method and + call it from acquire_for_read(). +kes When wrong volume is mounted during read, unload_autochanger. 15Apr08 kes Integrate the libdbi changes from Joao Henrique Freitas 14Apr08 -- 2.39.5