Skip to content

Commit

Permalink
Replace 'long' with os defined ZFS_MODULE_LONG for LLP64 on windows
Browse files Browse the repository at this point in the history
Unortunately, Windows defines 'long' as 32-bit even on x64
compiles. We create two new macros ZFS_MODULE_LONG
and ZFS_MODULE_ULONG. These two will be 'long' on Unix, and
let the toolchain handle the size of it.

On Windows the two macros are defined as 'int64_t'/'uint64_t'.

Signed-off-by: Andrew Innes <[email protected]>
Co-Authored-By: Jorgen Lundman <[email protected]>
  • Loading branch information
andrewc12 and lundman committed Oct 3, 2022
1 parent 67395be commit d95ec0d
Show file tree
Hide file tree
Showing 33 changed files with 89 additions and 76 deletions.
4 changes: 4 additions & 0 deletions include/os/freebsd/spl/sys/mod_os.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@

#include <sys/sysctl.h>

/* Other platforms have long as 32-bit */
#define ZFS_MODULE_LONG long
#define ZFS_MODULE_ULONG unsigned long

#define ZMOD_RW CTLFLAG_RWTUN
#define ZMOD_RD CTLFLAG_RDTUN

Expand Down
4 changes: 4 additions & 0 deletions include/os/linux/kernel/linux/mod_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ typedef struct kernel_param zfs_kernel_param_t;
/* END CSTYLED */
#define STRING charp

/* Other platforms have long as 32-bit */
#define ZFS_MODULE_LONG long
#define ZFS_MODULE_ULONG unsigned long

enum scope_prefix_types {
zfs,
zfs_arc,
Expand Down
2 changes: 1 addition & 1 deletion include/sys/dmu_zfetch.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
extern "C" {
#endif

extern unsigned long zfetch_array_rd_sz;
extern ZFS_MODULE_ULONG zfetch_array_rd_sz;

struct dnode; /* so we can reference dnode */

Expand Down
2 changes: 1 addition & 1 deletion include/sys/dsl_deadlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ typedef struct livelist_condense_entry {
boolean_t cancelled;
} livelist_condense_entry_t;

extern unsigned long zfs_livelist_max_entries;
extern ZFS_MODULE_ULONG zfs_livelist_max_entries;
extern int zfs_livelist_min_percent_shared;

typedef int deadlist_iter_t(void *args, dsl_deadlist_entry_t *dle);
Expand Down
8 changes: 4 additions & 4 deletions include/sys/dsl_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ struct dsl_scan;
struct dsl_crypto_params;
struct dsl_deadlist;

extern unsigned long zfs_dirty_data_max;
extern unsigned long zfs_dirty_data_max_max;
extern unsigned long zfs_wrlog_data_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 uint_t zfs_dirty_data_max_percent;
extern uint_t zfs_dirty_data_max_max_percent;
extern uint_t zfs_delay_min_dirty_percent;
extern unsigned long zfs_delay_scale;
extern ZFS_MODULE_ULONG zfs_delay_scale;

/* These macros are for indexing into the zfs_all_blkstats_t. */
#define DMU_OT_DEFERRED DMU_OT_NONE
Expand Down
2 changes: 1 addition & 1 deletion include/sys/mmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ extern void mmp_signal_all_threads(void);

/* Global tuning */
extern int param_set_multihost_interval(ZFS_MODULE_PARAM_ARGS);
extern ulong_t zfs_multihost_interval;
extern ZFS_MODULE_ULONG zfs_multihost_interval;
extern uint_t zfs_multihost_fail_intervals;
extern uint_t zfs_multihost_import_intervals;

Expand Down
6 changes: 3 additions & 3 deletions include/sys/spa.h
Original file line number Diff line number Diff line change
Expand Up @@ -1218,9 +1218,9 @@ int param_set_deadman_failmode(ZFS_MODULE_PARAM_ARGS);

extern spa_mode_t spa_mode_global;
extern int zfs_deadman_enabled;
extern unsigned long zfs_deadman_synctime_ms;
extern unsigned long zfs_deadman_ziotime_ms;
extern unsigned long zfs_deadman_checktime_ms;
extern ZFS_MODULE_ULONG zfs_deadman_synctime_ms;
extern ZFS_MODULE_ULONG zfs_deadman_ziotime_ms;
extern ZFS_MODULE_ULONG zfs_deadman_checktime_ms;

extern kmem_cache_t *zio_buf_cache[];
extern kmem_cache_t *zio_data_buf_cache[];
Expand Down
4 changes: 2 additions & 2 deletions include/sys/zcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ extern "C" {

#define ZCP_RUN_INFO_KEY "runinfo"

extern unsigned long zfs_lua_max_instrlimit;
extern unsigned long zfs_lua_max_memlimit;
extern ZFS_MODULE_ULONG zfs_lua_max_instrlimit;
extern ZFS_MODULE_ULONG zfs_lua_max_memlimit;

int zcp_argerror(lua_State *, int, const char *, ...);

Expand Down
4 changes: 4 additions & 0 deletions include/sys/zfs_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ typedef struct zfs_kernel_param {
const char *name; /* unused stub */
} zfs_kernel_param_t;

/* Other platforms have long as 32-bit */
#define ZFS_MODULE_LONG long
#define ZFS_MODULE_ULONG unsigned long

#define ZFS_MODULE_PARAM(scope_prefix, name_prefix, name, type, perm, desc)
#define ZFS_MODULE_PARAM_ARGS void
#define ZFS_MODULE_PARAM_CALL(scope_prefix, name_prefix, name, setfunc, \
Expand Down
2 changes: 1 addition & 1 deletion include/sys/zfs_ioctl_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#define _ZFS_IOCTL_IMPL_H_

extern kmutex_t zfsdev_state_lock;
extern unsigned long zfs_max_nvlist_src_size;
extern ZFS_MODULE_ULONG zfs_max_nvlist_src_size;

typedef int zfs_ioc_legacy_func_t(zfs_cmd_t *);
typedef int zfs_ioc_func_t(const char *, nvlist_t *, nvlist_t *);
Expand Down
4 changes: 2 additions & 2 deletions module/os/freebsd/zfs/vdev_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@

static taskq_t *vdev_file_taskq;

static unsigned long vdev_file_logical_ashift = SPA_MINBLOCKSHIFT;
static unsigned long vdev_file_physical_ashift = SPA_MINBLOCKSHIFT;
static ZFS_MODULE_ULONG vdev_file_logical_ashift = SPA_MINBLOCKSHIFT;
static ZFS_MODULE_ULONG vdev_file_physical_ashift = SPA_MINBLOCKSHIFT;

void
vdev_file_init(void)
Expand Down
4 changes: 2 additions & 2 deletions module/os/linux/zfs/vdev_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ static taskq_t *vdev_file_taskq;
* impact the vdev_ashift setting which can only be set at vdev creation
* time.
*/
static unsigned long vdev_file_logical_ashift = SPA_MINBLOCKSHIFT;
static unsigned long vdev_file_physical_ashift = SPA_MINBLOCKSHIFT;
static ZFS_MODULE_ULONG vdev_file_logical_ashift = SPA_MINBLOCKSHIFT;
static ZFS_MODULE_ULONG vdev_file_physical_ashift = SPA_MINBLOCKSHIFT;

static void
vdev_file_hold(vdev_t *vd)
Expand Down
28 changes: 14 additions & 14 deletions module/zfs/arc.c
Original file line number Diff line number Diff line change
Expand Up @@ -421,10 +421,10 @@ boolean_t arc_warm;
*/
unsigned long zfs_arc_max = 0;
unsigned long zfs_arc_min = 0;
unsigned long zfs_arc_meta_limit = 0;
unsigned long zfs_arc_meta_min = 0;
static unsigned long zfs_arc_dnode_limit = 0;
static unsigned long zfs_arc_dnode_reduce_percent = 10;
ZFS_MODULE_ULONG zfs_arc_meta_limit = 0;
ZFS_MODULE_ULONG zfs_arc_meta_min = 0;
static ZFS_MODULE_ULONG zfs_arc_dnode_limit = 0;
static ZFS_MODULE_ULONG zfs_arc_dnode_reduce_percent = 10;
static uint_t zfs_arc_grow_retry = 0;
static uint_t zfs_arc_shrink_shift = 0;
static uint_t zfs_arc_p_min_shift = 0;
Expand All @@ -449,12 +449,12 @@ int zfs_compressed_arc_enabled = B_TRUE;
* ARC will evict meta buffers that exceed arc_meta_limit. This
* tunable make arc_meta_limit adjustable for different workloads.
*/
static unsigned long zfs_arc_meta_limit_percent = 75;
static ZFS_MODULE_ULONG zfs_arc_meta_limit_percent = 75;

/*
* Percentage that can be consumed by dnodes of ARC meta buffers.
*/
static unsigned long zfs_arc_dnode_limit_percent = 10;
static ZFS_MODULE_ULONG zfs_arc_dnode_limit_percent = 10;

/*
* These tunables are Linux-specific
Expand Down Expand Up @@ -781,12 +781,12 @@ uint64_t zfs_crc64_table[256];
#define L2ARC_FEED_TYPES 4

/* L2ARC Performance Tunables */
unsigned long l2arc_write_max = L2ARC_WRITE_SIZE; /* def max write size */
unsigned long l2arc_write_boost = L2ARC_WRITE_SIZE; /* extra warmup write */
unsigned long l2arc_headroom = L2ARC_HEADROOM; /* # of dev writes */
unsigned long l2arc_headroom_boost = L2ARC_HEADROOM_BOOST;
unsigned long l2arc_feed_secs = L2ARC_FEED_SECS; /* interval seconds */
unsigned long l2arc_feed_min_ms = L2ARC_FEED_MIN_MS; /* min interval msecs */
ZFS_MODULE_ULONG l2arc_write_max = L2ARC_WRITE_SIZE; /* def max write size */
ZFS_MODULE_ULONG l2arc_write_boost = L2ARC_WRITE_SIZE; /* extra warmup write */
ZFS_MODULE_ULONG l2arc_headroom = L2ARC_HEADROOM; /* # of dev writes */
ZFS_MODULE_ULONG l2arc_headroom_boost = L2ARC_HEADROOM_BOOST;
ZFS_MODULE_ULONG l2arc_feed_secs = L2ARC_FEED_SECS; /* interval seconds */
ZFS_MODULE_ULONG l2arc_feed_min_ms = L2ARC_FEED_MIN_MS; /* min interval msecs */
int l2arc_noprefetch = B_TRUE; /* don't cache prefetch bufs */
int l2arc_feed_again = B_TRUE; /* turbo warmup */
int l2arc_norw = B_FALSE; /* no reads during writes */
Expand Down Expand Up @@ -909,7 +909,7 @@ static int l2arc_mfuonly = 0;
* will vary depending of how well the specific device handles
* these commands.
*/
static unsigned long l2arc_trim_ahead = 0;
static ZFS_MODULE_ULONG l2arc_trim_ahead = 0;

/*
* Performance tuning of L2ARC persistence:
Expand All @@ -925,7 +925,7 @@ static unsigned long l2arc_trim_ahead = 0;
* not to waste space.
*/
static int l2arc_rebuild_enabled = B_TRUE;
static unsigned long l2arc_rebuild_blocks_min_l2size = 1024 * 1024 * 1024;
static ZFS_MODULE_ULONG l2arc_rebuild_blocks_min_l2size = 1024 * 1024 * 1024;

/* L2ARC persistence rebuild control routines. */
void l2arc_rebuild_vdev(vdev_t *vd, boolean_t reopen);
Expand Down
4 changes: 2 additions & 2 deletions module/zfs/dbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ typedef struct dbuf_cache {
dbuf_cache_t dbuf_caches[DB_CACHE_MAX];

/* Size limits for the caches */
static unsigned long dbuf_cache_max_bytes = ULONG_MAX;
static unsigned long dbuf_metadata_cache_max_bytes = ULONG_MAX;
static ZFS_MODULE_ULONG dbuf_cache_max_bytes = ULONG_MAX;
static ZFS_MODULE_ULONG dbuf_metadata_cache_max_bytes = ULONG_MAX;

/* Set the default sizes of the caches to log2 fraction of arc size */
static uint_t dbuf_cache_shift = 5;
Expand Down
2 changes: 1 addition & 1 deletion module/zfs/dmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ static int zfs_nopwrite_enabled = 1;
* will wait until the next TXG.
* A value of zero will disable this throttle.
*/
static unsigned long zfs_per_txg_dirty_frees_percent = 30;
static ZFS_MODULE_ULONG zfs_per_txg_dirty_frees_percent = 30;

/*
* Enable/disable forcing txg sync when dirty checking for holes with lseek().
Expand Down
2 changes: 1 addition & 1 deletion module/zfs/dmu_zfetch.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ unsigned int zfetch_max_distance = 64 * 1024 * 1024;
/* max bytes to prefetch indirects for per stream (default 64MB) */
unsigned int zfetch_max_idistance = 64 * 1024 * 1024;
/* max number of bytes in an array_read in which we allow prefetching (1MB) */
unsigned long zfetch_array_rd_sz = 1024 * 1024;
ZFS_MODULE_ULONG zfetch_array_rd_sz = 1024 * 1024;

typedef struct zfetch_stats {
kstat_named_t zfetchstat_hits;
Expand Down
2 changes: 1 addition & 1 deletion module/zfs/dsl_deadlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
* will be loaded into memory and shouldn't take up an inordinate amount of
* space. We settled on ~500000 entries, corresponding to roughly 128M.
*/
unsigned long zfs_livelist_max_entries = 500000;
ZFS_MODULE_ULONG zfs_livelist_max_entries = 500000;

/*
* We can approximate how much of a performance gain a livelist will give us
Expand Down
8 changes: 4 additions & 4 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.
*/
unsigned long zfs_dirty_data_max = 0;
unsigned long 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 All @@ -109,7 +109,7 @@ uint_t zfs_dirty_data_max_max_percent = 25;
* when approaching the limit until log data is cleared out after txg sync.
* It only counts TX_WRITE log with WR_COPIED or WR_NEED_COPY.
*/
unsigned long zfs_wrlog_data_max = 0;
ZFS_MODULE_ULONG zfs_wrlog_data_max = 0;

/*
* If there's at least this much dirty data (as a percentage of
Expand Down Expand Up @@ -138,7 +138,7 @@ uint_t zfs_delay_min_dirty_percent = 60;
* Note: zfs_delay_scale * zfs_dirty_data_max must be < 2^64, due to the
* multiply in dmu_tx_delay().
*/
unsigned long zfs_delay_scale = 1000 * 1000 * 1000 / 2000;
ZFS_MODULE_ULONG zfs_delay_scale = 1000 * 1000 * 1000 / 2000;

/*
* This determines the number of threads used by the dp_sync_taskq.
Expand Down
8 changes: 4 additions & 4 deletions module/zfs/dsl_scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,13 @@ static int zfs_scan_strict_mem_lim = B_FALSE;
* overload the drives with I/O, since that is protected by
* zfs_vdev_scrub_max_active.
*/
static unsigned long zfs_scan_vdev_limit = 4 << 20;
static ZFS_MODULE_ULONG zfs_scan_vdev_limit = 4 << 20;

static uint_t zfs_scan_issue_strategy = 0;

/* don't queue & sort zios, go direct */
static int zfs_scan_legacy = B_FALSE;
static unsigned long zfs_scan_max_ext_gap = 2 << 20; /* in bytes */
static ZFS_MODULE_ULONG zfs_scan_max_ext_gap = 2 << 20; /* in bytes */

/*
* fill_weight is non-tunable at runtime, so we copy it at module init from
Expand Down Expand Up @@ -192,9 +192,9 @@ static int zfs_no_scrub_io = B_FALSE; /* set to disable scrub i/o */
static int zfs_no_scrub_prefetch = B_FALSE; /* set to disable scrub prefetch */
static const enum ddt_class zfs_scrub_ddt_class_max = DDT_CLASS_DUPLICATE;
/* max number of blocks to free in a single TXG */
static unsigned long zfs_async_block_max_blocks = ULONG_MAX;
static ZFS_MODULE_ULONG zfs_async_block_max_blocks = ULONG_MAX;
/* max number of dedup blocks to free in a single TXG */
static unsigned long zfs_max_async_dedup_frees = 100000;
static ZFS_MODULE_ULONG zfs_max_async_dedup_frees = 100000;

/* set to disable resilver deferring */
static int zfs_resilver_disable_defer = B_FALSE;
Expand Down
7 changes: 4 additions & 3 deletions module/zfs/metaslab.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@
* operation, we will try to write this amount of data to each disk before
* moving on to the next top-level vdev.
*/
static unsigned long metaslab_aliquot = 1024 * 1024;
static ZFS_MODULE_ULONG metaslab_aliquot = 1024 * 1024;

/*
* For testing, make some blocks above a certain size be gang blocks.
*/
unsigned long metaslab_force_ganging = SPA_MAXBLOCKSIZE + 1;
ZFS_MODULE_ULONG metaslab_force_ganging = SPA_MAXBLOCKSIZE + 1;

/*
* In pools where the log space map feature is not enabled we touch
Expand Down Expand Up @@ -286,7 +286,8 @@ static const int max_disabled_ms = 3;
* Time (in seconds) to respect ms_max_size when the metaslab is not loaded.
* To avoid 64-bit overflow, don't set above UINT32_MAX.
*/
static unsigned long zfs_metaslab_max_size_cache_sec = 1 * 60 * 60; /* 1 hour */
static ZFS_MODULE_ULONG zfs_metaslab_max_size_cache_sec = 1 * 60 * 60;
/* 1 hour */

/*
* Maximum percentage of memory to use on storing loaded metaslabs. If loading
Expand Down
2 changes: 1 addition & 1 deletion module/zfs/mmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
* vary with the I/O load and this observed value is the ub_mmp_delay which is
* stored in the uberblock. The minimum allowed value is 100 ms.
*/
ulong_t zfs_multihost_interval = MMP_DEFAULT_INTERVAL;
ZFS_MODULE_ULONG zfs_multihost_interval = MMP_DEFAULT_INTERVAL;

/*
* Used to control the duration of the activity test on import. Smaller values
Expand Down
2 changes: 1 addition & 1 deletion module/zfs/spa.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ static int spa_load_print_vdev_tree = B_FALSE;
* there are also risks of performing an inadvertent rewind as we might be
* missing all the vdevs with the latest uberblocks.
*/
unsigned long zfs_max_missing_tvds = 0;
ZFS_MODULE_ULONG zfs_max_missing_tvds = 0;

/*
* The parameters below are similar to zfs_max_missing_tvds but are only
Expand Down
2 changes: 1 addition & 1 deletion module/zfs/spa_checkpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
* amount of checkpointed data that has been freed within them while
* the pool had a checkpoint.
*/
static unsigned long zfs_spa_discard_memory_limit = 16 * 1024 * 1024;
static ZFS_MODULE_ULONG zfs_spa_discard_memory_limit = 16 * 1024 * 1024;

int
spa_checkpoint_get_stats(spa_t *spa, pool_checkpoint_stat_t *pcs)
Expand Down
Loading

0 comments on commit d95ec0d

Please sign in to comment.