From: Eric Bollengier Date: Mon, 27 Oct 2008 19:13:49 +0000 (+0000) Subject: ebl Apply 2.4.3-update-slots.patch to fix #1175. About update slots X-Git-Tag: Release-2.4.4~51 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=675ebc218156f312a0f5cc89e2d229e04c720631;p=bacula%2Fbacula ebl Apply 2.4.3-update-slots.patch to fix #1175. About update slots that don't reset InChanger flag when slot is empty. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/branches/Branch-2.4@7920 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/cats/sql_create.c b/bacula/src/cats/sql_create.c index 8415a02742..ba428cc584 100644 --- a/bacula/src/cats/sql_create.c +++ b/bacula/src/cats/sql_create.c @@ -459,14 +459,13 @@ db_create_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) "WHERE MediaId=%d", dt, mr->MediaId); stat = UPDATE_DB(jcr, mdb, mdb->cmd); } + /* + * Make sure that if InChanger is non-zero any other identical slot + * has InChanger zero. + */ + db_make_inchanger_unique(jcr, mdb, mr); } - /* - * Make sure that if InChanger is non-zero any other identical slot - * has InChanger zero. - */ - db_make_inchanger_unique(jcr, mdb, mr); - db_unlock(mdb); return stat; } diff --git a/bacula/src/cats/sql_update.c b/bacula/src/cats/sql_update.c index d77d025654..46c62ed973 100644 --- a/bacula/src/cats/sql_update.c +++ b/bacula/src/cats/sql_update.c @@ -445,14 +445,28 @@ void db_make_inchanger_unique(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) { char ed1[50], ed2[50]; - if (mr->InChanger != 0 && mr->Slot != 0 && mr->StorageId != 0 && - mr->MediaId != 0) { - Mmsg(mdb->cmd, "UPDATE Media SET InChanger=0 WHERE " - "Slot=%d AND StorageId=%s AND MediaId!=%s", - mr->Slot, - edit_int64(mr->StorageId, ed1), edit_int64(mr->MediaId, ed2)); - Dmsg1(400, "%s\n", mdb->cmd); - UPDATE_DB(jcr, mdb, mdb->cmd); + if (mr->InChanger != 0 && mr->Slot != 0 && mr->StorageId != 0) { + + if (mr->MediaId != 0) { + Mmsg(mdb->cmd, "UPDATE Media SET InChanger=0 WHERE " + "Slot=%d AND StorageId=%s AND MediaId!=%s", + mr->Slot, + edit_int64(mr->StorageId, ed1), edit_int64(mr->MediaId, ed2)); + + } else if (mr->VolumeName[0]) { /* We have a volume name */ + Mmsg(mdb->cmd, "UPDATE Media SET InChanger=0 WHERE " + "Slot=%d AND StorageId=%s AND VolumeName!='%s'", + mr->Slot, + edit_int64(mr->StorageId, ed1), mr->VolumeName); + + } else { /* used by ua_label to reset all volume with this slot */ + Mmsg(mdb->cmd, "UPDATE Media SET InChanger=0 WHERE " + "Slot=%d AND StorageId=%s", + mr->Slot, + edit_int64(mr->StorageId, ed1), mr->VolumeName); + } + Dmsg1(100, "%s\n", mdb->cmd); + UPDATE_DB(jcr, mdb, mdb->cmd); } } diff --git a/bacula/technotes-2.4 b/bacula/technotes-2.4 index 3298db6b30..1e82a143ee 100644 --- a/bacula/technotes-2.4 +++ b/bacula/technotes-2.4 @@ -2,6 +2,9 @@ General: Release Version 2.4.3 +27Oct08 +ebl Apply 2.4.3-update-slots.patch to fix #1175. About update slots + that don't reset InChanger flag when slot is empty. 10Oct08 ebl Apply 2.4.2-cancel-non-running-jobs.patch to be able to cancel a non created job faster.