2 * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
3 * Copyright (C) 2007 The Regents of the University of California.
4 * Copyright (c) 2015 by Chunwei Chen. All rights reserved.
5 * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
6 * Written by Brian Behlendorf <behlendorf1@llnl.gov>.
9 * This file is part of the SPL, Solaris Porting Layer.
10 * For details, see <http://zfsonlinux.org/>.
12 * The SPL is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version.
17 * The SPL is distributed in the hope that it will be useful, but WITHOUT
18 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 * You should have received a copy of the GNU General Public License along
23 * with the SPL. If not, see <http://www.gnu.org/licenses/>.
29 #include <sys/debug.h>
30 #include <linux/uio.h>
31 #include <linux/blkdev.h>
32 #include <linux/blkdev_compat.h>
34 #include <linux/bio.h>
35 #include <asm/uaccess.h>
36 #include <sys/types.h>
38 typedef struct iovec iovec_t;
45 typedef enum uio_seg {
54 const struct iovec *uio_iov;
55 const struct bio_vec *uio_bvec;
60 boolean_t uio_fault_disable;
68 typedef struct aio_req {
73 typedef enum xuio_type {
79 #define UIOA_IOV_MAX 16
81 typedef struct uioa_page_s {
90 enum xuio_type xu_type;
95 uioa_page_t *xu_a_lcur;
98 uioa_page_t xu_a_locked[UIOA_IOV_MAX];
108 #define XUIO_XUZC_PRIV(xuio) xuio->xu_ext.xu_zc.xu_zc_priv
109 #define XUIO_XUZC_RW(xuio) xuio->xu_ext.xu_zc.xu_zc_rw
111 #define uio_segflg(uio) (uio)->uio_segflg
112 #define uio_offset(uio) (uio)->uio_loffset
113 #define uio_resid(uio) (uio)->uio_resid
114 #define uio_iovcnt(uio) (uio)->uio_iovcnt
115 #define uio_iovlen(uio, idx) (uio)->uio_iov[(idx)].iov_len
116 #define uio_iovbase(uio, idx) (uio)->uio_iov[(idx)].iov_base
119 uio_iov_at_index(uio_t *uio, uint_t idx, void **base, uint64_t *len)
121 *base = uio_iovbase(uio, idx);
122 *len = uio_iovlen(uio, idx);
126 uio_advance(uio_t *uio, size_t size)
128 uio->uio_resid -= size;
129 uio->uio_loffset += size;
132 static inline offset_t
133 uio_index_at_offset(uio_t *uio, offset_t off, uint_t *vec_idx)
136 while (*vec_idx < uio_iovcnt(uio) && off >= uio_iovlen(uio, *vec_idx)) {
137 off -= uio_iovlen(uio, *vec_idx);
144 #endif /* SPL_UIO_H */