kernel/fs: Make io_context rw_lock'ed.
Applications that don't call open() or like functions too often,
and call many FD-related methods across multiple threads at once
(like "git status") now don't wait on the context lock as much.
("git status" performance isn't much improved because threads just
hit the "unused vnodes" lock instead.)
This commit is contained in:
@@ -76,8 +76,8 @@ extern struct file_descriptor *alloc_fd(void);
|
||||
extern int new_fd_etc(struct io_context *, struct file_descriptor *,
|
||||
int firstIndex);
|
||||
extern int new_fd(struct io_context *, struct file_descriptor *);
|
||||
extern struct file_descriptor *get_fd(struct io_context *, int);
|
||||
extern struct file_descriptor *get_open_fd(struct io_context *, int);
|
||||
extern struct file_descriptor *get_fd(const struct io_context *, int);
|
||||
extern struct file_descriptor *get_open_fd(const struct io_context *, int);
|
||||
extern void close_fd(struct io_context *context,
|
||||
struct file_descriptor *descriptor);
|
||||
extern status_t close_fd_index(struct io_context *context, int fd);
|
||||
@@ -91,7 +91,7 @@ extern bool fd_is_valid(int fd, bool kernel);
|
||||
extern struct vnode *fd_vnode(struct file_descriptor *descriptor);
|
||||
extern bool fd_is_file(struct file_descriptor* descriptor);
|
||||
|
||||
extern bool fd_close_on_exec(struct io_context *context, int fd);
|
||||
extern bool fd_close_on_exec(const struct io_context *context, int fd);
|
||||
extern void fd_set_close_on_exec(struct io_context *context, int fd,
|
||||
bool closeFD);
|
||||
|
||||
|
||||
@@ -47,8 +47,9 @@ struct vnode;
|
||||
/** The I/O context of a process/team, holds the fd array among others */
|
||||
typedef struct io_context {
|
||||
struct vnode *root;
|
||||
|
||||
mutable rw_lock lock;
|
||||
struct vnode *cwd;
|
||||
mutex io_mutex;
|
||||
int32 ref_count;
|
||||
uint32 table_size;
|
||||
uint32 num_used_fds;
|
||||
@@ -70,7 +71,7 @@ status_t vfs_init(struct kernel_args *args);
|
||||
status_t vfs_bootstrap_file_systems(void);
|
||||
void vfs_mount_boot_file_system(struct kernel_args *args);
|
||||
void vfs_exec_io_context(io_context *context);
|
||||
io_context* vfs_new_io_context(io_context* parentContext,
|
||||
io_context* vfs_new_io_context(const io_context *parentContext,
|
||||
bool purgeCloseOnExec);
|
||||
void vfs_get_io_context(io_context *context);
|
||||
void vfs_put_io_context(io_context *context);
|
||||
|
||||
Reference in New Issue
Block a user