Skip to content

Commit

Permalink
backup: prepare parallel sending
Browse files Browse the repository at this point in the history
  • Loading branch information
sebsura committed Nov 6, 2023
1 parent c9e6cf4 commit 26aed57
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions core/src/filed/backup.cc
Expand Up @@ -1056,9 +1056,40 @@ static inline bool SendEncryptedData(b_ctx& bctx)
}
#endif

static inline bool SendPlainDataSerially(b_ctx& bctx)
{
bool retval = false;
BareosSocket* sd = bctx.jcr->store_bsock;

// Read the file data
while ((sd->message_length
= (uint32_t)bread(&bctx.ff_pkt->bfd, bctx.rbuf, bctx.rsize))
> 0) {
if (!SendDataToSd(&bctx)) { goto bail_out; }
}
retval = true;

bail_out:
return retval;
}

// Send the content of a file on anything but an EFS filesystem.
static inline bool SendPlainData(b_ctx& bctx)
{
std::size_t max_buf_size = bctx.rsize;

auto file_size = bctx.ff_pkt->statp.st_size;
auto* flags = bctx.ff_pkt->flags;

// Currently we do not support encryption while doing
// parallel sending/checksumming/compression/etc.
// This is mostly because EncryptData() is weird!
// FIXME(ssura): change this
if (BitIsSet(FO_ENCRYPT, flags)
|| file_size < static_cast<ssize_t>(2 * max_buf_size)) {
return SendPlainDataSerially(bctx);
}

bool retval = false;
BareosSocket* sd = bctx.jcr->store_bsock;

Expand Down

0 comments on commit 26aed57

Please sign in to comment.