From 0fe1e6ff264cf15ec3812cd7114a24e679b9e0f7 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Fri, 16 Oct 2009 07:50:48 +0200 Subject: [PATCH] Fix switching read device reported by Nicolae Mihalache --- bacula/src/stored/acquire.c | 8 ++++++-- bacula/src/stored/reserve.c | 6 +++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/bacula/src/stored/acquire.c b/bacula/src/stored/acquire.c index 1d382d1f58..1458fb67c2 100644 --- a/bacula/src/stored/acquire.c +++ b/bacula/src/stored/acquire.c @@ -63,7 +63,8 @@ bool acquire_device_for_read(DCR *dcr) int vol_label_status; int retry = 0; - Dmsg1(950, "jcr->dcr=%p\n", jcr->dcr); + Dmsg2(950, "dcr=%p dev=%p\n", dcr, dcr->dev); + Dmsg2(950, "MediaType dcr=%s dev=%s\n", dcr->media_type, dev->device->media_type); dev->dblock(BST_DOING_ACQUIRE); if (dev->num_writers > 0) { @@ -123,6 +124,7 @@ bool acquire_device_for_read(DCR *dcr) lock_reservations(); memset(&rctx, 0, sizeof(RCTX)); rctx.jcr = jcr; + jcr->read_dcr = dcr; jcr->reserve_msgs = New(alist(10, not_owned_by_alist)); rctx.any_drive = true; rctx.device_name = vol->device; @@ -166,6 +168,7 @@ bool acquire_device_for_read(DCR *dcr) goto get_out; } } + Dmsg2(400, "MediaType dcr=%s dev=%s\n", dcr->media_type, dev->device->media_type); dev->clear_unload(); @@ -332,7 +335,8 @@ get_out: } else { dev->dunlock(); /* dunblock() unlock the device too */ } - Dmsg1(950, "jcr->dcr=%p\n", jcr->dcr); + Dmsg2(950, "dcr=%p dev=%p\n", dcr, dcr->dev); + Dmsg2(950, "MediaType dcr=%s dev=%s\n", dcr->media_type, dev->device->media_type); return ok; } diff --git a/bacula/src/stored/reserve.c b/bacula/src/stored/reserve.c index 2a1f3031f5..677d5ebdea 100644 --- a/bacula/src/stored/reserve.c +++ b/bacula/src/stored/reserve.c @@ -634,7 +634,11 @@ static int reserve_device(RCTX &rctx) rctx.suitable_device = true; Dmsg1(dbglvl, "try reserve %s\n", rctx.device->hdr.name); - dcr = new_dcr(rctx.jcr, rctx.jcr->dcr, rctx.device->dev); + if (rctx.store->append) { + dcr = new_dcr(rctx.jcr, rctx.jcr->dcr, rctx.device->dev); + } else { + dcr = new_dcr(rctx.jcr, rctx.jcr->read_dcr, rctx.device->dev); + } if (!dcr) { BSOCK *dir = rctx.jcr->dir_bsock; dir->fsend(_("3926 Could not get dcr for device: %s\n"), rctx.device_name); -- 2.39.5