mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-27 02:08:54 +00:00
parent
528913b220
commit
bfb00dfa01
2 changed files with 22 additions and 1 deletions
|
@ -1533,6 +1533,11 @@ def build_parser(self, args=None, prog=None):
|
||||||
|
|
||||||
To allow a regular user to use fstab entries, add the ``user`` option:
|
To allow a regular user to use fstab entries, add the ``user`` option:
|
||||||
``/path/to/repo /mnt/point fuse.borgfs defaults,noauto,user 0 0``
|
``/path/to/repo /mnt/point fuse.borgfs defaults,noauto,user 0 0``
|
||||||
|
|
||||||
|
The BORG_MOUNT_DATA_CACHE_ENTRIES environment variable is meant for advanced users
|
||||||
|
to tweak the performance. It sets the number of cached data chunks; additional
|
||||||
|
memory usage can be up to ~8 MiB times this number. The default is the number
|
||||||
|
of CPU cores.
|
||||||
""")
|
""")
|
||||||
subparser = subparsers.add_parser('mount', parents=[common_parser], add_help=False,
|
subparser = subparsers.add_parser('mount', parents=[common_parser], add_help=False,
|
||||||
description=self.do_mount.__doc__,
|
description=self.do_mount.__doc__,
|
||||||
|
|
16
borg/fuse.py
16
borg/fuse.py
|
@ -8,9 +8,13 @@
|
||||||
import time
|
import time
|
||||||
from .archive import Archive
|
from .archive import Archive
|
||||||
from .helpers import daemonize, bigint_to_int
|
from .helpers import daemonize, bigint_to_int
|
||||||
|
from .logger import create_logger
|
||||||
|
from .lrucache import LRUCache
|
||||||
from distutils.version import LooseVersion
|
from distutils.version import LooseVersion
|
||||||
import msgpack
|
import msgpack
|
||||||
|
|
||||||
|
logger = create_logger()
|
||||||
|
|
||||||
# Does this version of llfuse support ns precision?
|
# Does this version of llfuse support ns precision?
|
||||||
have_fuse_xtime_ns = hasattr(llfuse.EntryAttributes, 'st_mtime_ns')
|
have_fuse_xtime_ns = hasattr(llfuse.EntryAttributes, 'st_mtime_ns')
|
||||||
|
|
||||||
|
@ -54,6 +58,9 @@ def __init__(self, key, repository, manifest, archive, cached_repo):
|
||||||
self.pending_archives = {}
|
self.pending_archives = {}
|
||||||
self.accounted_chunks = {}
|
self.accounted_chunks = {}
|
||||||
self.cache = ItemCache()
|
self.cache = ItemCache()
|
||||||
|
data_cache_capacity = int(os.environ.get('BORG_MOUNT_DATA_CACHE_ENTRIES', os.cpu_count() or 1))
|
||||||
|
logger.debug('mount data cache capacity: %d chunks', data_cache_capacity)
|
||||||
|
self.data_cache = LRUCache(capacity=data_cache_capacity, dispose=lambda _: None)
|
||||||
if archive:
|
if archive:
|
||||||
self.process_archive(archive)
|
self.process_archive(archive)
|
||||||
else:
|
else:
|
||||||
|
@ -229,7 +236,16 @@ def read(self, fh, offset, size):
|
||||||
offset -= s
|
offset -= s
|
||||||
continue
|
continue
|
||||||
n = min(size, s - offset)
|
n = min(size, s - offset)
|
||||||
|
if id in self.data_cache:
|
||||||
|
data = self.data_cache[id]
|
||||||
|
if offset + n == len(data):
|
||||||
|
# evict fully read chunk from cache
|
||||||
|
del self.data_cache[id]
|
||||||
|
else:
|
||||||
_, data = self.key.decrypt(id, self.repository.get(id))
|
_, data = self.key.decrypt(id, self.repository.get(id))
|
||||||
|
if offset + n < len(data):
|
||||||
|
# chunk was only partially read, cache it
|
||||||
|
self.data_cache[id] = data
|
||||||
parts.append(data[offset:offset + n])
|
parts.append(data[offset:offset + n])
|
||||||
offset = 0
|
offset = 0
|
||||||
size -= n
|
size -= n
|
||||||
|
|
Loading…
Reference in a new issue