Kern Sibbald wrote:
Kern Sibbald wrote:
On Monday 23 November 2009 19:36:10 Steve Polyack wrote:

Steve Polyack wrote:

I've simply added another configuration option for any Storage {}
resource in the Director's config.  An admin may set
AllowCompression=No for a particular storage resource, causing the
director to prevent any GZIP compression options from being sent to
the FD when a job is run against that particular storage resource.
The default for the directive is Yes/true so that behavior is
unchanged for anyone who does not choose to set it.  There may be a
better way to strip the compression flags from the fo->opts[] going
out to the FD, but this works great and appears readable to me.

Any feedback or suggestions would be appreciated.  I'd like to see the
code added to a later version of Bacula.

No questions/comments/suggestions/hate mail?


We always appreciate patches :-)

As I mentioned on the bacula-devel list, I was on the road last week.  I
did
see your patch but have not worked through the stacked up emails yet.

Preliminary remark 1: cleaver idea. Preliminary remark 2: I think some
users
might be annoyed if compression is turned off with no warning, which
would
not be too hard to fix.

Regards,

Kern


Thanks.  I've added a warning to indicate that it's turning off
compression for the job because the option is set for the particular
storage resource.  I believe I've also introduced a bug which may cause
future runs of a similar job to run without compression - I've modified
my patch to send the a new/copied options string instead of modifying
fo->opts, which I believe will correct the problem.

After some more testing I'll re-submit the patch.

Thanks for making the warning change.  Also on the bug, thanks for
catching it, I didn't notice it in the original code :-(

Please try to resubmit as soon as possible (before the end of next week)
we have more or less frozen the feature set because we would like to
release in early January.  If we get the patch soon, I can almost
guarantee it will go in (provided no problems show up).  After next week,
it will probably need to be held for the next release ...


Attached is the updated patch. I'm certain this corrects the behavior I saw. I'll do what I can to get a regression test over to you in the next week or so along with a quick documentation blurb. Feel free to modify the warning message as you see fit, or suggest changes to me and I'll make them.

diff -ru 
/usr/obj/usr/ports/sysutils/bacula-server/work/bacula-3.0.3/src/dird/dird_conf.c
 bacula-3.0.3/src/dird/dird_conf.c
--- 
/usr/obj/usr/ports/sysutils/bacula-server/work/bacula-3.0.3/src/dird/dird_conf.c
    2009-10-18 05:10:16.000000000 -0400
+++ bacula-3.0.3/src/dird/dird_conf.c   2009-11-18 15:58:36.000000000 -0500
@@ -221,6 +221,7 @@
    {"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 -ru 
/usr/obj/usr/ports/sysutils/bacula-server/work/bacula-3.0.3/src/dird/dird_conf.h
 bacula-3.0.3/src/dird/dird_conf.h
--- 
/usr/obj/usr/ports/sysutils/bacula-server/work/bacula-3.0.3/src/dird/dird_conf.h
    2009-10-18 05:10:16.000000000 -0400
+++ bacula-3.0.3/src/dird/dird_conf.h   2009-11-18 15:58:05.000000000 -0500
@@ -306,6 +306,7 @@
    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 -ru 
/usr/obj/usr/ports/sysutils/bacula-server/work/bacula-3.0.3/src/dird/fd_cmds.c 
bacula-3.0.3/src/dird/fd_cmds.c
--- 
/usr/obj/usr/ports/sysutils/bacula-server/work/bacula-3.0.3/src/dird/fd_cmds.c  
    2009-10-18 05:10:16.000000000 -0400
+++ bacula-3.0.3/src/dird/fd_cmds.c     2009-12-03 10:39:14.000000000 -0500
@@ -333,6 +333,7 @@
 {
    FILESET *fileset = jcr->fileset;
    BSOCK   *fd = jcr->file_bsock;
+   STORE   *store = jcr->wstore;
    int num;
    bool include = true;
 
@@ -359,7 +360,6 @@
          }
          for (j=0; j<ie->num_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,30 @@
                }
             }
 
+            if (!store->allowcompress) {
+              char newopts[MAX_FOPTS];
+              int j = 0;
+              for (k=0; fo->opts[k]!='\0'; k++) {
+                if (fo->opts[k]=='Z') { // Z compress option is always 
followed by the single-digit compress level
+                  k++;                  //  this will skip over it
+                } else {
+                  newopts[j] = fo->opts[k];
+                  j++;
+                }
+              }
+              newopts[j] = '\0';
+
+              // Note in the logs that compression has been disabled because 
of the config
+              Jmsg(jcr, M_INFO, 0,
+                   _("Compression has been disabled for this job because 
AllowCompress=No is set for this storage device.\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; k<fo->regex.size(); k++) {
                fd->fsend("R %s\n", fo->regex.get(k));
             }
------------------------------------------------------------------------------
Join us December 9, 2009 for the Red Hat Virtual Experience,
a free event focused on virtualization and cloud computing. 
Attend in-depth sessions from your desk. Your couch. Anywhere.
http://p.sf.net/sfu/redhat-sfdev2dev
_______________________________________________
Bacula-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bacula-devel

Reply via email to