]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
BEE Backport bacula/src/stored/label.c
authorKern Sibbald <kern@sibbald.com>
Tue, 12 May 2020 17:02:24 +0000 (19:02 +0200)
committerEric Bollengier <eric@baculasystems.com>
Thu, 29 Apr 2021 08:44:18 +0000 (10:44 +0200)
This commit is the result of the squash of the following main commits:

Author: Kern Sibbald <kern@sibbald.com>
Date:   Mon Mar 27 14:39:45 2017 +0200

    Corrected the label type detection code

Signed-off-by: Eric Bollengier <eric@baculasystems.com>
Author: Kern Sibbald <kern@sibbald.com>
Date:   Tue Jul 26 12:54:42 2016 +0200

    First cut Cloud volume label

Author: Kern Sibbald <kern@sibbald.com>
Date:   Thu Jun 23 20:23:38 2016 +0200

    Small step to full SD classes make some label.c subroutines DEVICE methods

Author: Kern Sibbald <kern@sibbald.com>
Date:   Sun May 18 19:03:51 2014 +0200

    Add dedup block size and setup Volume header for dedup

Author: Kern Sibbald <kern@sibbald.com>
Date:   Wed May 14 16:21:30 2014 +0200

    First phase new Dedup Volume header

Author: Alain Spineux <alain@baculasystems.com>
Date:   Sun Apr 6 20:05:35 2014 +0200

    Beginning of dedup code

Author: Kern Sibbald <kern@sibbald.com>
Date:   Wed Oct 30 20:28:34 2013 +0100

    Ensure that aligned and non-aligned Volumes cannot be mixed

bacula/src/stored/label.c

index 6478fcb117632f8927f88e1b6be4d4f615d56c5a..66ff9d95e030b4decd71d12e4b2d763f4194ea6b 100644 (file)
@@ -144,6 +144,7 @@ int DEVICE::read_dev_volume_label(DCR *dcr)
               strcmp(VolHdr.Id, OldBaculaId) != 0 &&
               strcmp(VolHdr.Id, BaculaMetaDataId) != 0 &&
               strcmp(VolHdr.Id, BaculaAlignedDataId) != 0 &&
+              strcmp(VolHdr.Id, BaculaDedupMetaDataId) != 0 &&
               strcmp(VolHdr.Id, BaculaS3CloudId) != 0) {
       Mmsg(jcr->errmsg, _("Volume Header Id bad: %s\n"), VolHdr.Id);
       Dmsg1(dbglvl, "%s", jcr->errmsg);
@@ -179,6 +180,7 @@ int DEVICE::read_dev_volume_label(DCR *dcr)
     */
    if (VolHdr.VerNum != BaculaTapeVersion &&
        VolHdr.VerNum != BaculaMetaDataVersion &&
+       VolHdr.VerNum != BaculaDedupMetaDataVersion &&
        VolHdr.VerNum != BaculaS3CloudVersion &&
        VolHdr.VerNum != OldCompatibleBaculaTapeVersion1 &&
        VolHdr.VerNum != OldCompatibleBaculaTapeVersion2) {
@@ -227,6 +229,14 @@ int DEVICE::read_dev_volume_label(DCR *dcr)
 
    /* Compare VolType to Device Type */
    switch (dev_type) {
+   case B_DEDUP_DEV:
+      if (strcmp(VolHdr.Id, BaculaDedupMetaDataId) != 0) {
+         Mmsg(jcr->errmsg, _("Wrong Volume Type. Wanted a Dedup Volume %s on device %s, but got: %s\n"),
+            VolHdr.VolumeName, print_name(), VolHdr.Id);
+         stat = VOL_TYPE_ERROR;
+         goto bail_out;
+      }
+      break;
    case B_FILE_DEV:
       if (strcmp(VolHdr.Id, BaculaId) != 0) {
          Mmsg(jcr->errmsg, _("Wrong Volume Type. Wanted a File or Tape Volume %s on device %s, but got: %s\n"),
@@ -789,6 +799,10 @@ void create_volume_header(DEVICE *dev, const char *VolName,
       dev->VolHdr.FileAlignment = dev->file_alignment;
       dev->VolHdr.PaddingSize = dev->padding_size;
       dev->VolHdr.BlockSize = dev->adata_size;
+   } else if (dev->is_dedup()) {
+      bstrncpy(dev->VolHdr.Id, BaculaDedupMetaDataId, sizeof(dev->VolHdr.Id));
+      dev->VolHdr.VerNum = BaculaDedupMetaDataVersion;
+      dev->VolHdr.BlockSize = dev->max_block_size;
    } else if (dev->is_cloud()) {
       bstrncpy(dev->VolHdr.Id, BaculaS3CloudId, sizeof(dev->VolHdr.Id));
       dev->VolHdr.VerNum = BaculaS3CloudVersion;