Skip to content

Commit

Permalink
lxfs: ipc performance fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jewelcodes committed Nov 30, 2024
1 parent d0c77b7 commit 96b3f3e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 31 deletions.
32 changes: 16 additions & 16 deletions fs/lxfs/src/dirent.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ void lxfsOpendir(OpendirCommand *ocmd) {
Mountpoint *mp = findMP(ocmd->device);
if(!mp) {
ocmd->header.header.status = -EIO; // device doesn't exist
luxSendDependency(ocmd);
luxSendKernel(ocmd);
return;
}

LXFSDirectoryEntry entry;
if(!lxfsFind(&entry, mp, ocmd->path)) {
ocmd->header.header.status = -ENOENT; // file doesn't exist
luxSendDependency(ocmd);
luxSendKernel(ocmd);
return;
}

// ensure this is a directory
if(((entry.flags >> LXFS_DIR_TYPE_SHIFT) & LXFS_DIR_TYPE_MASK) != LXFS_DIR_TYPE_DIR) {
ocmd->header.header.status = -ENOTDIR;
luxSendDependency(ocmd);
luxSendKernel(ocmd);
return;
}

Expand All @@ -50,7 +50,7 @@ void lxfsOpendir(OpendirCommand *ocmd) {
else if(!(entry.permissions & LXFS_PERMS_OTHER_X))
ocmd->header.header.status = -EPERM;

luxSendDependency(ocmd);
luxSendKernel(ocmd);
}

/* lxfsReaddir(): reads a directory entry from an lxfs volume
Expand All @@ -65,21 +65,21 @@ void lxfsReaddir(ReaddirCommand *rcmd) {
Mountpoint *mp = findMP(rcmd->device);
if(!mp) {
rcmd->header.header.status = -EIO; // device doesn't exist
luxSendDependency(rcmd);
luxSendKernel(rcmd);
return;
}

LXFSDirectoryEntry entry;
if(!lxfsFind(&entry, mp, rcmd->path)) {
rcmd->header.header.status = -ENOENT; // file doesn't exist
luxSendDependency(rcmd);
luxSendKernel(rcmd);
return;
}

// ensure this is a directory
if(((entry.flags >> LXFS_DIR_TYPE_SHIFT) & LXFS_DIR_TYPE_MASK) != LXFS_DIR_TYPE_DIR) {
rcmd->header.header.status = -ENOTDIR;
luxSendDependency(rcmd);
luxSendKernel(rcmd);
return;
}

Expand All @@ -90,15 +90,15 @@ void lxfsReaddir(ReaddirCommand *rcmd) {
rcmd->position++;
rcmd->end = 0;
rcmd->header.header.status = 0;
luxSendDependency(rcmd);
luxSendKernel(rcmd);
return;
} else if(rcmd->position == 1) {
strcpy(rcmd->entry.d_name, "..");
rcmd->entry.d_ino = 2;
rcmd->position++;
rcmd->end = 0;
rcmd->header.header.status = 0;
luxSendDependency(rcmd);
luxSendKernel(rcmd);
return;
}

Expand All @@ -109,15 +109,15 @@ void lxfsReaddir(ReaddirCommand *rcmd) {

if(lxfsReadBlock(mp, next, mp->dataBuffer)) {
rcmd->header.header.status = -EIO;
luxSendDependency(rcmd);
luxSendKernel(rcmd);
return;
}

while(dir->entrySize) {
next = lxfsReadNextBlock(mp, next, mp->dataBuffer);
if(!next) {
rcmd->header.header.status = -EIO;
luxSendDependency(rcmd);
luxSendKernel(rcmd);
return;
}

Expand All @@ -135,7 +135,7 @@ void lxfsReaddir(ReaddirCommand *rcmd) {
rcmd->position++;
rcmd->end = 0;
rcmd->header.header.status = 0;
luxSendDependency(rcmd);
luxSendKernel(rcmd);
return;
}

Expand All @@ -146,7 +146,7 @@ void lxfsReaddir(ReaddirCommand *rcmd) {
if(!oldSize) {
rcmd->header.header.status = 0;
rcmd->end = 1;
luxSendDependency(rcmd);
luxSendKernel(rcmd);
return;
}

Expand All @@ -162,15 +162,15 @@ void lxfsReaddir(ReaddirCommand *rcmd) {
if(!dir->entrySize) {
rcmd->header.header.status = 0;
rcmd->end = 1;
luxSendDependency(rcmd);
luxSendKernel(rcmd);
return;
}

// and read the next block
next = lxfsReadNextBlock(mp, next, mp->dataBuffer);
if(!next) {
rcmd->header.header.status = -EIO;
luxSendDependency(rcmd);
luxSendKernel(rcmd);
return;
}
}
Expand All @@ -179,6 +179,6 @@ void lxfsReaddir(ReaddirCommand *rcmd) {

rcmd->header.header.status = 0;
rcmd->end = 1;
luxSendDependency(rcmd);
luxSendKernel(rcmd);
return;
}
8 changes: 4 additions & 4 deletions fs/lxfs/src/open.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@ void lxfsOpen(OpenCommand *ocmd) {
Mountpoint *mp = findMP(ocmd->device);
if(!mp) {
ocmd->header.header.status = -EIO; // device doesn't exist
luxSendDependency(ocmd);
luxSendKernel(ocmd);
return;
}

LXFSDirectoryEntry entry;
if(!lxfsFind(&entry, mp, ocmd->path)) {
ocmd->header.header.status = -ENOENT; // file doesn't exist
luxSendDependency(ocmd);
luxSendKernel(ocmd);
return;
}

// ensure this is a file
if(((entry.flags >> LXFS_DIR_TYPE_SHIFT) & LXFS_DIR_TYPE_MASK) != LXFS_DIR_TYPE_FILE) {
ocmd->header.header.status = -EISDIR;
luxSendDependency(ocmd);
luxSendKernel(ocmd);
return;
}

Expand All @@ -57,5 +57,5 @@ void lxfsOpen(OpenCommand *ocmd) {
if((ocmd->flags & O_WRONLY) && !(entry.permissions & LXFS_PERMS_OTHER_W)) ocmd->header.header.status = -EACCES;
}

luxSendDependency(ocmd);
luxSendKernel(ocmd);
}
14 changes: 7 additions & 7 deletions fs/lxfs/src/read.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,23 @@ void lxfsRead(RWCommand *rcmd) {
Mountpoint *mp = findMP(rcmd->device);
if(!mp) {
rcmd->header.header.status = -EIO;
luxSendDependency(rcmd);
luxSendKernel(rcmd);
return;
}

// and the file entry
LXFSDirectoryEntry entry;
if(!lxfsFind(&entry, mp, rcmd->path)) {
rcmd->header.header.status = -ENOENT;
luxSendDependency(rcmd);
luxSendKernel(rcmd);
return;
}

// use the file entry to read metadata as well as find the first file block
uint64_t first = lxfsReadNextBlock(mp, entry.block, mp->meta);
if(!first) {
rcmd->header.header.status = -EIO;
luxSendDependency(rcmd);
luxSendKernel(rcmd);
return;
}

Expand All @@ -52,7 +52,7 @@ void lxfsRead(RWCommand *rcmd) {
// input validation
if(rcmd->position >= metadata->size) {
rcmd->header.header.status = -EOVERFLOW;
luxSendDependency(rcmd);
luxSendKernel(rcmd);
return;
}

Expand All @@ -65,7 +65,7 @@ void lxfsRead(RWCommand *rcmd) {
RWCommand *res = calloc(1, sizeof(RWCommand) + truelen);
if(!res) {
rcmd->header.header.status = -ENOMEM;
luxSendDependency(rcmd);
luxSendKernel(rcmd);
return;
}

Expand All @@ -83,7 +83,7 @@ void lxfsRead(RWCommand *rcmd) {
if(!block) {
free(res);
rcmd->header.header.status = -EIO;
luxSendDependency(rcmd);
luxSendKernel(rcmd);
return;
}

Expand Down Expand Up @@ -133,6 +133,6 @@ void lxfsRead(RWCommand *rcmd) {
res->header.header.status = -EIO;
}

luxSendDependency(res);
luxSendKernel(res);
free(res);
}
8 changes: 4 additions & 4 deletions fs/lxfs/src/stat.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,23 @@ void lxfsStat(StatCommand *cmd) {
Mountpoint *mp = findMP(cmd->source);
if(!mp) {
cmd->header.header.status = -EIO;
luxSendDependency(cmd);
luxSendKernel(cmd);
return;
}

// and the file entry
LXFSDirectoryEntry entry;
if(!lxfsFind(&entry, mp, cmd->path)) {
cmd->header.header.status = -ENOENT;
luxSendDependency(cmd);
luxSendKernel(cmd);
return;
}

// use the file entry to read metadata as well
uint64_t first = lxfsReadNextBlock(mp, entry.block, mp->meta);
if(!first) {
cmd->header.header.status = -EIO;
luxSendDependency(cmd);
luxSendKernel(cmd);
return;
}

Expand Down Expand Up @@ -84,5 +84,5 @@ void lxfsStat(StatCommand *cmd) {

// and we're done, relay the response
cmd->header.header.status = 0;
luxSendDependency(cmd);
luxSendKernel(cmd);
}

0 comments on commit 96b3f3e

Please sign in to comment.