From 1dcdf8800ecb4be1888c9a3d57a0e5612b84ca32 Mon Sep 17 00:00:00 2001 From: Grady Wong Date: Thu, 4 Oct 2018 03:15:00 +0800 Subject: [PATCH] To re-run quota check when EFAULT in zfs_write Signed-off-by: Grady Wong --- include/sys/dmu.h | 2 +- module/zfs/dmu.c | 7 +++---- module/zfs/dmu_tx.c | 1 - module/zfs/zfs_sa.c | 4 ++-- module/zfs/zfs_vnops.c | 7 +++---- module/zfs/zvol.c | 3 +-- 6 files changed, 10 insertions(+), 14 deletions(-) diff --git a/include/sys/dmu.h b/include/sys/dmu.h index b2cb6bcf1755..bc7046fdced8 100644 --- a/include/sys/dmu.h +++ b/include/sys/dmu.h @@ -846,7 +846,7 @@ int dmu_write_uio(objset_t *os, uint64_t object, struct uio *uio, uint64_t size, int dmu_write_uio_dbuf(dmu_buf_t *zdb, struct uio *uio, uint64_t size, dmu_tx_t *tx); int dmu_write_uio_dnode(dnode_t *dn, struct uio *uio, uint64_t size, - dmu_tx_t *tx, boolean_t fault_disable); + dmu_tx_t *tx); #endif struct arc_buf *dmu_request_arcbuf(dmu_buf_t *handle, int size); void dmu_return_arcbuf(struct arc_buf *buf); diff --git a/module/zfs/dmu.c b/module/zfs/dmu.c index 96698b6f9ea2..8779eb3586ca 100644 --- a/module/zfs/dmu.c +++ b/module/zfs/dmu.c @@ -1488,8 +1488,7 @@ dmu_read_uio(objset_t *os, uint64_t object, uio_t *uio, uint64_t size) } int -dmu_write_uio_dnode(dnode_t *dn, uio_t *uio, uint64_t size, dmu_tx_t *tx, - boolean_t fault_disable) +dmu_write_uio_dnode(dnode_t *dn, uio_t *uio, uint64_t size, dmu_tx_t *tx) { dmu_buf_t **dbp; int numbufs; @@ -1562,7 +1561,7 @@ dmu_write_uio_dbuf(dmu_buf_t *zdb, uio_t *uio, uint64_t size, DB_DNODE_ENTER(db); dn = DB_DNODE(db); - err = dmu_write_uio_dnode(dn, uio, size, tx, B_TRUE); + err = dmu_write_uio_dnode(dn, uio, size, tx); DB_DNODE_EXIT(db); return (err); @@ -1587,7 +1586,7 @@ dmu_write_uio(objset_t *os, uint64_t object, uio_t *uio, uint64_t size, if (err) return (err); - err = dmu_write_uio_dnode(dn, uio, size, tx, B_FALSE); + err = dmu_write_uio_dnode(dn, uio, size, tx); dnode_rele(dn, FTAG); diff --git a/module/zfs/dmu_tx.c b/module/zfs/dmu_tx.c index 5bde56c18c2a..c268f3c40465 100644 --- a/module/zfs/dmu_tx.c +++ b/module/zfs/dmu_tx.c @@ -1040,7 +1040,6 @@ dmu_tx_assign(dmu_tx_t *tx, uint64_t txg_how) return (0); } - void dmu_tx_wait(dmu_tx_t *tx) { diff --git a/module/zfs/zfs_sa.c b/module/zfs/zfs_sa.c index a1dc7dc4ccb1..bd21ba896cc3 100644 --- a/module/zfs/zfs_sa.c +++ b/module/zfs/zfs_sa.c @@ -86,8 +86,8 @@ zfs_sa_readlink(znode_t *zp, uio_t *uio) dmu_buf_t *dbp; if ((error = dmu_buf_hold(ZTOZSB(zp)->z_os, zp->z_id, 0, FTAG, &dbp, DMU_READ_NO_PREFETCH)) == 0) { - error = uiomove(dbp->db_data, MIN((size_t)bufsz, - uio->uio_resid), UIO_READ, uio); + error = uiomove(dbp->db_data, + MIN((size_t)bufsz, uio->uio_resid), UIO_READ, uio); dmu_buf_rele(dbp, FTAG); } } diff --git a/module/zfs/zfs_vnops.c b/module/zfs/zfs_vnops.c index 37e414892d99..bb4257e76e4e 100644 --- a/module/zfs/zfs_vnops.c +++ b/module/zfs/zfs_vnops.c @@ -763,9 +763,7 @@ zfs_write(struct inode *ip, uio_t *uio, int ioflag, cred_t *cr) /* * Start a transaction. */ - dmu_tx_t *tx = NULL; -top: - tx = dmu_tx_create(zfsvfs->z_os); + dmu_tx_t *tx = dmu_tx_create(zfsvfs->z_os); dmu_tx_hold_sa(tx, zp->z_sa_hdl, B_FALSE); dmu_tx_hold_write(tx, zp->z_id, woff, MIN(n, max_blksz)); zfs_sa_upgrade_txholds(tx, zp); @@ -811,12 +809,13 @@ zfs_write(struct inode *ip, uio_t *uio, int ioflag, cred_t *cr) ssize_t tx_bytes; if (abuf == NULL) { tx_bytes = uio->uio_resid; + uio->uio_fault_disable = B_TRUE; error = dmu_write_uio_dbuf(sa_get_db(zp->z_sa_hdl), uio, nbytes, tx); if (error == EFAULT) { uio_prefaultpages(MIN(n, max_blksz), uio); dmu_tx_commit(tx); - goto top; + continue; } else if (error != 0) { dmu_tx_abort(tx); break; diff --git a/module/zfs/zvol.c b/module/zfs/zvol.c index 60cd43bbfc5d..f7706f14312f 100644 --- a/module/zfs/zvol.c +++ b/module/zfs/zvol.c @@ -769,8 +769,7 @@ zvol_write(void *arg) dmu_tx_abort(tx); break; } - error = dmu_write_uio_dnode(zv->zv_dn, &uio, bytes, tx, - B_FALSE); + error = dmu_write_uio_dnode(zv->zv_dn, &uio, bytes, tx); if (error == 0) { zvol_log_write(zv, tx, off, bytes, sync); }