From: Zooko O'Whielacronx Date: Tue, 8 Apr 2008 18:36:56 +0000 (-0700) Subject: don't do a du on startup if there is no size limit configured X-Git-Url: https://git.rkrishnan.org/junkers?a=commitdiff_plain;h=8783eabf5a45a893682dae0aa21a1fe26c9be82f;p=tahoe-lafs%2Ftahoe-lafs.git 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. --- diff --git a/docs/configuration.txt b/docs/configuration.txt index 233392c9..e17d4b3c 100644 --- a/docs/configuration.txt +++ b/docs/configuration.txt @@ -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 diff --git a/src/allmydata/storage.py b/src/allmydata/storage.py index 23fea4dd..acbe1b72 100644 --- a/src/allmydata/storage.py +++ b/src/allmydata/storage.py @@ -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]