Changeset View
Changeset View
Standalone View
Standalone View
sys/contrib/openzfs/module/os/linux/zfs/zpl_file.c
Show First 20 Lines • Show All 236 Lines • ▼ Show 20 Lines | |||||
/* | /* | ||||
* When HAVE_VFS_IOV_ITER is defined the iov_iter structure supports | * When HAVE_VFS_IOV_ITER is defined the iov_iter structure supports | ||||
* iovecs, kvevs, bvecs and pipes, plus all the required interfaces to | * iovecs, kvevs, bvecs and pipes, plus all the required interfaces to | ||||
* manipulate the iov_iter are available. In which case the full iov_iter | * manipulate the iov_iter are available. In which case the full iov_iter | ||||
* can be attached to the uio and correctly handled in the lower layers. | * can be attached to the uio and correctly handled in the lower layers. | ||||
* Otherwise, for older kernels extract the iovec and pass it instead. | * Otherwise, for older kernels extract the iovec and pass it instead. | ||||
*/ | */ | ||||
static void | static void | ||||
zpl_uio_init(uio_t *uio, struct kiocb *kiocb, struct iov_iter *to, | zpl_uio_init(zfs_uio_t *uio, struct kiocb *kiocb, struct iov_iter *to, | ||||
loff_t pos, ssize_t count, size_t skip) | loff_t pos, ssize_t count, size_t skip) | ||||
{ | { | ||||
#if defined(HAVE_VFS_IOV_ITER) | #if defined(HAVE_VFS_IOV_ITER) | ||||
uio_iov_iter_init(uio, to, pos, count, skip); | zfs_uio_iov_iter_init(uio, to, pos, count, skip); | ||||
#else | #else | ||||
uio_iovec_init(uio, to->iov, to->nr_segs, pos, | zfs_uio_iovec_init(uio, to->iov, to->nr_segs, pos, | ||||
to->type & ITER_KVEC ? UIO_SYSSPACE : UIO_USERSPACE, | to->type & ITER_KVEC ? UIO_SYSSPACE : UIO_USERSPACE, | ||||
count, skip); | count, skip); | ||||
#endif | #endif | ||||
} | } | ||||
static ssize_t | static ssize_t | ||||
zpl_iter_read(struct kiocb *kiocb, struct iov_iter *to) | zpl_iter_read(struct kiocb *kiocb, struct iov_iter *to) | ||||
{ | { | ||||
cred_t *cr = CRED(); | cred_t *cr = CRED(); | ||||
fstrans_cookie_t cookie; | fstrans_cookie_t cookie; | ||||
struct file *filp = kiocb->ki_filp; | struct file *filp = kiocb->ki_filp; | ||||
ssize_t count = iov_iter_count(to); | ssize_t count = iov_iter_count(to); | ||||
uio_t uio; | zfs_uio_t uio; | ||||
zpl_uio_init(&uio, kiocb, to, kiocb->ki_pos, count, 0); | zpl_uio_init(&uio, kiocb, to, kiocb->ki_pos, count, 0); | ||||
crhold(cr); | crhold(cr); | ||||
cookie = spl_fstrans_mark(); | cookie = spl_fstrans_mark(); | ||||
int error = -zfs_read(ITOZ(filp->f_mapping->host), &uio, | int error = -zfs_read(ITOZ(filp->f_mapping->host), &uio, | ||||
filp->f_flags | zfs_io_flags(kiocb), cr); | filp->f_flags | zfs_io_flags(kiocb), cr); | ||||
Show All 39 Lines | |||||
static ssize_t | static ssize_t | ||||
zpl_iter_write(struct kiocb *kiocb, struct iov_iter *from) | zpl_iter_write(struct kiocb *kiocb, struct iov_iter *from) | ||||
{ | { | ||||
cred_t *cr = CRED(); | cred_t *cr = CRED(); | ||||
fstrans_cookie_t cookie; | fstrans_cookie_t cookie; | ||||
struct file *filp = kiocb->ki_filp; | struct file *filp = kiocb->ki_filp; | ||||
struct inode *ip = filp->f_mapping->host; | struct inode *ip = filp->f_mapping->host; | ||||
uio_t uio; | zfs_uio_t uio; | ||||
size_t count = 0; | size_t count = 0; | ||||
ssize_t ret; | ssize_t ret; | ||||
ret = zpl_generic_write_checks(kiocb, from, &count); | ret = zpl_generic_write_checks(kiocb, from, &count); | ||||
if (ret) | if (ret) | ||||
return (ret); | return (ret); | ||||
zpl_uio_init(&uio, kiocb, from, kiocb->ki_pos, count, from->iov_offset); | zpl_uio_init(&uio, kiocb, from, kiocb->ki_pos, count, from->iov_offset); | ||||
Show All 30 Lines | zpl_aio_read(struct kiocb *kiocb, const struct iovec *iov, | ||||
struct file *filp = kiocb->ki_filp; | struct file *filp = kiocb->ki_filp; | ||||
size_t count; | size_t count; | ||||
ssize_t ret; | ssize_t ret; | ||||
ret = generic_segment_checks(iov, &nr_segs, &count, VERIFY_WRITE); | ret = generic_segment_checks(iov, &nr_segs, &count, VERIFY_WRITE); | ||||
if (ret) | if (ret) | ||||
return (ret); | return (ret); | ||||
uio_t uio; | zfs_uio_t uio; | ||||
uio_iovec_init(&uio, iov, nr_segs, kiocb->ki_pos, UIO_USERSPACE, | zfs_uio_iovec_init(&uio, iov, nr_segs, kiocb->ki_pos, UIO_USERSPACE, | ||||
count, 0); | count, 0); | ||||
crhold(cr); | crhold(cr); | ||||
cookie = spl_fstrans_mark(); | cookie = spl_fstrans_mark(); | ||||
int error = -zfs_read(ITOZ(filp->f_mapping->host), &uio, | int error = -zfs_read(ITOZ(filp->f_mapping->host), &uio, | ||||
filp->f_flags | zfs_io_flags(kiocb), cr); | filp->f_flags | zfs_io_flags(kiocb), cr); | ||||
Show All 25 Lines | zpl_aio_write(struct kiocb *kiocb, const struct iovec *iov, | ||||
ret = generic_segment_checks(iov, &nr_segs, &count, VERIFY_READ); | ret = generic_segment_checks(iov, &nr_segs, &count, VERIFY_READ); | ||||
if (ret) | if (ret) | ||||
return (ret); | return (ret); | ||||
ret = generic_write_checks(filp, &pos, &count, S_ISBLK(ip->i_mode)); | ret = generic_write_checks(filp, &pos, &count, S_ISBLK(ip->i_mode)); | ||||
if (ret) | if (ret) | ||||
return (ret); | return (ret); | ||||
uio_t uio; | zfs_uio_t uio; | ||||
uio_iovec_init(&uio, iov, nr_segs, kiocb->ki_pos, UIO_USERSPACE, | zfs_uio_iovec_init(&uio, iov, nr_segs, kiocb->ki_pos, UIO_USERSPACE, | ||||
count, 0); | count, 0); | ||||
crhold(cr); | crhold(cr); | ||||
cookie = spl_fstrans_mark(); | cookie = spl_fstrans_mark(); | ||||
int error = -zfs_write(ITOZ(ip), &uio, | int error = -zfs_write(ITOZ(ip), &uio, | ||||
filp->f_flags | zfs_io_flags(kiocb), cr); | filp->f_flags | zfs_io_flags(kiocb), cr); | ||||
▲ Show 20 Lines • Show All 650 Lines • Show Last 20 Lines |