From: Eric Bollengier Date: Fri, 25 Feb 2022 17:37:19 +0000 (+0100) Subject: Reorganize dynamically device order in Autochangers to use read-only devices first X-Git-Tag: Beta-15.0.0~479 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7c68f7f64a8b0a3fc88c5d1e8daa93735db43bb3;p=thirdparty%2Fbacula.git Reorganize dynamically device order in Autochangers to use read-only devices first --- diff --git a/bacula/src/stored/stored.c b/bacula/src/stored/stored.c index 4212b3436..37eae8606 100644 --- a/bacula/src/stored/stored.c +++ b/bacula/src/stored/stored.c @@ -603,10 +603,30 @@ static int check_resources() } } + /* During the device selection, if we put read-only device first, + * they will be selected automatically during a restore, so we + * reorder the list to keep the device order, but put read-only + * devices first. + */ foreach_res(changer, R_AUTOCHANGER) { + alist *org_list = changer->device; + alist *new_list = New(alist(org_list->size(), not_owned_by_alist)); + /* We loop two times to keep the order of the devices + * per type (readonly/read-write) + */ foreach_alist(device, changer->device) { device->cap_bits |= CAP_AUTOCHANGER; + if (device->read_only) { + new_list->append(device); + } + } + foreach_alist(device, changer->device) { + if (!device->read_only) { + new_list->append(device); + } } + changer->device = new_list; + delete org_list; } CLOUD *cloud;