Skip to content

Commit 09e8063

Browse files
committed
core: PseudoFS: Properly resolve the inner root inode
When we try to resolve the inner FS's root inode given a pseudo inode in PseudoFS, we can directly return the inner FS's root inode as returned by VirtualFileSystem#getRootInode(), which is most likely cached, instead of creating new Inode instances all over again. This further reduces the number of Inode allocations. Also fail with BadHandleException for any other pseudo inode because they will by definition be invalid in the underlying file system. Related: #149 Signed-off-by: Christian Kohlschütter <[email protected]>
1 parent 3ad63db commit 09e8063

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

core/src/main/java/org/dcache/nfs/vfs/PseudoFs.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -746,8 +746,17 @@ private boolean inheritUidGid(Inode inode) {
746746
*
747747
* @param inode The {@link Inode} as passed from and to the NFS client.
748748
* @return The {@link Inode} as passed from {@link PseudoFs} to the underlying {@link VirtualFileSystem}.
749+
* @throws IOException on error.
749750
*/
750-
private Inode innerInode(Inode inode) {
751+
private Inode innerInode(Inode inode) throws IOException {
752+
if (inode.isPseudoInode()) {
753+
Inode innerRootInode = _inner.getRootInode();
754+
if (innerRootInode.getFileIdKey().equals(inode.getFileIdKey())) {
755+
return innerRootInode;
756+
} else {
757+
throw new BadHandleException();
758+
}
759+
}
751760
return Inode.innerInode(inode);
752761
}
753762
}

0 commit comments

Comments
 (0)