diff --git a/include/sys/dmu.h b/include/sys/dmu.h index ec89e9018..9d61d94ee 100644 --- a/include/sys/dmu.h +++ b/include/sys/dmu.h @@ -744,6 +744,7 @@ struct arc_buf *dmu_request_arcbuf(dmu_buf_t *handle, int size); void dmu_return_arcbuf(struct arc_buf *buf); void dmu_assign_arcbuf(dmu_buf_t *handle, uint64_t offset, struct arc_buf *buf, dmu_tx_t *tx); +#ifdef HAVE_UIO_ZEROCOPY int dmu_xuio_init(struct xuio *uio, int niov); void dmu_xuio_fini(struct xuio *uio); int dmu_xuio_add(struct xuio *uio, struct arc_buf *abuf, offset_t off, @@ -751,6 +752,7 @@ int dmu_xuio_add(struct xuio *uio, struct arc_buf *abuf, offset_t off, int dmu_xuio_cnt(struct xuio *uio); struct arc_buf *dmu_xuio_arcbuf(struct xuio *uio, int i); void dmu_xuio_clear(struct xuio *uio, int i); +#endif /* HAVE_UIO_ZEROCOPY */ void xuio_stat_wbuf_copied(void); void xuio_stat_wbuf_nocopy(void); diff --git a/module/zfs/dmu.c b/module/zfs/dmu.c index 80185706c..7da49af7b 100644 --- a/module/zfs/dmu.c +++ b/module/zfs/dmu.c @@ -987,6 +987,7 @@ static xuio_stats_t xuio_stats = { atomic_add_64(&xuio_stats.stat.value.ui64, (val)) #define XUIOSTAT_BUMP(stat) XUIOSTAT_INCR(stat, 1) +#ifdef HAVE_UIO_ZEROCOPY int dmu_xuio_init(xuio_t *xuio, int nblk) { @@ -1071,6 +1072,7 @@ dmu_xuio_clear(xuio_t *xuio, int i) ASSERT(i < priv->cnt); priv->bufs[i] = NULL; } +#endif /* HAVE_UIO_ZEROCOPY */ static void xuio_stat_init(void) @@ -1111,7 +1113,9 @@ dmu_read_uio_dnode(dnode_t *dn, uio_t *uio, uint64_t size) { dmu_buf_t **dbp; int numbufs, i, err; +#ifdef HAVE_UIO_ZEROCOPY xuio_t *xuio = NULL; +#endif /* * NB: we could do this block-at-a-time, but it's nice @@ -1132,6 +1136,7 @@ dmu_read_uio_dnode(dnode_t *dn, uio_t *uio, uint64_t size) bufoff = uio->uio_loffset - db->db_offset; tocpy = MIN(db->db_size - bufoff, size); +#ifdef HAVE_UIO_ZEROCOPY if (xuio) { dmu_buf_impl_t *dbi = (dmu_buf_impl_t *)db; arc_buf_t *dbuf_abuf = dbi->db_buf; @@ -1146,10 +1151,10 @@ dmu_read_uio_dnode(dnode_t *dn, uio_t *uio, uint64_t size) XUIOSTAT_BUMP(xuiostat_rbuf_nocopy); else XUIOSTAT_BUMP(xuiostat_rbuf_copied); - } else { + } else +#endif err = uiomove((char *)db->db_data + bufoff, tocpy, UIO_READ, uio); - } if (err) break; diff --git a/module/zfs/zfs_vnops.c b/module/zfs/zfs_vnops.c index 116bb2730..8ac14df00 100644 --- a/module/zfs/zfs_vnops.c +++ b/module/zfs/zfs_vnops.c @@ -596,14 +596,16 @@ zfs_write(struct inode *ip, uio_t *uio, int ioflag, cred_t *cr) arc_buf_t *abuf; const iovec_t *aiov = NULL; xuio_t *xuio = NULL; - int i_iov = 0; - const iovec_t *iovp = uio->uio_iov; int write_eof; int count = 0; sa_bulk_attr_t bulk[4]; uint64_t mtime[2], ctime[2]; uint32_t uid; +#ifdef HAVE_UIO_ZEROCOPY + int i_iov = 0; + const iovec_t *iovp = uio->uio_iov; ASSERTV(int iovcnt = uio->uio_iovcnt); +#endif /* * Fasttrack empty write @@ -726,6 +728,7 @@ zfs_write(struct inode *ip, uio_t *uio, int ioflag, cred_t *cr) } if (xuio && abuf == NULL) { +#ifdef HAVE_UIO_ZEROCOPY ASSERT(i_iov < iovcnt); ASSERT3U(uio->uio_segflg, !=, UIO_BVEC); aiov = &iovp[i_iov]; @@ -735,6 +738,7 @@ zfs_write(struct inode *ip, uio_t *uio, int ioflag, cred_t *cr) ((char *)aiov->iov_base - (char *)abuf->b_data + aiov->iov_len == arc_buf_size(abuf))); i_iov++; +#endif } else if (abuf == NULL && n >= max_blksz && woff >= zp->z_size && P2PHASE(woff, max_blksz) == 0 &&