Merge "Maintain the fuse buffer pool keyed by inode instead of threadId." into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
b52a288e0c
@@ -210,7 +210,7 @@ public class FuseAppLoop implements Handler.Callback {
|
|||||||
if (mInstance != 0) {
|
if (mInstance != 0) {
|
||||||
native_replySimple(mInstance, unique, FUSE_OK);
|
native_replySimple(mInstance, unique, FUSE_OK);
|
||||||
}
|
}
|
||||||
mBytesMap.stopUsing(entry.getThreadId());
|
mBytesMap.stopUsing(inode);
|
||||||
recycleLocked(args);
|
recycleLocked(args);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -270,7 +270,7 @@ public class FuseAppLoop implements Handler.Callback {
|
|||||||
if (mInstance != 0) {
|
if (mInstance != 0) {
|
||||||
native_replyOpen(mInstance, unique, /* fh */ inode);
|
native_replyOpen(mInstance, unique, /* fh */ inode);
|
||||||
entry.opened = true;
|
entry.opened = true;
|
||||||
return mBytesMap.startUsing(entry.getThreadId());
|
return mBytesMap.startUsing(inode);
|
||||||
}
|
}
|
||||||
} catch (ErrnoException error) {
|
} catch (ErrnoException error) {
|
||||||
replySimpleLocked(unique, getError(error));
|
replySimpleLocked(unique, getError(error));
|
||||||
@@ -354,27 +354,27 @@ public class FuseAppLoop implements Handler.Callback {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map between Thread ID and byte buffer.
|
* Map between inode and byte buffer.
|
||||||
*/
|
*/
|
||||||
private static class BytesMap {
|
private static class BytesMap {
|
||||||
final Map<Long, BytesMapEntry> mEntries = new HashMap<>();
|
final Map<Long, BytesMapEntry> mEntries = new HashMap<>();
|
||||||
|
|
||||||
byte[] startUsing(long threadId) {
|
byte[] startUsing(long inode) {
|
||||||
BytesMapEntry entry = mEntries.get(threadId);
|
BytesMapEntry entry = mEntries.get(inode);
|
||||||
if (entry == null) {
|
if (entry == null) {
|
||||||
entry = new BytesMapEntry();
|
entry = new BytesMapEntry();
|
||||||
mEntries.put(threadId, entry);
|
mEntries.put(inode, entry);
|
||||||
}
|
}
|
||||||
entry.counter++;
|
entry.counter++;
|
||||||
return entry.bytes;
|
return entry.bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
void stopUsing(long threadId) {
|
void stopUsing(long inode) {
|
||||||
final BytesMapEntry entry = mEntries.get(threadId);
|
final BytesMapEntry entry = mEntries.get(inode);
|
||||||
Objects.requireNonNull(entry);
|
Objects.requireNonNull(entry);
|
||||||
entry.counter--;
|
entry.counter--;
|
||||||
if (entry.counter <= 0) {
|
if (entry.counter <= 0) {
|
||||||
mEntries.remove(threadId);
|
mEntries.remove(inode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user