From: Eric Bollengier Date: Fri, 9 Sep 2022 13:03:00 +0000 (+0200) Subject: sir: Fix the record number with aligned volume X-Git-Tag: Beta-15.0.0~513 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1c9712568c159c8b4f8d06386651f66eca3893d9;p=thirdparty%2Fbacula.git sir: Fix the record number with aligned volume --- diff --git a/bacula/src/stored/record_read.c b/bacula/src/stored/record_read.c index 423dff742..f39f21dfb 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 = 200|DT_VOLUME; /* debug execution path */ +static const int dbgep = 400|DT_VOLUME; /* debug execution path */ /* * Read the header record @@ -86,7 +86,6 @@ 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; @@ -238,6 +237,13 @@ 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; @@ -247,7 +253,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: @@ -264,6 +270,13 @@ 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"); + goto get_out; + case st_data: Dmsg0(dbgep, "=== rpath 37 st_data\n"); read_data(dcr->block, rec);