]> git.proxmox.com Git - mirror_zfs.git/blame - include/sys/zvol_impl.h
zvol: Implement zvol threading as a Property
[mirror_zfs.git] / include / sys / zvol_impl.h
CommitLineData
5df7e9d8
MM
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
1d3ba0bf 9 * or https://opensource.org/licenses/CDDL-1.0.
5df7e9d8
MM
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22#ifndef _SYS_ZVOL_IMPL_H
23#define _SYS_ZVOL_IMPL_H
24
25#include <sys/zfs_context.h>
26
27#define ZVOL_RDONLY 0x1
28/*
29 * Whether the zvol has been written to (as opposed to ZVOL_RDONLY, which
30 * specifies whether or not the zvol _can_ be written to)
31 */
32#define ZVOL_WRITTEN_TO 0x2
33
34#define ZVOL_DUMPIFIED 0x4
35
36#define ZVOL_EXCL 0x8
37
38/*
39 * The in-core state of each volume.
40 */
41typedef struct zvol_state {
42 char zv_name[MAXNAMELEN]; /* name */
43 uint64_t zv_volsize; /* advertised space */
44 uint64_t zv_volblocksize; /* volume block size */
45 objset_t *zv_objset; /* objset handle */
46 uint32_t zv_flags; /* ZVOL_* flags */
47 uint32_t zv_open_count; /* open counts */
48 uint32_t zv_changed; /* disk changed */
0ca45cb3 49 uint32_t zv_volmode; /* volmode */
5df7e9d8 50 zilog_t *zv_zilog; /* ZIL handle */
bd4dde8e 51 zfs_rangelock_t zv_rangelock; /* for range locking */
5df7e9d8 52 dnode_t *zv_dn; /* dnode hold */
4547fc4e 53 dataset_kstats_t zv_kstat; /* zvol kstats */
5df7e9d8
MM
54 list_node_t zv_next; /* next zvol_state_t linkage */
55 uint64_t zv_hash; /* name hash */
56 struct hlist_node zv_hlink; /* hash link */
57 kmutex_t zv_state_lock; /* protects zvol_state_t */
58 atomic_t zv_suspend_ref; /* refcount for suspend */
59 krwlock_t zv_suspend_lock; /* suspend lock */
60 struct zvol_state_os *zv_zso; /* private platform state */
60387fac 61 boolean_t zv_threading; /* volthreading property */
5df7e9d8
MM
62} zvol_state_t;
63
64
5df7e9d8
MM
65extern krwlock_t zvol_state_lock;
66#define ZVOL_HT_SIZE 1024
67extern struct hlist_head *zvol_htable;
68#define ZVOL_HT_HEAD(hash) (&zvol_htable[(hash) & (ZVOL_HT_SIZE-1)])
18168da7 69extern zil_replay_func_t *const zvol_replay_vector[TX_MAX_TYPE];
5df7e9d8
MM
70
71extern unsigned int zvol_volmode;
72extern unsigned int zvol_inhibit_dev;
73
74/*
75 * platform independent functions exported to platform code
76 */
77zvol_state_t *zvol_find_by_name_hash(const char *name,
78 uint64_t hash, int mode);
79int zvol_first_open(zvol_state_t *zv, boolean_t readonly);
80uint64_t zvol_name_hash(const char *name);
81void zvol_remove_minors_impl(const char *name);
82void zvol_last_close(zvol_state_t *zv);
83void zvol_insert(zvol_state_t *zv);
84void zvol_log_truncate(zvol_state_t *zv, dmu_tx_t *tx, uint64_t off,
c3773de1 85 uint64_t len);
5df7e9d8 86void zvol_log_write(zvol_state_t *zv, dmu_tx_t *tx, uint64_t offset,
c3773de1 87 uint64_t size, boolean_t commit);
296a4a36
CC
88int zvol_get_data(void *arg, uint64_t arg2, lr_write_t *lr, char *buf,
89 struct lwb *lwb, zio_t *zio);
5df7e9d8
MM
90int zvol_init_impl(void);
91void zvol_fini_impl(void);
0ca45cb3 92void zvol_wait_close(zvol_state_t *zv);
5df7e9d8
MM
93
94/*
95 * platform dependent functions exported to platform independent code
96 */
1dccfd7a
CS
97void zvol_os_free(zvol_state_t *zv);
98void zvol_os_rename_minor(zvol_state_t *zv, const char *newname);
99int zvol_os_create_minor(const char *name);
100int zvol_os_update_volsize(zvol_state_t *zv, uint64_t volsize);
101boolean_t zvol_os_is_zvol(const char *path);
102void zvol_os_clear_private(zvol_state_t *zv);
103void zvol_os_set_disk_ro(zvol_state_t *zv, int flags);
104void zvol_os_set_capacity(zvol_state_t *zv, uint64_t capacity);
5df7e9d8
MM
105
106#endif