Skip to content

Commit

Permalink
refactor(coroutine): reimplemented coroutine
Browse files Browse the repository at this point in the history
1. remove implementation of coroutine from c
2. reimplement taskq using dynamic thread strategy

Signed-off-by: sundengyu <[email protected]>
  • Loading branch information
sundengyu authored and hpingfs committed Sep 25, 2024
1 parent 0db8684 commit 0d4a97f
Show file tree
Hide file tree
Showing 23 changed files with 410 additions and 2,695 deletions.
5 changes: 1 addition & 4 deletions include/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ COMMON_H = \
zfs_fletcher.h \
zfs_namecheck.h \
zfs_prop.h \
coroutine.h \
timer_thread.h \
coroutine_impl.h \
libcontext.h
sync_ops.h

USER_H = \
libnvpair.h \
Expand Down
53 changes: 0 additions & 53 deletions include/coroutine.h

This file was deleted.

124 changes: 0 additions & 124 deletions include/coroutine_impl.h

This file was deleted.

87 changes: 0 additions & 87 deletions include/libcontext.h

This file was deleted.

24 changes: 6 additions & 18 deletions include/libuzfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#ifndef _LIBUZFS_H
#define _LIBUZFS_H

#include "coroutine.h"
#include <sync_ops.h>
#include "sys/stdtypes.h"
#include "sys/time.h"
#include <libnvpair.h>
Expand Down Expand Up @@ -91,28 +91,16 @@ typedef int (*filldir_t)(void *, const char *, int, loff_t, u64, unsigned);

#define UZFS_XATTR_MAXVALUELEN (8192)

extern uzfs_coroutine_t *libuzfs_new_coroutine(void (*func)(void *), void *arg,
uint64_t task_id, boolean_t foreground, void (*record_backtrace)(uint64_t),
void (*wake)(void *), void *wake_arg);
extern void libuzfs_destroy_coroutine(uzfs_coroutine_t *coroutine);

typedef enum run_state {
RUN_STATE_PENDING = 0,
RUN_STATE_YIELDED = 1,
RUN_STATE_DONE = 2,
} run_state_t;

extern run_state_t libuzfs_run_coroutine(uzfs_coroutine_t *coroutine);
extern void libuzfs_coroutine_yield(void);
extern void *libuzfs_current_coroutine_arg(void);
extern void libuzfs_coroutine_exit(void);
extern void libuzfs_set_sync_ops(const coroutine_ops_t *,
const co_mutex_ops_t *, const co_cond_ops_t *,
const co_rwlock_ops_t *, const aio_ops_t *,
const thread_ops_t *, const taskq_ops_t *);

// only have effect when in debug binary
extern void libuzfs_enable_debug_msg(void);
extern void libuzfs_disable_debug_msg(void);

extern void libuzfs_init(thread_create_func create, thread_exit_func exit,
thread_join_func join, backtrace_func bt_func);
extern void libuzfs_init(void);
extern void libuzfs_fini(void);
extern void libuzfs_set_zpool_cache_path(const char *zpool_cache);

Expand Down
Loading

0 comments on commit 0d4a97f

Please sign in to comment.