From: Kern Sibbald Date: Tue, 19 Jun 2007 21:48:53 +0000 (+0000) Subject: kes Simplify search of autochanger for in-use Volume. X-Git-Tag: Release-2.2.0~260 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=95474bea4852c48ac704001bd4ffeaba8a537c32;p=bacula%2Fbacula kes Simplify search of autochanger for in-use Volume. kes Fix exit condition of check for in-use volume. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@5046 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/stored/askdir.c b/bacula/src/stored/askdir.c index 0966d9c19d..f6fd066898 100644 --- a/bacula/src/stored/askdir.c +++ b/bacula/src/stored/askdir.c @@ -179,7 +179,7 @@ static bool do_get_volume_info(DCR *dcr) return false; } memset(&vol, 0, sizeof(vol)); - Dmsg1(100, "msg); + Dmsg1(100, "msg); n = sscanf(dir->msg, OK_media, vol.VolCatName, &vol.VolCatJobs, &vol.VolCatFiles, &vol.VolCatBlocks, &vol.VolCatBytes, @@ -191,7 +191,7 @@ static bool do_get_volume_info(DCR *dcr) &vol.EndFile, &vol.EndBlock, &vol.VolCatParts, &vol.LabelType, &vol.VolMediaId); if (n != 22) { - Dmsg2(100, "Bad response from Dir fields=%d: %s", n, dir->msg); + Dmsg3(100, "Bad response from Dir fields=%d, len=%d: %s", n, dir->msglen, dir->msg); Mmsg(jcr->errmsg, _("Error getting Volume info: %s"), dir->msg); return false; } @@ -226,7 +226,7 @@ bool dir_get_volume_info(DCR *dcr, enum get_vol_info_rw writing) bash_spaces(dcr->VolCatInfo.VolCatName); dir->fsend(Get_Vol_Info, jcr->Job, dcr->VolCatInfo.VolCatName, writing==GET_VOL_INFO_FOR_WRITE?1:0); - Dmsg1(100, ">dird: %s", dir->msg); + Dmsg1(100, ">dird: %s\n", dir->msg); unbash_spaces(dcr->VolCatInfo.VolCatName); bool ok = do_get_volume_info(dcr); V(vol_info_mutex); diff --git a/bacula/src/stored/reserve.c b/bacula/src/stored/reserve.c index 091668f341..787ad34316 100644 --- a/bacula/src/stored/reserve.c +++ b/bacula/src/stored/reserve.c @@ -814,30 +814,16 @@ void release_msgs(JCR *jcr) */ static bool is_vol_in_autochanger(RCTX &rctx, VOLRES *vol) { - AUTOCHANGER *changer; - - return false; + AUTOCHANGER *changer = vol->dev->device->changer_res; - Dmsg2(dbglvl, "jid=%u search changers for %s\n", (int)rctx.jcr->JobId, - rctx.device_name); - foreach_res(changer, R_AUTOCHANGER) { - Dmsg3(dbglvl, "jid=%u Try match changer res=%s device=%s\n", - (int)rctx.jcr->JobId, changer->hdr.name, rctx.device_name); - /* Find resource, and make sure we were able to open it */ - if (fnmatch(rctx.device_name, changer->hdr.name, 0) == 0) { - DEVRES *device; - /* Try each device in this AutoChanger */ - foreach_alist(device, changer->device) { - if (device->dev == vol->dev) { - Dmsg2(dbglvl, "jid=%u Found changer device %s\n", - (int)rctx.jcr->JobId, device->hdr.name); - return true; - } - Dmsg2(dbglvl, "jid=%u Incorrect changer device %s\n", - (int)rctx.jcr->JobId, device->hdr.name); - } - } - } + /* Find resource, and make sure we were able to open it */ + if (fnmatch(rctx.device_name, changer->hdr.name, 0) == 0) { + Dmsg2(dbglvl, "jid=%u Found changer device %s\n", + (int)rctx.jcr->JobId, vol->dev->device->hdr.name); + return true; + } + Dmsg2(dbglvl, "jid=%u Incorrect changer device %s\n", + (int)rctx.jcr->JobId, changer->hdr.name); return false; } @@ -913,7 +899,7 @@ bool find_suitable_device_for_job(JCR *jcr, RCTX &rctx) continue; } - Dmsg2(dbglvl, "jid=%u vol=%s\n", (int)rctx.jcr->JobId, vol->vol_name); + Dmsg2(dbglvl, "jid=%u vol=%s OK for this job\n", (int)rctx.jcr->JobId, vol->vol_name); foreach_alist(store, dirstore) { int stat; rctx.store = store; @@ -958,6 +944,9 @@ bool find_suitable_device_for_job(JCR *jcr, RCTX &rctx) break; } } + if (ok) { + break; + } } /* end for loop over reserved volumes */ lock_volumes(); @@ -969,7 +958,7 @@ bool find_suitable_device_for_job(JCR *jcr, RCTX &rctx) unlock_volumes(); } if (ok) { - Dmsg2(dbglvl, "jid=%u got vol %s in reserved volums list\n", (int)rctx.jcr->JobId, + Dmsg2(dbglvl, "jid=%u got vol %s from in-use vols list\n", (int)rctx.jcr->JobId, rctx.VolumeName); return true; } diff --git a/bacula/technotes-2.1 b/bacula/technotes-2.1 index 84df401a5d..79e6879094 100644 --- a/bacula/technotes-2.1 +++ b/bacula/technotes-2.1 @@ -2,6 +2,8 @@ General: 19Jun07 +kes Simplify search of autochanger for in-use Volume. +kes Fix exit condition of check for in-use volume. kes Remove inappropriate my_postgresql_free_result() in db_close() routine. kes Fix bad return in FD when encryption signature not found.