From: Eric Bollengier Date: Wed, 17 Aug 2022 07:50:29 +0000 (+0200) Subject: Add device function to compute the file_size depending on the device driver X-Git-Tag: Beta-15.0.0~519 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=35568e02de166f4a596153a488ff06d072417b39;p=thirdparty%2Fbacula.git Add device function to compute the file_size depending on the device driver --- diff --git a/bacula/src/stored/block.c b/bacula/src/stored/block.c index 01efd75a4..0f8fa2cbc 100644 --- a/bacula/src/stored/block.c +++ b/bacula/src/stored/block.c @@ -235,9 +235,9 @@ bool DCR::write_block_to_dev() dev->clrerror(-1); } stat = dev->write(block->buf, (size_t)wlen); - Dmsg4(100, "%s write() BlockAddr=%lld wlen=%d Vol=%s wlen=%d\n", - block->adata?"Adata":"Ameta", block->BlockAddr, wlen, - dev->VolHdr.VolumeName); + Dmsg4(100, "%s write() BlockAddr=%lld wlen=%d Vol=%s\n", + block->adata?"Adata":"Ameta", + block->BlockAddr, wlen, dev->VolHdr.VolumeName); } while (stat == -1 && (errno == EBUSY || errno == EIO) && retry++ < 3); /* ***FIXME*** remove 2 lines debug */ @@ -392,7 +392,7 @@ bool DCR::write_block_to_dev() } dev->file_addr += wlen; /* update file address */ - dev->file_size += wlen; + dev->update_file_size(wlen); dev->usage += wlen; /* update usage counter */ if (dev->part > 0) { dev->part_size += wlen; @@ -629,7 +629,7 @@ reread: if (forge_on) { /* Skip the current byte to find a valid block */ dev->file_addr += 1; - dev->file_size += 1; + dev->update_file_size(1); /* Can be canceled at this point... */ if (jcr->is_canceled()) { jcr->forceJobStatus(status); @@ -724,7 +724,7 @@ reread: dcr->VolMediaId = dev->VolCatInfo.VolMediaId; } dev->file_addr += block->read_len; - dev->file_size += block->read_len; + dev->update_file_size(block->read_len); dev->usage += block->read_len; /* update usage counter */ /* @@ -751,7 +751,7 @@ reread: edit_int64(pos, ed1), block->block_len, block->read_len); dev->file_addr = pos; - dev->file_size = pos; + dev->set_file_size(pos); } Dmsg3(150, "Exit read_block read_len=%d block_len=%d binbuf=%d\n", block->read_len, block->block_len, block->binbuf); diff --git a/bacula/src/stored/dev.c b/bacula/src/stored/dev.c index 973a11563..5d1992ee2 100644 --- a/bacula/src/stored/dev.c +++ b/bacula/src/stored/dev.c @@ -179,7 +179,7 @@ void DEVICE::set_ateof() { set_eof(); file_addr = 0; - file_size = 0; + set_file_size(0); block_num = 0; } @@ -356,7 +356,7 @@ bool DEVICE::close(DCR *dcr) ST_NOSPACE|ST_MOUNTED|ST_MEDIA|ST_SHORT); label_type = B_BACULA_LABEL; file = block_num = 0; - file_size = 0; + set_file_size(0); file_addr = 0; EndFile = EndBlock = 0; openmode = 0; @@ -941,7 +941,7 @@ bool DEVICE::weof(DCR */*dcr*/, int num) return false; } - file_size = 0; + set_file_size(0); return true; } @@ -968,7 +968,7 @@ bool DEVICE::eod(DCR *dcr) } clear_eof(); /* remove EOF flag */ block_num = file = 0; - file_size = 0; + set_file_size(0); file_addr = 0; Leave(100); return ok; @@ -1056,7 +1056,6 @@ char *DEVICE::print_addr(char *buf, int32_t buf_len, boffset_t addr) bool DEVICE::do_size_checks(DCR *dcr, DEV_BLOCK *block) { JCR *jcr = dcr->jcr; - if (is_pool_size_reached(dcr, true)) { if (!dir_get_pool_info(dcr, &VolCatInfo)) { Dmsg0(50, "Error updating volume info.\n"); @@ -1081,7 +1080,7 @@ bool DEVICE::do_size_checks(DCR *dcr, DEV_BLOCK *block) */ if ((max_file_size > 0) && (file_size+block->binbuf) >= max_file_size) { - file_size = 0; /* reset file size */ + set_file_size(0); /* reset file size */ if (!weof(dcr, 1)) { /* write eof */ Dmsg0(50, "WEOF error in max file size.\n"); diff --git a/bacula/src/stored/dev.h b/bacula/src/stored/dev.h index fa0a29c05..ed45758a3 100644 --- a/bacula/src/stored/dev.h +++ b/bacula/src/stored/dev.h @@ -527,6 +527,8 @@ 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 */