Skip to content

fix: dist chmod #314

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 26, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ private static void update_subtree(Set<INode> inodes) {
}

public static final void invalidateAndWriteBackDB(String parent, String name) {
LOG.info("invalidate dirty data under " + parent + " " + name);
long dirtyCount = 100000;
String dirtyCountStr = System.getenv("FILESCALE_DIRTY_OBJECT_NUM");
if (dirtyCountStr != null) {
Expand All @@ -437,25 +438,23 @@ public static final void invalidateAndWriteBackDB(String parent, String name) {
}
}
inodes.add(child);
count++;
// invalidate inode
INodeKeyedObjects.getCache().invalidate(child.getPath());
if (inodes.size() >= 5120) {
if (count < dirtyCount && inodes.size() >= 5120) {
// write back to db
count += inodes.size();
update_subtree(inodes);
}
if (count >= dirtyCount) return;
}
}
if (inodes.size() > 0) {
if (count < dirtyCount && inodes.size() > 0) {
// write back to db
update_subtree(inodes);
}
}

private final void remoteChmod(Set<Pair<String, String>> mpoints) {
// 1. invalidate cache and write back dirty data
invalidateAndWriteBackDB(getParentName(), getLocalName());
List<String> parents = new ArrayList<>();
List<String> names = new ArrayList<>();
for (Pair<String, String> pair : mpoints) {
Expand All @@ -464,13 +463,17 @@ private final void remoteChmod(Set<Pair<String, String>> mpoints) {
String name = file.getName();
String url = pair.getRight();
try {
MountPoint.Builder b = MountPoint.newBuilder().setParent(parent).setName(name);
byte[] data = b.build().toByteArray();

FSEditLogProtocol proxy = (FSEditLogProtocol) RPC.getProxy(
FSEditLogProtocol.class, FSEditLogProtocol.versionID,
new InetSocketAddress(url, 10087), new Configuration());
proxy.invalidateAndWriteBackDB(data);
if (url == "localhost") {
invalidateAndWriteBackDB(parent, name);
} else {
MountPoint.Builder b = MountPoint.newBuilder().setParent(parent).setName(name);
byte[] data = b.build().toByteArray();

FSEditLogProtocol proxy = (FSEditLogProtocol) RPC.getProxy(
FSEditLogProtocol.class, FSEditLogProtocol.versionID,
new InetSocketAddress(url, 10087), new Configuration());
proxy.invalidateAndWriteBackDB(data);
}
} catch (Exception e) {
e.printStackTrace();
}
Expand All @@ -480,6 +483,7 @@ private final void remoteChmod(Set<Pair<String, String>> mpoints) {
}

// 2. execute distributed txn
LOG.info("Execute dist txn for chmod");
DatabaseINode.setPermissions(parents, names, this.permission);
}

Expand Down