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.
11 * The SPL is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
16 * The SPL is distributed in the hope that it will be useful, but WITHOUT
17 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 * You should have received a copy of the GNU General Public License along
22 * with the SPL. If not, see <http://www.gnu.org/licenses/>.
28 #include <sys/debug.h>
29 #include <linux/uio.h>
30 #include <linux/blkdev.h>
31 #include <linux/blkdev_compat.h>
33 #include <linux/bio.h>
34 #include <asm/uaccess.h>
35 #include <sys/types.h>
37 typedef struct iovec iovec_t;
44 typedef enum uio_seg {
53 const struct iovec *uio_iov;
54 const struct bio_vec *uio_bvec;
59 boolean_t uio_fault_disable;
67 typedef struct aio_req {
72 typedef enum xuio_type {
78 #define UIOA_IOV_MAX 16
80 typedef struct uioa_page_s {
89 enum xuio_type xu_type;
94 uioa_page_t *xu_a_lcur;
97 uioa_page_t xu_a_locked[UIOA_IOV_MAX];
107 #define XUIO_XUZC_PRIV(xuio) xuio->xu_ext.xu_zc.xu_zc_priv
108 #define XUIO_XUZC_RW(xuio) xuio->xu_ext.xu_zc.xu_zc_rw
110 #define uio_segflg(uio) (uio)->uio_segflg
111 #define uio_offset(uio) (uio)->uio_loffset
112 #define uio_resid(uio) (uio)->uio_resid
113 #define uio_iovcnt(uio) (uio)->uio_iovcnt
114 #define uio_iovlen(uio, idx) (uio)->uio_iov[(idx)].iov_len
115 #define uio_iovbase(uio, idx) (uio)->uio_iov[(idx)].iov_base
118 uio_iov_at_index(uio_t *uio, uint_t idx, void **base, uint64_t *len)
120 *base = uio_iovbase(uio, idx);
121 *len = uio_iovlen(uio, idx);
125 uio_advance(uio_t *uio, size_t size)
127 uio->uio_resid -= size;
128 uio->uio_loffset += size;
131 static inline offset_t
132 uio_index_at_offset(uio_t *uio, offset_t off, uint_t *vec_idx)
135 while (*vec_idx < uio_iovcnt(uio) && off >= uio_iovlen(uio, *vec_idx)) {
136 off -= uio_iovlen(uio, *vec_idx);
143 #endif /* SPL_UIO_H */