1168404Spjd/*
2168404Spjd * CDDL HEADER START
3168404Spjd *
4168404Spjd * The contents of this file are subject to the terms of the
5168404Spjd * Common Development and Distribution License (the "License").
6168404Spjd * You may not use this file except in compliance with the License.
7168404Spjd *
8168404Spjd * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9168404Spjd * or http://www.opensolaris.org/os/licensing.
10168404Spjd * See the License for the specific language governing permissions
11168404Spjd * and limitations under the License.
12168404Spjd *
13168404Spjd * When distributing Covered Code, include this CDDL HEADER in each
14168404Spjd * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15168404Spjd * If applicable, add the following below this CDDL HEADER, with the
16168404Spjd * fields enclosed by brackets "[]" replaced with your own identifying
17168404Spjd * information: Portions Copyright [yyyy] [name of copyright owner]
18168404Spjd *
19168404Spjd * CDDL HEADER END
20168404Spjd */
21168404Spjd
22168404Spjd/*
23219089Spjd * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
24168404Spjd */
25168404Spjd
26168404Spjd#ifndef	_SYS_ZVOL_H
27168404Spjd#define	_SYS_ZVOL_H
28168404Spjd
29168404Spjd#include <sys/zfs_context.h>
30168404Spjd
31168404Spjd#ifdef	__cplusplus
32168404Spjdextern "C" {
33168404Spjd#endif
34168404Spjd
35185029Spjd#define	ZVOL_OBJ		1ULL
36185029Spjd#define	ZVOL_ZAP_OBJ		2ULL
37185029Spjd
38168404Spjd#ifdef _KERNEL
39168404Spjdextern int zvol_check_volsize(uint64_t volsize, uint64_t blocksize);
40168404Spjdextern int zvol_check_volblocksize(uint64_t volblocksize);
41168404Spjdextern int zvol_get_stats(objset_t *os, nvlist_t *nv);
42185029Spjdextern void zvol_create_cb(objset_t *os, void *arg, cred_t *cr, dmu_tx_t *tx);
43219089Spjdextern int zvol_create_minor(const char *);
44168404Spjdextern int zvol_remove_minor(const char *);
45219089Spjdextern void zvol_remove_minors(const char *);
46276069Ssmhextern int zvol_set_volsize(const char *, uint64_t);
47168404Spjd
48277300Ssmh#ifdef illumos
49168404Spjdextern int zvol_open(dev_t *devp, int flag, int otyp, cred_t *cr);
50185029Spjdextern int zvol_dump(dev_t dev, caddr_t addr, daddr_t offset, int nblocks);
51168404Spjdextern int zvol_close(dev_t dev, int flag, int otyp, cred_t *cr);
52168404Spjdextern int zvol_strategy(buf_t *bp);
53168404Spjdextern int zvol_read(dev_t dev, uio_t *uiop, cred_t *cr);
54168404Spjdextern int zvol_write(dev_t dev, uio_t *uiop, cred_t *cr);
55168404Spjdextern int zvol_aread(dev_t dev, struct aio_req *aio, cred_t *cr);
56168404Spjdextern int zvol_awrite(dev_t dev, struct aio_req *aio, cred_t *cr);
57277300Ssmh#endif	/* illumos */
58168404Spjdextern int zvol_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cr,
59168404Spjd    int *rvalp);
60168404Spjdextern int zvol_busy(void);
61168404Spjdextern void zvol_init(void);
62168404Spjdextern void zvol_fini(void);
63219089Spjd
64277300Ssmh#ifdef illumos
65219089Spjdextern int zvol_get_volume_params(minor_t minor, uint64_t *blksize,
66219089Spjd    uint64_t *max_xfer_len, void **minor_hdl, void **objset_hdl, void **zil_hdl,
67219089Spjd    void **rl_hdl, void **bonus_hdl);
68219089Spjdextern uint64_t zvol_get_volume_size(void *minor_hdl);
69219089Spjdextern int zvol_get_volume_wce(void *minor_hdl);
70219089Spjdextern void zvol_log_write_minor(void *minor_hdl, dmu_tx_t *tx, offset_t off,
71219089Spjd    ssize_t resid, boolean_t sync);
72277300Ssmh#endif	/* illumos */
73219089Spjd
74252431Srmh#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
75219089Spjdextern int zvol_create_minors(const char *name);
76219317Spjdextern void zvol_rename_minors(const char *oldname, const char *newname);
77168404Spjd#endif
78168404Spjd
79219320Spjd#endif	/* _KERNEL */
80219089Spjd
81168404Spjd#ifdef	__cplusplus
82168404Spjd}
83168404Spjd#endif
84168404Spjd
85168404Spjd#endif	/* _SYS_ZVOL_H */
86