Skip to content

ZVOL: Make zvol_prefetch_bytes module parameter platform-independent #17385

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/sys/zvol_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ extern struct hlist_head *zvol_htable;
#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 unsigned int zvol_volmode;
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_num_taskqs;
extern unsigned int zvol_request_sync;
Expand Down
9 changes: 7 additions & 2 deletions module/os/freebsd/zfs/zvol_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -1369,7 +1369,7 @@ zvol_os_create_minor(const char *name)
objset_t *os;
dmu_object_info_t *doi;
uint64_t volsize;
uint64_t volmode, hash;
uint64_t volmode, hash, len;
int error;
bool replayed_zil = B_FALSE;

Expand Down Expand Up @@ -1480,7 +1480,12 @@ zvol_os_create_minor(const char *name)
zil_close(zv->zv_zilog);
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;
out_dmu_objset_disown:
Expand Down
4 changes: 0 additions & 4 deletions module/os/linux/zfs/zvol_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ static void zvol_request_impl(zvol_state_t *zv, struct bio *bio,
struct request *rq, boolean_t force_sync);

static unsigned int zvol_major = ZVOL_MAJOR;
static unsigned int zvol_prefetch_bytes = (128 * 1024);
static unsigned long zvol_max_discard_blocks = 16384;

#ifndef HAVE_BLKDEV_GET_ERESTARTSYS
Expand Down Expand Up @@ -1796,9 +1795,6 @@ MODULE_PARM_DESC(zvol_major, "Major number for zvol device");
module_param(zvol_max_discard_blocks, ulong, 0444);
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_PARM_DESC(zvol_volmode, "Default volmode property value");

Expand Down
3 changes: 3 additions & 0 deletions module/zfs/zvol.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
#include <sys/zvol_impl.h>

unsigned int zvol_inhibit_dev = 0;
unsigned int zvol_prefetch_bytes = (128 * 1024);
unsigned int zvol_volmode = ZFS_VOLMODE_GEOM;
unsigned int zvol_threads = 0;
unsigned int zvol_num_taskqs = 0;
Expand Down Expand Up @@ -2156,6 +2157,8 @@ zvol_fini_impl(void)

ZFS_MODULE_PARAM(zfs_vol, zvol_, inhibit_dev, UINT, ZMOD_RW,
"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,
"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,
Expand Down
Loading