if obj.in_use():
_logger.debug("InodeCache cannot clear inode %i, in use", obj.inode)
return
- if obj.has_ref(only_children=True):
+ if obj.has_ref(True):
obj.kernel_invalidate()
_logger.debug("InodeCache sent kernel invalidate inode %i", obj.inode)
return
self.ref_count -= n
return self.ref_count
- def has_ref(self, only_children=False):
- return self.ref_count > 0
+ def has_ref(self, only_children):
+ """Determine if there are any kernel references to this
+ object or its children.
+
+ If only_children is True, ignore refcount of self and only consider
+ children.
+ """
+ if only_children:
+ return False
+ else:
+ return self.ref_count > 0
def objsize(self):
return 0
return True
return False
- def has_ref(self, only_children=False):
- if not only_children and super(Directory, self).has_ref():
+ def has_ref(self, only_children):
+ if super(Directory, self).has_ref(only_children):
return True
for v in self._entries.itervalues():
- if v.has_ref():
+ if v.has_ref(False):
return True
return False
from .integration_test import IntegrationTest
from .mount_test_base import MountTestBase
-class TmpCollectionTest(IntegrationTest):
+class CacheTest(IntegrationTest):
mnt_args = ["--by-id", "--directory-cache=0"]
@IntegrationTest.mount(argv=mnt_args)
cache.touch(ent3)
self.assertFalse(ent1.clear.called)
self.assertFalse(ent3.clear.called)
+ self.assertTrue(ent3.kernel_invalidate.called)
self.assertEqual(1100, cache.total())
# ent1 still in use, ent3 doesn't have ref,