From: Kern Sibbald Date: Sat, 20 Nov 2010 07:08:42 +0000 (+0100) Subject: First cut Delta code in FD X-Git-Tag: Release-7.0.0~1390 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f631d3509f3962dc42944653c453752512aa60b1;p=bacula%2Fbacula First cut Delta code in FD --- diff --git a/bacula/src/filed/backup.c b/bacula/src/filed/backup.c index 3116d7f62e..6e583ac563 100644 --- a/bacula/src/filed/backup.c +++ b/bacula/src/filed/backup.c @@ -810,7 +810,7 @@ static int send_data(JCR *jcr, int stream, FF_PKT *ff_pkt, DIGEST *digest, int zstat; if (ff_pkt->flags & FO_GZIP) { - if (ff_pkt->flags & FO_SPARSE) { + if ((ff_pkt->flags & FO_SPARSE) || (ff_pkt->flags & FO_DELTA)) { cbuf = (Bytef *)jcr->compress_buf + SPARSE_FADDR_SIZE; max_compress_len = jcr->compress_buf_size - SPARSE_FADDR_SIZE; } else { @@ -884,7 +884,7 @@ static int send_data(JCR *jcr, int stream, FF_PKT *ff_pkt, DIGEST *digest, * Make space at beginning of buffer for fileAddr because this * same buffer will be used for writing if compression is off. */ - if (ff_pkt->flags & FO_SPARSE) { + if ((ff_pkt->flags & FO_SPARSE) || (ff_pkt->flags & FO_DELTA)) { rbuf += SPARSE_FADDR_SIZE; rsize -= SPARSE_FADDR_SIZE; #ifdef HAVE_FREEBSD_OS @@ -927,6 +927,10 @@ static int send_data(JCR *jcr, int stream, FF_PKT *ff_pkt, DIGEST *digest, if (allZeros) { continue; /* skip block of zeros */ } + } else if (ff_pkt->flags & FO_DELTA) { + ser_declare; + ser_begin(wbuf, SPARSE_FADDR_SIZE); + ser_uint64(ff_pkt->bfd.offset); /* store offset in begin of buffer */ } jcr->ReadBytes += sd->msglen; /* count bytes read */ @@ -991,7 +995,7 @@ static int send_data(JCR *jcr, int stream, FF_PKT *ff_pkt, DIGEST *digest, uint32_t initial_len = 0; ser_declare; - if (ff_pkt->flags & FO_SPARSE) { + if ((ff_pkt->flags & FO_SPARSE) || (ff_pkt->flags & FO_DELTA)) { cipher_input_len += SPARSE_FADDR_SIZE; } @@ -1027,7 +1031,7 @@ static int send_data(JCR *jcr, int stream, FF_PKT *ff_pkt, DIGEST *digest, } /* Send the buffer to the Storage daemon */ - if (ff_pkt->flags & FO_SPARSE) { + if ((ff_pkt->flags & FO_SPARSE) || (ff_pkt->flags & FO_DELTA)) { sd->msglen += SPARSE_FADDR_SIZE; /* include fileAddr in size */ } sd->msg = wbuf; /* set correct write buffer */ @@ -1229,6 +1233,11 @@ bool encode_and_send_attributes(JCR *jcr, FF_PKT *ff_pkt, int &data_stream) free_and_null_pool_memory(ff_pkt->object); } break; + case FT_REG: + stat = sd->fsend("%ld %d %s%c%s%c%c%s%c%d%c", jcr->JobFiles, + ff_pkt->type, ff_pkt->fname, 0, attribs, 0, 0, attribsEx, 0, + ff_pkt->delta_seq, 0); + break; default: stat = sd->fsend("%ld %d %s%c%s%c%c%s%c%u%c", jcr->JobFiles, ff_pkt->type, ff_pkt->fname, 0, attribs, 0, 0, diff --git a/bacula/src/filed/fd_plugins.c b/bacula/src/filed/fd_plugins.c index d07341cd81..467cea104e 100644 --- a/bacula/src/filed/fd_plugins.c +++ b/bacula/src/filed/fd_plugins.c @@ -354,6 +354,7 @@ int plugin_save(JCR *jcr, FF_PKT *ff_pkt, bool top_level) sp.pkt_size = sizeof(sp); sp.pkt_end = sizeof(sp); sp.portable = true; + sp.flags = 0; sp.cmd = cmd; Dmsg3(dbglvl, "startBackup st_size=%p st_blocks=%p sp=%p\n", &sp.statp.st_size, &sp.statp.st_blocks, &sp); @@ -395,6 +396,11 @@ int plugin_save(JCR *jcr, FF_PKT *ff_pkt, bool top_level) pm_strcpy(link, sp.link); ff_pkt->fname = fname.c_str(); ff_pkt->link = link.c_str(); + if (sp.flags & FO_DELTA) { + ff_pkt->flags |= FO_DELTA; + } else { + ff_pkt->flags &= ~FO_DELTA; + } } memcpy(&ff_pkt->statp, &sp.statp, sizeof(ff_pkt->statp)); @@ -412,9 +418,9 @@ int plugin_save(JCR *jcr, FF_PKT *ff_pkt, bool top_level) continue; } goto bail_out; - } + } /* end while loop */ goto bail_out; - } + } /* end loop over all plugins */ Jmsg1(jcr, M_FATAL, 0, "Command plugin \"%s\" not found.\n", cmd); bail_out: diff --git a/bacula/src/filed/fd_plugins.h b/bacula/src/filed/fd_plugins.h index 65d9ce430b..2564244319 100644 --- a/bacula/src/filed/fd_plugins.h +++ b/bacula/src/filed/fd_plugins.h @@ -101,6 +101,7 @@ struct save_pkt { uint32_t flags; /* Bacula internal flags */ bool portable; /* set if data format is portable */ char *cmd; /* command */ + uint32_t delta_seq; /* Delta sequence number */ char *object_name; /* Object name to create */ char *object; /* restore object data to save */ int32_t object_len; /* restore object length */ diff --git a/bacula/src/filed/restore.c b/bacula/src/filed/restore.c index 1eff06734d..711586c284 100644 --- a/bacula/src/filed/restore.c +++ b/bacula/src/filed/restore.c @@ -1233,7 +1233,7 @@ int32_t extract_data(JCR *jcr, BFILE *bfd, POOLMEM *buf, int32_t buflen, Dmsg2(130, "Encryption writing full block, %u bytes, remaining %u bytes in buffer\n", wsize, cipher_ctx->buf_len); } - if (flags & FO_SPARSE) { + if ((flags & FO_SPARSE) || (flags & FO_DELTA)) { if (!sparse_data(jcr, bfd, addr, &wbuf, &wsize)) { goto bail_out; } @@ -1374,7 +1374,7 @@ again: cipher_ctx->buf_len -= cipher_ctx->packet_len; Dmsg2(130, "Encryption writing full block, %u bytes, remaining %u bytes in buffer\n", wsize, cipher_ctx->buf_len); - if (flags & FO_SPARSE) { + if ((flags & FO_SPARSE) || (flags & FO_DELTA)) { if (!sparse_data(jcr, bfd, addr, &wbuf, &wsize)) { return false; } diff --git a/bacula/src/findlib/bfile.h b/bacula/src/findlib/bfile.h index 021dcc0863..a727a141e7 100644 --- a/bacula/src/findlib/bfile.h +++ b/bacula/src/findlib/bfile.h @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2003-2008 Free Software Foundation Europe e.V. + Copyright (C) 2003-2010 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -85,6 +85,7 @@ struct BFILE { DWORD rw_bytes; /* Bytes read or written */ DWORD lerror; /* Last error code */ int berrno; /* errno */ + bofset_t offset; /* Delta offset */ JCR *jcr; /* jcr for editing job codes */ PROCESS_WIN32_BACKUPAPIBLOCK_CONTEXT win32DecompContext; /* context for decomposition of win32 backup streams */ int use_backup_decomp; /* set if using BackupRead Stream Decomposition */ @@ -109,6 +110,7 @@ struct BFILE { int m_flags; /* open flags */ int berrno; /* errno */ int32_t lerror; /* not used - simplies Win32 builds */ + boffset_t offset; /* Delta offset */ JCR *jcr; /* jcr for editing job codes */ PROCESS_WIN32_BACKUPAPIBLOCK_CONTEXT win32DecompContext; /* context for decomposition of win32 backup streams */ int use_backup_decomp; /* set if using BackupRead Stream Decomposition */ diff --git a/bacula/src/findlib/find.h b/bacula/src/findlib/find.h index 4939d7446c..30e7c98fdd 100644 --- a/bacula/src/findlib/find.h +++ b/bacula/src/findlib/find.h @@ -102,6 +102,7 @@ int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result); #define FO_STRIPPATH (1<<25) /* Check for stripping path */ #define FO_HONOR_NODUMP (1<<26) /* honor NODUMP flag */ #define FO_XATTR (1<<27) /* Backup Extended Attributes */ +#define FO_DELTA (1<<28) /* Do delta on file */ struct s_included_file { struct s_included_file *next; @@ -201,6 +202,7 @@ struct FF_PKT { int32_t object_index; /* Object index */ int32_t object_len; /* Object length */ int32_t object_compression; /* Type of compression for object */ + uint32_t delta_seq; /* Delta sequence number */ struct f_link *linked; /* Set if this file is hard linked */ int type; /* FT_ type from above */ int ff_errno; /* errno */