Skip to content

Commit

Permalink
Remove UIO_ZEROCOPY functions structures
Browse files Browse the repository at this point in the history
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 openzfs#11124
  • Loading branch information
mattmacy authored and tonyhutter committed Nov 13, 2021
1 parent 3fcf17e commit 6f59f64
Show file tree
Hide file tree
Showing 9 changed files with 0 additions and 454 deletions.
1 change: 0 additions & 1 deletion cmd/arc_summary/arc_summary3
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ SECTION_PATHS = {'arc': 'arcstats',
'dmu': 'dmu_tx',
'l2arc': 'arcstats', # L2ARC stuff lives in arcstats
'vdev': 'vdev_cache_stats',
'xuio': 'xuio_stats',
'zfetch': 'zfetchstats',
'zil': 'zil'}

Expand Down
21 changes: 0 additions & 21 deletions include/os/freebsd/spl/sys/uio.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,6 @@ typedef struct uio uio_t;
typedef struct iovec iovec_t;
typedef enum uio_seg uio_seg_t;

typedef enum xuio_type {
UIOTYPE_ASYNCIO,
UIOTYPE_ZEROCOPY
} xuio_type_t;

typedef struct xuio {
uio_t xu_uio;

/* Extended uio fields */
enum xuio_type xu_type; /* What kind of uio structure? */
union {
struct {
int xu_zc_rw;
void *xu_zc_priv;
} xu_zc;
} xu_ext;
} xuio_t;

#define XUIO_XUZC_PRIV(xuio) xuio->xu_ext.xu_zc.xu_zc_priv
#define XUIO_XUZC_RW(xuio) xuio->xu_ext.xu_zc.xu_zc_rw

static __inline int
zfs_uiomove(void *cp, size_t n, enum uio_rw dir, uio_t *uio)
{
Expand Down
43 changes: 0 additions & 43 deletions include/os/linux/spl/sys/uio.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,49 +68,6 @@ typedef struct uio {
size_t uio_skip;
} uio_t;

typedef struct aio_req {
uio_t *aio_uio;
void *aio_private;
} aio_req_t;

typedef enum xuio_type {
UIOTYPE_ASYNCIO,
UIOTYPE_ZEROCOPY,
} xuio_type_t;


#define UIOA_IOV_MAX 16

typedef struct uioa_page_s {
int uioa_pfncnt;
void **uioa_ppp;
caddr_t uioa_base;
size_t uioa_len;
} uioa_page_t;

typedef struct xuio {
uio_t xu_uio;
enum xuio_type xu_type;
union {
struct {
uint32_t xu_a_state;
ssize_t xu_a_mbytes;
uioa_page_t *xu_a_lcur;
void **xu_a_lppp;
void *xu_a_hwst[4];
uioa_page_t xu_a_locked[UIOA_IOV_MAX];
} xu_aio;

struct {
int xu_zc_rw;
void *xu_zc_priv;
} xu_zc;
} xu_ext;
} xuio_t;

#define XUIO_XUZC_PRIV(xuio) xuio->xu_ext.xu_zc.xu_zc_priv
#define XUIO_XUZC_RW(xuio) xuio->xu_ext.xu_zc.xu_zc_rw

#define uio_segflg(uio) (uio)->uio_segflg
#define uio_offset(uio) (uio)->uio_loffset
#define uio_resid(uio) (uio)->uio_resid
Expand Down
12 changes: 0 additions & 12 deletions include/sys/dmu.h
Original file line number Diff line number Diff line change
Expand Up @@ -864,18 +864,6 @@ int dmu_assign_arcbuf_by_dnode(dnode_t *dn, uint64_t offset,
int dmu_assign_arcbuf_by_dbuf(dmu_buf_t *handle, uint64_t offset,
struct arc_buf *buf, dmu_tx_t *tx);
#define dmu_assign_arcbuf dmu_assign_arcbuf_by_dbuf
#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,
size_t n);
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);

extern int zfs_prefetch_disable;
extern int zfs_max_recordsize;

Expand Down
7 changes: 0 additions & 7 deletions include/sys/dmu_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,13 +237,6 @@ extern "C" {
struct objset;
struct dmu_pool;

typedef struct dmu_xuio {
int next;
int cnt;
struct arc_buf **bufs;
iovec_t *iovp;
} dmu_xuio_t;

typedef struct dmu_sendstatus {
list_node_t dss_link;
int dss_outfd;
Expand Down
39 changes: 0 additions & 39 deletions lib/libspl/include/sys/uio.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,45 +75,6 @@ typedef struct uio {
ssize_t uio_resid; /* residual count */
} uio_t;

typedef enum xuio_type {
UIOTYPE_ASYNCIO,
UIOTYPE_ZEROCOPY,
} xuio_type_t;

#define UIOA_IOV_MAX 16

typedef struct uioa_page_s { /* locked uio_iov state */
int uioa_pfncnt; /* count of pfn_t(s) in *uioa_ppp */
void **uioa_ppp; /* page_t or pfn_t array */
caddr_t uioa_base; /* address base */
size_t uioa_len; /* span length */
} uioa_page_t;

typedef struct xuio {
uio_t xu_uio; /* embedded UIO structure */

/* Extended uio fields */
enum xuio_type xu_type; /* uio type */
union {
struct {
uint32_t xu_a_state; /* state of async i/o */
ssize_t xu_a_mbytes; /* bytes moved */
uioa_page_t *xu_a_lcur; /* uioa_locked[] pointer */
void **xu_a_lppp; /* lcur->uioa_pppp[] pointer */
void *xu_a_hwst[4]; /* opaque hardware state */
uioa_page_t xu_a_locked[UIOA_IOV_MAX];
} xu_aio;

struct {
int xu_zc_rw; /* read or write buffer */
void *xu_zc_priv; /* fs specific */
} xu_zc;
} xu_ext;
} xuio_t;

#define XUIO_XUZC_PRIV(xuio) xuio->xu_ext.xu_zc.xu_zc_priv
#define XUIO_XUZC_RW(xuio) xuio->xu_ext.xu_zc.xu_zc_rw

#define uio_segflg(uio) (uio)->uio_segflg
#define uio_offset(uio) (uio)->uio_loffset
#define uio_resid(uio) (uio)->uio_resid
Expand Down
158 changes: 0 additions & 158 deletions module/os/linux/zfs/zfs_vnops_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -3978,164 +3978,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);
Expand Down
2 changes: 0 additions & 2 deletions module/zfs/dbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -2617,11 +2617,9 @@ dbuf_assign_arcbuf(dmu_buf_impl_t *db, arc_buf_t *buf, dmu_tx_t *tx)
(void) dbuf_dirty(db, tx);
bcopy(buf->b_data, db->db.db_data, db->db.db_size);
arc_buf_destroy(buf, db);
xuio_stat_wbuf_copied();
return;
}

xuio_stat_wbuf_nocopy();
if (db->db_state == DB_CACHED) {
dbuf_dirty_record_t *dr = list_head(&db->db_dirty_records);

Expand Down
Loading

0 comments on commit 6f59f64

Please sign in to comment.