Skip to content

Commit

Permalink
file: Add RCU implementation of the file descriptor table
Browse files Browse the repository at this point in the history
Signed-off-by: Pedro Falcato <[email protected]>
  • Loading branch information
heatd committed Aug 15, 2023
1 parent d36171f commit 1642410
Show file tree
Hide file tree
Showing 3 changed files with 238 additions and 112 deletions.
22 changes: 15 additions & 7 deletions kernel/include/onyx/ioctx.h
Original file line number Diff line number Diff line change
@@ -1,30 +1,38 @@
/*
* Copyright (c) 2016, 2017 Pedro Falcato
* Copyright (c) 2016 - 2023 Pedro Falcato
* This file is part of Onyx, and is released under the terms of the MIT License
* check LICENSE at the root directory for more information
*
* SPDX-License-Identifier: MIT
*/
#ifndef _IOCTX_H
#define _IOCTX_H

#include <onyx/types.h>

#include <onyx/file.h>
#include <onyx/mutex.h>
#include <onyx/rcupdate.h>
#include <onyx/types.h>
#include <onyx/vfs.h>

#define FDS_PER_LONG (sizeof(unsigned long) * 8)
#define FILE_DESCRIPTOR_GROW_NR (FDS_PER_LONG)

struct fd_table
{
struct file **file_desc{nullptr};
unsigned int file_desc_entries{};
unsigned long *cloexec_fds{};
unsigned long *open_fds{};
struct rcu_head rcuhead;
};

struct ioctx
{
/* Current working directory */
spinlock cwd_lock{};
file *cwd{};
spinlock fdlock{};
struct file **file_desc{};
unsigned int file_desc_entries{};
unsigned long *cloexec_fds{};
unsigned long *open_fds{};
fd_table __rcu *table{};
mode_t umask{};
};

Expand Down
6 changes: 5 additions & 1 deletion kernel/include/onyx/vfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include <onyx/mm/vm_object.h>
#include <onyx/object.h>
#include <onyx/rcupdate.h>
#include <onyx/rwlock.h>
#include <onyx/superblock.h>
#include <onyx/vm.h>
Expand Down Expand Up @@ -152,7 +153,10 @@ struct file
struct inode *f_ino;
unsigned int f_flags;
struct dentry *f_dentry;
void *private_data;
union {
void *private_data;
struct rcu_head rcuhead;
};
};

int inode_create_vmo(struct inode *ino);
Expand Down
Loading

0 comments on commit 1642410

Please sign in to comment.