don't do a du on startup if there is no size limit configured

This also turns off the production of the "space measurement done" log message, if there is no size limit configured.
This commit is contained in:
Zooko O'Whielacronx 2008-04-08 11:36:56 -07:00
parent 8b4d530036
commit 8783eabf5a
2 changed files with 14 additions and 11 deletions

View File

@ -78,7 +78,9 @@ this file. Note that this is a fairly loose bound, and the node may
occasionally use slightly more storage than this. To enforce a stronger (and
possibly more reliable) limit, use a symlink to place the 'storage/'
directory on a separate size-limited filesystem, and/or use per-user
OS/filesystem quotas.
OS/filesystem quotas. If a size limit is specified then Tahoe will do a "du"
at startup (traversing all the storage and summing the sizes of the files),
which can take a long time if there are a lot of shares stored.
private/root_dir.cap (optional): The command-line tools will read a directory
cap out of this file and use it, if you don't specify a '--dir-cap' option or

View File

@ -700,10 +700,12 @@ class StorageServer(service.MultiService, Referenceable):
self._active_writers = weakref.WeakKeyDictionary()
lp = log.msg("StorageServer created, now measuring space..",
facility="tahoe.storage")
self.measure_size()
log.msg(format="space measurement done, consumed=%(consumed)d bytes",
consumed=self.consumed,
parent=lp, facility="tahoe.storage")
self.consumed = None
if self.sizelimit:
self.consumed = fileutil.du(self.sharedir)
log.msg(format="space measurement done, consumed=%(consumed)d bytes",
consumed=self.consumed,
parent=lp, facility="tahoe.storage")
def log(self, *args, **kwargs):
if "facility" not in kwargs:
@ -730,11 +732,8 @@ class StorageServer(service.MultiService, Referenceable):
'storage_server.allocated': self.allocated_size(),
}
def measure_size(self):
self.consumed = fileutil.du(self.sharedir)
def allocated_size(self):
space = self.consumed
space = self.consumed or 0
for bw in self._active_writers:
space += bw.allocated_size()
return space
@ -866,14 +865,16 @@ class StorageServer(service.MultiService, Referenceable):
total_space_freed += filelen
if not remaining_files:
fileutil.rm_dir(storagedir)
self.consumed -= total_space_freed
if self.consumed is not None:
self.consumed -= total_space_freed
if self.stats_provider:
self.stats_provider.count('storage_server.bytes_freed', total_space_freed)
if not found_buckets:
raise IndexError("no such lease to cancel")
def bucket_writer_closed(self, bw, consumed_size):
self.consumed += consumed_size
if self.consumed is not None:
self.consumed += consumed_size
if self.stats_provider:
self.stats_provider.count('storage_server.bytes_added', consumed_size)
del self._active_writers[bw]