From 69f7810658956d7abfa9b0c609f89af4727647de Mon Sep 17 00:00:00 2001 From: Marian Beermann Date: Wed, 22 Feb 2017 16:53:03 +0100 Subject: [PATCH 1/2] info: show utilization of maximum archive size See #1452 This is 100 % accurate. Also increases maximum data size by ~41 bytes. Not 100 % side-effect free; if you manage to exactly land in that area then older Borg would not read it. OTOH it gives us a nice round number there. --- src/borg/archive.py | 7 +++++-- src/borg/archiver.py | 1 + src/borg/constants.py | 2 ++ src/borg/repository.py | 6 ++++-- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/borg/archive.py b/src/borg/archive.py index 3ebbca9d3..07d62e168 100644 --- a/src/borg/archive.py +++ b/src/borg/archive.py @@ -350,10 +350,13 @@ Archive fingerprint: {0.fpr} Time (start): {start} Time (end): {end} Duration: {0.duration} -Number of files: {0.stats.nfiles}'''.format( +Number of files: {0.stats.nfiles} +Utilization of max. archive size: {csize_max:.0%} +'''.format( self, start=format_time(to_localtime(self.start.replace(tzinfo=timezone.utc))), - end=format_time(to_localtime(self.end.replace(tzinfo=timezone.utc)))) + end=format_time(to_localtime(self.end.replace(tzinfo=timezone.utc))), + csize_max=self.cache.chunks[self.id].csize / MAX_DATA_SIZE) def __repr__(self): return 'Archive(%r)' % self.name diff --git a/src/borg/archiver.py b/src/borg/archiver.py index 371576801..041749a19 100644 --- a/src/borg/archiver.py +++ b/src/borg/archiver.py @@ -987,6 +987,7 @@ class Archiver: print('Duration: %s' % archive.duration_from_meta) print('Number of files: %d' % stats.nfiles) print('Command line: %s' % format_cmdline(archive.metadata.cmdline)) + print('Utilization of max. archive size: %d%%' % (100 * cache.chunks[archive.id].csize / MAX_DATA_SIZE)) print(DASHES) print(STATS_HEADER) print(str(stats)) diff --git a/src/borg/constants.py b/src/borg/constants.py index 27ad8c297..18e0bd5bf 100644 --- a/src/borg/constants.py +++ b/src/borg/constants.py @@ -27,6 +27,8 @@ CACHE_TAG_CONTENTS = b'Signature: 8a477f597d28d172789f06886806bc55' # bytes. That's why it's 500 MiB instead of 512 MiB. DEFAULT_MAX_SEGMENT_SIZE = 500 * 1024 * 1024 +MAX_DATA_SIZE = 20 * 1024 * 1024 + # A few hundred files per directory to go easy on filesystems which don't like too many files per dir (NTFS) DEFAULT_SEGMENTS_PER_DIR = 500 diff --git a/src/borg/repository.py b/src/borg/repository.py index 235873559..2999d8555 100644 --- a/src/borg/repository.py +++ b/src/borg/repository.py @@ -26,7 +26,6 @@ from .crc32 import crc32 logger = create_logger(__name__) -MAX_OBJECT_SIZE = 20 * 1024 * 1024 MAGIC = b'BORG_SEG' MAGIC_LEN = len(MAGIC) TAG_PUT = 0 @@ -1204,4 +1203,7 @@ class LoggedIO: return self.segment - 1 # close_segment() increments it -MAX_DATA_SIZE = MAX_OBJECT_SIZE - LoggedIO.put_header_fmt.size +# MAX_OBJECT_SIZE = 20 MiB (MAX_DATA_SIZE) + 41 bytes for a Repository PUT header, which consists of +# a 1 byte tag ID, 4 byte CRC, 4 byte size and 32 bytes for the ID. +MAX_OBJECT_SIZE = MAX_DATA_SIZE + LoggedIO.put_header_fmt.size +assert MAX_OBJECT_SIZE == 20971561 From b0e4f13fba9e415f6d70620ebb539b6c74f85abb Mon Sep 17 00:00:00 2001 From: Marian Beermann Date: Thu, 23 Feb 2017 00:34:40 +0100 Subject: [PATCH 2/2] set MAX_DATA_SIZE = 20971479 bytes in solid stone --- src/borg/constants.py | 4 +++- src/borg/repository.py | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/borg/constants.py b/src/borg/constants.py index 18e0bd5bf..610486d08 100644 --- a/src/borg/constants.py +++ b/src/borg/constants.py @@ -27,7 +27,9 @@ CACHE_TAG_CONTENTS = b'Signature: 8a477f597d28d172789f06886806bc55' # bytes. That's why it's 500 MiB instead of 512 MiB. DEFAULT_MAX_SEGMENT_SIZE = 500 * 1024 * 1024 -MAX_DATA_SIZE = 20 * 1024 * 1024 +# 20 MiB minus 41 bytes for a Repository header (because the "size" field in the Repository includes +# the header, and the total size was set to 20 MiB). +MAX_DATA_SIZE = 20971479 # A few hundred files per directory to go easy on filesystems which don't like too many files per dir (NTFS) DEFAULT_SEGMENTS_PER_DIR = 500 diff --git a/src/borg/repository.py b/src/borg/repository.py index 2999d8555..81935f4a9 100644 --- a/src/borg/repository.py +++ b/src/borg/repository.py @@ -1203,7 +1203,7 @@ class LoggedIO: return self.segment - 1 # close_segment() increments it -# MAX_OBJECT_SIZE = 20 MiB (MAX_DATA_SIZE) + 41 bytes for a Repository PUT header, which consists of +# MAX_OBJECT_SIZE = <20 MiB (MAX_DATA_SIZE) + 41 bytes for a Repository PUT header, which consists of # a 1 byte tag ID, 4 byte CRC, 4 byte size and 32 bytes for the ID. MAX_OBJECT_SIZE = MAX_DATA_SIZE + LoggedIO.put_header_fmt.size -assert MAX_OBJECT_SIZE == 20971561 +assert MAX_OBJECT_SIZE == 20971520 == 20 * 1024 * 1024