summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Zim <zezeozue@google.com> 2021-10-13 19:43:37 +0100
committer Zim <zezeozue@google.com> 2021-10-13 19:46:33 +0100
commitd37b97788462188f194e2dc98a0356fc8cb6c64a (patch)
tree801c44cefd6e31f95e8754a961d33bc30ffd0e13
parent22448241a8278c4005b871578cbe0c64c892f1e2 (diff)
Remove redundant FUSE node#should_invalidate field
Since I15a3b84535521cf61445856f5de5e12a1a1d4fbd, we no longer needed the field, but it wasn't removed. Test: atest fuse_node_test Bug: 183762925 Change-Id: I5c0a4f2bfade889970171cded61b5039bbfc391c
-rwxr-xr-xjni/FuseDaemon.cpp8
-rw-r--r--jni/node-inl.h26
-rw-r--r--jni/node_test.cpp12
3 files changed, 19 insertions, 27 deletions
diff --git a/jni/FuseDaemon.cpp b/jni/FuseDaemon.cpp
index b9eda64fc..5bacba14b 100755
--- a/jni/FuseDaemon.cpp
+++ b/jni/FuseDaemon.cpp
@@ -549,12 +549,16 @@ static node* make_node_entry(fuse_req_t req, node* parent, const string& name, c
const int transforms = file_lookup_result->transforms;
const int transforms_reason = file_lookup_result->transforms_reason;
const string& io_path = file_lookup_result->io_path;
+ if (transforms) {
+ // If the node requires transforms, we MUST never cache it in the VFS
+ CHECK(should_invalidate);
+ }
node = parent->LookupChildByName(name, true /* acquire */, transforms);
if (!node) {
ino_t ino = e->attr.st_ino;
- node = ::node::Create(parent, name, io_path, should_invalidate, transforms_complete,
- transforms, transforms_reason, &fuse->lock, ino, &fuse->tracker);
+ node = ::node::Create(parent, name, io_path, transforms_complete, transforms,
+ transforms_reason, &fuse->lock, ino, &fuse->tracker);
} else if (!mediaprovider::fuse::containsMount(path)) {
// Only invalidate a path if it does not contain mount and |name| != node->GetName.
// Invalidate both names to ensure there's no dentry left in the kernel after the following
diff --git a/jni/node-inl.h b/jni/node-inl.h
index bb1b01331..01d6cbabb 100644
--- a/jni/node-inl.h
+++ b/jni/node-inl.h
@@ -127,15 +127,15 @@ class node {
public:
// Creates a new node with the specified parent, name and lock.
static node* Create(node* parent, const std::string& name, const std::string& io_path,
- bool should_invalidate, bool transforms_complete, const int transforms,
+ const bool transforms_complete, const int transforms,
const int transforms_reason, std::recursive_mutex* lock, ino_t ino,
NodeTracker* tracker) {
// Place the entire constructor under a critical section to make sure
// node creation, tracking (if enabled) and the addition to a parent are
// atomic.
std::lock_guard<std::recursive_mutex> guard(*lock);
- return new node(parent, name, io_path, should_invalidate, transforms_complete, transforms,
- transforms_reason, lock, ino, tracker);
+ return new node(parent, name, io_path, transforms_complete, transforms, transforms_reason,
+ lock, ino, tracker);
}
// Creates a new root node. Root nodes have no parents by definition
@@ -143,9 +143,8 @@ class node {
static node* CreateRoot(const std::string& path, std::recursive_mutex* lock, ino_t ino,
NodeTracker* tracker) {
std::lock_guard<std::recursive_mutex> guard(*lock);
- node* root = new node(nullptr, path, path, false /* should_invalidate */,
- true /* transforms_complete */, 0 /* transforms */,
- 0 /* transforms_reason */, lock, ino, tracker);
+ node* root = new node(nullptr, path, path, true /* transforms_complete */,
+ 0 /* transforms */, 0 /* transforms_reason */, lock, ino, tracker);
// The root always has one extra reference to avoid it being
// accidentally collected.
@@ -319,11 +318,6 @@ class node {
return false;
}
- bool ShouldInvalidate() const {
- std::lock_guard<std::recursive_mutex> guard(*lock_);
- return should_invalidate_;
- }
-
void SetName(std::string name) {
std::lock_guard<std::recursive_mutex> guard(*lock_);
name_ = std::move(name);
@@ -366,8 +360,8 @@ class node {
private:
node(node* parent, const std::string& name, const std::string& io_path,
- const bool should_invalidate, const bool transforms_complete, const int transforms,
- const int transforms_reason, std::recursive_mutex* lock, ino_t ino, NodeTracker* tracker)
+ const bool transforms_complete, const int transforms, const int transforms_reason,
+ std::recursive_mutex* lock, ino_t ino, NodeTracker* tracker)
: name_(name),
io_path_(io_path),
transforms_complete_(transforms_complete),
@@ -376,7 +370,6 @@ class node {
refcount_(0),
parent_(nullptr),
has_redacted_cache_(false),
- should_invalidate_(should_invalidate),
deleted_(false),
lock_(lock),
ino_(ino),
@@ -388,10 +381,6 @@ class node {
if (parent != nullptr) {
AddToParent(parent);
}
- // If the node requires transforms, we MUST never cache it in the VFS
- if (transforms) {
- CHECK(should_invalidate_);
- }
}
// Acquires a reference to a node. This maps to the "lookup count" specified
@@ -530,7 +519,6 @@ class node {
// List of directory handles associated with this node. Guarded by |lock_|.
std::vector<std::unique_ptr<dirhandle>> dirhandles_;
bool has_redacted_cache_;
- bool should_invalidate_;
bool deleted_;
std::recursive_mutex* lock_;
// Inode number of the file represented by this node.
diff --git a/jni/node_test.cpp b/jni/node_test.cpp
index e6870f8b8..d0c86dfbe 100644
--- a/jni/node_test.cpp
+++ b/jni/node_test.cpp
@@ -33,7 +33,7 @@ class NodeTest : public ::testing::Test {
unique_node_ptr CreateNode(node* parent, const std::string& path, const int transforms = 0) {
return unique_node_ptr(
- node::Create(parent, path, "", true, true, transforms, 0, &lock_, 0, &tracker_),
+ node::Create(parent, path, "", true, transforms, 0, &lock_, 0, &tracker_),
&NodeTest::destroy);
}
@@ -68,7 +68,7 @@ TEST_F(NodeTest, TestCreate_withParent) {
}
TEST_F(NodeTest, TestRelease) {
- node* node = node::Create(nullptr, "/path", "", false, true, 0, 0, &lock_, 0, &tracker_);
+ node* node = node::Create(nullptr, "/path", "", true, 0, 0, &lock_, 0, &tracker_);
acquire(node);
acquire(node);
ASSERT_EQ(3, GetRefCount(node));
@@ -278,10 +278,10 @@ TEST_F(NodeTest, DeleteTree) {
unique_node_ptr parent = CreateNode(nullptr, "/path");
// This is the tree that we intend to delete.
- node* child = node::Create(parent.get(), "subdir", "", false, true, 0, 0, &lock_, 0, &tracker_);
- node::Create(child, "s1", "", false, true, 0, 0, &lock_, 0, &tracker_);
- node* subchild2 = node::Create(child, "s2", "", false, true, 0, 0, &lock_, 0, &tracker_);
- node::Create(subchild2, "sc2", "", false, true, 0, 0, &lock_, 0, &tracker_);
+ node* child = node::Create(parent.get(), "subdir", "", true, 0, 0, &lock_, 0, &tracker_);
+ node::Create(child, "s1", "", true, 0, 0, &lock_, 0, &tracker_);
+ node* subchild2 = node::Create(child, "s2", "", true, 0, 0, &lock_, 0, &tracker_);
+ node::Create(subchild2, "sc2", "", true, 0, 0, &lock_, 0, &tracker_);
ASSERT_EQ(child, parent->LookupChildByName("subdir", false /* acquire */));
node::DeleteTree(child);