+static int is_pool_ok(DCR *dcr)
+{
+ DEVICE *dev = dcr->dev;
+ JCR *jcr = dcr->jcr;
+
+ /* Now check if we want the same Pool and pool type */
+ if (strcmp(dev->pool_name, dcr->pool_name) == 0 &&
+ strcmp(dev->pool_type, dcr->pool_type) == 0) {
+ /* OK, compatible device */
+ Dmsg1(dbglvl, "OK dev: %s num_writers=0, reserved, pool matches\n", dev->print_name());
+ return 1;
+ } else {
+ /* Drive Pool not suitable for us */
+ Mmsg(jcr->errmsg, _(
+"3608 JobId=%u wants Pool=\"%s\" but have Pool=\"%s\" nreserve=%d on drive %s.\n"),
+ (uint32_t)jcr->JobId, dcr->pool_name, dev->pool_name,
+ dev->num_reserved(), dev->print_name());
+ queue_reserve_message(jcr);
+ Dmsg2(dbglvl, "failed: busy num_writers=0, reserved, pool=%s wanted=%s\n",
+ dev->pool_name, dcr->pool_name);
+ }
+ return 0;
+}
+
+static bool is_max_jobs_ok(DCR *dcr)
+{
+ DEVICE *dev = dcr->dev;
+ JCR *jcr = dcr->jcr;
+
+ Dmsg5(dbglvl, "MaxJobs=%d Jobs=%d reserves=%d Status=%s Vol=%s\n",
+ dcr->VolCatInfo.VolCatMaxJobs,
+ dcr->VolCatInfo.VolCatJobs, dev->num_reserved(),
+ dcr->VolCatInfo.VolCatStatus,
+ dcr->VolumeName);
+ if (strcmp(dcr->VolCatInfo.VolCatStatus, "Recycle") == 0) {
+ return true;
+ }
+ if (dcr->VolCatInfo.VolCatMaxJobs > 0 && dcr->VolCatInfo.VolCatMaxJobs <=
+ (dcr->VolCatInfo.VolCatJobs + dev->num_reserved())) {
+ /* Max Job Vols depassed or already reserved */
+ Mmsg(jcr->errmsg, _("3610 JobId=%u Volume max jobs exceeded on drive %s.\n"),
+ (uint32_t)jcr->JobId, dev->print_name());
+ queue_reserve_message(jcr);
+ Dmsg1(dbglvl, "reserve dev failed: %s", jcr->errmsg);
+ return false; /* wait */
+ }
+ return true;
+}
+