2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-22 12:55:18 +00:00

repo: Remove packer limits

This commit simplifies finding a packer: The first open packer is taken,
and the upper limit for the pack file is removed.
This commit is contained in:
Alexander Neumann 2017-07-16 20:02:59 +02:00
parent d3fee08f9a
commit db0e3cd772
3 changed files with 6 additions and 15 deletions

View File

@ -38,8 +38,6 @@ type packerManager struct {
}
const minPackSize = 4 * 1024 * 1024
const maxPackSize = 16 * 1024 * 1024
const maxPackers = 200
// newPackerManager returns an new packer manager which writes temporary files
// to a temporary directory
@ -58,15 +56,9 @@ func (r *packerManager) findPacker(size uint) (packer *Packer, err error) {
// search for a suitable packer
if len(r.packers) > 0 {
debug.Log("searching packer for %d bytes\n", size)
for i, p := range r.packers {
if p.Packer.Size()+size < maxPackSize {
debug.Log("found packer %v", p)
// remove from list
r.packers = append(r.packers[:i], r.packers[i+1:]...)
return p, nil
}
}
p := r.packers[0]
r.packers = r.packers[1:]
return p, nil
}
// no suitable packer found, return new

View File

@ -91,7 +91,7 @@ func fillPacks(t testing.TB, rnd *randReader, be Saver, pm *packerManager, buf [
}
bytes += l
if packer.Size() < minPackSize && pm.countPacker() < maxPackers {
if packer.Size() < minPackSize {
pm.insertPacker(packer)
continue
}

View File

@ -191,9 +191,8 @@ func (r *Repository) SaveAndEncrypt(ctx context.Context, t restic.BlobType, data
return restic.ID{}, err
}
// if the pack is not full enough and there are less than maxPackers
// packers, put back to the list
if packer.Size() < minPackSize && r.countPacker() < maxPackers {
// if the pack is not full enough, put back to the list
if packer.Size() < minPackSize {
debug.Log("pack is not full enough (%d bytes)", packer.Size())
r.insertPacker(packer)
return *id, nil