mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 18:40:43 +03:00
Remove UIO_ZEROCOPY functions structures
The original xuio zero copy functionality has always been unused on Linux and FreeBSD. Remove this disabled code to avoid any confusion and improve readability. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Ryan Moeller <ryan@iXsystems.com> Signed-off-by: Matt Macy <mmacy@FreeBSD.org> Closes #11124
This commit is contained in:
@@ -4211,164 +4211,6 @@ zfs_fid(struct inode *ip, fid_t *fidp)
|
||||
return (0);
|
||||
}
|
||||
|
||||
#ifdef HAVE_UIO_ZEROCOPY
|
||||
/*
|
||||
* The smallest read we may consider to loan out an arcbuf.
|
||||
* This must be a power of 2.
|
||||
*/
|
||||
int zcr_blksz_min = (1 << 10); /* 1K */
|
||||
/*
|
||||
* If set to less than the file block size, allow loaning out of an
|
||||
* arcbuf for a partial block read. This must be a power of 2.
|
||||
*/
|
||||
int zcr_blksz_max = (1 << 17); /* 128K */
|
||||
|
||||
|
||||
/*ARGSUSED*/
|
||||
static int
|
||||
zfs_reqzcbuf(struct inode *ip, enum uio_rw ioflag, xuio_t *xuio, cred_t *cr)
|
||||
{
|
||||
znode_t *zp = ITOZ(ip);
|
||||
zfsvfs_t *zfsvfs = ITOZSB(ip);
|
||||
int max_blksz = zfsvfs->z_max_blksz;
|
||||
uio_t *uio = &xuio->xu_uio;
|
||||
ssize_t size = uio->uio_resid;
|
||||
offset_t offset = uio->uio_loffset;
|
||||
int blksz;
|
||||
int fullblk, i;
|
||||
arc_buf_t *abuf;
|
||||
ssize_t maxsize;
|
||||
int preamble, postamble;
|
||||
|
||||
if (xuio->xu_type != UIOTYPE_ZEROCOPY)
|
||||
return (SET_ERROR(EINVAL));
|
||||
|
||||
ZFS_ENTER(zfsvfs);
|
||||
ZFS_VERIFY_ZP(zp);
|
||||
switch (ioflag) {
|
||||
case UIO_WRITE:
|
||||
/*
|
||||
* Loan out an arc_buf for write if write size is bigger than
|
||||
* max_blksz, and the file's block size is also max_blksz.
|
||||
*/
|
||||
blksz = max_blksz;
|
||||
if (size < blksz || zp->z_blksz != blksz) {
|
||||
ZFS_EXIT(zfsvfs);
|
||||
return (SET_ERROR(EINVAL));
|
||||
}
|
||||
/*
|
||||
* Caller requests buffers for write before knowing where the
|
||||
* write offset might be (e.g. NFS TCP write).
|
||||
*/
|
||||
if (offset == -1) {
|
||||
preamble = 0;
|
||||
} else {
|
||||
preamble = P2PHASE(offset, blksz);
|
||||
if (preamble) {
|
||||
preamble = blksz - preamble;
|
||||
size -= preamble;
|
||||
}
|
||||
}
|
||||
|
||||
postamble = P2PHASE(size, blksz);
|
||||
size -= postamble;
|
||||
|
||||
fullblk = size / blksz;
|
||||
(void) dmu_xuio_init(xuio,
|
||||
(preamble != 0) + fullblk + (postamble != 0));
|
||||
|
||||
/*
|
||||
* Have to fix iov base/len for partial buffers. They
|
||||
* currently represent full arc_buf's.
|
||||
*/
|
||||
if (preamble) {
|
||||
/* data begins in the middle of the arc_buf */
|
||||
abuf = dmu_request_arcbuf(sa_get_db(zp->z_sa_hdl),
|
||||
blksz);
|
||||
ASSERT(abuf);
|
||||
(void) dmu_xuio_add(xuio, abuf,
|
||||
blksz - preamble, preamble);
|
||||
}
|
||||
|
||||
for (i = 0; i < fullblk; i++) {
|
||||
abuf = dmu_request_arcbuf(sa_get_db(zp->z_sa_hdl),
|
||||
blksz);
|
||||
ASSERT(abuf);
|
||||
(void) dmu_xuio_add(xuio, abuf, 0, blksz);
|
||||
}
|
||||
|
||||
if (postamble) {
|
||||
/* data ends in the middle of the arc_buf */
|
||||
abuf = dmu_request_arcbuf(sa_get_db(zp->z_sa_hdl),
|
||||
blksz);
|
||||
ASSERT(abuf);
|
||||
(void) dmu_xuio_add(xuio, abuf, 0, postamble);
|
||||
}
|
||||
break;
|
||||
case UIO_READ:
|
||||
/*
|
||||
* Loan out an arc_buf for read if the read size is larger than
|
||||
* the current file block size. Block alignment is not
|
||||
* considered. Partial arc_buf will be loaned out for read.
|
||||
*/
|
||||
blksz = zp->z_blksz;
|
||||
if (blksz < zcr_blksz_min)
|
||||
blksz = zcr_blksz_min;
|
||||
if (blksz > zcr_blksz_max)
|
||||
blksz = zcr_blksz_max;
|
||||
/* avoid potential complexity of dealing with it */
|
||||
if (blksz > max_blksz) {
|
||||
ZFS_EXIT(zfsvfs);
|
||||
return (SET_ERROR(EINVAL));
|
||||
}
|
||||
|
||||
maxsize = zp->z_size - uio->uio_loffset;
|
||||
if (size > maxsize)
|
||||
size = maxsize;
|
||||
|
||||
if (size < blksz) {
|
||||
ZFS_EXIT(zfsvfs);
|
||||
return (SET_ERROR(EINVAL));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ZFS_EXIT(zfsvfs);
|
||||
return (SET_ERROR(EINVAL));
|
||||
}
|
||||
|
||||
uio->uio_extflg = UIO_XUIO;
|
||||
XUIO_XUZC_RW(xuio) = ioflag;
|
||||
ZFS_EXIT(zfsvfs);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
static int
|
||||
zfs_retzcbuf(struct inode *ip, xuio_t *xuio, cred_t *cr)
|
||||
{
|
||||
int i;
|
||||
arc_buf_t *abuf;
|
||||
int ioflag = XUIO_XUZC_RW(xuio);
|
||||
|
||||
ASSERT(xuio->xu_type == UIOTYPE_ZEROCOPY);
|
||||
|
||||
i = dmu_xuio_cnt(xuio);
|
||||
while (i-- > 0) {
|
||||
abuf = dmu_xuio_arcbuf(xuio, i);
|
||||
/*
|
||||
* if abuf == NULL, it must be a write buffer
|
||||
* that has been returned in zfs_write().
|
||||
*/
|
||||
if (abuf)
|
||||
dmu_return_arcbuf(abuf);
|
||||
ASSERT(abuf || ioflag == UIO_WRITE);
|
||||
}
|
||||
|
||||
dmu_xuio_fini(xuio);
|
||||
return (0);
|
||||
}
|
||||
#endif /* HAVE_UIO_ZEROCOPY */
|
||||
|
||||
#if defined(_KERNEL)
|
||||
EXPORT_SYMBOL(zfs_open);
|
||||
EXPORT_SYMBOL(zfs_close);
|
||||
|
||||
Reference in New Issue
Block a user