dedup

deduplicating backup program
git clone git://git.2f30.org/dedup
Log | Files | Refs | README | LICENSE

commit 00d03339c89087d34d11f3147daae28de6f94c7a
parent d6e4ca0475985f2f98e35fcfd5bdb3b4304a0eff
Author: sin <sin@2f30.org>
Date:   Thu, 25 Apr 2019 22:08:08 +0100

If fallocate(2) fails do our best to recover

Diffstat:
Mbstorage.c | 8+++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/bstorage.c b/bstorage.c @@ -567,7 +567,13 @@ bsrm(struct bctx *bctx, unsigned char *md) int mode; mode = FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE; - fallocate(sctx->fd, mode, bd->offset, bd->size); + if (fallocate(sctx->fd, mode, bd->offset, bd->size) < 0) { + lseek(sctx->fd, bdoffs, SEEK_SET); + bd->refcnt++; + packbd(sctx->fd, bd); + return -1; + } + RB_REMOVE(bdcache, &sctx->bdcache, bd); free(bd); }