Skip to content

Commit

Permalink
Add option to work without qouta
Browse files Browse the repository at this point in the history
Based on existing work AmesCornish#29.

Use estimation option twice to disable relying on quotas (`-ee`).

Lacking of snapshot size information
cause crazy diff paths on current algorithm.

Closes: AmesCornish#29
Resolves: AmesCornish#38
  • Loading branch information
eugene-bright committed Jul 11, 2018
1 parent 1f13eca commit 50752bf
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
6 changes: 3 additions & 3 deletions buttersink/BestDiffs.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ def summary(nodes):
if n.diff is None:
continue

total.size += n.diff.size
total.size += (n.diff.size or 0)

sink = sinks[n.diff.sink]
sink.count += 1
sink.size += n.diff.size
sink.size += (n.diff.size or 0)

sinksSorted = collections.OrderedDict(
{s: b for s, b in sinks.items() if s is not None}
Expand Down Expand Up @@ -205,7 +205,7 @@ def sortKey(node):

logger.debug("Considering %s", edge)

edgeSize = edge.size
edgeSize = (edge.size or 0)
if edge.sizeIsEstimated:
if willMeasureLater:
# Slight preference for accurate sizes
Expand Down
3 changes: 3 additions & 0 deletions buttersink/ButterStore.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,3 +335,6 @@ def deletePartials(self, dryrun=False):
if self._skipDryRun(logger, 'INFO', dryrun=dryrun)("Delete subvolume %s", path):
continue
self.butterVolumes[vol.uuid].destroy()

def rescanSizes(self):
self.btrfs.rescanSizes()
9 changes: 4 additions & 5 deletions buttersink/btrfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,6 @@ def subvolumes(self):
self._getDevices()
self._getRoots()
self._getMounts()
self._getUsage()

volumes = self.volumes.values()
volumes.sort(key=(lambda v: v.fullPath))
Expand Down Expand Up @@ -669,16 +668,16 @@ def _getRoots(self):
self.defaultID = info.location.objectid
logger.debug("Found dir '%s' is %d", name, self.defaultID)

def _getUsage(self):
def rescanSizes(self):
try:
self._rescanSizes(False)
self._unsafeGetUsage()
self._getUsage()
except (IOError, _BtrfsError) as error:
logger.warn("%s", error)
self._rescanSizes()
self._unsafeGetUsage()
self._getUsage()

def _unsafeGetUsage(self):
def _getUsage(self):
for (header, buf) in self._walkTree(BTRFS_QUOTA_TREE_OBJECTID):
# logger.debug("%s %s", objectTypeNames[header.type], header)

Expand Down
12 changes: 9 additions & 3 deletions buttersink/buttersink.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,12 @@
command.add_argument('-d', '--delete', action="store_true",
help='delete any snapshots in <dst> that are not in <src>',
)
command.add_argument('-e', '--estimate', action="store_true",
help='use estimated size instead of measuring diffs with a local test send',
)
command.add_argument('-e', '--estimate', action="count",
help=(
'use estimated size instead of measuring diffs '
'with a local test send. '
'Use it twice to disable relying on quota too.'
))

command.add_argument('-q', '--quiet', action="store_true",
help='only display error messages',
Expand Down Expand Up @@ -220,6 +223,9 @@ def main():
dest.showProgress = True

with source:
if args.estimate < 2:
source.rescanSizes()

try:
next(source.listVolumes())
except StopIteration:
Expand Down

0 comments on commit 50752bf

Please sign in to comment.