don't do a du on startup if there is no size limit configured
authorZooko O'Whielacronx <zooko@zooko.com>
Tue, 8 Apr 2008 18:36:56 +0000 (11:36 -0700)
committerZooko O'Whielacronx <zooko@zooko.com>
Tue, 8 Apr 2008 18:36:56 +0000 (11:36 -0700)
This also turns off the production of the "space measurement done" log message, if there is no size limit configured.

docs/configuration.txt
src/allmydata/storage.py

index 233392c9872235a1a776502cd9c3db68a1f3200b..e17d4b3c9dcb720982f70c6db6fa989b299bd469 100644 (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
index 23fea4dd9a47213062dfe3e2887a7e67358dd778..acbe1b7214fb3485d5ec418ac830ec79cb9563ba 100644 (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]