iAdd some comments - dedup - deduplicating backup program Err bitreich.org 70 hgit clone git://bitreich.org/dedup/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/dedup/ URL:git://bitreich.org/dedup/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/dedup/ bitreich.org 70 1Log /scm/dedup/log.gph bitreich.org 70 1Files /scm/dedup/files.gph bitreich.org 70 1Refs /scm/dedup/refs.gph bitreich.org 70 1Tags /scm/dedup/tag bitreich.org 70 1README /scm/dedup/file/README.gph bitreich.org 70 1LICENSE /scm/dedup/file/LICENSE.gph bitreich.org 70 i--- Err bitreich.org 70 1commit 53b588c7899ecf4f4c969259e2c80f18192893ba /scm/dedup/commit/53b588c7899ecf4f4c969259e2c80f18192893ba.gph bitreich.org 70 1parent ff783e2a9af6d97d55697d654d759ca48d6a28a1 /scm/dedup/commit/ff783e2a9af6d97d55697d654d759ca48d6a28a1.gph bitreich.org 70 hAuthor: sin URL:mailto:sin@2f30.org bitreich.org 70 iDate: Sat, 27 Apr 2019 18:31:05 +0100 Err bitreich.org 70 i Err bitreich.org 70 iAdd some comments Err bitreich.org 70 i Err bitreich.org 70 iDiffstat: Err bitreich.org 70 i M bstorage.c | 15 ++++++++++----- Err bitreich.org 70 i Err bitreich.org 70 i1 file changed, 10 insertions(+), 5 deletions(-) Err bitreich.org 70 i--- Err bitreich.org 70 1diff --git a/bstorage.c b/bstorage.c /scm/dedup/file/bstorage.c.gph bitreich.org 70 i@@ -84,8 +84,8 @@ struct bhdr { Err bitreich.org 70 i /* Block descriptor */ Err bitreich.org 70 i struct bd { Err bitreich.org 70 i uint64_t type; Err bitreich.org 70 i- uint64_t offset; Err bitreich.org 70 i- uint64_t size; Err bitreich.org 70 i+ uint64_t offset; /* offset of block */ Err bitreich.org 70 i+ uint64_t size; /* size of block */ Err bitreich.org 70 i uint64_t refcnt; Err bitreich.org 70 i unsigned char md[MDSIZE]; Err bitreich.org 70 i RB_ENTRY(bd) rbe; Err bitreich.org 70 i@@ -359,7 +359,6 @@ bscreat(struct bctx *bctx, char *path, int mode, struct bparam *bpar) Err bitreich.org 70 i close(fd); Err bitreich.org 70 i return -1; Err bitreich.org 70 i } Err bitreich.org 70 i- Err bitreich.org 70 i bhdr->nbd = 0; Err bitreich.org 70 i sctx->fd = fd; Err bitreich.org 70 i Err bitreich.org 70 i@@ -484,6 +483,7 @@ bsput(struct bctx *bctx, void *buf, size_t n, unsigned char *md) Err bitreich.org 70 i if (lseek(sctx->fd, bdoffs, SEEK_SET) < 0) Err bitreich.org 70 i return -1; Err bitreich.org 70 i Err bitreich.org 70 i+ /* Block already present, increment the reference count */ Err bitreich.org 70 i bd->refcnt++; Err bitreich.org 70 i if (packbd(sctx->fd, bd) < 0) { Err bitreich.org 70 i bd->refcnt--; Err bitreich.org 70 i@@ -583,8 +583,7 @@ bsrm(struct bctx *bctx, unsigned char *md) Err bitreich.org 70 i if (punchhole(sctx->fd, bd->offset, bd->size) < 0) { Err bitreich.org 70 i /* Err bitreich.org 70 i * Filesystem does not support hole punching. Err bitreich.org 70 i- * Try to recover the block descriptor so we don't Err bitreich.org 70 i- * lose track of the block. Err bitreich.org 70 i+ * Restore reference count. Err bitreich.org 70 i */ Err bitreich.org 70 i lseek(sctx->fd, bdoffs, SEEK_SET); Err bitreich.org 70 i bd->refcnt++; Err bitreich.org 70 i@@ -592,6 +591,11 @@ bsrm(struct bctx *bctx, unsigned char *md) Err bitreich.org 70 i return -1; Err bitreich.org 70 i } Err bitreich.org 70 i Err bitreich.org 70 i+ /* Err bitreich.org 70 i+ * Remove block from block descriptor cache as this is no Err bitreich.org 70 i+ * longer a valid block. Insert it into the garbage collector Err bitreich.org 70 i+ * list instead. Err bitreich.org 70 i+ */ Err bitreich.org 70 i RB_REMOVE(bdcache, &sctx->bdcache, bd); Err bitreich.org 70 i SLIST_INSERT_HEAD(&sctx->gchead, bd, sle); Err bitreich.org 70 i return 0; Err bitreich.org 70 i@@ -685,6 +689,7 @@ bsclose(struct bctx *bctx) Err bitreich.org 70 i return -1; Err bitreich.org 70 i Err bitreich.org 70 i sctx = bctx->sctx; Err bitreich.org 70 i+ Err bitreich.org 70 i /* Free block descriptor cache */ Err bitreich.org 70 i RB_FOREACH_SAFE(bd, bdcache, &sctx->bdcache, tmp) { Err bitreich.org 70 i RB_REMOVE(bdcache, &sctx->bdcache, bd); Err bitreich.org 70 .