From a44f01482f8b65b0851f474076565a12c07eee79 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Thu, 1 May 2008 20:05:56 +0000 Subject: [PATCH] Prevent a Volume that is being swapped from being freed from the volume list. This will most likely fix, at least partially, bug #1083. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/branches/Branch-2.2@6872 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/patches/2.2.8-strippath.patch | 4 ++-- bacula/src/stored/reserve.c | 27 ++++++++++++++++----------- bacula/technotes-2.1 | 3 +++ 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/bacula/patches/2.2.8-strippath.patch b/bacula/patches/2.2.8-strippath.patch index 0aae25245b..2e2f037bbe 100644 --- a/bacula/patches/2.2.8-strippath.patch +++ b/bacula/patches/2.2.8-strippath.patch @@ -49,7 +49,7 @@ Index: src/filed/backup.c + pm_strcpy(ff_pkt->link_save, ff_pkt->link); + Dmsg2(500, "strcpy link_save=%d link=%d\n", strlen(ff_pkt->link_save), + strlen(ff_pkt->link)); -+ sm_check(__FILE__, __LINE__, true); ++// sm_check(__FILE__, __LINE__, true); + } /* @@ -98,6 +98,6 @@ Index: src/filed/backup.c strcpy(ff_pkt->link, ff_pkt->link_save); + Dmsg2(500, "strcpy link=%d link_save=%d\n", strlen(ff_pkt->link), + strlen(ff_pkt->link_save)); -+ sm_check(__FILE__, __LINE__, true); ++// sm_check(__FILE__, __LINE__, true); } } diff --git a/bacula/src/stored/reserve.c b/bacula/src/stored/reserve.c index 429cc87b71..35b4f090ea 100644 --- a/bacula/src/stored/reserve.c +++ b/bacula/src/stored/reserve.c @@ -388,22 +388,24 @@ VOLRES *reserve_volume(DCR *dcr, const char *VolumeName) nvol->dev = NULL; /* don't zap dev entry */ free_vol_item(nvol); - /* Check if we are trying to use the Volume on a different drive */ + /* + * Check if we are trying to use the Volume on a different drive + * dev is our device + * vol->dev is where the Volume we want is + */ if (dev != vol->dev) { /* Caller wants to switch Volume to another device */ if (!vol->dev->is_busy() && !vol->is_swapping()) { Dmsg4(dbglvl, "==== jid=%u Swap vol=%s from dev=%s to %s\n", jid(), VolumeName, vol->dev->print_name(), dev->print_name()); free_volume(dev); /* free any volume attached to our drive */ - vol->dev->set_unload(); /* unload our drive */ + vol->dev->set_unload(); /* unload the other drive */ vol->set_swapping(); /* swap from other drive */ dev->swap_dev = vol->dev; /* remember to get this vol */ vol->dev->set_load(); /* then reload on our drive */ vol->dev->vol = NULL; /* remove volume from other drive */ - vol->dev = dev; /* point it at our drive */ - dev->vol = vol; /* point our drive at it */ - Dmsg3(dbglvl, "==== Swap vol=%s from dev=%s to %s\n", - VolumeName, vol->dev->print_name(), dev->print_name()); + vol->dev = dev; /* point the Volume at our drive */ + dev->vol = vol; /* point our drive at the Volume */ } else { Dmsg4(dbglvl, "jid=%u ==== Swap not possible Vol busy vol=%s from dev=%s to %s\n", jid(), VolumeName, vol->dev->print_name(), dev->print_name()); @@ -591,11 +593,14 @@ bool free_volume(DEVICE *dev) } lock_volumes(); vol = dev->vol; - dev->vol = NULL; - vol_list->remove(vol); - Dmsg3(dbglvl, "jid=%u === free_volume %s dev=%s\n", jid(), vol->vol_name, dev->print_name()); - free_vol_item(vol); - debug_list_volumes("free_volume"); + /* Don't free a volume while it is being swapped */ + if (!vol->is_swapping()) { + dev->vol = NULL; + vol_list->remove(vol); + Dmsg3(dbglvl, "jid=%u === free_volume %s dev=%s\n", jid(), vol->vol_name, dev->print_name()); + free_vol_item(vol); + debug_list_volumes("free_volume"); + } unlock_volumes(); return true; } diff --git a/bacula/technotes-2.1 b/bacula/technotes-2.1 index a378f7ba20..d12c12415f 100644 --- a/bacula/technotes-2.1 +++ b/bacula/technotes-2.1 @@ -2,6 +2,9 @@ General: 01May08 +kes Prevent a Volume that is being swapped from being freed from + the volume list. This will most likely fix, at least partially, + bug #1083. kes Fix strippath so that it does not get a buffer overrun and crash FD. This fixes bug #1078. kes Make inability to change owner/group when creating a dir only a -- 2.39.2