[ARVADOS] created: 3a391d6693d89c0cfe5862227fcc9a0568bc775d

Git user git at public.curoverse.com
Wed Sep 21 11:29:14 EDT 2016


        at  3a391d6693d89c0cfe5862227fcc9a0568bc775d (commit)


commit 3a391d6693d89c0cfe5862227fcc9a0568bc775d
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Wed Sep 21 11:13:32 2016 -0400

    10117: Consider both use_count and ref_count and check subdirectories to determine if it is safe to evict directory contents from cache.

diff --git a/services/fuse/arvados_fuse/__init__.py b/services/fuse/arvados_fuse/__init__.py
index 6ac51f4..ac6e236 100644
--- a/services/fuse/arvados_fuse/__init__.py
+++ b/services/fuse/arvados_fuse/__init__.py
@@ -143,8 +143,8 @@ class InodeCache(object):
         return self._total
 
     def _remove(self, obj, clear):
-        if clear and not obj.clear():
-            _logger.debug("InodeCache could not clear %i in_use %s", obj.inode, obj.in_use())
+        if clear and not obj.can_clear():
+            _logger.debug("InodeCache cannot clear %i", obj.inode)
             return False
         self._total -= obj.cache_size
         del self._entries[obj.cache_priority]
diff --git a/services/fuse/arvados_fuse/fresh.py b/services/fuse/arvados_fuse/fresh.py
index 2075741..635acea 100644
--- a/services/fuse/arvados_fuse/fresh.py
+++ b/services/fuse/arvados_fuse/fresh.py
@@ -92,7 +92,7 @@ class FreshBase(object):
     def persisted(self):
         return False
 
-    def clear(self, force=False):
+    def clear(self):
         pass
 
     def in_use(self):
@@ -112,6 +112,9 @@ class FreshBase(object):
         self.ref_count -= n
         return self.ref_count
 
+    def can_clear(self):
+        return not (self.use_count > 0 or self.ref_count > 0)
+
     def objsize(self):
         return 0
 
diff --git a/services/fuse/arvados_fuse/fusedir.py b/services/fuse/arvados_fuse/fusedir.py
index 3f2bcd5..aa9c4fd 100644
--- a/services/fuse/arvados_fuse/fusedir.py
+++ b/services/fuse/arvados_fuse/fusedir.py
@@ -156,24 +156,25 @@ class Directory(FreshBase):
 
         self.fresh()
 
-    def clear(self, force=False):
-        """Delete all entries"""
-
-        if not self.in_use() or force:
-            oldentries = self._entries
-            self._entries = {}
-            for n in oldentries:
-                if not oldentries[n].clear(force):
-                    self._entries = oldentries
-                    return False
-            for n in oldentries:
-                self.inodes.invalidate_entry(self.inode, n.encode(self.inodes.encoding))
-                self.inodes.del_entry(oldentries[n])
-            self.inodes.invalidate_inode(self.inode)
-            self.invalidate()
-            return True
-        else:
+    def can_clear(self):
+        if not super(Directory, self).can_clear():
             return False
+        for v in self._entries.itervalues():
+            if not v.can_clear():
+                return False
+        return True
+
+    def clear(self):
+        """Delete all entries"""
+        oldentries = self._entries
+        self._entries = {}
+        for n in oldentries:
+            oldentries[n].clear()
+        for n in oldentries:
+            self.inodes.invalidate_entry(self.inode, n.encode(self.inodes.encoding))
+            self.inodes.del_entry(oldentries[n])
+        self.inodes.invalidate_inode(self.inode)
+        self.invalidate()
 
     def mtime(self):
         return self._mtime
@@ -320,8 +321,8 @@ class CollectionDirectoryBase(Directory):
         self.flush()
         src.flush()
 
-    def clear(self, force=False):
-        r = super(CollectionDirectoryBase, self).clear(force)
+    def clear(self):
+        r = super(CollectionDirectoryBase, self).clear()
         self.collection = None
         return r
 
@@ -375,7 +376,7 @@ class CollectionDirectory(CollectionDirectoryBase):
 
     def new_collection(self, new_collection_record, coll_reader):
         if self.inode:
-            self.clear(force=True)
+            self.clear()
 
         self.collection_record = new_collection_record
 
@@ -407,7 +408,7 @@ class CollectionDirectory(CollectionDirectoryBase):
                     if not self.stale():
                         return
 
-                    _logger.debug("Updating %s", to_record_version)
+                    _logger.debug("Updating collection %s inode %s to record version %s", self.collection_locator, self.inode, to_record_version)
                     if self.collection is not None:
                         if self.collection.known_past_version(to_record_version):
                             _logger.debug("%s already processed %s", self.collection_locator, to_record_version)
@@ -640,7 +641,7 @@ will appear if it exists.
         else:
             raise KeyError("No collection with id " + item)
 
-    def clear(self, force=False):
+    def clear(self):
         pass
 
     def want_event_subscribe(self):
diff --git a/services/fuse/arvados_fuse/fusefile.py b/services/fuse/arvados_fuse/fusefile.py
index 3f0e493..81fcd40 100644
--- a/services/fuse/arvados_fuse/fusefile.py
+++ b/services/fuse/arvados_fuse/fusefile.py
@@ -29,8 +29,8 @@ class File(FreshBase):
     def mtime(self):
         return self._mtime
 
-    def clear(self, force=False):
-        return True
+    def clear(self):
+        pass
 
     def writable(self):
         return False

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list