Skip to content

Commit

Permalink
Clean up source to get Linux builds working (openzfs#119)
Browse files Browse the repository at this point in the history
* 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
openzfsonwindows#119 (comment)

* Fix code formatting

in reference to openzfsonwindows#119 (comment)

* 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
  • Loading branch information
andrewc12 committed Oct 6, 2022
1 parent 88d7692 commit 2f30f7f
Show file tree
Hide file tree
Showing 12 changed files with 162 additions and 95 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/build_for_wsl.yaml
Original file line number Diff line number Diff line change
@@ -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
6 changes: 0 additions & 6 deletions cmd/zpool/os/linux/zpool_vdev_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
1 change: 0 additions & 1 deletion cmd/zpool/os/windows/zpool_vdev_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,3 @@ void
after_zpool_upgrade(zpool_handle_t *zhp)
{
}

5 changes: 2 additions & 3 deletions include/sys/dsl_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 uint_t zfs_dirty_data_max_percent;
extern uint_t zfs_dirty_data_max_max_percent;
extern uint_t zfs_delay_min_dirty_percent;
Expand Down
5 changes: 5 additions & 0 deletions include/sys/vdev_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
49 changes: 0 additions & 49 deletions include/sys/zfs_ioctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -537,42 +537,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;
Expand Down Expand Up @@ -672,19 +636,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 */
Expand Down
1 change: 1 addition & 0 deletions include/sys/zvol_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions lib/libspl/include/sys/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,9 @@ typedef union {

#include <sys/param.h> /* for NBBY */

#ifndef _WIN32
#define posix_memalign_free free
#define NTSTATUS int32_t
#endif

#endif
54 changes: 54 additions & 0 deletions module/os/windows/zfs/zfs_ioctl_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,60 @@
#include <zfs_gitrev.h>

#include <Wdmsec.h>



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 <sys/spa_impl.h>
#include <sys/zfs_ioctl.h>
#include "../OpenZFS_perf.h"
Expand Down
34 changes: 34 additions & 0 deletions module/os/windows/zfs/zvol_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
4 changes: 2 additions & 2 deletions module/zfs/dsl_pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
uint_t zfs_dirty_data_max_percent = 10;
uint_t zfs_dirty_data_max_max_percent = 25;

Expand Down
35 changes: 1 addition & 34 deletions module/zfs/zvol.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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);
}

0 comments on commit 2f30f7f

Please sign in to comment.