From: Steve Polyack Date: Sun, 6 Dec 2009 09:41:24 +0000 (+0100) Subject: Add AllowCompression feature X-Git-Tag: Release-5.0.0~193 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=7d4fdcbc2db38fc707dc001cb3fcb95c7bef360a;p=bacula%2Fbacula Add AllowCompression feature --- diff --git a/bacula/src/dird/dird_conf.c b/bacula/src/dird/dird_conf.c index 56b3e76bc8..18954b8479 100644 --- a/bacula/src/dird/dird_conf.c +++ b/bacula/src/dird/dird_conf.c @@ -222,6 +222,7 @@ static RES_ITEM store_items[] = { {"mediatype", store_strname, ITEM(res_store.media_type), 0, ITEM_REQUIRED, 0}, {"autochanger", store_bool, ITEM(res_store.autochanger), 0, ITEM_DEFAULT, 0}, {"enabled", store_bool, ITEM(res_store.enabled), 0, ITEM_DEFAULT, true}, + {"allowcompression", store_bool, ITEM(res_store.AllowCompress), 0, ITEM_DEFAULT, true}, {"heartbeatinterval", store_time, ITEM(res_store.heartbeat_interval), 0, ITEM_DEFAULT, 0}, {"maximumconcurrentjobs", store_pint32, ITEM(res_store.MaxConcurrentJobs), 0, ITEM_DEFAULT, 1}, {"sddport", store_pint32, ITEM(res_store.SDDport), 0, 0, 0}, /* deprecated */ diff --git a/bacula/src/dird/dird_conf.h b/bacula/src/dird/dird_conf.h index 9f19992a99..f57fe5fbd8 100644 --- a/bacula/src/dird/dird_conf.h +++ b/bacula/src/dird/dird_conf.h @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2000-2008 Free Software Foundation Europe e.V. + Copyright (C) 2000-2009 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -306,6 +306,7 @@ public: bool tls_require; /* Require TLS */ bool enabled; /* Set if device is enabled */ bool autochanger; /* set if autochanger */ + bool AllowCompress; /* set if this Storage should allow jobs to enable compression */ int64_t StorageId; /* Set from Storage DB record */ utime_t heartbeat_interval; /* Interval to send heartbeats */ uint32_t drives; /* number of drives in autochanger */ diff --git a/bacula/src/dird/fd_cmds.c b/bacula/src/dird/fd_cmds.c index a8f3dce9fa..46ca8138f7 100644 --- a/bacula/src/dird/fd_cmds.c +++ b/bacula/src/dird/fd_cmds.c @@ -333,6 +333,7 @@ static bool send_fileset(JCR *jcr) { FILESET *fileset = jcr->fileset; BSOCK *fd = jcr->file_bsock; + STORE *store = jcr->wstore; int num; bool include = true; @@ -359,7 +360,6 @@ static bool send_fileset(JCR *jcr) } for (j=0; jnum_opts; j++) { FOPTS *fo = ie->opts_list[j]; - fd->fsend("O %s\n", fo->opts); bool enhanced_wild = false; for (k=0; fo->opts[k]!='\0'; k++) { @@ -369,6 +369,31 @@ static bool send_fileset(JCR *jcr) } } + /* Strip out compression option Zn if disallowed for this Storage */ + if (!store->AllowCompress) { + char newopts[MAX_FOPTS]; + int j = 0; + for (k=0; fo->opts[k]!='\0'; k++) { + /* Z compress option is followed by the single-digit compress level */ + if (fo->opts[k]=='Z') { + k++; /* skip option and level */ + } else { + newopts[j] = fo->opts[k]; + j++; + } + } + newopts[j] = '\0'; + + Jmsg(jcr, M_INFO, 0, + _("FD compression disabled for this Job because AllowCompress=No in Storage resource.\n") ); + + /* Send the new trimmed option set without overwriting fo->opts */ + fd->fsend("O %s\n", newopts); + } else { + /* Send the original options */ + fd->fsend("O %s\n", fo->opts); + } + for (k=0; kregex.size(); k++) { fd->fsend("R %s\n", fo->regex.get(k)); }