From: Eric Bollengier Date: Fri, 17 Jun 2022 08:56:20 +0000 (+0200) Subject: Optimize Aligned format for Single Item Restore X-Git-Tag: Beta-15.0.0~512 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5b82fb68430f0166836689b6cd589b1e3b0ec2bd;p=thirdparty%2Fbacula.git Optimize Aligned format for Single Item Restore Allow to read only the ameta records and rehydrate the data block only when needed. dev->clear_rehydrate_record(); ... // read blocks dev->rehydrate_record(dcr, rec) --- diff --git a/bacula/src/stored/aligned_dev.h b/bacula/src/stored/aligned_dev.h index b3c9ebeb0..1f016617c 100644 --- a/bacula/src/stored/aligned_dev.h +++ b/bacula/src/stored/aligned_dev.h @@ -102,9 +102,9 @@ public: void select_data_stream(DCR *dcr, DEV_RECORD *rec); bool flush_block(DCR *dcr); bool do_pre_write_checks(DCR *dcr, DEV_RECORD *rec); - - - + bool get_os_device_freespace(); + bool is_fs_nearly_full(uint64_t threshold); + int rehydrate_record(DCR *dcr, DEV_RECORD *rec); /* * Locking and blocking calls */ diff --git a/bacula/src/stored/butil.c b/bacula/src/stored/butil.c index 9aa95cf13..34403ab42 100644 --- a/bacula/src/stored/butil.c +++ b/bacula/src/stored/butil.c @@ -197,6 +197,9 @@ static DCR *setup_to_access_device(JCR *jcr, char *dev_name, if (read_dedup_data) { Dmsg0(DT_DEDUP|215, "Initialize dedup interface\n"); jcr->read_dcr->dev->setup_dedup_rehydration_interface(jcr->read_dcr); + + } else { + dev->set_delay_adata(); /* Do not read aligned data */ } } else { if (!first_open_device(dcr)) { diff --git a/bacula/src/stored/dev.h b/bacula/src/stored/dev.h index ed45758a3..54eaf9f19 100644 --- a/bacula/src/stored/dev.h +++ b/bacula/src/stored/dev.h @@ -299,6 +299,7 @@ public: bool m_shstore_user_lock; /* set if user set shared lock */ bool m_shstore_register; /* set if register key set */ bool m_shstore_blocked; /* Set if I am blocked */ + bool m_delay_adata; /* Set if we need to ask to read adata */ bool adata; /* set if adata device */ int label_type; /* Bacula/ANSI/IBM label types */ uint32_t drive_index; /* Autochanger drive index (base 0) */ @@ -464,6 +465,8 @@ public: void set_load() { m_load = true; }; void set_wait() { m_wait = true; }; void clear_wait() { m_wait = false; }; + void set_delay_adata() { m_delay_adata = true;}; + void clear_delay_adata() { m_delay_adata = false;}; bool must_wait() const { return m_wait; }; void inc_reserved() { m_num_reserved++; } void set_mounted(int val) { if (val) state |= ST_MOUNTED; \ @@ -527,8 +530,6 @@ public: /* Virtual functions that can be overridden */ - virtual void set_file_size(uint64_t val) { file_size = val;}; - virtual uint64_t update_file_size(uint64_t add) { file_size += add; return file_size; }; virtual void setVolCatName(const char *name); virtual void setVolCatStatus(const char *status); virtual void free_dcr_blocks(DCR *dcr); /* in block_util.c */ @@ -708,6 +709,7 @@ public: void open_tape_device(DCR *dcr, int omode); /* in dev.c */ void open_file_device(DCR *dcr, int omode); /* in dev.c */ + virtual int rehydrate_record(DCR *dcr, DEV_RECORD *rec) { return 1;}; virtual bool setup_dedup_rehydration_interface(DCR *dcr) { return false; }; virtual void free_dedup_rehydration_interface(DCR *dcr) { }; virtual GetMsg *get_msg_queue(JCR *jcr, BSOCK *sock, int32_t bufsize) @@ -811,6 +813,7 @@ public: int Copy; /* identical copy number */ int Stripe; /* RAIT stripe */ VOLUME_CAT_INFO VolCatInfo; /* Catalog info for desired volume */ + /* *** BEEF *** */ uint32_t crc32(unsigned char *buf, int len, uint32_t expected_crc); /* *** SIR *** */ diff --git a/bacula/src/stored/record.h b/bacula/src/stored/record.h index 196849d60..4f87de3bb 100644 --- a/bacula/src/stored/record.h +++ b/bacula/src/stored/record.h @@ -52,7 +52,8 @@ enum rec_state { st_cont_adata_rechdr, /* 6 Adata continuation rechdr */ st_adata, /* 7 Write aligned data */ st_cont_adata, /* 8 Write more aligned data */ - st_adata_label /* 9 Writing adata vol label */ + st_adata_label, /* 9 Writing adata vol label */ + st_header_only /* 10 Read only the header (aligned) */ }; diff --git a/bacula/src/stored/record_read.c b/bacula/src/stored/record_read.c index f39f21dfb..8b728758a 100644 --- a/bacula/src/stored/record_read.c +++ b/bacula/src/stored/record_read.c @@ -31,7 +31,7 @@ /* Imported subroutines */ static const int read_dbglvl = 200|DT_VOLUME; -static const int dbgep = 400|DT_VOLUME; /* debug execution path */ +static const int dbgep = 200|DT_VOLUME; /* debug execution path */ /* * Read the header record @@ -86,6 +86,7 @@ static bool read_header(DCR *dcr, DEV_BLOCK *block, DEV_RECORD *rec) if (dcr->dev->have_adata_header(dcr, rec, FileIndex, Stream, VolSessionId)) { return true; } + block->bufp += rhl; block->binbuf -= rhl; rec->remlen -= rhl; @@ -237,13 +238,6 @@ bool read_record_from_block(DCR *dcr, DEV_RECORD *rec) Dmsg0(dbgep, "=== rpath 1 Enter read_record_from block\n"); - /* We return from a previous call with aligned volume, we did not read - * the data on disk, let's read the next ameta record. - */ - if (rec->rstate == st_header_only) { - rec->remainder = 0; - rec->rstate = st_header; - } /* Update the Record number only if we have a new record */ if (rec->remainder == 0) { rec->RecNum = dcr->block->RecNum; @@ -253,7 +247,7 @@ bool read_record_from_block(DCR *dcr, DEV_RECORD *rec) /* We read the next record */ dcr->block->RecNum++; - + for ( ;; ) { switch (rec->rstate) { case st_none: @@ -271,10 +265,8 @@ bool read_record_from_block(DCR *dcr, DEV_RECORD *rec) continue; case st_header_only: - /* We come from the st_cont_adata_rechdr state and we may read - * or not the data associated - */ Dmsg0(dbgep, "=== rpath 37 st_header_only\n"); + rec->rstate = st_header; goto get_out; case st_data: