ZVOL: Make zvol_prefetch_bytes module parameter platform-independent

The module parameter now is represented in FreeBSD sysctls list
with name: 'vfs.zfs.vol.prefetch_bytes'. The default value is 131072,
same as on Linux side.

Sponsored-by: vStack, Inc.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Rob Norris <rob.norris@klarasystems.com>
Signed-off-by: Fedor Uporov <fuporov.vstack@gmail.com>
Closes #17385
This commit is contained in:
Fedor Uporov 2025-05-31 16:58:54 +03:00 committed by GitHub
parent e8e602d987
commit e1677d9ee1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 12 additions and 7 deletions

View File

@ -93,8 +93,9 @@ extern struct hlist_head *zvol_htable;
#define ZVOL_HT_HEAD(hash) (&zvol_htable[(hash) & (ZVOL_HT_SIZE-1)]) #define ZVOL_HT_HEAD(hash) (&zvol_htable[(hash) & (ZVOL_HT_SIZE-1)])
extern zil_replay_func_t *const zvol_replay_vector[TX_MAX_TYPE]; extern zil_replay_func_t *const zvol_replay_vector[TX_MAX_TYPE];
extern unsigned int zvol_volmode;
extern unsigned int zvol_inhibit_dev; extern unsigned int zvol_inhibit_dev;
extern unsigned int zvol_prefetch_bytes;
extern unsigned int zvol_volmode;
extern unsigned int zvol_threads; extern unsigned int zvol_threads;
extern unsigned int zvol_num_taskqs; extern unsigned int zvol_num_taskqs;
extern unsigned int zvol_request_sync; extern unsigned int zvol_request_sync;

View File

@ -1369,7 +1369,7 @@ zvol_os_create_minor(const char *name)
objset_t *os; objset_t *os;
dmu_object_info_t *doi; dmu_object_info_t *doi;
uint64_t volsize; uint64_t volsize;
uint64_t volmode, hash; uint64_t volmode, hash, len;
int error; int error;
bool replayed_zil = B_FALSE; bool replayed_zil = B_FALSE;
@ -1480,7 +1480,12 @@ zvol_os_create_minor(const char *name)
zil_close(zv->zv_zilog); zil_close(zv->zv_zilog);
zv->zv_zilog = NULL; zv->zv_zilog = NULL;
/* TODO: prefetch for geom tasting */ len = MIN(zvol_prefetch_bytes, SPA_MAXBLOCKSIZE);
if (len > 0) {
dmu_prefetch(os, ZVOL_OBJ, 0, 0, len, ZIO_PRIORITY_ASYNC_READ);
dmu_prefetch(os, ZVOL_OBJ, 0, volsize - len, len,
ZIO_PRIORITY_ASYNC_READ);
}
zv->zv_objset = NULL; zv->zv_objset = NULL;
out_dmu_objset_disown: out_dmu_objset_disown:

View File

@ -51,7 +51,6 @@ static void zvol_request_impl(zvol_state_t *zv, struct bio *bio,
struct request *rq, boolean_t force_sync); struct request *rq, boolean_t force_sync);
static unsigned int zvol_major = ZVOL_MAJOR; static unsigned int zvol_major = ZVOL_MAJOR;
static unsigned int zvol_prefetch_bytes = (128 * 1024);
static unsigned long zvol_max_discard_blocks = 16384; static unsigned long zvol_max_discard_blocks = 16384;
#ifndef HAVE_BLKDEV_GET_ERESTARTSYS #ifndef HAVE_BLKDEV_GET_ERESTARTSYS
@ -1796,9 +1795,6 @@ MODULE_PARM_DESC(zvol_major, "Major number for zvol device");
module_param(zvol_max_discard_blocks, ulong, 0444); module_param(zvol_max_discard_blocks, ulong, 0444);
MODULE_PARM_DESC(zvol_max_discard_blocks, "Max number of blocks to discard"); MODULE_PARM_DESC(zvol_max_discard_blocks, "Max number of blocks to discard");
module_param(zvol_prefetch_bytes, uint, 0644);
MODULE_PARM_DESC(zvol_prefetch_bytes, "Prefetch N bytes at zvol start+end");
module_param(zvol_volmode, uint, 0644); module_param(zvol_volmode, uint, 0644);
MODULE_PARM_DESC(zvol_volmode, "Default volmode property value"); MODULE_PARM_DESC(zvol_volmode, "Default volmode property value");

View File

@ -89,6 +89,7 @@
#include <sys/zvol_impl.h> #include <sys/zvol_impl.h>
unsigned int zvol_inhibit_dev = 0; unsigned int zvol_inhibit_dev = 0;
unsigned int zvol_prefetch_bytes = (128 * 1024);
unsigned int zvol_volmode = ZFS_VOLMODE_GEOM; unsigned int zvol_volmode = ZFS_VOLMODE_GEOM;
unsigned int zvol_threads = 0; unsigned int zvol_threads = 0;
unsigned int zvol_num_taskqs = 0; unsigned int zvol_num_taskqs = 0;
@ -2156,6 +2157,8 @@ zvol_fini_impl(void)
ZFS_MODULE_PARAM(zfs_vol, zvol_, inhibit_dev, UINT, ZMOD_RW, ZFS_MODULE_PARAM(zfs_vol, zvol_, inhibit_dev, UINT, ZMOD_RW,
"Do not create zvol device nodes"); "Do not create zvol device nodes");
ZFS_MODULE_PARAM(zfs_vol, zvol_, prefetch_bytes, UINT, ZMOD_RW,
"Prefetch N bytes at zvol start+end");
ZFS_MODULE_PARAM(zfs_vol, zvol_, threads, UINT, ZMOD_RW, ZFS_MODULE_PARAM(zfs_vol, zvol_, threads, UINT, ZMOD_RW,
"Number of threads for I/O requests. Set to 0 to use all active CPUs"); "Number of threads for I/O requests. Set to 0 to use all active CPUs");
ZFS_MODULE_PARAM(zfs_vol, zvol_, num_taskqs, UINT, ZMOD_RW, ZFS_MODULE_PARAM(zfs_vol, zvol_, num_taskqs, UINT, ZMOD_RW,