From 903a3457da21ef6a8f169a8d71cb7021c5c50da1 Mon Sep 17 00:00:00 2001 From: Andrew Innes Date: Wed, 17 Aug 2022 12:59:59 +0800 Subject: [PATCH] Clean up source to get Linux builds working (#119) * Move perfmon functions to windows from zfs_ioctl.h to zfs_ioctl_os.c * remove static for zfs_dirty_data_sync_percent * uint64_t to ZFS_MODULE_ULONG * add ifdef _WIN32 to zvol.c * define posix_memalign_free for other os * add vdev_file_t for other os * remove duplicate check_file * Create build_for_wsl.yaml * move functions to zvol_os.c and add them to the header zvol_impl.h in answer to this discussion https://github.com/openzfsonwindows/openzfs/pull/119#discussion_r941958584 * Fix code formatting in reference to https://github.com/openzfsonwindows/openzfs/pull/119#discussion_r941959208 * revert the removal of static in dsl_pool.c * remove zfs_dirty_data_sync_percent in dsl_pool.h * make zvol_find_by_name not static * changed workflow name * cstyle zpool_vdev_os.c --- .github/workflows/build_for_wsl.yaml | 58 ++++++++++++++++++++++++++++ cmd/zpool/os/linux/zpool_vdev_os.c | 6 --- cmd/zpool/os/windows/zpool_vdev_os.c | 1 - include/sys/dsl_pool.h | 5 +-- include/sys/vdev_file.h | 5 +++ include/sys/zfs_ioctl.h | 49 ----------------------- include/sys/zvol_impl.h | 1 + lib/libspl/include/sys/types.h | 5 +++ module/os/windows/zfs/zfs_ioctl_os.c | 54 ++++++++++++++++++++++++++ module/os/windows/zfs/zvol_os.c | 34 ++++++++++++++++ module/zfs/dsl_pool.c | 4 +- module/zfs/zvol.c | 35 +---------------- 12 files changed, 162 insertions(+), 95 deletions(-) create mode 100644 .github/workflows/build_for_wsl.yaml diff --git a/.github/workflows/build_for_wsl.yaml b/.github/workflows/build_for_wsl.yaml new file mode 100644 index 000000000000..accb49254031 --- /dev/null +++ b/.github/workflows/build_for_wsl.yaml @@ -0,0 +1,58 @@ +name: build_for_wsl + +on: + push: + pull_request: + workflow_dispatch: + +jobs: + tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + ref: ${{ github.event.pull_request.head.sha }} + - name: Reclaim disk space + run: | + ${{ github.workspace }}/.github/workflows/scripts/reclaim_disk_space.sh + - name: Install dependencies + run: | + sudo apt-get update + xargs --arg-file=${{ github.workspace }}/.github/workflows/build-dependencies.txt sudo apt-get install -qq + sudo apt-get clean + - name: Autogen.sh + run: | + ./autogen.sh + - name: Configure + run: | + ./configure --enable-debug --enable-debuginfo --enable-asan --enable-ubsan + - name: Make + run: | + make -j16 --no-print-directory --silent pkg-utils pkg-kmod + #make -j$(nproc) --no-print-directory --silent pkg-utils pkg-kmod + - name: get files + run: ls -Rla + - name: Prepare artifacts + if: failure() + run: | + RESULTS_PATH=$(readlink -f /var/tmp/test_results/current) + sudo dmesg > $RESULTS_PATH/dmesg + sudo cp /var/log/syslog /var/tmp/dmesg-prerun $RESULTS_PATH/ + sudo chmod +r $RESULTS_PATH/* + # Replace ':' in dir names, actions/upload-artifact doesn't support it + for f in $(find /var/tmp/test_results -name '*:*'); do mv "$f" "${f//:/__}"; done + - uses: actions/upload-artifact@v2 + if: failure() + with: + name: Test logs Ubuntu-${{ matrix.os }} + path: | + /var/tmp/test_results/* + !/var/tmp/test_results/current + if-no-files-found: ignore + + - uses: actions/upload-artifact@v2 + with: + name: build result + path: | + *.deb + *.rpm diff --git a/cmd/zpool/os/linux/zpool_vdev_os.c b/cmd/zpool/os/linux/zpool_vdev_os.c index 5e8fd64b00f8..7f4486e062fe 100644 --- a/cmd/zpool/os/linux/zpool_vdev_os.c +++ b/cmd/zpool/os/linux/zpool_vdev_os.c @@ -416,9 +416,3 @@ check_file(const char *file, boolean_t force, boolean_t isspare) { return (check_file_generic(file, force, isspare)); } - -int -check_file(const char *file, boolean_t force, boolean_t isspare) -{ - return (check_file_generic(file, force, isspare)); -} diff --git a/cmd/zpool/os/windows/zpool_vdev_os.c b/cmd/zpool/os/windows/zpool_vdev_os.c index b353a0850a8a..079b269abd7a 100644 --- a/cmd/zpool/os/windows/zpool_vdev_os.c +++ b/cmd/zpool/os/windows/zpool_vdev_os.c @@ -170,4 +170,3 @@ void after_zpool_upgrade(zpool_handle_t *zhp) { } - diff --git a/include/sys/dsl_pool.h b/include/sys/dsl_pool.h index 97ffa9a39924..799550b23a4c 100644 --- a/include/sys/dsl_pool.h +++ b/include/sys/dsl_pool.h @@ -57,10 +57,9 @@ struct dsl_scan; struct dsl_crypto_params; struct dsl_deadlist; -extern uint64_t zfs_dirty_data_max; -extern uint64_t zfs_dirty_data_max_max; +extern ZFS_MODULE_ULONG zfs_dirty_data_max; +extern ZFS_MODULE_ULONG zfs_dirty_data_max_max; extern ZFS_MODULE_ULONG zfs_wrlog_data_max; -extern int zfs_dirty_data_sync_percent; extern int zfs_dirty_data_max_percent; extern int zfs_dirty_data_max_max_percent; extern int zfs_delay_min_dirty_percent; diff --git a/include/sys/vdev_file.h b/include/sys/vdev_file.h index b7decbfd700b..cab38b8a5bbf 100644 --- a/include/sys/vdev_file.h +++ b/include/sys/vdev_file.h @@ -35,6 +35,11 @@ typedef struct vdev_file { uint64_t vdev_win_offset; /* soft partition start */ uint64_t vdev_win_length; /* soft partition length */ } vdev_file_t; +#else +/* Grabbed from https://github.com/openzfs/zfs/blob/1d3ba0bf01020f5459b1c28db3979129088924c0/include/sys/vdev_file.h#L36 */ +typedef struct vdev_file { + zfs_file_t *vf_file; +} vdev_file_t; #endif extern void vdev_file_init(void); diff --git a/include/sys/zfs_ioctl.h b/include/sys/zfs_ioctl.h index f87d7a18e122..97cedc513472 100644 --- a/include/sys/zfs_ioctl.h +++ b/include/sys/zfs_ioctl.h @@ -531,42 +531,6 @@ typedef struct uint64_t count; }stat_pair; -typedef struct { - unsigned __int64 read_iops; - unsigned __int64 write_iops; - unsigned __int64 total_iops; - unsigned __int64 read_bytes; - unsigned __int64 write_bytes; - unsigned __int64 total_bytes; - unsigned __int64 ddt_entry_count; // number of elments in ddt ,zpool only - unsigned __int64 ddt_dspace; // size of ddt on disk ,zpool only - unsigned __int64 ddt_mspace; // size of ddt in-core ,zpool only - unsigned __int64 vsx_active_queue_sync_read; - unsigned __int64 vsx_active_queue_sync_write; - unsigned __int64 vsx_active_queue_async_read; - unsigned __int64 vsx_active_queue_async_write; - unsigned __int64 vsx_pend_queue_sync_read; - unsigned __int64 vsx_pend_queue_sync_write; - unsigned __int64 vsx_pend_queue_async_read; - unsigned __int64 vsx_pend_queue_async_write; - unsigned __int64 vsx_queue_histo_sync_read_time; - unsigned __int64 vsx_queue_histo_sync_read_count; - unsigned __int64 vsx_queue_histo_async_read_time; - unsigned __int64 vsx_queue_histo_async_read_count; - unsigned __int64 vsx_queue_histo_sync_write_time; - unsigned __int64 vsx_queue_histo_sync_write_count; - unsigned __int64 vsx_queue_histo_async_write_time; - unsigned __int64 vsx_queue_histo_async_write_count; - unsigned __int64 vsx_total_histo_read_time; - unsigned __int64 vsx_total_histo_read_count; - unsigned __int64 vsx_total_histo_write_time; - unsigned __int64 vsx_total_histo_write_count; - unsigned __int64 vsx_disk_histo_read_time; - unsigned __int64 vsx_disk_histo_read_count; - unsigned __int64 vsx_disk_histo_write_time; - unsigned __int64 vsx_disk_histo_write_count; - unsigned __int64 dp_dirty_total_io; // zpool only -} zpool_perf_counters; typedef struct { uint64_t arcstat_hits; @@ -666,19 +630,6 @@ extern int zfsdev_getminor(zfs_file_t *fp, minor_t *minorp); extern uint_t zfs_fsyncer_key; extern uint_t zfs_allow_log_key; -NTSTATUS NTAPI -ZFSinPerfCallBack(PCW_CALLBACK_TYPE Type, PPCW_CALLBACK_INFORMATION Info, - PVOID Context); - -void ZFSinPerfCollect(PCW_MASK_INFORMATION CollectData); -void ZFSinPerfVdevCollect(PCW_MASK_INFORMATION CollectData); -void ZFSinCachePerfCollect(PCW_MASK_INFORMATION CollectData); - -PUNICODE_STRING MapInvalidChars(PUNICODE_STRING InstanceName); - -void ZFSinPerfEnumerate(PCW_MASK_INFORMATION EnumerateInstances); -void ZFSinPerfVdevEnumerate(PCW_MASK_INFORMATION EnumerateInstances); -void ZFSinCachePerfEnumerate(PCW_MASK_INFORMATION EnumerateInstances); #endif /* _KERNEL */ diff --git a/include/sys/zvol_impl.h b/include/sys/zvol_impl.h index 3243917bcd3f..e6d2541005f8 100644 --- a/include/sys/zvol_impl.h +++ b/include/sys/zvol_impl.h @@ -75,6 +75,7 @@ extern unsigned int zvol_inhibit_dev; */ zvol_state_t *zvol_find_by_name_hash(const char *name, uint64_t hash, int mode); +zvol_state_t *zvol_find_by_name(const char* name, int mode); int zvol_first_open(zvol_state_t *zv, boolean_t readonly); uint64_t zvol_name_hash(const char *name); void zvol_remove_minors_impl(const char *name); diff --git a/lib/libspl/include/sys/types.h b/lib/libspl/include/sys/types.h index 5a84123d201f..d404201816ef 100644 --- a/lib/libspl/include/sys/types.h +++ b/lib/libspl/include/sys/types.h @@ -74,4 +74,9 @@ typedef union { #include /* for NBBY */ +#ifndef _WIN32 +#define posix_memalign_free free +#define NTSTATUS int32_t +#endif + #endif diff --git a/module/os/windows/zfs/zfs_ioctl_os.c b/module/os/windows/zfs/zfs_ioctl_os.c index 296ee2258003..f5250f4024f5 100644 --- a/module/os/windows/zfs/zfs_ioctl_os.c +++ b/module/os/windows/zfs/zfs_ioctl_os.c @@ -52,6 +52,60 @@ #include #include + + + +typedef struct { + unsigned __int64 read_iops; + unsigned __int64 write_iops; + unsigned __int64 total_iops; + unsigned __int64 read_bytes; + unsigned __int64 write_bytes; + unsigned __int64 total_bytes; + unsigned __int64 ddt_entry_count; // number of elments in ddt ,zpool only + unsigned __int64 ddt_dspace; // size of ddt on disk ,zpool only + unsigned __int64 ddt_mspace; // size of ddt in-core ,zpool only + unsigned __int64 vsx_active_queue_sync_read; + unsigned __int64 vsx_active_queue_sync_write; + unsigned __int64 vsx_active_queue_async_read; + unsigned __int64 vsx_active_queue_async_write; + unsigned __int64 vsx_pend_queue_sync_read; + unsigned __int64 vsx_pend_queue_sync_write; + unsigned __int64 vsx_pend_queue_async_read; + unsigned __int64 vsx_pend_queue_async_write; + unsigned __int64 vsx_queue_histo_sync_read_time; + unsigned __int64 vsx_queue_histo_sync_read_count; + unsigned __int64 vsx_queue_histo_async_read_time; + unsigned __int64 vsx_queue_histo_async_read_count; + unsigned __int64 vsx_queue_histo_sync_write_time; + unsigned __int64 vsx_queue_histo_sync_write_count; + unsigned __int64 vsx_queue_histo_async_write_time; + unsigned __int64 vsx_queue_histo_async_write_count; + unsigned __int64 vsx_total_histo_read_time; + unsigned __int64 vsx_total_histo_read_count; + unsigned __int64 vsx_total_histo_write_time; + unsigned __int64 vsx_total_histo_write_count; + unsigned __int64 vsx_disk_histo_read_time; + unsigned __int64 vsx_disk_histo_read_count; + unsigned __int64 vsx_disk_histo_write_time; + unsigned __int64 vsx_disk_histo_write_count; + unsigned __int64 dp_dirty_total_io; // zpool only +} zpool_perf_counters; + +NTSTATUS NTAPI +ZFSinPerfCallBack(PCW_CALLBACK_TYPE Type, PPCW_CALLBACK_INFORMATION Info, + PVOID Context); + +void ZFSinPerfCollect(PCW_MASK_INFORMATION CollectData); +void ZFSinPerfVdevCollect(PCW_MASK_INFORMATION CollectData); +void ZFSinCachePerfCollect(PCW_MASK_INFORMATION CollectData); + +PUNICODE_STRING MapInvalidChars(PUNICODE_STRING InstanceName); + +void ZFSinPerfEnumerate(PCW_MASK_INFORMATION EnumerateInstances); +void ZFSinPerfVdevEnumerate(PCW_MASK_INFORMATION EnumerateInstances); +void ZFSinCachePerfEnumerate(PCW_MASK_INFORMATION EnumerateInstances); + #include #include #include "../OpenZFS_perf.h" diff --git a/module/os/windows/zfs/zvol_os.c b/module/os/windows/zfs/zvol_os.c index bdd553b6e345..eedda84a5222 100644 --- a/module/os/windows/zfs/zvol_os.c +++ b/module/os/windows/zfs/zvol_os.c @@ -1048,3 +1048,37 @@ zvol_fini(void) zvol_fini_impl(); taskq_destroy(zvol_taskq); } + +/* ZFS ZVOLDI */ + +_Function_class_(PINTERFACE_REFERENCE) +void +IncZvolRef(PVOID Context) +{ + zvol_state_t* zv = (zvol_state_t*)Context; + atomic_inc_32(&zv->zv_open_count); +} + +_Function_class_(PINTERFACE_REFERENCE) +void +DecZvolRef(PVOID Context) +{ + zvol_state_t* zv = (zvol_state_t*)Context; + atomic_dec_32(&zv->zv_open_count); +} + +zvol_state_t* +zvol_name2zvolState(const char* name, uint32_t* openCount) +{ + zvol_state_t* zv; + + zv = zvol_find_by_name(name, RW_NONE); + if (zv == NULL) + return (zv); + + if (openCount) + *openCount = zv->zv_open_count; + + mutex_exit(&zv->zv_state_lock); + return (zv); +} diff --git a/module/zfs/dsl_pool.c b/module/zfs/dsl_pool.c index 73cceb3f22fa..a0de24352803 100644 --- a/module/zfs/dsl_pool.c +++ b/module/zfs/dsl_pool.c @@ -99,8 +99,8 @@ * capped at zfs_dirty_data_max_max. It can also be overridden with a module * parameter. */ -uint64_t zfs_dirty_data_max = 0; -uint64_t zfs_dirty_data_max_max = 0; +ZFS_MODULE_ULONG zfs_dirty_data_max = 0; +ZFS_MODULE_ULONG zfs_dirty_data_max_max = 0; int zfs_dirty_data_max_percent = 10; int zfs_dirty_data_max_max_percent = 25; diff --git a/module/zfs/zvol.c b/module/zfs/zvol.c index 140f45cab6dd..f46e0568e95a 100644 --- a/module/zfs/zvol.c +++ b/module/zfs/zvol.c @@ -174,7 +174,7 @@ zvol_find_by_name_hash(const char *name, uint64_t hash, int mode) * before zv_state_lock. The mode argument indicates the mode (including none) * for zv_suspend_lock to be taken. */ -static zvol_state_t * +zvol_state_t * zvol_find_by_name(const char *name, int mode) { return (zvol_find_by_name_hash(name, zvol_name_hash(name), mode)); @@ -1739,36 +1739,3 @@ zvol_fini_impl(void) list_destroy(&zvol_state_list); rw_destroy(&zvol_state_lock); } - -/* ZFS ZVOLDI */ -_Function_class_(PINTERFACE_REFERENCE) - void - IncZvolRef(PVOID Context) -{ - zvol_state_t *zv = (zvol_state_t *)Context; - atomic_inc_32(&zv->zv_open_count); -} - -_Function_class_(PINTERFACE_REFERENCE) - void - DecZvolRef(PVOID Context) -{ - zvol_state_t *zv = (zvol_state_t *)Context; - atomic_dec_32(&zv->zv_open_count); -} - -zvol_state_t * -zvol_name2zvolState(const char *name, uint32_t *openCount) -{ - zvol_state_t *zv; - - zv = zvol_find_by_name(name, RW_NONE); - if (zv == NULL) - return (zv); - - if (openCount) - *openCount = zv->zv_open_count; - - mutex_exit(&zv->zv_state_lock); - return (zv); -}