summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormm <mm@FreeBSD.org>2013-03-12 21:46:29 +0000
committermm <mm@FreeBSD.org>2013-03-12 21:46:29 +0000
commit527a129440798a212313abbdaf086ba9f73eec52 (patch)
treece16be33fb431f47f57fbba7e4183e4128293e3d
parentcabc494cc19627efb1289b18b58da6d30faacd4d (diff)
downloadFreeBSD-src-527a129440798a212313abbdaf086ba9f73eec52.zip
FreeBSD-src-527a129440798a212313abbdaf086ba9f73eec52.tar.gz
Update vendor/illumos/dist and vendor-sys/illumos/dist
to illumos-gate 13980:d7059eb1884c Illumos ZFS issues: 3598 want to dtrace when errors are generated in zfs
-rw-r--r--uts/common/fs/zfs/arc.c16
-rw-r--r--uts/common/fs/zfs/dbuf.c12
-rw-r--r--uts/common/fs/zfs/ddt.c8
-rw-r--r--uts/common/fs/zfs/dmu.c31
-rw-r--r--uts/common/fs/zfs/dmu_diff.c10
-rw-r--r--uts/common/fs/zfs/dmu_object.c5
-rw-r--r--uts/common/fs/zfs/dmu_objset.c46
-rw-r--r--uts/common/fs/zfs/dmu_send.c118
-rw-r--r--uts/common/fs/zfs/dmu_traverse.c4
-rw-r--r--uts/common/fs/zfs/dmu_tx.c10
-rw-r--r--uts/common/fs/zfs/dnode.c28
-rw-r--r--uts/common/fs/zfs/dsl_dataset.c82
-rw-r--r--uts/common/fs/zfs/dsl_deleg.c20
-rw-r--r--uts/common/fs/zfs/dsl_destroy.c22
-rw-r--r--uts/common/fs/zfs/dsl_dir.c38
-rw-r--r--uts/common/fs/zfs/dsl_pool.c6
-rw-r--r--uts/common/fs/zfs/dsl_prop.c16
-rw-r--r--uts/common/fs/zfs/dsl_scan.c8
-rw-r--r--uts/common/fs/zfs/dsl_synctask.c4
-rw-r--r--uts/common/fs/zfs/dsl_userhold.c18
-rw-r--r--uts/common/fs/zfs/metaslab.c12
-rw-r--r--uts/common/fs/zfs/sa.c16
-rw-r--r--uts/common/fs/zfs/spa.c112
-rw-r--r--uts/common/fs/zfs/spa_errlog.c9
-rw-r--r--uts/common/fs/zfs/spa_history.c6
-rw-r--r--uts/common/fs/zfs/spa_misc.c4
-rw-r--r--uts/common/fs/zfs/uberblock.c3
-rw-r--r--uts/common/fs/zfs/vdev.c50
-rw-r--r--uts/common/fs/zfs/vdev_cache.c13
-rw-r--r--uts/common/fs/zfs/vdev_disk.c26
-rw-r--r--uts/common/fs/zfs/vdev_file.c12
-rw-r--r--uts/common/fs/zfs/vdev_label.c8
-rw-r--r--uts/common/fs/zfs/vdev_mirror.c10
-rw-r--r--uts/common/fs/zfs/vdev_missing.c4
-rw-r--r--uts/common/fs/zfs/vdev_raidz.c14
-rw-r--r--uts/common/fs/zfs/vdev_root.c4
-rw-r--r--uts/common/fs/zfs/zap.c18
-rw-r--r--uts/common/fs/zfs/zap_leaf.c13
-rw-r--r--uts/common/fs/zfs/zap_micro.c45
-rw-r--r--uts/common/fs/zfs/zfeature.c14
-rw-r--r--uts/common/fs/zfs/zfs_acl.c37
-rw-r--r--uts/common/fs/zfs/zfs_ctldir.c44
-rw-r--r--uts/common/fs/zfs/zfs_dir.c27
-rw-r--r--uts/common/fs/zfs/zfs_ioctl.c290
-rw-r--r--uts/common/fs/zfs/zfs_onexit.c9
-rw-r--r--uts/common/fs/zfs/zfs_replay.c9
-rw-r--r--uts/common/fs/zfs/zfs_vfsops.c66
-rw-r--r--uts/common/fs/zfs/zfs_vnops.c186
-rw-r--r--uts/common/fs/zfs/zfs_znode.c18
-rw-r--r--uts/common/fs/zfs/zil.c12
-rw-r--r--uts/common/fs/zfs/zio.c12
-rw-r--r--uts/common/fs/zfs/zio_checksum.c9
-rw-r--r--uts/common/fs/zfs/zio_compress.c6
-rw-r--r--uts/common/fs/zfs/zio_inject.c10
-rw-r--r--uts/common/fs/zfs/zvol.c104
55 files changed, 875 insertions, 859 deletions
diff --git a/uts/common/fs/zfs/arc.c b/uts/common/fs/zfs/arc.c
index 9588e40..0d33c5e 100644
--- a/uts/common/fs/zfs/arc.c
+++ b/uts/common/fs/zfs/arc.c
@@ -21,7 +21,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
/*
@@ -3466,14 +3466,14 @@ arc_memory_throttle(uint64_t reserve, uint64_t inflight_data, uint64_t txg)
*/
if (curproc == proc_pageout) {
if (page_load > MAX(ptob(minfree), available_memory) / 4)
- return (ERESTART);
+ return (SET_ERROR(ERESTART));
/* Note: reserve is inflated, so we deflate */
page_load += reserve / 8;
return (0);
} else if (page_load > 0 && arc_reclaim_needed()) {
/* memory is low, delay before restarting */
ARCSTAT_INCR(arcstat_memory_throttle_count, 1);
- return (EAGAIN);
+ return (SET_ERROR(EAGAIN));
}
page_load = 0;
@@ -3488,7 +3488,7 @@ arc_memory_throttle(uint64_t reserve, uint64_t inflight_data, uint64_t txg)
if (inflight_data > available_memory / 4) {
ARCSTAT_INCR(arcstat_memory_throttle_count, 1);
- return (ERESTART);
+ return (SET_ERROR(ERESTART));
}
#endif
return (0);
@@ -3513,13 +3513,13 @@ arc_tempreserve_space(uint64_t reserve, uint64_t txg)
*/
if (spa_get_random(10000) == 0) {
dprintf("forcing random failure\n");
- return (ERESTART);
+ return (SET_ERROR(ERESTART));
}
#endif
if (reserve > arc_c/4 && !arc_no_grow)
arc_c = MIN(arc_c_max, reserve * 4);
if (reserve > arc_c)
- return (ENOMEM);
+ return (SET_ERROR(ENOMEM));
/*
* Don't count loaned bufs as in flight dirty data to prevent long
@@ -3552,7 +3552,7 @@ arc_tempreserve_space(uint64_t reserve, uint64_t txg)
arc_anon->arcs_lsize[ARC_BUFC_METADATA]>>10,
arc_anon->arcs_lsize[ARC_BUFC_DATA]>>10,
reserve>>10, arc_c>>10);
- return (ERESTART);
+ return (SET_ERROR(ERESTART));
}
atomic_add_64(&arc_tempreserve, reserve);
return (0);
@@ -4145,7 +4145,7 @@ l2arc_read_done(zio_t *zio)
if (zio->io_error != 0) {
ARCSTAT_BUMP(arcstat_l2_io_error);
} else {
- zio->io_error = EIO;
+ zio->io_error = SET_ERROR(EIO);
}
if (!equal)
ARCSTAT_BUMP(arcstat_l2_cksum_bad);
diff --git a/uts/common/fs/zfs/dbuf.c b/uts/common/fs/zfs/dbuf.c
index 57abfa1..1572acb 100644
--- a/uts/common/fs/zfs/dbuf.c
+++ b/uts/common/fs/zfs/dbuf.c
@@ -21,7 +21,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
#include <sys/zfs_context.h>
@@ -598,7 +598,7 @@ dbuf_read(dmu_buf_impl_t *db, zio_t *zio, uint32_t flags)
ASSERT(!refcount_is_zero(&db->db_holds));
if (db->db_state == DB_NOFILL)
- return (EIO);
+ return (SET_ERROR(EIO));
DB_DNODE_ENTER(db);
dn = DB_DNODE(db);
@@ -655,7 +655,7 @@ dbuf_read(dmu_buf_impl_t *db, zio_t *zio, uint32_t flags)
cv_wait(&db->db_changed, &db->db_mtx);
}
if (db->db_state == DB_UNCACHED)
- err = EIO;
+ err = SET_ERROR(EIO);
}
mutex_exit(&db->db_mtx);
}
@@ -1593,7 +1593,7 @@ dbuf_findbp(dnode_t *dn, int level, uint64_t blkid, int fail_sparse,
if (level >= nlevels ||
(blkid > (dn->dn_phys->dn_maxblkid >> (level * epbs)))) {
/* the buffer has no parent yet */
- return (ENOENT);
+ return (SET_ERROR(ENOENT));
} else if (level < nlevels-1) {
/* this block is referenced from an indirect block */
int err = dbuf_hold_impl(dn, level+1,
@@ -1844,7 +1844,7 @@ top:
err = dbuf_findbp(dn, level, blkid, fail_sparse, &parent, &bp);
if (fail_sparse) {
if (err == 0 && bp && BP_IS_HOLE(bp))
- err = ENOENT;
+ err = SET_ERROR(ENOENT);
if (err) {
if (parent)
dbuf_rele(parent, NULL);
@@ -1941,7 +1941,7 @@ dbuf_spill_set_blksz(dmu_buf_t *db_fake, uint64_t blksz, dmu_tx_t *tx)
dnode_t *dn;
if (db->db_blkid != DMU_SPILL_BLKID)
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
if (blksz == 0)
blksz = SPA_MINBLOCKSIZE;
if (blksz > SPA_MAXBLOCKSIZE)
diff --git a/uts/common/fs/zfs/ddt.c b/uts/common/fs/zfs/ddt.c
index b3ec3cc..be88ec0 100644
--- a/uts/common/fs/zfs/ddt.c
+++ b/uts/common/fs/zfs/ddt.c
@@ -21,7 +21,7 @@
/*
* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
#include <sys/zfs_context.h>
@@ -160,7 +160,7 @@ ddt_object_lookup(ddt_t *ddt, enum ddt_type type, enum ddt_class class,
ddt_entry_t *dde)
{
if (!ddt_object_exists(ddt, type, class))
- return (ENOENT);
+ return (SET_ERROR(ENOENT));
return (ddt_ops[type]->ddt_op_lookup(ddt->ddt_os,
ddt->ddt_object[type][class], dde));
@@ -221,7 +221,7 @@ ddt_object_info(ddt_t *ddt, enum ddt_type type, enum ddt_class class,
dmu_object_info_t *doi)
{
if (!ddt_object_exists(ddt, type, class))
- return (ENOENT);
+ return (SET_ERROR(ENOENT));
return (dmu_object_info(ddt->ddt_os, ddt->ddt_object[type][class],
doi));
@@ -1141,5 +1141,5 @@ ddt_walk(spa_t *spa, ddt_bookmark_t *ddb, ddt_entry_t *dde)
ddb->ddb_type = 0;
} while (++ddb->ddb_class < DDT_CLASSES);
- return (ENOENT);
+ return (SET_ERROR(ENOENT));
}
diff --git a/uts/common/fs/zfs/dmu.c b/uts/common/fs/zfs/dmu.c
index 3e09873..00eddac 100644
--- a/uts/common/fs/zfs/dmu.c
+++ b/uts/common/fs/zfs/dmu.c
@@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
#include <sys/dmu.h>
@@ -143,7 +143,7 @@ dmu_buf_hold(objset_t *os, uint64_t object, uint64_t offset,
db = dbuf_hold(dn, blkid, tag);
rw_exit(&dn->dn_struct_rwlock);
if (db == NULL) {
- err = EIO;
+ err = SET_ERROR(EIO);
} else {
err = dbuf_read(db, NULL, db_flags);
if (err) {
@@ -174,9 +174,9 @@ dmu_set_bonus(dmu_buf_t *db_fake, int newsize, dmu_tx_t *tx)
dn = DB_DNODE(db);
if (dn->dn_bonus != db) {
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
} else if (newsize < 0 || newsize > db_fake->db_size) {
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
} else {
dnode_setbonuslen(dn, newsize, tx);
error = 0;
@@ -197,9 +197,9 @@ dmu_set_bonustype(dmu_buf_t *db_fake, dmu_object_type_t type, dmu_tx_t *tx)
dn = DB_DNODE(db);
if (!DMU_OT_IS_VALID(type)) {
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
} else if (dn->dn_bonus != db) {
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
} else {
dnode_setbonus_type(dn, type, tx);
error = 0;
@@ -326,12 +326,12 @@ dmu_spill_hold_existing(dmu_buf_t *bonus, void *tag, dmu_buf_t **dbp)
dn = DB_DNODE(db);
if (spa_version(dn->dn_objset->os_spa) < SPA_VERSION_SA) {
- err = EINVAL;
+ err = SET_ERROR(EINVAL);
} else {
rw_enter(&dn->dn_struct_rwlock, RW_READER);
if (!dn->dn_have_spill) {
- err = ENOENT;
+ err = SET_ERROR(ENOENT);
} else {
err = dmu_spill_hold_by_dnode(dn,
DB_RF_HAVESTRUCT | DB_RF_CANFAIL, tag, dbp);
@@ -397,7 +397,7 @@ dmu_buf_hold_array_by_dnode(dnode_t *dn, uint64_t offset, uint64_t length,
(longlong_t)dn->dn_object, dn->dn_datablksz,
(longlong_t)offset, (longlong_t)length);
rw_exit(&dn->dn_struct_rwlock);
- return (EIO);
+ return (SET_ERROR(EIO));
}
nblks = 1;
}
@@ -414,7 +414,7 @@ dmu_buf_hold_array_by_dnode(dnode_t *dn, uint64_t offset, uint64_t length,
rw_exit(&dn->dn_struct_rwlock);
dmu_buf_rele_array(dbp, nblks, tag);
zio_nowait(zio);
- return (EIO);
+ return (SET_ERROR(EIO));
}
/* initiate async i/o */
if (read) {
@@ -443,7 +443,7 @@ dmu_buf_hold_array_by_dnode(dnode_t *dn, uint64_t offset, uint64_t length,
db->db_state == DB_FILL)
cv_wait(&db->db_changed, &db->db_mtx);
if (db->db_state == DB_UNCACHED)
- err = EIO;
+ err = SET_ERROR(EIO);
mutex_exit(&db->db_mtx);
if (err) {
dmu_buf_rele_array(dbp, nblks, tag);
@@ -1353,7 +1353,8 @@ dmu_sync_late_arrival(zio_t *pio, objset_t *os, dmu_sync_cb_t *done, zgd_t *zgd,
dmu_tx_hold_space(tx, zgd->zgd_db->db_size);
if (dmu_tx_assign(tx, TXG_WAIT) != 0) {
dmu_tx_abort(tx);
- return (EIO); /* Make zl_get_data do txg_waited_synced() */
+ /* Make zl_get_data do txg_waited_synced() */
+ return (SET_ERROR(EIO));
}
dsa = kmem_alloc(sizeof (dmu_sync_arg_t), KM_SLEEP);
@@ -1438,7 +1439,7 @@ dmu_sync(zio_t *pio, uint64_t txg, dmu_sync_cb_t *done, zgd_t *zgd)
* This txg has already synced. There's nothing to do.
*/
mutex_exit(&db->db_mtx);
- return (EEXIST);
+ return (SET_ERROR(EEXIST));
}
if (txg <= spa_syncing_txg(os->os_spa)) {
@@ -1460,7 +1461,7 @@ dmu_sync(zio_t *pio, uint64_t txg, dmu_sync_cb_t *done, zgd_t *zgd)
* There's no need to log writes to freed blocks, so we're done.
*/
mutex_exit(&db->db_mtx);
- return (ENOENT);
+ return (SET_ERROR(ENOENT));
}
ASSERT(dr->dr_next == NULL || dr->dr_next->dr_txg < txg);
@@ -1489,7 +1490,7 @@ dmu_sync(zio_t *pio, uint64_t txg, dmu_sync_cb_t *done, zgd_t *zgd)
* have been dirtied since, or we would have cleared the state.
*/
mutex_exit(&db->db_mtx);
- return (EALREADY);
+ return (SET_ERROR(EALREADY));
}
ASSERT(dr->dt.dl.dr_override_state == DR_NOT_OVERRIDDEN);
diff --git a/uts/common/fs/zfs/dmu_diff.c b/uts/common/fs/zfs/dmu_diff.c
index 2d1aaa4..a2cb2fc 100644
--- a/uts/common/fs/zfs/dmu_diff.c
+++ b/uts/common/fs/zfs/dmu_diff.c
@@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
#include <sys/dmu.h>
@@ -113,7 +113,7 @@ diff_cb(spa_t *spa, zilog_t *zilog, const blkptr_t *bp,
int err = 0;
if (issig(JUSTLOOKING) && issig(FORREAL))
- return (EINTR);
+ return (SET_ERROR(EINTR));
if (zb->zb_object != DMU_META_DNODE_OBJECT)
return (0);
@@ -136,7 +136,7 @@ diff_cb(spa_t *spa, zilog_t *zilog, const blkptr_t *bp,
if (arc_read(NULL, spa, bp, arc_getbuf_func, &abuf,
ZIO_PRIORITY_ASYNC_READ, ZIO_FLAG_CANFAIL,
&aflags, zb) != 0)
- return (EIO);
+ return (SET_ERROR(EIO));
blk = abuf->b_data;
for (i = 0; i < blksz >> DNODE_SHIFT; i++) {
@@ -168,7 +168,7 @@ dmu_diff(const char *tosnap_name, const char *fromsnap_name,
if (strchr(tosnap_name, '@') == NULL ||
strchr(fromsnap_name, '@') == NULL)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
error = dsl_pool_hold(tosnap_name, FTAG, &dp);
if (error != 0)
@@ -191,7 +191,7 @@ dmu_diff(const char *tosnap_name, const char *fromsnap_name,
dsl_dataset_rele(fromsnap, FTAG);
dsl_dataset_rele(tosnap, FTAG);
dsl_pool_rele(dp, FTAG);
- return (EXDEV);
+ return (SET_ERROR(EXDEV));
}
fromtxg = fromsnap->ds_phys->ds_creation_txg;
diff --git a/uts/common/fs/zfs/dmu_object.c b/uts/common/fs/zfs/dmu_object.c
index 8dff460..11561f2 100644
--- a/uts/common/fs/zfs/dmu_object.c
+++ b/uts/common/fs/zfs/dmu_object.c
@@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
#include <sys/dmu.h>
@@ -90,7 +91,7 @@ dmu_object_claim(objset_t *os, uint64_t object, dmu_object_type_t ot,
int err;
if (object == DMU_META_DNODE_OBJECT && !dmu_tx_private_ok(tx))
- return (EBADF);
+ return (SET_ERROR(EBADF));
err = dnode_hold_impl(os, object, DNODE_MUST_BE_FREE, FTAG, &dn);
if (err)
@@ -112,7 +113,7 @@ dmu_object_reclaim(objset_t *os, uint64_t object, dmu_object_type_t ot,
int err;
if (object == DMU_META_DNODE_OBJECT)
- return (EBADF);
+ return (SET_ERROR(EBADF));
err = dnode_hold_impl(os, object, DNODE_MUST_BE_ALLOCATED,
FTAG, &dn);
diff --git a/uts/common/fs/zfs/dmu_objset.c b/uts/common/fs/zfs/dmu_objset.c
index a646f40..4f8c265 100644
--- a/uts/common/fs/zfs/dmu_objset.c
+++ b/uts/common/fs/zfs/dmu_objset.c
@@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
/* Portions Copyright 2010 Robert Milkowski */
@@ -285,7 +285,7 @@ dmu_objset_open_impl(spa_t *spa, dsl_dataset_t *ds, blkptr_t *bp,
kmem_free(os, sizeof (objset_t));
/* convert checksum errors into IO errors */
if (err == ECKSUM)
- err = EIO;
+ err = SET_ERROR(EIO);
return (err);
}
@@ -498,10 +498,10 @@ dmu_objset_own(const char *name, dmu_objset_type_t type,
dsl_dataset_disown(ds, tag);
} else if (type != DMU_OST_ANY && type != (*osp)->os_phys->os_type) {
dsl_dataset_disown(ds, tag);
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
} else if (!readonly && dsl_dataset_is_snapshot(ds)) {
dsl_dataset_disown(ds, tag);
- return (EROFS);
+ return (SET_ERROR(EROFS));
}
return (err);
}
@@ -714,14 +714,14 @@ dmu_objset_create_check(void *arg, dmu_tx_t *tx)
int error;
if (strchr(doca->doca_name, '@') != NULL)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
error = dsl_dir_hold(dp, doca->doca_name, FTAG, &pdd, &tail);
if (error != 0)
return (error);
if (tail == NULL) {
dsl_dir_rele(pdd, FTAG);
- return (EEXIST);
+ return (SET_ERROR(EEXIST));
}
dsl_dir_rele(pdd, FTAG);
@@ -795,19 +795,19 @@ dmu_objset_clone_check(void *arg, dmu_tx_t *tx)
dsl_pool_t *dp = dmu_tx_pool(tx);
if (strchr(doca->doca_clone, '@') != NULL)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
error = dsl_dir_hold(dp, doca->doca_clone, FTAG, &pdd, &tail);
if (error != 0)
return (error);
if (tail == NULL) {
dsl_dir_rele(pdd, FTAG);
- return (EEXIST);
+ return (SET_ERROR(EEXIST));
}
/* You can't clone across pools. */
if (pdd->dd_pool != dp) {
dsl_dir_rele(pdd, FTAG);
- return (EXDEV);
+ return (SET_ERROR(EXDEV));
}
dsl_dir_rele(pdd, FTAG);
@@ -818,13 +818,13 @@ dmu_objset_clone_check(void *arg, dmu_tx_t *tx)
/* You can't clone across pools. */
if (origin->ds_dir->dd_pool != dp) {
dsl_dataset_rele(origin, FTAG);
- return (EXDEV);
+ return (SET_ERROR(EXDEV));
}
/* You can only clone snapshots, not the head datasets. */
if (!dsl_dataset_is_snapshot(origin)) {
dsl_dataset_rele(origin, FTAG);
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
dsl_dataset_rele(origin, FTAG);
@@ -1302,9 +1302,9 @@ dmu_objset_userspace_upgrade(objset_t *os)
if (dmu_objset_userspace_present(os))
return (0);
if (!dmu_objset_userused_enabled(os))
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
if (dmu_objset_is_snapshot(os))
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
/*
* We simply need to mark every object dirty, so that it will be
@@ -1320,7 +1320,7 @@ dmu_objset_userspace_upgrade(objset_t *os)
int objerr;
if (issig(JUSTLOOKING) && issig(FORREAL))
- return (EINTR);
+ return (SET_ERROR(EINTR));
objerr = dmu_bonus_hold(os, obj, FTAG, &db);
if (objerr != 0)
@@ -1396,7 +1396,7 @@ dmu_snapshot_realname(objset_t *os, char *name, char *real, int maxlen,
uint64_t ignored;
if (ds->ds_phys->ds_snapnames_zapobj == 0)
- return (ENOENT);
+ return (SET_ERROR(ENOENT));
return (zap_lookup_norm(ds->ds_dir->dd_pool->dp_meta_objset,
ds->ds_phys->ds_snapnames_zapobj, name, 8, 1, &ignored, MT_FIRST,
@@ -1414,7 +1414,7 @@ dmu_snapshot_list_next(objset_t *os, int namelen, char *name,
ASSERT(dsl_pool_config_held(dmu_objset_pool(os)));
if (ds->ds_phys->ds_snapnames_zapobj == 0)
- return (ENOENT);
+ return (SET_ERROR(ENOENT));
zap_cursor_init_serialized(&cursor,
ds->ds_dir->dd_pool->dp_meta_objset,
@@ -1422,12 +1422,12 @@ dmu_snapshot_list_next(objset_t *os, int namelen, char *name,
if (zap_cursor_retrieve(&cursor, &attr) != 0) {
zap_cursor_fini(&cursor);
- return (ENOENT);
+ return (SET_ERROR(ENOENT));
}
if (strlen(attr.za_name) + 1 > namelen) {
zap_cursor_fini(&cursor);
- return (ENAMETOOLONG);
+ return (SET_ERROR(ENAMETOOLONG));
}
(void) strcpy(name, attr.za_name);
@@ -1453,7 +1453,7 @@ dmu_dir_list_next(objset_t *os, int namelen, char *name,
/* there is no next dir on a snapshot! */
if (os->os_dsl_dataset->ds_object !=
dd->dd_phys->dd_head_dataset_obj)
- return (ENOENT);
+ return (SET_ERROR(ENOENT));
zap_cursor_init_serialized(&cursor,
dd->dd_pool->dp_meta_objset,
@@ -1461,12 +1461,12 @@ dmu_dir_list_next(objset_t *os, int namelen, char *name,
if (zap_cursor_retrieve(&cursor, &attr) != 0) {
zap_cursor_fini(&cursor);
- return (ENOENT);
+ return (SET_ERROR(ENOENT));
}
if (strlen(attr.za_name) + 1 > namelen) {
zap_cursor_fini(&cursor);
- return (ENAMETOOLONG);
+ return (SET_ERROR(ENAMETOOLONG));
}
(void) strcpy(name, attr.za_name);
@@ -1733,9 +1733,9 @@ dmu_fsname(const char *snapname, char *buf)
{
char *atp = strchr(snapname, '@');
if (atp == NULL)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
if (atp - snapname >= MAXNAMELEN)
- return (ENAMETOOLONG);
+ return (SET_ERROR(ENAMETOOLONG));
(void) strlcpy(buf, snapname, atp - snapname + 1);
return (0);
}
diff --git a/uts/common/fs/zfs/dmu_send.c b/uts/common/fs/zfs/dmu_send.c
index a2a3647..756447d 100644
--- a/uts/common/fs/zfs/dmu_send.c
+++ b/uts/common/fs/zfs/dmu_send.c
@@ -21,7 +21,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
* Copyright (c) 2012, Joyent, Inc. All rights reserved.
*/
@@ -94,7 +94,7 @@ dump_free(dmu_sendarg_t *dsp, uint64_t object, uint64_t offset,
dsp->dsa_pending_op != PENDING_FREE) {
if (dump_bytes(dsp, dsp->dsa_drr,
sizeof (dmu_replay_record_t)) != 0)
- return (EINTR);
+ return (SET_ERROR(EINTR));
dsp->dsa_pending_op = PENDING_NONE;
}
@@ -118,7 +118,7 @@ dump_free(dmu_sendarg_t *dsp, uint64_t object, uint64_t offset,
/* not a continuation. Push out pending record */
if (dump_bytes(dsp, dsp->dsa_drr,
sizeof (dmu_replay_record_t)) != 0)
- return (EINTR);
+ return (SET_ERROR(EINTR));
dsp->dsa_pending_op = PENDING_NONE;
}
}
@@ -132,7 +132,7 @@ dump_free(dmu_sendarg_t *dsp, uint64_t object, uint64_t offset,
if (length == -1ULL) {
if (dump_bytes(dsp, dsp->dsa_drr,
sizeof (dmu_replay_record_t)) != 0)
- return (EINTR);
+ return (SET_ERROR(EINTR));
} else {
dsp->dsa_pending_op = PENDING_FREE;
}
@@ -156,7 +156,7 @@ dump_data(dmu_sendarg_t *dsp, dmu_object_type_t type,
if (dsp->dsa_pending_op != PENDING_NONE) {
if (dump_bytes(dsp, dsp->dsa_drr,
sizeof (dmu_replay_record_t)) != 0)
- return (EINTR);
+ return (SET_ERROR(EINTR));
dsp->dsa_pending_op = PENDING_NONE;
}
/* write a DATA record */
@@ -176,9 +176,9 @@ dump_data(dmu_sendarg_t *dsp, dmu_object_type_t type,
drrw->drr_key.ddk_cksum = bp->blk_cksum;
if (dump_bytes(dsp, dsp->dsa_drr, sizeof (dmu_replay_record_t)) != 0)
- return (EINTR);
+ return (SET_ERROR(EINTR));
if (dump_bytes(dsp, data, blksz) != 0)
- return (EINTR);
+ return (SET_ERROR(EINTR));
return (0);
}
@@ -190,7 +190,7 @@ dump_spill(dmu_sendarg_t *dsp, uint64_t object, int blksz, void *data)
if (dsp->dsa_pending_op != PENDING_NONE) {
if (dump_bytes(dsp, dsp->dsa_drr,
sizeof (dmu_replay_record_t)) != 0)
- return (EINTR);
+ return (SET_ERROR(EINTR));
dsp->dsa_pending_op = PENDING_NONE;
}
@@ -202,9 +202,9 @@ dump_spill(dmu_sendarg_t *dsp, uint64_t object, int blksz, void *data)
drrs->drr_toguid = dsp->dsa_toguid;
if (dump_bytes(dsp, dsp->dsa_drr, sizeof (dmu_replay_record_t)))
- return (EINTR);
+ return (SET_ERROR(EINTR));
if (dump_bytes(dsp, data, blksz))
- return (EINTR);
+ return (SET_ERROR(EINTR));
return (0);
}
@@ -224,7 +224,7 @@ dump_freeobjects(dmu_sendarg_t *dsp, uint64_t firstobj, uint64_t numobjs)
dsp->dsa_pending_op != PENDING_FREEOBJECTS) {
if (dump_bytes(dsp, dsp->dsa_drr,
sizeof (dmu_replay_record_t)) != 0)
- return (EINTR);
+ return (SET_ERROR(EINTR));
dsp->dsa_pending_op = PENDING_NONE;
}
if (dsp->dsa_pending_op == PENDING_FREEOBJECTS) {
@@ -239,7 +239,7 @@ dump_freeobjects(dmu_sendarg_t *dsp, uint64_t firstobj, uint64_t numobjs)
/* can't be aggregated. Push out pending record */
if (dump_bytes(dsp, dsp->dsa_drr,
sizeof (dmu_replay_record_t)) != 0)
- return (EINTR);
+ return (SET_ERROR(EINTR));
dsp->dsa_pending_op = PENDING_NONE;
}
}
@@ -267,7 +267,7 @@ dump_dnode(dmu_sendarg_t *dsp, uint64_t object, dnode_phys_t *dnp)
if (dsp->dsa_pending_op != PENDING_NONE) {
if (dump_bytes(dsp, dsp->dsa_drr,
sizeof (dmu_replay_record_t)) != 0)
- return (EINTR);
+ return (SET_ERROR(EINTR));
dsp->dsa_pending_op = PENDING_NONE;
}
@@ -284,17 +284,17 @@ dump_dnode(dmu_sendarg_t *dsp, uint64_t object, dnode_phys_t *dnp)
drro->drr_toguid = dsp->dsa_toguid;
if (dump_bytes(dsp, dsp->dsa_drr, sizeof (dmu_replay_record_t)) != 0)
- return (EINTR);
+ return (SET_ERROR(EINTR));
if (dump_bytes(dsp, DN_BONUS(dnp), P2ROUNDUP(dnp->dn_bonuslen, 8)) != 0)
- return (EINTR);
+ return (SET_ERROR(EINTR));
/* free anything past the end of the file */
if (dump_free(dsp, object, (dnp->dn_maxblkid + 1) *
(dnp->dn_datablkszsec << SPA_MINBLOCKSHIFT), -1ULL))
- return (EINTR);
+ return (SET_ERROR(EINTR));
if (dsp->dsa_err != 0)
- return (EINTR);
+ return (SET_ERROR(EINTR));
return (0);
}
@@ -312,7 +312,7 @@ backup_cb(spa_t *spa, zilog_t *zilog, const blkptr_t *bp,
int err = 0;
if (issig(JUSTLOOKING) && issig(FORREAL))
- return (EINTR);
+ return (SET_ERROR(EINTR));
if (zb->zb_object != DMU_META_DNODE_OBJECT &&
DMU_OBJECT_IS_SPECIAL(zb->zb_object)) {
@@ -336,7 +336,7 @@ backup_cb(spa_t *spa, zilog_t *zilog, const blkptr_t *bp,
if (arc_read(NULL, spa, bp, arc_getbuf_func, &abuf,
ZIO_PRIORITY_ASYNC_READ, ZIO_FLAG_CANFAIL,
&aflags, zb) != 0)
- return (EIO);
+ return (SET_ERROR(EIO));
blk = abuf->b_data;
for (i = 0; i < blksz >> DNODE_SHIFT; i++) {
@@ -355,7 +355,7 @@ backup_cb(spa_t *spa, zilog_t *zilog, const blkptr_t *bp,
if (arc_read(NULL, spa, bp, arc_getbuf_func, &abuf,
ZIO_PRIORITY_ASYNC_READ, ZIO_FLAG_CANFAIL,
&aflags, zb) != 0)
- return (EIO);
+ return (SET_ERROR(EIO));
err = dump_spill(dsp, zb->zb_object, blksz, abuf->b_data);
(void) arc_buf_remove_ref(abuf, &abuf);
@@ -377,7 +377,7 @@ backup_cb(spa_t *spa, zilog_t *zilog, const blkptr_t *bp,
ptr++)
*ptr = 0x2f5baddb10c;
} else {
- return (EIO);
+ return (SET_ERROR(EIO));
}
}
@@ -407,7 +407,7 @@ dmu_send_impl(void *tag, dsl_pool_t *dp, dsl_dataset_t *ds,
dsl_dataset_rele(fromds, tag);
dsl_dataset_rele(ds, tag);
dsl_pool_rele(dp, tag);
- return (EXDEV);
+ return (SET_ERROR(EXDEV));
}
err = dmu_objset_from_ds(ds, &os);
@@ -434,7 +434,7 @@ dmu_send_impl(void *tag, dsl_pool_t *dp, dsl_dataset_t *ds,
dsl_dataset_rele(fromds, tag);
dsl_dataset_rele(ds, tag);
dsl_pool_rele(dp, tag);
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
if (version >= ZPL_VERSION_SA) {
DMU_SET_FEATUREFLAGS(
@@ -492,7 +492,7 @@ dmu_send_impl(void *tag, dsl_pool_t *dp, dsl_dataset_t *ds,
if (dsp->dsa_pending_op != PENDING_NONE)
if (dump_bytes(dsp, drr, sizeof (dmu_replay_record_t)) != 0)
- err = EINTR;
+ err = SET_ERROR(EINTR);
if (err != 0) {
if (err == EINTR && dsp->dsa_err != 0)
@@ -565,9 +565,9 @@ dmu_send(const char *tosnap, const char *fromsnap,
int err;
if (strchr(tosnap, '@') == NULL)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
if (fromsnap != NULL && strchr(fromsnap, '@') == NULL)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
err = dsl_pool_hold(tosnap, FTAG, &dp);
if (err != 0)
@@ -601,14 +601,14 @@ dmu_send_estimate(dsl_dataset_t *ds, dsl_dataset_t *fromds, uint64_t *sizep)
/* tosnap must be a snapshot */
if (!dsl_dataset_is_snapshot(ds))
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
/*
* fromsnap must be an earlier snapshot from the same fs as tosnap,
* or the origin's fs.
*/
if (fromds != NULL && !dsl_dataset_is_before(ds, fromds))
- return (EXDEV);
+ return (SET_ERROR(EXDEV));
/* Get uncompressed size estimate of changed data. */
if (fromds == NULL) {
@@ -667,7 +667,7 @@ recv_begin_check_existing_impl(dmu_recv_begin_arg_t *drba, dsl_dataset_t *ds,
/* must not have any changes since most recent snapshot */
if (!drba->drba_cookie->drc_force &&
dsl_dataset_modified_since_lastsnap(ds))
- return (ETXTBSY);
+ return (SET_ERROR(ETXTBSY));
/* temporary clone name must not exist */
error = zap_lookup(dp->dp_meta_objset,
@@ -686,7 +686,7 @@ recv_begin_check_existing_impl(dmu_recv_begin_arg_t *drba, dsl_dataset_t *ds,
if (fromguid != 0) {
/* if incremental, most recent snapshot must match fromguid */
if (ds->ds_prev == NULL)
- return (ENODEV);
+ return (SET_ERROR(ENODEV));
/*
* most recent snapshot must match fromguid, or there are no
@@ -700,10 +700,10 @@ recv_begin_check_existing_impl(dmu_recv_begin_arg_t *drba, dsl_dataset_t *ds,
error = dsl_dataset_hold_obj(dp, obj, FTAG,
&snap);
if (error != 0)
- return (ENODEV);
+ return (SET_ERROR(ENODEV));
if (snap->ds_phys->ds_creation_txg < birth) {
dsl_dataset_rele(snap, FTAG);
- return (ENODEV);
+ return (SET_ERROR(ENODEV));
}
if (snap->ds_phys->ds_guid == fromguid) {
dsl_dataset_rele(snap, FTAG);
@@ -713,12 +713,12 @@ recv_begin_check_existing_impl(dmu_recv_begin_arg_t *drba, dsl_dataset_t *ds,
dsl_dataset_rele(snap, FTAG);
}
if (obj == 0)
- return (ENODEV);
+ return (SET_ERROR(ENODEV));
}
} else {
/* if full, most recent snapshot must be $ORIGIN */
if (ds->ds_phys->ds_prev_snap_txg >= TXG_INITIAL)
- return (ENODEV);
+ return (SET_ERROR(ENODEV));
}
return (0);
@@ -744,13 +744,13 @@ dmu_recv_begin_check(void *arg, dmu_tx_t *tx)
DMU_COMPOUNDSTREAM ||
drrb->drr_type >= DMU_OST_NUMTYPES ||
((flags & DRR_FLAG_CLONE) && drba->drba_origin == NULL))
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
/* Verify pool version supports SA if SA_SPILL feature set */
if ((DMU_GET_FEATUREFLAGS(drrb->drr_versioninfo) &
DMU_BACKUP_FEATURE_SA_SPILL) &&
spa_version(dp->dp_spa) < SPA_VERSION_SA) {
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
}
error = dsl_dataset_hold(dp, tofs, FTAG, &ds);
@@ -760,7 +760,7 @@ dmu_recv_begin_check(void *arg, dmu_tx_t *tx)
/* Can't recv a clone into an existing fs */
if (flags & DRR_FLAG_CLONE) {
dsl_dataset_rele(ds, FTAG);
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
error = recv_begin_check_existing_impl(drba, ds, fromguid);
@@ -774,7 +774,7 @@ dmu_recv_begin_check(void *arg, dmu_tx_t *tx)
* target fs, so fail the recv.
*/
if (fromguid != 0 && !(flags & DRR_FLAG_CLONE))
- return (ENOENT);
+ return (SET_ERROR(ENOENT));
/* Open the parent of tofs */
ASSERT3U(strlen(tofs), <, MAXNAMELEN);
@@ -794,12 +794,12 @@ dmu_recv_begin_check(void *arg, dmu_tx_t *tx)
if (!dsl_dataset_is_snapshot(origin)) {
dsl_dataset_rele(origin, FTAG);
dsl_dataset_rele(ds, FTAG);
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
if (origin->ds_phys->ds_guid != fromguid) {
dsl_dataset_rele(origin, FTAG);
dsl_dataset_rele(ds, FTAG);
- return (ENODEV);
+ return (SET_ERROR(ENODEV));
}
dsl_dataset_rele(origin, FTAG);
}
@@ -890,7 +890,7 @@ dmu_recv_begin(char *tofs, char *tosnap, struct drr_begin *drrb,
if (drrb->drr_magic == BSWAP_64(DMU_BACKUP_MAGIC))
drc->drc_byteswap = B_TRUE;
else if (drrb->drr_magic != DMU_BACKUP_MAGIC)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
drr = kmem_zalloc(sizeof (dmu_replay_record_t), KM_SLEEP);
drr->drr_type = DRR_BEGIN;
@@ -984,7 +984,7 @@ restore_read(struct restorearg *ra, int len)
RLIM64_INFINITY, CRED(), &resid);
if (resid == len - done)
- ra->err = EINVAL;
+ ra->err = SET_ERROR(EINVAL);
ra->voff += len - done - resid;
done = len - resid;
if (ra->err != 0)
@@ -1096,13 +1096,13 @@ restore_object(struct restorearg *ra, objset_t *os, struct drr_object *drro)
drro->drr_blksz < SPA_MINBLOCKSIZE ||
drro->drr_blksz > SPA_MAXBLOCKSIZE ||
drro->drr_bonuslen > DN_MAX_BONUSLEN) {
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
err = dmu_object_info(os, drro->drr_object, NULL);
if (err != 0 && err != ENOENT)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
if (drro->drr_bonuslen) {
data = restore_read(ra, P2ROUNDUP(drro->drr_bonuslen, 8));
@@ -1130,7 +1130,7 @@ restore_object(struct restorearg *ra, objset_t *os, struct drr_object *drro)
drro->drr_bonustype, drro->drr_bonuslen);
}
if (err != 0) {
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
tx = dmu_tx_create(os);
@@ -1173,7 +1173,7 @@ restore_freeobjects(struct restorearg *ra, objset_t *os,
uint64_t obj;
if (drrfo->drr_firstobj + drrfo->drr_numobjs < drrfo->drr_firstobj)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
for (obj = drrfo->drr_firstobj;
obj < drrfo->drr_firstobj + drrfo->drr_numobjs;
@@ -1200,14 +1200,14 @@ restore_write(struct restorearg *ra, objset_t *os,
if (drrw->drr_offset + drrw->drr_length < drrw->drr_offset ||
!DMU_OT_IS_VALID(drrw->drr_type))
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
data = restore_read(ra, drrw->drr_length);
if (data == NULL)
return (ra->err);
if (dmu_object_info(os, drrw->drr_object, NULL) != 0)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
tx = dmu_tx_create(os);
@@ -1249,7 +1249,7 @@ restore_write_byref(struct restorearg *ra, objset_t *os,
dmu_buf_t *dbp;
if (drrwbr->drr_offset + drrwbr->drr_length < drrwbr->drr_offset)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
/*
* If the GUID of the referenced dataset is different from the
@@ -1259,10 +1259,10 @@ restore_write_byref(struct restorearg *ra, objset_t *os,
gmesrch.guid = drrwbr->drr_refguid;
if ((gmep = avl_find(ra->guid_to_ds_map, &gmesrch,
&where)) == NULL) {
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
if (dmu_objset_from_ds(gmep->gme_ds, &ref_os))
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
} else {
ref_os = os;
}
@@ -1297,14 +1297,14 @@ restore_spill(struct restorearg *ra, objset_t *os, struct drr_spill *drrs)
if (drrs->drr_length < SPA_MINBLOCKSIZE ||
drrs->drr_length > SPA_MAXBLOCKSIZE)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
data = restore_read(ra, drrs->drr_length);
if (data == NULL)
return (ra->err);
if (dmu_object_info(os, drrs->drr_object, NULL) != 0)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
VERIFY(0 == dmu_bonus_hold(os, drrs->drr_object, FTAG, &db));
if ((err = dmu_spill_hold_by_bonus(db, FTAG, &db_spill)) != 0) {
@@ -1346,10 +1346,10 @@ restore_free(struct restorearg *ra, objset_t *os,
if (drrf->drr_length != -1ULL &&
drrf->drr_offset + drrf->drr_length < drrf->drr_offset)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
if (dmu_object_info(os, drrf->drr_object, NULL) != 0)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
err = dmu_free_long_range(os, drrf->drr_object,
drrf->drr_offset, drrf->drr_length);
@@ -1405,7 +1405,7 @@ dmu_recv_stream(dmu_recv_cookie_t *drc, vnode_t *vp, offset_t *voffp,
minor_t minor;
if (cleanup_fd == -1) {
- ra.err = EBADF;
+ ra.err = SET_ERROR(EBADF);
goto out;
}
ra.err = zfs_onexit_fd_hold(cleanup_fd, &minor);
@@ -1442,7 +1442,7 @@ dmu_recv_stream(dmu_recv_cookie_t *drc, vnode_t *vp, offset_t *voffp,
while (ra.err == 0 &&
NULL != (drr = restore_read(&ra, sizeof (*drr)))) {
if (issig(JUSTLOOKING) && issig(FORREAL)) {
- ra.err = EINTR;
+ ra.err = SET_ERROR(EINTR);
goto out;
}
@@ -1496,7 +1496,7 @@ dmu_recv_stream(dmu_recv_cookie_t *drc, vnode_t *vp, offset_t *voffp,
* everything before the DRR_END record.
*/
if (!ZIO_CHECKSUM_EQUAL(drre.drr_checksum, pcksum))
- ra.err = ECKSUM;
+ ra.err = SET_ERROR(ECKSUM);
goto out;
}
case DRR_SPILL:
@@ -1506,7 +1506,7 @@ dmu_recv_stream(dmu_recv_cookie_t *drc, vnode_t *vp, offset_t *voffp,
break;
}
default:
- ra.err = EINVAL;
+ ra.err = SET_ERROR(EINVAL);
goto out;
}
pcksum = ra.cksum;
diff --git a/uts/common/fs/zfs/dmu_traverse.c b/uts/common/fs/zfs/dmu_traverse.c
index e976517..1ff47c8 100644
--- a/uts/common/fs/zfs/dmu_traverse.c
+++ b/uts/common/fs/zfs/dmu_traverse.c
@@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
#include <sys/zfs_context.h>
@@ -434,7 +434,7 @@ traverse_prefetcher(spa_t *spa, zilog_t *zilog, const blkptr_t *bp,
ASSERT(pfd->pd_blks_fetched >= 0);
if (pfd->pd_cancel)
- return (EINTR);
+ return (SET_ERROR(EINTR));
if (bp == NULL || !((pfd->pd_flags & TRAVERSE_PREFETCH_DATA) ||
BP_GET_TYPE(bp) == DMU_OT_DNODE || BP_GET_LEVEL(bp) > 0) ||
diff --git a/uts/common/fs/zfs/dmu_tx.c b/uts/common/fs/zfs/dmu_tx.c
index 8e6beec..3eeaca6 100644
--- a/uts/common/fs/zfs/dmu_tx.c
+++ b/uts/common/fs/zfs/dmu_tx.c
@@ -160,7 +160,7 @@ dmu_tx_check_ioerr(zio_t *zio, dnode_t *dn, int level, uint64_t blkid)
db = dbuf_hold_level(dn, level, blkid, FTAG);
rw_exit(&dn->dn_struct_rwlock);
if (db == NULL)
- return (EIO);
+ return (SET_ERROR(EIO));
err = dbuf_read(db, zio, DB_RF_CANFAIL | DB_RF_NOPREFETCH);
dbuf_rele(db, FTAG);
return (err);
@@ -370,7 +370,7 @@ dmu_tx_count_write(dmu_tx_hold_t *txh, uint64_t off, uint64_t len)
out:
if (txh->txh_space_towrite + txh->txh_space_tooverwrite >
2 * DMU_MAX_ACCESS)
- err = EFBIG;
+ err = SET_ERROR(EFBIG);
if (err)
txh->txh_tx->tx_err = err;
@@ -922,9 +922,9 @@ dmu_tx_try_assign(dmu_tx_t *tx, txg_how_t txg_how)
*/
if (spa_get_failmode(spa) == ZIO_FAILURE_MODE_CONTINUE &&
txg_how != TXG_WAIT)
- return (EIO);
+ return (SET_ERROR(EIO));
- return (ERESTART);
+ return (SET_ERROR(ERESTART));
}
tx->tx_txg = txg_hold_open(tx->tx_pool, &tx->tx_txgh);
@@ -945,7 +945,7 @@ dmu_tx_try_assign(dmu_tx_t *tx, txg_how_t txg_how)
if (dn->dn_assigned_txg == tx->tx_txg - 1) {
mutex_exit(&dn->dn_mtx);
tx->tx_needassign_txh = txh;
- return (ERESTART);
+ return (SET_ERROR(ERESTART));
}
if (dn->dn_assigned_txg == 0)
dn->dn_assigned_txg = tx->tx_txg;
diff --git a/uts/common/fs/zfs/dnode.c b/uts/common/fs/zfs/dnode.c
index 5b5ece4..417e219 100644
--- a/uts/common/fs/zfs/dnode.c
+++ b/uts/common/fs/zfs/dnode.c
@@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
#include <sys/zfs_context.h>
@@ -1031,12 +1031,12 @@ dnode_hold_impl(objset_t *os, uint64_t object, int flag,
dn = (object == DMU_USERUSED_OBJECT) ?
DMU_USERUSED_DNODE(os) : DMU_GROUPUSED_DNODE(os);
if (dn == NULL)
- return (ENOENT);
+ return (SET_ERROR(ENOENT));
type = dn->dn_type;
if ((flag & DNODE_MUST_BE_ALLOCATED) && type == DMU_OT_NONE)
- return (ENOENT);
+ return (SET_ERROR(ENOENT));
if ((flag & DNODE_MUST_BE_FREE) && type != DMU_OT_NONE)
- return (EEXIST);
+ return (SET_ERROR(EEXIST));
DNODE_VERIFY(dn);
(void) refcount_add(&dn->dn_holds, tag);
*dnp = dn;
@@ -1044,7 +1044,7 @@ dnode_hold_impl(objset_t *os, uint64_t object, int flag,
}
if (object == 0 || object >= DN_MAX_OBJECT)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
mdn = DMU_META_DNODE(os);
ASSERT(mdn->dn_object == DMU_META_DNODE_OBJECT);
@@ -1062,7 +1062,7 @@ dnode_hold_impl(objset_t *os, uint64_t object, int flag,
if (drop_struct_lock)
rw_exit(&mdn->dn_struct_rwlock);
if (db == NULL)
- return (EIO);
+ return (SET_ERROR(EIO));
err = dbuf_read(db, NULL, DB_RF_CANFAIL);
if (err) {
dbuf_rele(db, FTAG);
@@ -1370,7 +1370,7 @@ dnode_set_blksz(dnode_t *dn, uint64_t size, int ibs, dmu_tx_t *tx)
fail:
rw_exit(&dn->dn_struct_rwlock);
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
}
/* read-holding callers must not rely on the lock being continuously held */
@@ -1856,7 +1856,7 @@ dnode_next_offset_level(dnode_t *dn, int flags, uint64_t *offset,
* at the pointer to this block in its parent, and its
* going to be unallocated, so we will skip over it.
*/
- return (ESRCH);
+ return (SET_ERROR(ESRCH));
}
error = dbuf_read(db, NULL, DB_RF_CANFAIL | DB_RF_HAVESTRUCT);
if (error) {
@@ -1872,7 +1872,7 @@ dnode_next_offset_level(dnode_t *dn, int flags, uint64_t *offset,
* This can only happen when we are searching up the tree
* and these conditions mean that we need to keep climbing.
*/
- error = ESRCH;
+ error = SET_ERROR(ESRCH);
} else if (lvl == 0) {
dnode_phys_t *dnp = data;
span = DNODE_SHIFT;
@@ -1885,7 +1885,7 @@ dnode_next_offset_level(dnode_t *dn, int flags, uint64_t *offset,
*offset += (1ULL << span) * inc;
}
if (i < 0 || i == blkfill)
- error = ESRCH;
+ error = SET_ERROR(ESRCH);
} else {
blkptr_t *bp = data;
uint64_t start = *offset;
@@ -1917,7 +1917,7 @@ dnode_next_offset_level(dnode_t *dn, int flags, uint64_t *offset,
*offset = start;
}
if (i < 0 || i >= epb)
- error = ESRCH;
+ error = SET_ERROR(ESRCH);
}
if (db)
@@ -1961,7 +1961,7 @@ dnode_next_offset(dnode_t *dn, int flags, uint64_t *offset,
rw_enter(&dn->dn_struct_rwlock, RW_READER);
if (dn->dn_phys->dn_nlevels == 0) {
- error = ESRCH;
+ error = SET_ERROR(ESRCH);
goto out;
}
@@ -1970,7 +1970,7 @@ dnode_next_offset(dnode_t *dn, int flags, uint64_t *offset,
if (flags & DNODE_FIND_HOLE)
*offset = dn->dn_datablksz;
} else {
- error = ESRCH;
+ error = SET_ERROR(ESRCH);
}
goto out;
}
@@ -1991,7 +1991,7 @@ dnode_next_offset(dnode_t *dn, int flags, uint64_t *offset,
if (error == 0 && (flags & DNODE_FIND_BACKWARDS ?
initial_offset < *offset : initial_offset > *offset))
- error = ESRCH;
+ error = SET_ERROR(ESRCH);
out:
if (!(flags & DNODE_FIND_HAVELOCK))
rw_exit(&dn->dn_struct_rwlock);
diff --git a/uts/common/fs/zfs/dsl_dataset.c b/uts/common/fs/zfs/dsl_dataset.c
index 5e0446d..bfc8b06 100644
--- a/uts/common/fs/zfs/dsl_dataset.c
+++ b/uts/common/fs/zfs/dsl_dataset.c
@@ -357,7 +357,7 @@ dsl_dataset_hold_obj(dsl_pool_t *dp, uint64_t dsobj, void *tag,
/* Make sure dsobj has the correct object type. */
dmu_object_info_from_db(dbuf, &doi);
if (doi.doi_type != DMU_OT_DSL_DATASET)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
ds = dmu_buf_get_user(dbuf);
if (ds == NULL) {
@@ -474,7 +474,7 @@ dsl_dataset_hold(dsl_pool_t *dp, const char *name,
if (obj != 0)
err = dsl_dataset_hold_obj(dp, obj, tag, dsp);
else
- err = ENOENT;
+ err = SET_ERROR(ENOENT);
/* we may be looking for a snapshot */
if (err == 0 && snapname != NULL) {
@@ -483,7 +483,7 @@ dsl_dataset_hold(dsl_pool_t *dp, const char *name,
if (*snapname++ != '@') {
dsl_dataset_rele(*dsp, tag);
dsl_dir_rele(dd, FTAG);
- return (ENOENT);
+ return (SET_ERROR(ENOENT));
}
dprintf("looking for snapshot '%s'\n", snapname);
@@ -516,7 +516,7 @@ dsl_dataset_own_obj(dsl_pool_t *dp, uint64_t dsobj,
if (!dsl_dataset_tryown(*dsp, tag)) {
dsl_dataset_rele(*dsp, tag);
*dsp = NULL;
- return (EBUSY);
+ return (SET_ERROR(EBUSY));
}
return (0);
}
@@ -530,7 +530,7 @@ dsl_dataset_own(dsl_pool_t *dp, const char *name,
return (err);
if (!dsl_dataset_tryown(*dsp, tag)) {
dsl_dataset_rele(*dsp, tag);
- return (EBUSY);
+ return (SET_ERROR(EBUSY));
}
return (0);
}
@@ -925,7 +925,7 @@ dsl_dataset_snapshot_reserve_space(dsl_dataset_t *ds, dmu_tx_t *tx)
ASSERT(ds->ds_reserved == 0 || DS_UNIQUE_IS_ACCURATE(ds));
asize = MIN(ds->ds_phys->ds_unique_bytes, ds->ds_reserved);
if (asize > dsl_dir_space_available(ds->ds_dir, NULL, 0, TRUE))
- return (ENOSPC);
+ return (SET_ERROR(ENOSPC));
/*
* Propagate any reserved space for this snapshot to other
@@ -960,14 +960,14 @@ dsl_dataset_snapshot_check_impl(dsl_dataset_t *ds, const char *snapname,
* is already one, try again.
*/
if (ds->ds_phys->ds_prev_snap_txg >= tx->tx_txg)
- return (EAGAIN);
+ return (SET_ERROR(EAGAIN));
/*
* Check for conflicting snapshot name.
*/
error = dsl_dataset_snap_lookup(ds, snapname, &value);
if (error == 0)
- return (EEXIST);
+ return (SET_ERROR(EEXIST));
if (error != ENOENT)
return (error);
@@ -995,11 +995,11 @@ dsl_dataset_snapshot_check(void *arg, dmu_tx_t *tx)
name = nvpair_name(pair);
if (strlen(name) >= MAXNAMELEN)
- error = ENAMETOOLONG;
+ error = SET_ERROR(ENAMETOOLONG);
if (error == 0) {
atp = strchr(name, '@');
if (atp == NULL)
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
if (error == 0)
(void) strlcpy(dsname, name, atp - name + 1);
}
@@ -1206,7 +1206,7 @@ dsl_dataset_snapshot(nvlist_t *snaps, nvlist_t *props, nvlist_t *errors)
atp = strchr(snapname, '@');
if (atp == NULL) {
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
break;
}
(void) strlcpy(fsname, snapname, atp - snapname + 1);
@@ -1268,7 +1268,7 @@ dsl_dataset_snapshot_tmp_check(void *arg, dmu_tx_t *tx)
if (spa_version(dp->dp_spa) < SPA_VERSION_USERREFS) {
dsl_dataset_rele(ds, FTAG);
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
}
error = dsl_dataset_user_hold_check_one(NULL, ddsta->ddsta_htag,
B_TRUE, tx);
@@ -1570,14 +1570,14 @@ dsl_dataset_rename_snapshot_check_impl(dsl_pool_t *dp,
/* new name should not exist */
error = dsl_dataset_snap_lookup(hds, ddrsa->ddrsa_newsnapname, &val);
if (error == 0)
- error = EEXIST;
+ error = SET_ERROR(EEXIST);
else if (error == ENOENT)
error = 0;
/* dataset name + 1 for the "@" + the new snapshot name must fit */
if (dsl_dir_namelen(hds->ds_dir) + 1 +
strlen(ddrsa->ddrsa_newsnapname) >= MAXNAMELEN)
- error = ENAMETOOLONG;
+ error = SET_ERROR(ENAMETOOLONG);
return (error);
}
@@ -1689,18 +1689,18 @@ dsl_dataset_rollback_check(void *arg, dmu_tx_t *tx)
/* must not be a snapshot */
if (dsl_dataset_is_snapshot(ds)) {
dsl_dataset_rele(ds, FTAG);
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
/* must have a most recent snapshot */
if (ds->ds_phys->ds_prev_snap_txg < TXG_INITIAL) {
dsl_dataset_rele(ds, FTAG);
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
if (dsl_dataset_long_held(ds)) {
dsl_dataset_rele(ds, FTAG);
- return (EBUSY);
+ return (SET_ERROR(EBUSY));
}
/*
@@ -1710,7 +1710,7 @@ dsl_dataset_rollback_check(void *arg, dmu_tx_t *tx)
if (ds->ds_quota != 0 &&
ds->ds_prev->ds_phys->ds_referenced_bytes > ds->ds_quota) {
dsl_dataset_rele(ds, FTAG);
- return (EDQUOT);
+ return (SET_ERROR(EDQUOT));
}
/*
@@ -1727,7 +1727,7 @@ dsl_dataset_rollback_check(void *arg, dmu_tx_t *tx)
unused_refres_delta >
dsl_dir_space_available(ds->ds_dir, NULL, 0, TRUE)) {
dsl_dataset_rele(ds, FTAG);
- return (ENOSPC);
+ return (SET_ERROR(ENOSPC));
}
dsl_dataset_rele(ds, FTAG);
@@ -1803,7 +1803,7 @@ dsl_dataset_promote_check(void *arg, dmu_tx_t *tx)
if (hds->ds_phys->ds_flags & DS_FLAG_NOPROMOTE) {
promote_rele(ddpa, FTAG);
- return (EXDEV);
+ return (SET_ERROR(EXDEV));
}
/*
@@ -1853,7 +1853,7 @@ dsl_dataset_promote_check(void *arg, dmu_tx_t *tx)
* the objset.
*/
if (dsl_dataset_long_held(ds)) {
- err = EBUSY;
+ err = SET_ERROR(EBUSY);
goto out;
}
@@ -1862,7 +1862,7 @@ dsl_dataset_promote_check(void *arg, dmu_tx_t *tx)
err = dsl_dataset_snap_lookup(hds, ds->ds_snapname, &val);
if (err == 0) {
(void) strcpy(ddpa->err_ds, snap->ds->ds_snapname);
- err = EEXIST;
+ err = SET_ERROR(EEXIST);
goto out;
}
if (err != ENOENT)
@@ -2199,7 +2199,7 @@ promote_hold(dsl_dataset_promote_arg_t *ddpa, dsl_pool_t *dp, void *tag)
if (dsl_dataset_is_snapshot(ddpa->ddpa_clone) ||
!dsl_dir_is_clone(dd)) {
dsl_dataset_rele(ddpa->ddpa_clone, tag);
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
error = snaplist_make(dp, 0, dd->dd_phys->dd_origin_obj,
@@ -2287,30 +2287,30 @@ dsl_dataset_clone_swap_check_impl(dsl_dataset_t *clone,
/* they should both be heads */
if (dsl_dataset_is_snapshot(clone) ||
dsl_dataset_is_snapshot(origin_head))
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
/* the branch point should be just before them */
if (clone->ds_prev != origin_head->ds_prev)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
/* clone should be the clone (unless they are unrelated) */
if (clone->ds_prev != NULL &&
clone->ds_prev != clone->ds_dir->dd_pool->dp_origin_snap &&
origin_head->ds_object !=
clone->ds_prev->ds_phys->ds_next_snap_obj)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
/* the clone should be a child of the origin */
if (clone->ds_dir->dd_parent != origin_head->ds_dir)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
/* origin_head shouldn't be modified unless 'force' */
if (!force && dsl_dataset_modified_since_lastsnap(origin_head))
- return (ETXTBSY);
+ return (SET_ERROR(ETXTBSY));
/* origin_head should have no long holds (e.g. is not mounted) */
if (dsl_dataset_long_held(origin_head))
- return (EBUSY);
+ return (SET_ERROR(EBUSY));
/* check amount of any unconsumed refreservation */
unused_refres_delta =
@@ -2322,12 +2322,12 @@ dsl_dataset_clone_swap_check_impl(dsl_dataset_t *clone,
if (unused_refres_delta > 0 &&
unused_refres_delta >
dsl_dir_space_available(origin_head->ds_dir, NULL, 0, TRUE))
- return (ENOSPC);
+ return (SET_ERROR(ENOSPC));
/* clone can't be over the head's refquota */
if (origin_head->ds_quota != 0 &&
clone->ds_phys->ds_referenced_bytes > origin_head->ds_quota)
- return (EDQUOT);
+ return (SET_ERROR(EDQUOT));
return (0);
}
@@ -2522,9 +2522,9 @@ dsl_dataset_check_quota(dsl_dataset_t *ds, boolean_t check_quota,
if (ds->ds_phys->ds_referenced_bytes + inflight >= ds->ds_quota) {
if (inflight > 0 ||
ds->ds_phys->ds_referenced_bytes < ds->ds_quota)
- error = ERESTART;
+ error = SET_ERROR(ERESTART);
else
- error = EDQUOT;
+ error = SET_ERROR(EDQUOT);
}
mutex_exit(&ds->ds_lock);
@@ -2549,7 +2549,7 @@ dsl_dataset_set_refquota_check(void *arg, dmu_tx_t *tx)
uint64_t newval;
if (spa_version(dp->dp_spa) < SPA_VERSION_REFQUOTA)
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
error = dsl_dataset_hold(dp, ddsqra->ddsqra_name, FTAG, &ds);
if (error != 0)
@@ -2557,7 +2557,7 @@ dsl_dataset_set_refquota_check(void *arg, dmu_tx_t *tx)
if (dsl_dataset_is_snapshot(ds)) {
dsl_dataset_rele(ds, FTAG);
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
error = dsl_prop_predict(ds->ds_dir,
@@ -2576,7 +2576,7 @@ dsl_dataset_set_refquota_check(void *arg, dmu_tx_t *tx)
if (newval < ds->ds_phys->ds_referenced_bytes ||
newval < ds->ds_reserved) {
dsl_dataset_rele(ds, FTAG);
- return (ENOSPC);
+ return (SET_ERROR(ENOSPC));
}
dsl_dataset_rele(ds, FTAG);
@@ -2632,7 +2632,7 @@ dsl_dataset_set_refreservation_check(void *arg, dmu_tx_t *tx)
uint64_t newval, unique;
if (spa_version(dp->dp_spa) < SPA_VERSION_REFRESERVATION)
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
error = dsl_dataset_hold(dp, ddsqra->ddsqra_name, FTAG, &ds);
if (error != 0)
@@ -2640,7 +2640,7 @@ dsl_dataset_set_refreservation_check(void *arg, dmu_tx_t *tx)
if (dsl_dataset_is_snapshot(ds)) {
dsl_dataset_rele(ds, FTAG);
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
error = dsl_prop_predict(ds->ds_dir,
@@ -2674,7 +2674,7 @@ dsl_dataset_set_refreservation_check(void *arg, dmu_tx_t *tx)
dsl_dir_space_available(ds->ds_dir, NULL, 0, B_TRUE) ||
(ds->ds_quota > 0 && newval > ds->ds_quota)) {
dsl_dataset_rele(ds, FTAG);
- return (ENOSPC);
+ return (SET_ERROR(ENOSPC));
}
}
@@ -2819,7 +2819,7 @@ dsl_dataset_space_written(dsl_dataset_t *oldsnap, dsl_dataset_t *new,
if (snap != new)
dsl_dataset_rele(snap, FTAG);
if (snapobj == 0) {
- err = EINVAL;
+ err = SET_ERROR(EINVAL);
break;
}
@@ -2861,7 +2861,7 @@ dsl_dataset_space_wouldfree(dsl_dataset_t *firstsnap,
if (firstsnap->ds_dir != lastsnap->ds_dir ||
firstsnap->ds_phys->ds_creation_txg >
lastsnap->ds_phys->ds_creation_txg)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
*usedp = *compp = *uncompp = 0;
diff --git a/uts/common/fs/zfs/dsl_deleg.c b/uts/common/fs/zfs/dsl_deleg.c
index f09cb2f..4f98c84 100644
--- a/uts/common/fs/zfs/dsl_deleg.c
+++ b/uts/common/fs/zfs/dsl_deleg.c
@@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
/*
@@ -107,7 +107,7 @@ dsl_deleg_can_allow(char *ddname, nvlist_t *nvp, cred_t *cr)
const char *perm = nvpair_name(permpair);
if (strcmp(perm, ZFS_DELEG_PERM_ALLOW) == 0)
- return (EPERM);
+ return (SET_ERROR(EPERM));
if ((error = dsl_deleg_access(ddname, perm, cr)) != 0)
return (error);
@@ -139,10 +139,10 @@ dsl_deleg_can_unallow(char *ddname, nvlist_t *nvp, cred_t *cr)
if (type != ZFS_DELEG_USER &&
type != ZFS_DELEG_USER_SETS)
- return (EPERM);
+ return (SET_ERROR(EPERM));
if (strcmp(idstr, &nvpair_name(whopair)[3]) != 0)
- return (EPERM);
+ return (SET_ERROR(EPERM));
}
return (0);
}
@@ -261,7 +261,7 @@ dsl_deleg_check(void *arg, dmu_tx_t *tx)
if (spa_version(dmu_tx_pool(tx)->dp_spa) <
SPA_VERSION_DELEGATED_PERMS) {
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
}
error = dsl_dir_hold(dmu_tx_pool(tx), dda->dda_name, FTAG, &dd, NULL);
@@ -417,7 +417,7 @@ dsl_check_access(objset_t *mos, uint64_t zapobj,
if (error == 0) {
error = zap_lookup(mos, jumpobj, perm, 8, 1, &zero);
if (error == ENOENT)
- error = EPERM;
+ error = SET_ERROR(EPERM);
}
return (error);
}
@@ -462,7 +462,7 @@ dsl_check_user_access(objset_t *mos, uint64_t zapobj, const char *perm,
return (0);
}
- return (EPERM);
+ return (SET_ERROR(EPERM));
}
/*
@@ -555,11 +555,11 @@ dsl_deleg_access_impl(dsl_dataset_t *ds, const char *perm, cred_t *cr)
mos = dp->dp_meta_objset;
if (dsl_delegation_on(mos) == B_FALSE)
- return (ECANCELED);
+ return (SET_ERROR(ECANCELED));
if (spa_version(dmu_objset_spa(dp->dp_meta_objset)) <
SPA_VERSION_DELEGATED_PERMS)
- return (EPERM);
+ return (SET_ERROR(EPERM));
if (dsl_dataset_is_snapshot(ds)) {
/*
@@ -633,7 +633,7 @@ again:
if (error == 0)
goto success;
}
- error = EPERM;
+ error = SET_ERROR(EPERM);
success:
cookie = NULL;
diff --git a/uts/common/fs/zfs/dsl_destroy.c b/uts/common/fs/zfs/dsl_destroy.c
index 20d401f..d465e71 100644
--- a/uts/common/fs/zfs/dsl_destroy.c
+++ b/uts/common/fs/zfs/dsl_destroy.c
@@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
#include <sys/zfs_context.h>
@@ -52,10 +52,10 @@ static int
dsl_destroy_snapshot_check_impl(dsl_dataset_t *ds, boolean_t defer)
{
if (!dsl_dataset_is_snapshot(ds))
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
if (dsl_dataset_long_held(ds))
- return (EBUSY);
+ return (SET_ERROR(EBUSY));
/*
* Only allow deferred destroy on pools that support it.
@@ -64,7 +64,7 @@ dsl_destroy_snapshot_check_impl(dsl_dataset_t *ds, boolean_t defer)
if (defer) {
if (spa_version(ds->ds_dir->dd_pool->dp_spa) <
SPA_VERSION_USERREFS)
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
return (0);
}
@@ -73,13 +73,13 @@ dsl_destroy_snapshot_check_impl(dsl_dataset_t *ds, boolean_t defer)
* we can't destroy it yet.
*/
if (ds->ds_userrefs > 0)
- return (EBUSY);
+ return (SET_ERROR(EBUSY));
/*
* Can't delete a branch point.
*/
if (ds->ds_phys->ds_num_children > 1)
- return (EEXIST);
+ return (SET_ERROR(EEXIST));
return (0);
}
@@ -587,10 +587,10 @@ dsl_destroy_head_check_impl(dsl_dataset_t *ds, int expected_holds)
objset_t *mos;
if (dsl_dataset_is_snapshot(ds))
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
if (refcount_count(&ds->ds_longholds) != expected_holds)
- return (EBUSY);
+ return (SET_ERROR(EBUSY));
mos = ds->ds_dir->dd_pool->dp_meta_objset;
@@ -601,7 +601,7 @@ dsl_destroy_head_check_impl(dsl_dataset_t *ds, int expected_holds)
*/
if (ds->ds_prev != NULL &&
ds->ds_prev->ds_phys->ds_next_snap_obj == ds->ds_object)
- return (EBUSY);
+ return (SET_ERROR(EBUSY));
/*
* Can't delete if there are children of this fs.
@@ -611,14 +611,14 @@ dsl_destroy_head_check_impl(dsl_dataset_t *ds, int expected_holds)
if (error != 0)
return (error);
if (count != 0)
- return (EEXIST);
+ return (SET_ERROR(EEXIST));
if (dsl_dir_is_clone(ds->ds_dir) && DS_IS_DEFER_DESTROY(ds->ds_prev) &&
ds->ds_prev->ds_phys->ds_num_children == 2 &&
ds->ds_prev->ds_userrefs == 0) {
/* We need to remove the origin snapshot as well. */
if (!refcount_is_zero(&ds->ds_prev->ds_longholds))
- return (EBUSY);
+ return (SET_ERROR(EBUSY));
}
return (0);
}
diff --git a/uts/common/fs/zfs/dsl_dir.c b/uts/common/fs/zfs/dsl_dir.c
index c53c3c8..ca56829 100644
--- a/uts/common/fs/zfs/dsl_dir.c
+++ b/uts/common/fs/zfs/dsl_dir.c
@@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
#include <sys/dmu.h>
@@ -249,12 +249,12 @@ getcomponent(const char *path, char *component, const char **nextp)
char *p;
if ((path == NULL) || (path[0] == '\0'))
- return (ENOENT);
+ return (SET_ERROR(ENOENT));
/* This would be a good place to reserve some namespace... */
p = strpbrk(path, "/@");
if (p && (p[1] == '/' || p[1] == '@')) {
/* two separators in a row */
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
if (p == NULL || p == path) {
/*
@@ -264,14 +264,14 @@ getcomponent(const char *path, char *component, const char **nextp)
*/
if (p != NULL &&
(p[0] != '@' || strpbrk(path+1, "/@") || p[1] == '\0'))
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
if (strlen(path) >= MAXNAMELEN)
- return (ENAMETOOLONG);
+ return (SET_ERROR(ENAMETOOLONG));
(void) strcpy(component, path);
p = NULL;
} else if (p[0] == '/') {
if (p - path >= MAXNAMELEN)
- return (ENAMETOOLONG);
+ return (SET_ERROR(ENAMETOOLONG));
(void) strncpy(component, path, p - path);
component[p - path] = '\0';
p++;
@@ -281,9 +281,9 @@ getcomponent(const char *path, char *component, const char **nextp)
* any more slashes.
*/
if (strchr(path, '/'))
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
if (p - path >= MAXNAMELEN)
- return (ENAMETOOLONG);
+ return (SET_ERROR(ENAMETOOLONG));
(void) strncpy(component, path, p - path);
component[p - path] = '\0';
} else {
@@ -317,7 +317,7 @@ dsl_dir_hold(dsl_pool_t *dp, const char *name, void *tag,
/* Make sure the name is in the specified pool. */
spaname = spa_name(dp->dp_spa);
if (strcmp(buf, spaname) != 0)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
ASSERT(dsl_pool_config_held(dp));
@@ -368,7 +368,7 @@ dsl_dir_hold(dsl_pool_t *dp, const char *name, void *tag,
/* bad path name */
dsl_dir_rele(dd, tag);
dprintf("next=%p (%s) tail=%p\n", next, next?next:"", tailp);
- err = ENOENT;
+ err = SET_ERROR(ENOENT);
}
if (tailp != NULL)
*tailp = next;
@@ -677,7 +677,7 @@ dsl_dir_tempreserve_impl(dsl_dir_t *dd, uint64_t asize, boolean_t netfree,
used_on_disk>>10, est_inflight>>10,
quota>>10, asize>>10, retval);
mutex_exit(&dd->dd_lock);
- return (retval);
+ return (SET_ERROR(retval));
}
/* We need to up our estimated delta before dropping dd_lock */
@@ -740,7 +740,7 @@ dsl_dir_tempreserve_space(dsl_dir_t *dd, uint64_t lsize, uint64_t asize,
if (err == EAGAIN) {
txg_delay(dd->dd_pool, tx->tx_txg,
MSEC2NSEC(10), MSEC2NSEC(10));
- err = ERESTART;
+ err = SET_ERROR(ERESTART);
}
dsl_pool_memory_pressure(dd->dd_pool);
}
@@ -950,7 +950,7 @@ dsl_dir_set_quota_check(void *arg, dmu_tx_t *tx)
if ((dmu_tx_is_syncing(tx) || towrite == 0) &&
(newval < ds->ds_dir->dd_phys->dd_reserved ||
newval < ds->ds_dir->dd_phys->dd_used_bytes + towrite)) {
- error = ENOSPC;
+ error = SET_ERROR(ENOSPC);
}
mutex_exit(&ds->ds_dir->dd_lock);
dsl_dataset_rele(ds, FTAG);
@@ -1044,7 +1044,7 @@ dsl_dir_set_reservation_check(void *arg, dmu_tx_t *tx)
if (delta > avail ||
(dd->dd_phys->dd_quota > 0 &&
newval > dd->dd_phys->dd_quota))
- error = ENOSPC;
+ error = SET_ERROR(ENOSPC);
}
dsl_dataset_rele(ds, FTAG);
@@ -1152,7 +1152,7 @@ dsl_valid_rename(dsl_pool_t *dp, dsl_dataset_t *ds, void *arg)
dsl_dataset_name(ds, namebuf);
if (strlen(namebuf) + *deltap >= MAXNAMELEN)
- return (ENAMETOOLONG);
+ return (SET_ERROR(ENAMETOOLONG));
return (0);
}
@@ -1183,14 +1183,14 @@ dsl_dir_rename_check(void *arg, dmu_tx_t *tx)
if (dd->dd_pool != newparent->dd_pool) {
dsl_dir_rele(newparent, FTAG);
dsl_dir_rele(dd, FTAG);
- return (ENXIO);
+ return (SET_ERROR(ENXIO));
}
/* new name should not already exist */
if (mynewname == NULL) {
dsl_dir_rele(newparent, FTAG);
dsl_dir_rele(dd, FTAG);
- return (EEXIST);
+ return (SET_ERROR(EEXIST));
}
/* if the name length is growing, validate child name lengths */
@@ -1213,7 +1213,7 @@ dsl_dir_rename_check(void *arg, dmu_tx_t *tx)
if (closest_common_ancestor(dd, newparent) == dd) {
dsl_dir_rele(newparent, FTAG);
dsl_dir_rele(dd, FTAG);
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
error = dsl_dir_transfer_possible(dd->dd_parent,
@@ -1315,7 +1315,7 @@ dsl_dir_transfer_possible(dsl_dir_t *sdd, dsl_dir_t *tdd, uint64_t space)
adelta = would_change(sdd, -space, ancestor);
avail = dsl_dir_space_available(tdd, ancestor, adelta, FALSE);
if (avail < space)
- return (ENOSPC);
+ return (SET_ERROR(ENOSPC));
return (0);
}
diff --git a/uts/common/fs/zfs/dsl_pool.c b/uts/common/fs/zfs/dsl_pool.c
index c83068a..c72f13c 100644
--- a/uts/common/fs/zfs/dsl_pool.c
+++ b/uts/common/fs/zfs/dsl_pool.c
@@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
#include <sys/dsl_pool.h>
@@ -608,7 +608,7 @@ dsl_pool_tempreserve_space(dsl_pool_t *dp, uint64_t space, dmu_tx_t *tx)
+ dp->dp_tempreserved[tx->tx_txg & TXG_MASK] / 2;
if (reserved && reserved > write_limit)
- return (ERESTART);
+ return (SET_ERROR(ERESTART));
}
atomic_add_64(&dp->dp_tempreserved[tx->tx_txg & TXG_MASK], space);
@@ -892,7 +892,7 @@ dsl_pool_user_hold_rele_impl(dsl_pool_t *dp, uint64_t dsobj,
dsl_pool_user_hold_create_obj(dp, tx);
zapobj = dp->dp_tmp_userrefs_obj;
} else {
- return (ENOENT);
+ return (SET_ERROR(ENOENT));
}
}
diff --git a/uts/common/fs/zfs/dsl_prop.c b/uts/common/fs/zfs/dsl_prop.c
index cd7c3ec..0c288b5 100644
--- a/uts/common/fs/zfs/dsl_prop.c
+++ b/uts/common/fs/zfs/dsl_prop.c
@@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
#include <sys/zfs_context.h>
@@ -52,16 +52,16 @@ dodefault(const char *propname, int intsz, int numints, void *buf)
*/
if ((prop = zfs_name_to_prop(propname)) == ZPROP_INVAL ||
(zfs_prop_readonly(prop) && !zfs_prop_setonce(prop)))
- return (ENOENT);
+ return (SET_ERROR(ENOENT));
if (zfs_prop_get_type(prop) == PROP_TYPE_STRING) {
if (intsz != 1)
- return (EOVERFLOW);
+ return (SET_ERROR(EOVERFLOW));
(void) strncpy(buf, zfs_prop_default_string(prop),
numints);
} else {
if (intsz != 8 || numints < 1)
- return (EOVERFLOW);
+ return (SET_ERROR(EOVERFLOW));
*(uint64_t *)buf = zfs_prop_default_numeric(prop);
}
@@ -144,7 +144,7 @@ dsl_prop_get_dd(dsl_dir_t *dd, const char *propname,
* at the end of the loop (instead of at the beginning) ensures
* that err has a valid post-loop value.
*/
- err = ENOENT;
+ err = SET_ERROR(ENOENT);
}
if (err == ENOENT)
@@ -400,7 +400,7 @@ dsl_prop_unregister(dsl_dataset_t *ds, const char *propname,
if (cbr == NULL) {
mutex_exit(&dd->dd_lock);
- return (ENOMSG);
+ return (SET_ERROR(ENOMSG));
}
list_remove(&dd->dd_prop_cbs, cbr);
@@ -749,7 +749,7 @@ dsl_props_set_check(void *arg, dmu_tx_t *tx)
while ((elem = nvlist_next_nvpair(dpsa->dpsa_props, elem)) != NULL) {
if (strlen(nvpair_name(elem)) >= ZAP_MAXNAMELEN) {
dsl_dataset_rele(ds, FTAG);
- return (ENAMETOOLONG);
+ return (SET_ERROR(ENAMETOOLONG));
}
if (nvpair_type(elem) == DATA_TYPE_STRING) {
char *valstr = fnvpair_value_string(elem);
@@ -764,7 +764,7 @@ dsl_props_set_check(void *arg, dmu_tx_t *tx)
if (dsl_dataset_is_snapshot(ds) && version < SPA_VERSION_SNAP_PROPS) {
dsl_dataset_rele(ds, FTAG);
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
}
dsl_dataset_rele(ds, FTAG);
return (0);
diff --git a/uts/common/fs/zfs/dsl_scan.c b/uts/common/fs/zfs/dsl_scan.c
index 167f382..77e881d 100644
--- a/uts/common/fs/zfs/dsl_scan.c
+++ b/uts/common/fs/zfs/dsl_scan.c
@@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
#include <sys/dsl_scan.h>
@@ -159,7 +159,7 @@ dsl_scan_setup_check(void *arg, dmu_tx_t *tx)
dsl_scan_t *scn = dmu_tx_pool(tx)->dp_scan;
if (scn->scn_phys.scn_state == DSS_SCANNING)
- return (EBUSY);
+ return (SET_ERROR(EBUSY));
return (0);
}
@@ -319,7 +319,7 @@ dsl_scan_cancel_check(void *arg, dmu_tx_t *tx)
dsl_scan_t *scn = dmu_tx_pool(tx)->dp_scan;
if (scn->scn_phys.scn_state != DSS_SCANNING)
- return (ENOENT);
+ return (SET_ERROR(ENOENT));
return (0);
}
@@ -1321,7 +1321,7 @@ dsl_scan_free_block_cb(void *arg, const blkptr_t *bp, dmu_tx_t *tx)
if (!scn->scn_is_bptree ||
(BP_GET_LEVEL(bp) == 0 && BP_GET_TYPE(bp) != DMU_OT_OBJSET)) {
if (dsl_scan_free_should_pause(scn))
- return (ERESTART);
+ return (SET_ERROR(ERESTART));
}
zio_nowait(zio_free_sync(scn->scn_zio_root, scn->scn_dp->dp_spa,
diff --git a/uts/common/fs/zfs/dsl_synctask.c b/uts/common/fs/zfs/dsl_synctask.c
index ecb45fb..58f7d37 100644
--- a/uts/common/fs/zfs/dsl_synctask.c
+++ b/uts/common/fs/zfs/dsl_synctask.c
@@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
#include <sys/dmu.h>
@@ -155,7 +155,7 @@ dsl_sync_task_sync(dsl_sync_task_t *dst, dmu_tx_t *tx)
used = dp->dp_root_dir->dd_phys->dd_used_bytes;
/* MOS space is triple-dittoed, so we multiply by 3. */
if (dst->dst_space > 0 && used + dst->dst_space * 3 > quota) {
- dst->dst_error = ENOSPC;
+ dst->dst_error = SET_ERROR(ENOSPC);
if (dst->dst_nowaiter)
kmem_free(dst, sizeof (*dst));
return;
diff --git a/uts/common/fs/zfs/dsl_userhold.c b/uts/common/fs/zfs/dsl_userhold.c
index e30169e..fa9d937 100644
--- a/uts/common/fs/zfs/dsl_userhold.c
+++ b/uts/common/fs/zfs/dsl_userhold.c
@@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
#include <sys/zfs_context.h>
@@ -67,7 +67,7 @@ dsl_dataset_user_hold_check_one(dsl_dataset_t *ds, const char *htag,
error = zap_lookup(mos, ds->ds_phys->ds_userrefs_obj,
htag, 8, 1, &value);
if (error == 0)
- error = EEXIST;
+ error = SET_ERROR(EEXIST);
else if (error == ENOENT)
error = 0;
}
@@ -86,7 +86,7 @@ dsl_dataset_user_hold_check(void *arg, dmu_tx_t *tx)
int rv = 0;
if (spa_version(dp->dp_spa) < SPA_VERSION_USERREFS)
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
for (pair = nvlist_next_nvpair(dduha->dduha_holds, NULL); pair != NULL;
pair = nvlist_next_nvpair(dduha->dduha_holds, pair)) {
@@ -96,7 +96,7 @@ dsl_dataset_user_hold_check(void *arg, dmu_tx_t *tx)
/* must be a snapshot */
if (strchr(nvpair_name(pair), '@') == NULL)
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
if (error == 0)
error = nvpair_value_string(pair, &htag);
@@ -218,11 +218,11 @@ dsl_dataset_user_release_check_one(dsl_dataset_t *ds,
*todelete = B_FALSE;
if (!dsl_dataset_is_snapshot(ds))
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
zapobj = ds->ds_phys->ds_userrefs_obj;
if (zapobj == 0)
- return (ESRCH);
+ return (SET_ERROR(ESRCH));
for (pair = nvlist_next_nvpair(holds, NULL); pair != NULL;
pair = nvlist_next_nvpair(holds, pair)) {
@@ -230,7 +230,7 @@ dsl_dataset_user_release_check_one(dsl_dataset_t *ds,
uint64_t tmp;
error = zap_lookup(mos, zapobj, nvpair_name(pair), 8, 1, &tmp);
if (error == ENOENT)
- error = ESRCH;
+ error = SET_ERROR(ESRCH);
if (error != 0)
return (error);
numholds++;
@@ -241,7 +241,7 @@ dsl_dataset_user_release_check_one(dsl_dataset_t *ds,
/* we need to destroy the snapshot as well */
if (dsl_dataset_long_held(ds))
- return (EBUSY);
+ return (SET_ERROR(EBUSY));
*todelete = B_TRUE;
}
return (0);
@@ -267,7 +267,7 @@ dsl_dataset_user_release_check(void *arg, dmu_tx_t *tx)
error = nvpair_value_nvlist(pair, &holds);
if (error != 0)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
error = dsl_dataset_hold(dp, name, FTAG, &ds);
if (error == 0) {
diff --git a/uts/common/fs/zfs/metaslab.c b/uts/common/fs/zfs/metaslab.c
index aae2ccd..d297bc9 100644
--- a/uts/common/fs/zfs/metaslab.c
+++ b/uts/common/fs/zfs/metaslab.c
@@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
* Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
*/
@@ -1508,7 +1508,7 @@ metaslab_alloc_dva(spa_t *spa, metaslab_class_t *mc, uint64_t psize,
* For testing, make some blocks above a certain size be gang blocks.
*/
if (psize >= metaslab_gang_bang && (ddi_get_lbolt() & 3) == 0)
- return (ENOSPC);
+ return (SET_ERROR(ENOSPC));
/*
* Start at the rotor and loop through all mgs until we find something.
@@ -1673,7 +1673,7 @@ next:
bzero(&dva[d], sizeof (dva_t));
- return (ENOSPC);
+ return (SET_ERROR(ENOSPC));
}
/*
@@ -1742,7 +1742,7 @@ metaslab_claim_dva(spa_t *spa, const dva_t *dva, uint64_t txg)
if ((vd = vdev_lookup_top(spa, vdev)) == NULL ||
(offset >> vd->vdev_ms_shift) >= vd->vdev_ms_count)
- return (ENXIO);
+ return (SET_ERROR(ENXIO));
msp = vd->vdev_ms[offset >> vd->vdev_ms_shift];
@@ -1755,7 +1755,7 @@ metaslab_claim_dva(spa_t *spa, const dva_t *dva, uint64_t txg)
error = metaslab_activate(msp, METASLAB_WEIGHT_SECONDARY);
if (error == 0 && !space_map_contains(msp->ms_map, offset, size))
- error = ENOENT;
+ error = SET_ERROR(ENOENT);
if (error || txg == 0) { /* txg == 0 indicates dry run */
mutex_exit(&msp->ms_lock);
@@ -1790,7 +1790,7 @@ metaslab_alloc(spa_t *spa, metaslab_class_t *mc, uint64_t psize, blkptr_t *bp,
if (mc->mc_rotor == NULL) { /* no vdevs in this class */
spa_config_exit(spa, SCL_ALLOC, FTAG);
- return (ENOSPC);
+ return (SET_ERROR(ENOSPC));
}
ASSERT(ndvas > 0 && ndvas <= spa_max_replication(spa));
diff --git a/uts/common/fs/zfs/sa.c b/uts/common/fs/zfs/sa.c
index 05f329c..996f6e1 100644
--- a/uts/common/fs/zfs/sa.c
+++ b/uts/common/fs/zfs/sa.c
@@ -22,7 +22,7 @@
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* Portions Copyright 2011 iXsystems, Inc
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
#include <sys/zfs_context.h>
@@ -373,7 +373,7 @@ sa_attr_op(sa_handle_t *hdl, sa_bulk_attr_t *bulk, int count,
switch (data_op) {
case SA_LOOKUP:
if (bulk[i].sa_addr == NULL)
- return (ENOENT);
+ return (SET_ERROR(ENOENT));
if (bulk[i].sa_data) {
SA_COPY_DATA(bulk[i].sa_data_func,
bulk[i].sa_addr, bulk[i].sa_data,
@@ -503,7 +503,7 @@ sa_resize_spill(sa_handle_t *hdl, uint32_t size, dmu_tx_t *tx)
blocksize = SPA_MINBLOCKSIZE;
} else if (size > SPA_MAXBLOCKSIZE) {
ASSERT(0);
- return (EFBIG);
+ return (SET_ERROR(EFBIG));
} else {
blocksize = P2ROUNDUP_TYPED(size, SPA_MINBLOCKSIZE, uint32_t);
}
@@ -677,7 +677,7 @@ sa_build_layouts(sa_handle_t *hdl, sa_bulk_attr_t *attr_desc, int attr_count,
SA_BONUS, &i, &used, &spilling);
if (used > SPA_MAXBLOCKSIZE)
- return (EFBIG);
+ return (SET_ERROR(EFBIG));
VERIFY(0 == dmu_set_bonus(hdl->sa_bonus, spilling ?
MIN(DN_MAX_BONUSLEN - sizeof (blkptr_t), used + hdrsize) :
@@ -701,7 +701,7 @@ sa_build_layouts(sa_handle_t *hdl, sa_bulk_attr_t *attr_desc, int attr_count,
&spill_used, &dummy);
if (spill_used > SPA_MAXBLOCKSIZE)
- return (EFBIG);
+ return (SET_ERROR(EFBIG));
buf_space = hdl->sa_spill->db_size - spillhdrsize;
if (BUF_SPACE_NEEDED(spill_used, spillhdrsize) >
@@ -858,7 +858,7 @@ sa_attr_table_setup(objset_t *os, sa_attr_reg_t *reg_attrs, int count)
*/
if (error || (error == 0 && sa_attr_count == 0)) {
if (error == 0)
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
goto bail;
}
sa_reg_count = sa_attr_count;
@@ -889,7 +889,7 @@ sa_attr_table_setup(objset_t *os, sa_attr_reg_t *reg_attrs, int count)
error = zap_lookup(os, sa->sa_reg_attr_obj,
reg_attrs[i].sa_name, 8, 1, &attr_value);
else
- error = ENOENT;
+ error = SET_ERROR(ENOENT);
switch (error) {
case ENOENT:
sa->sa_user_table[i] = (sa_attr_type_t)sa_attr_count;
@@ -1048,7 +1048,7 @@ sa_setup(objset_t *os, uint64_t sa_obj, sa_attr_reg_t *reg_attrs, int count,
*/
if (error || (error == 0 && layout_count == 0)) {
if (error == 0)
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
goto fail;
}
diff --git a/uts/common/fs/zfs/spa.c b/uts/common/fs/zfs/spa.c
index 004dfe9..0fc3e66 100644
--- a/uts/common/fs/zfs/spa.c
+++ b/uts/common/fs/zfs/spa.c
@@ -21,7 +21,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
* Copyright 2013 Nexenta Systems, Inc. All rights reserved.
*/
@@ -401,7 +401,7 @@ spa_prop_validate(spa_t *spa, nvlist_t *props)
switch (prop) {
case ZPROP_INVAL:
if (!zpool_prop_feature(propname)) {
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
break;
}
@@ -409,23 +409,23 @@ spa_prop_validate(spa_t *spa, nvlist_t *props)
* Sanitize the input.
*/
if (nvpair_type(elem) != DATA_TYPE_UINT64) {
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
break;
}
if (nvpair_value_uint64(elem, &intval) != 0) {
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
break;
}
if (intval != 0) {
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
break;
}
fname = strchr(propname, '@') + 1;
if (zfeature_lookup_name(fname, NULL) != 0) {
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
break;
}
@@ -438,7 +438,7 @@ spa_prop_validate(spa_t *spa, nvlist_t *props)
(intval < spa_version(spa) ||
intval > SPA_VERSION_BEFORE_FEATURES ||
has_feature))
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
break;
case ZPOOL_PROP_DELEGATION:
@@ -447,7 +447,7 @@ spa_prop_validate(spa_t *spa, nvlist_t *props)
case ZPOOL_PROP_AUTOEXPAND:
error = nvpair_value_uint64(elem, &intval);
if (!error && intval > 1)
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
break;
case ZPOOL_PROP_BOOTFS:
@@ -457,7 +457,7 @@ spa_prop_validate(spa_t *spa, nvlist_t *props)
* the bootfs property cannot be set.
*/
if (spa_version(spa) < SPA_VERSION_BOOTFS) {
- error = ENOTSUP;
+ error = SET_ERROR(ENOTSUP);
break;
}
@@ -465,7 +465,7 @@ spa_prop_validate(spa_t *spa, nvlist_t *props)
* Make sure the vdev config is bootable
*/
if (!vdev_is_bootable(spa->spa_root_vdev)) {
- error = ENOTSUP;
+ error = SET_ERROR(ENOTSUP);
break;
}
@@ -489,13 +489,13 @@ spa_prop_validate(spa_t *spa, nvlist_t *props)
/* Must be ZPL and not gzip compressed. */
if (dmu_objset_type(os) != DMU_OST_ZFS) {
- error = ENOTSUP;
+ error = SET_ERROR(ENOTSUP);
} else if ((error =
dsl_prop_get_int_ds(dmu_objset_ds(os),
zfs_prop_to_name(ZFS_PROP_COMPRESSION),
&compress)) == 0 &&
!BOOTFS_COMPRESS_VALID(compress)) {
- error = ENOTSUP;
+ error = SET_ERROR(ENOTSUP);
} else {
objnum = dmu_objset_id(os);
}
@@ -507,7 +507,7 @@ spa_prop_validate(spa_t *spa, nvlist_t *props)
error = nvpair_value_uint64(elem, &intval);
if (!error && (intval < ZIO_FAILURE_MODE_WAIT ||
intval > ZIO_FAILURE_MODE_PANIC))
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
/*
* This is a special case which only occurs when
@@ -521,7 +521,7 @@ spa_prop_validate(spa_t *spa, nvlist_t *props)
*/
if (!error && spa_suspended(spa)) {
spa->spa_failmode = intval;
- error = EIO;
+ error = SET_ERROR(EIO);
}
break;
@@ -536,7 +536,7 @@ spa_prop_validate(spa_t *spa, nvlist_t *props)
break;
if (strval[0] != '/') {
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
break;
}
@@ -545,7 +545,7 @@ spa_prop_validate(spa_t *spa, nvlist_t *props)
if (slash[1] == '\0' || strcmp(slash, "/.") == 0 ||
strcmp(slash, "/..") == 0)
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
break;
case ZPOOL_PROP_COMMENT:
@@ -559,7 +559,7 @@ spa_prop_validate(spa_t *spa, nvlist_t *props)
* there is an easy-to-use kernel isprint().
*/
if (*check >= 0x7f) {
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
break;
}
check++;
@@ -570,12 +570,12 @@ spa_prop_validate(spa_t *spa, nvlist_t *props)
case ZPOOL_PROP_DEDUPDITTO:
if (spa_version(spa) < SPA_VERSION_DEDUP)
- error = ENOTSUP;
+ error = SET_ERROR(ENOTSUP);
else
error = nvpair_value_uint64(elem, &intval);
if (error == 0 &&
intval != 0 && intval < ZIO_DEDUPDITTO_MIN)
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
break;
}
@@ -707,7 +707,7 @@ spa_change_guid_check(void *arg, dmu_tx_t *tx)
spa_config_exit(spa, SCL_STATE, FTAG);
if (vdev_state != VDEV_STATE_HEALTHY)
- return (ENXIO);
+ return (SET_ERROR(ENXIO));
ASSERT3U(spa_guid(spa), !=, *newguid);
@@ -1163,7 +1163,7 @@ spa_config_parse(spa_t *spa, vdev_t **vdp, nvlist_t *nv, vdev_t *parent,
if (error) {
vdev_free(*vdp);
*vdp = NULL;
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
for (int c = 0; c < children; c++) {
@@ -1872,7 +1872,7 @@ spa_load_verify(spa_t *spa)
if (error) {
if (error != ENXIO && error != EIO)
- error = EIO;
+ error = SET_ERROR(EIO);
return (error);
}
@@ -2000,7 +2000,7 @@ spa_load(spa_t *spa, spa_load_state_t state, spa_import_type_t type,
nvlist_t *nvl;
if (nvlist_lookup_uint64(config, ZPOOL_CONFIG_POOL_GUID, &pool_guid))
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
ASSERT(spa->spa_comment == NULL);
if (nvlist_lookup_string(config, ZPOOL_CONFIG_COMMENT, &comment) == 0)
@@ -2019,7 +2019,7 @@ spa_load(spa_t *spa, spa_load_state_t state, spa_import_type_t type,
if ((state == SPA_LOAD_IMPORT || state == SPA_LOAD_TRYIMPORT) &&
spa_guid_exists(pool_guid, 0)) {
- error = EEXIST;
+ error = SET_ERROR(EEXIST);
} else {
spa->spa_config_guid = pool_guid;
@@ -2085,7 +2085,7 @@ spa_load_impl(spa_t *spa, uint64_t pool_guid, nvlist_t *config,
spa->spa_load_state = state;
if (nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE, &nvroot))
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
parse = (type == SPA_IMPORT_EXISTING ?
VDEV_ALLOC_LOAD : VDEV_ALLOC_SPLIT);
@@ -2145,7 +2145,7 @@ spa_load_impl(spa_t *spa, uint64_t pool_guid, nvlist_t *config,
return (error);
if (rvd->vdev_state <= VDEV_STATE_CANT_OPEN)
- return (ENXIO);
+ return (SET_ERROR(ENXIO));
}
/*
@@ -2380,7 +2380,7 @@ spa_load_impl(spa_t *spa, uint64_t pool_guid, nvlist_t *config,
"See: http://illumos.org/msg/ZFS-8000-EY",
spa_name(spa), hostname,
(unsigned long)hostid);
- return (EBADF);
+ return (SET_ERROR(EBADF));
}
}
if (nvlist_lookup_nvlist(spa->spa_config,
@@ -2569,7 +2569,7 @@ spa_load_impl(spa_t *spa, uint64_t pool_guid, nvlist_t *config,
* more toplevel vdevs are faulted.
*/
if (rvd->vdev_state <= VDEV_STATE_CANT_OPEN)
- return (ENXIO);
+ return (SET_ERROR(ENXIO));
if (spa_check_logs(spa)) {
*ereport = FM_EREPORT_ZFS_LOG_REPLAY;
@@ -2831,7 +2831,7 @@ spa_open_common(const char *pool, spa_t **spapp, void *tag, nvlist_t *nvpolicy,
if ((spa = spa_lookup(pool)) == NULL) {
if (locked)
mutex_exit(&spa_namespace_lock);
- return (ENOENT);
+ return (SET_ERROR(ENOENT));
}
if (spa->spa_state == POOL_STATE_UNINITIALIZED) {
@@ -2864,7 +2864,7 @@ spa_open_common(const char *pool, spa_t **spapp, void *tag, nvlist_t *nvpolicy,
spa_remove(spa);
if (locked)
mutex_exit(&spa_namespace_lock);
- return (ENOENT);
+ return (SET_ERROR(ENOENT));
}
if (error) {
@@ -3195,14 +3195,14 @@ spa_validate_aux_devs(spa_t *spa, nvlist_t *nvroot, uint64_t crtxg, int mode,
return (0);
if (ndev == 0)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
/*
* Make sure the pool is formatted with a version that supports this
* device type.
*/
if (spa_version(spa) < version)
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
/*
* Set the pending device list so we correctly handle device in-use
@@ -3218,7 +3218,7 @@ spa_validate_aux_devs(spa_t *spa, nvlist_t *nvroot, uint64_t crtxg, int mode,
if (!vd->vdev_ops->vdev_op_leaf) {
vdev_free(vd);
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
goto out;
}
@@ -3229,7 +3229,7 @@ spa_validate_aux_devs(spa_t *spa, nvlist_t *nvroot, uint64_t crtxg, int mode,
#ifdef _KERNEL
if ((strcmp(config, ZPOOL_CONFIG_L2CACHE) == 0) &&
strcmp(vd->vdev_ops->vdev_op_type, VDEV_TYPE_DISK) != 0) {
- error = ENOTBLK;
+ error = SET_ERROR(ENOTBLK);
vdev_free(vd);
goto out;
}
@@ -3368,7 +3368,7 @@ spa_create(const char *pool, nvlist_t *nvroot, nvlist_t *props,
mutex_enter(&spa_namespace_lock);
if (spa_lookup(pool) != NULL) {
mutex_exit(&spa_namespace_lock);
- return (EEXIST);
+ return (SET_ERROR(EEXIST));
}
/*
@@ -3421,7 +3421,7 @@ spa_create(const char *pool, nvlist_t *nvroot, nvlist_t *props,
ASSERT(error != 0 || spa->spa_root_vdev == rvd);
if (error == 0 && !zfs_allocatable_devs(nvroot))
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
if (error == 0 &&
(error = vdev_create(rvd, txg, B_FALSE)) == 0 &&
@@ -3693,7 +3693,7 @@ spa_import_rootpool(char *devpath, char *devid)
if (config == NULL) {
cmn_err(CE_NOTE, "Cannot read the pool label from '%s'",
devpath);
- return (EIO);
+ return (SET_ERROR(EIO));
}
VERIFY(nvlist_lookup_string(config, ZPOOL_CONFIG_POOL_NAME,
@@ -3736,7 +3736,7 @@ spa_import_rootpool(char *devpath, char *devid)
if ((bvd = vdev_lookup_by_guid(rvd, guid)) == NULL) {
cmn_err(CE_NOTE, "Can not find the boot vdev for guid %llu",
(u_longlong_t)guid);
- error = ENOENT;
+ error = SET_ERROR(ENOENT);
goto out;
}
@@ -3748,7 +3748,7 @@ spa_import_rootpool(char *devpath, char *devid)
if (avd != bvd) {
cmn_err(CE_NOTE, "The boot device is 'degraded'. Please "
"try booting from '%s'", avd->vdev_path);
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
goto out;
}
@@ -3762,7 +3762,7 @@ spa_import_rootpool(char *devpath, char *devid)
"try booting from '%s'",
bvd->vdev_parent->
vdev_child[bvd->vdev_parent->vdev_children - 1]->vdev_path);
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
goto out;
}
@@ -3802,7 +3802,7 @@ spa_import(const char *pool, nvlist_t *config, nvlist_t *props, uint64_t flags)
mutex_enter(&spa_namespace_lock);
if (spa_lookup(pool) != NULL) {
mutex_exit(&spa_namespace_lock);
- return (EEXIST);
+ return (SET_ERROR(EEXIST));
}
/*
@@ -4075,12 +4075,12 @@ spa_export_common(char *pool, int new_state, nvlist_t **oldconfig,
*oldconfig = NULL;
if (!(spa_mode_global & FWRITE))
- return (EROFS);
+ return (SET_ERROR(EROFS));
mutex_enter(&spa_namespace_lock);
if ((spa = spa_lookup(pool)) == NULL) {
mutex_exit(&spa_namespace_lock);
- return (ENOENT);
+ return (SET_ERROR(ENOENT));
}
/*
@@ -4114,7 +4114,7 @@ spa_export_common(char *pool, int new_state, nvlist_t **oldconfig,
new_state != POOL_STATE_UNINITIALIZED)) {
spa_async_resume(spa);
mutex_exit(&spa_namespace_lock);
- return (EBUSY);
+ return (SET_ERROR(EBUSY));
}
/*
@@ -4127,7 +4127,7 @@ spa_export_common(char *pool, int new_state, nvlist_t **oldconfig,
spa_has_active_shared_spare(spa)) {
spa_async_resume(spa);
mutex_exit(&spa_namespace_lock);
- return (EXDEV);
+ return (SET_ERROR(EXDEV));
}
/*
@@ -4835,7 +4835,7 @@ spa_vdev_split_mirror(spa_t *spa, char *newname, nvlist_t *config,
spa->spa_root_vdev->vdev_child[c]->vdev_islog) {
continue;
} else {
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
break;
}
}
@@ -4843,14 +4843,14 @@ spa_vdev_split_mirror(spa_t *spa, char *newname, nvlist_t *config,
/* which disk is going to be split? */
if (nvlist_lookup_uint64(child[c], ZPOOL_CONFIG_GUID,
&glist[c]) != 0) {
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
break;
}
/* look it up in the spa */
vml[c] = spa_lookup_by_guid(spa, glist[c], B_FALSE);
if (vml[c] == NULL) {
- error = ENODEV;
+ error = SET_ERROR(ENODEV);
break;
}
@@ -4864,12 +4864,12 @@ spa_vdev_split_mirror(spa_t *spa, char *newname, nvlist_t *config,
vml[c]->vdev_children != 0 ||
vml[c]->vdev_state != VDEV_STATE_HEALTHY ||
c != spa->spa_root_vdev->vdev_child[c]->vdev_id) {
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
break;
}
if (vdev_dtl_required(vml[c])) {
- error = EBUSY;
+ error = SET_ERROR(EBUSY);
break;
}
@@ -5097,7 +5097,7 @@ spa_vdev_remove_evacuate(spa_t *spa, vdev_t *vd)
if (vd->vdev_stat.vs_alloc != 0)
error = spa_offline_log(spa);
} else {
- error = ENOTSUP;
+ error = SET_ERROR(ENOTSUP);
}
if (error)
@@ -5206,7 +5206,7 @@ spa_vdev_remove(spa_t *spa, uint64_t guid, boolean_t unspare)
spa_load_spares(spa);
spa->spa_spares.sav_sync = B_TRUE;
} else {
- error = EBUSY;
+ error = SET_ERROR(EBUSY);
}
} else if (spa->spa_l2cache.sav_vdevs != NULL &&
nvlist_lookup_nvlist_array(spa->spa_l2cache.sav_config,
@@ -5266,12 +5266,12 @@ spa_vdev_remove(spa_t *spa, uint64_t guid, boolean_t unspare)
/*
* Normal vdevs cannot be removed (yet).
*/
- error = ENOTSUP;
+ error = SET_ERROR(ENOTSUP);
} else {
/*
* There is no vdev of any kind with the specified guid.
*/
- error = ENOENT;
+ error = SET_ERROR(ENOENT);
}
if (!locked)
@@ -5458,7 +5458,7 @@ spa_scan_stop(spa_t *spa)
{
ASSERT(spa_config_held(spa, SCL_ALL, RW_WRITER) == 0);
if (dsl_scan_resilvering(spa->spa_dsl_pool))
- return (EBUSY);
+ return (SET_ERROR(EBUSY));
return (dsl_scan_cancel(spa->spa_dsl_pool));
}
@@ -5468,7 +5468,7 @@ spa_scan(spa_t *spa, pool_scan_func_t func)
ASSERT(spa_config_held(spa, SCL_ALL, RW_WRITER) == 0);
if (func >= POOL_SCAN_FUNCS || func == POOL_SCAN_NONE)
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
/*
* If a resilver was requested, but there is no DTL on a
diff --git a/uts/common/fs/zfs/spa_errlog.c b/uts/common/fs/zfs/spa_errlog.c
index 282140b..9152846 100644
--- a/uts/common/fs/zfs/spa_errlog.c
+++ b/uts/common/fs/zfs/spa_errlog.c
@@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
/*
@@ -175,7 +176,7 @@ process_error_log(spa_t *spa, uint64_t obj, void *addr, size_t *count)
if (*count == 0) {
zap_cursor_fini(&zc);
- return (ENOMEM);
+ return (SET_ERROR(ENOMEM));
}
name_to_bookmark(za.za_name, &zb);
@@ -183,7 +184,7 @@ process_error_log(spa_t *spa, uint64_t obj, void *addr, size_t *count)
if (copyout(&zb, (char *)addr +
(*count - 1) * sizeof (zbookmark_t),
sizeof (zbookmark_t)) != 0)
- return (EFAULT);
+ return (SET_ERROR(EFAULT));
*count -= 1;
}
@@ -201,12 +202,12 @@ process_error_list(avl_tree_t *list, void *addr, size_t *count)
for (se = avl_first(list); se != NULL; se = AVL_NEXT(list, se)) {
if (*count == 0)
- return (ENOMEM);
+ return (SET_ERROR(ENOMEM));
if (copyout(&se->se_bookmark, (char *)addr +
(*count - 1) * sizeof (zbookmark_t),
sizeof (zbookmark_t)) != 0)
- return (EFAULT);
+ return (SET_ERROR(EFAULT));
*count -= 1;
}
diff --git a/uts/common/fs/zfs/spa_history.c b/uts/common/fs/zfs/spa_history.c
index eef642a..9e17248 100644
--- a/uts/common/fs/zfs/spa_history.c
+++ b/uts/common/fs/zfs/spa_history.c
@@ -21,7 +21,7 @@
/*
* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
#include <sys/spa.h>
@@ -304,7 +304,7 @@ spa_history_log_nvl(spa_t *spa, nvlist_t *nvl)
nvlist_t *nvarg;
if (spa_version(spa) < SPA_VERSION_ZPOOL_HISTORY || !spa_writeable(spa))
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
tx = dmu_tx_create_dd(spa_get_dsl(spa)->dp_mos_dir);
err = dmu_tx_assign(tx, TXG_WAIT);
@@ -348,7 +348,7 @@ spa_history_get(spa_t *spa, uint64_t *offp, uint64_t *len, char *buf)
* that's ok, just return ENOENT.
*/
if (!spa->spa_history)
- return (ENOENT);
+ return (SET_ERROR(ENOENT));
/*
* The history is logged asynchronously, so when they request
diff --git a/uts/common/fs/zfs/spa_misc.c b/uts/common/fs/zfs/spa_misc.c
index 1663abb..e57d8ab 100644
--- a/uts/common/fs/zfs/spa_misc.c
+++ b/uts/common/fs/zfs/spa_misc.c
@@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
*/
@@ -1820,7 +1820,7 @@ spa_scan_get_stats(spa_t *spa, pool_scan_stat_t *ps)
dsl_scan_t *scn = spa->spa_dsl_pool ? spa->spa_dsl_pool->dp_scan : NULL;
if (scn == NULL || scn->scn_phys.scn_func == POOL_SCAN_NONE)
- return (ENOENT);
+ return (SET_ERROR(ENOENT));
bzero(ps, sizeof (pool_scan_stat_t));
/* data stored on disk */
diff --git a/uts/common/fs/zfs/uberblock.c b/uts/common/fs/zfs/uberblock.c
index 692cda1..a07dc00 100644
--- a/uts/common/fs/zfs/uberblock.c
+++ b/uts/common/fs/zfs/uberblock.c
@@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
#include <sys/zfs_context.h>
@@ -33,7 +34,7 @@ uberblock_verify(uberblock_t *ub)
byteswap_uint64_array(ub, sizeof (uberblock_t));
if (ub->ub_magic != UBERBLOCK_MAGIC)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
return (0);
}
diff --git a/uts/common/fs/zfs/vdev.c b/uts/common/fs/zfs/vdev.c
index 41f9a07..0c7f794 100644
--- a/uts/common/fs/zfs/vdev.c
+++ b/uts/common/fs/zfs/vdev.c
@@ -22,7 +22,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
#include <sys/zfs_context.h>
@@ -350,10 +350,10 @@ vdev_alloc(spa_t *spa, vdev_t **vdp, nvlist_t *nv, vdev_t *parent, uint_t id,
ASSERT(spa_config_held(spa, SCL_ALL, RW_WRITER) == SCL_ALL);
if (nvlist_lookup_string(nv, ZPOOL_CONFIG_TYPE, &type) != 0)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
if ((ops = vdev_getops(type)) == NULL)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
/*
* If this is a load, get the vdev guid from the nvlist.
@@ -364,26 +364,26 @@ vdev_alloc(spa_t *spa, vdev_t **vdp, nvlist_t *nv, vdev_t *parent, uint_t id,
if (nvlist_lookup_uint64(nv, ZPOOL_CONFIG_ID, &label_id) ||
label_id != id)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
if (nvlist_lookup_uint64(nv, ZPOOL_CONFIG_GUID, &guid) != 0)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
} else if (alloctype == VDEV_ALLOC_SPARE) {
if (nvlist_lookup_uint64(nv, ZPOOL_CONFIG_GUID, &guid) != 0)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
} else if (alloctype == VDEV_ALLOC_L2CACHE) {
if (nvlist_lookup_uint64(nv, ZPOOL_CONFIG_GUID, &guid) != 0)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
} else if (alloctype == VDEV_ALLOC_ROOTPOOL) {
if (nvlist_lookup_uint64(nv, ZPOOL_CONFIG_GUID, &guid) != 0)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
/*
* The first allocated vdev must be of type 'root'.
*/
if (ops != &vdev_root_ops && spa->spa_root_vdev == NULL)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
/*
* Determine whether we're a log vdev.
@@ -391,10 +391,10 @@ vdev_alloc(spa_t *spa, vdev_t **vdp, nvlist_t *nv, vdev_t *parent, uint_t id,
islog = 0;
(void) nvlist_lookup_uint64(nv, ZPOOL_CONFIG_IS_LOG, &islog);
if (islog && spa_version(spa) < SPA_VERSION_SLOGS)
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
if (ops == &vdev_hole_ops && spa_version(spa) < SPA_VERSION_HOLES)
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
/*
* Set the nparity property for RAID-Z vdevs.
@@ -404,24 +404,24 @@ vdev_alloc(spa_t *spa, vdev_t **vdp, nvlist_t *nv, vdev_t *parent, uint_t id,
if (nvlist_lookup_uint64(nv, ZPOOL_CONFIG_NPARITY,
&nparity) == 0) {
if (nparity == 0 || nparity > VDEV_RAIDZ_MAXPARITY)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
/*
* Previous versions could only support 1 or 2 parity
* device.
*/
if (nparity > 1 &&
spa_version(spa) < SPA_VERSION_RAIDZ2)
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
if (nparity > 2 &&
spa_version(spa) < SPA_VERSION_RAIDZ3)
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
} else {
/*
* We require the parity to be specified for SPAs that
* support multiple parity levels.
*/
if (spa_version(spa) >= SPA_VERSION_RAIDZ2)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
/*
* Otherwise, we default to 1 parity device for RAID-Z.
*/
@@ -939,7 +939,7 @@ vdev_probe_done(zio_t *zio)
ASSERT(zio->io_error != 0);
zfs_ereport_post(FM_EREPORT_ZFS_PROBE_FAILURE,
spa, vd, NULL, 0, 0);
- zio->io_error = ENXIO;
+ zio->io_error = SET_ERROR(ENXIO);
}
mutex_enter(&vd->vdev_probe_lock);
@@ -949,7 +949,7 @@ vdev_probe_done(zio_t *zio)
while ((pio = zio_walk_parents(zio)) != NULL)
if (!vdev_accessible(vd, pio))
- pio->io_error = ENXIO;
+ pio->io_error = SET_ERROR(ENXIO);
kmem_free(vps, sizeof (*vps));
}
@@ -1134,11 +1134,11 @@ vdev_open(vdev_t *vd)
vd->vdev_label_aux == VDEV_AUX_EXTERNAL);
vdev_set_state(vd, B_TRUE, VDEV_STATE_FAULTED,
vd->vdev_label_aux);
- return (ENXIO);
+ return (SET_ERROR(ENXIO));
} else if (vd->vdev_offline) {
ASSERT(vd->vdev_children == 0);
vdev_set_state(vd, B_TRUE, VDEV_STATE_OFFLINE, VDEV_AUX_NONE);
- return (ENXIO);
+ return (SET_ERROR(ENXIO));
}
error = vd->vdev_ops->vdev_op_open(vd, &osize, &max_osize, &ashift);
@@ -1173,7 +1173,7 @@ vdev_open(vdev_t *vd)
vd->vdev_label_aux == VDEV_AUX_EXTERNAL);
vdev_set_state(vd, B_TRUE, VDEV_STATE_FAULTED,
vd->vdev_label_aux);
- return (ENXIO);
+ return (SET_ERROR(ENXIO));
}
if (vd->vdev_degraded) {
@@ -1205,7 +1205,7 @@ vdev_open(vdev_t *vd)
if (osize < SPA_MINDEVSIZE) {
vdev_set_state(vd, B_TRUE, VDEV_STATE_CANT_OPEN,
VDEV_AUX_TOO_SMALL);
- return (EOVERFLOW);
+ return (SET_ERROR(EOVERFLOW));
}
psize = osize;
asize = osize - (VDEV_LABEL_START_SIZE + VDEV_LABEL_END_SIZE);
@@ -1216,7 +1216,7 @@ vdev_open(vdev_t *vd)
(VDEV_LABEL_START_SIZE + VDEV_LABEL_END_SIZE)) {
vdev_set_state(vd, B_TRUE, VDEV_STATE_CANT_OPEN,
VDEV_AUX_TOO_SMALL);
- return (EOVERFLOW);
+ return (SET_ERROR(EOVERFLOW));
}
psize = 0;
asize = osize;
@@ -1231,7 +1231,7 @@ vdev_open(vdev_t *vd)
if (asize < vd->vdev_min_asize) {
vdev_set_state(vd, B_TRUE, VDEV_STATE_CANT_OPEN,
VDEV_AUX_BAD_LABEL);
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
if (vd->vdev_asize == 0) {
@@ -1317,7 +1317,7 @@ vdev_validate(vdev_t *vd, boolean_t strict)
for (int c = 0; c < vd->vdev_children; c++)
if (vdev_validate(vd->vdev_child[c], strict) != 0)
- return (EBADF);
+ return (SET_ERROR(EBADF));
/*
* If the device has already failed, or was marked offline, don't do
@@ -1403,7 +1403,7 @@ vdev_validate(vdev_t *vd, boolean_t strict)
if (!(spa->spa_import_flags & ZFS_IMPORT_VERBATIM) &&
spa_load_state(spa) == SPA_LOAD_OPEN &&
state != POOL_STATE_ACTIVE)
- return (EBADF);
+ return (SET_ERROR(EBADF));
/*
* If we were able to open and validate a vdev that was
diff --git a/uts/common/fs/zfs/vdev_cache.c b/uts/common/fs/zfs/vdev_cache.c
index 77f8116..be2a999 100644
--- a/uts/common/fs/zfs/vdev_cache.c
+++ b/uts/common/fs/zfs/vdev_cache.c
@@ -22,6 +22,9 @@
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+/*
+ * Copyright (c) 2013 by Delphix. All rights reserved.
+ */
#include <sys/zfs_context.h>
#include <sys/spa.h>
@@ -259,16 +262,16 @@ vdev_cache_read(zio_t *zio)
ASSERT(zio->io_type == ZIO_TYPE_READ);
if (zio->io_flags & ZIO_FLAG_DONT_CACHE)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
if (zio->io_size > zfs_vdev_cache_max)
- return (EOVERFLOW);
+ return (SET_ERROR(EOVERFLOW));
/*
* If the I/O straddles two or more cache blocks, don't cache it.
*/
if (P2BOUNDARY(zio->io_offset, zio->io_size, VCBS))
- return (EXDEV);
+ return (SET_ERROR(EXDEV));
ASSERT(cache_phase + zio->io_size <= VCBS);
@@ -280,7 +283,7 @@ vdev_cache_read(zio_t *zio)
if (ve != NULL) {
if (ve->ve_missed_update) {
mutex_exit(&vc->vc_lock);
- return (ESTALE);
+ return (SET_ERROR(ESTALE));
}
if ((fio = ve->ve_fill_io) != NULL) {
@@ -303,7 +306,7 @@ vdev_cache_read(zio_t *zio)
if (ve == NULL) {
mutex_exit(&vc->vc_lock);
- return (ENOMEM);
+ return (SET_ERROR(ENOMEM));
}
fio = zio_vdev_delegated_io(zio->io_vd, cache_offset,
diff --git a/uts/common/fs/zfs/vdev_disk.c b/uts/common/fs/zfs/vdev_disk.c
index 655728c..aa5b67d 100644
--- a/uts/common/fs/zfs/vdev_disk.c
+++ b/uts/common/fs/zfs/vdev_disk.c
@@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
#include <sys/zfs_context.h>
@@ -145,7 +145,7 @@ vdev_disk_open(vdev_t *vd, uint64_t *psize, uint64_t *max_psize,
*/
if (vd->vdev_path == NULL || vd->vdev_path[0] != '/') {
vd->vdev_stat.vs_aux = VDEV_AUX_BAD_LABEL;
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
/*
@@ -180,7 +180,7 @@ vdev_disk_open(vdev_t *vd, uint64_t *psize, uint64_t *max_psize,
if (ddi_devid_str_decode(vd->vdev_devid, &dvd->vd_devid,
&dvd->vd_minor) != 0) {
vd->vdev_stat.vs_aux = VDEV_AUX_BAD_LABEL;
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
}
@@ -216,7 +216,7 @@ vdev_disk_open(vdev_t *vd, uint64_t *psize, uint64_t *max_psize,
if (error == 0 && vd->vdev_devid != NULL &&
ldi_get_devid(dvd->vd_lh, &devid) == 0) {
if (ddi_devid_compare(devid, dvd->vd_devid) != 0) {
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
(void) ldi_close(dvd->vd_lh, spa_mode(spa),
kcred);
dvd->vd_lh = NULL;
@@ -298,7 +298,7 @@ skip_open:
*/
if (ldi_get_size(dvd->vd_lh, psize) != 0) {
vd->vdev_stat.vs_aux = VDEV_AUX_OPEN_FAILED;
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
/*
@@ -369,7 +369,7 @@ vdev_disk_physio(ldi_handle_t vd_lh, caddr_t data, size_t size,
int error = 0;
if (vd_lh == NULL)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
ASSERT(flags & B_READ || flags & B_WRITE);
@@ -383,7 +383,7 @@ vdev_disk_physio(ldi_handle_t vd_lh, caddr_t data, size_t size,
error = ldi_strategy(vd_lh, bp);
ASSERT(error == 0);
if ((error = biowait(bp)) == 0 && bp->b_resid != 0)
- error = EIO;
+ error = SET_ERROR(EIO);
freerbuf(bp);
return (error);
@@ -403,7 +403,7 @@ vdev_disk_io_intr(buf_t *bp)
zio->io_error = (geterror(bp) != 0 ? EIO : 0);
if (zio->io_error == 0 && bp->b_resid != 0)
- zio->io_error = EIO;
+ zio->io_error = SET_ERROR(EIO);
kmem_free(vb, sizeof (vdev_buf_t));
@@ -444,7 +444,7 @@ vdev_disk_io_start(zio_t *zio)
if (zio->io_type == ZIO_TYPE_IOCTL) {
/* XXPOLICY */
if (!vdev_readable(vd)) {
- zio->io_error = ENXIO;
+ zio->io_error = SET_ERROR(ENXIO);
return (ZIO_PIPELINE_CONTINUE);
}
@@ -456,7 +456,7 @@ vdev_disk_io_start(zio_t *zio)
break;
if (vd->vdev_nowritecache) {
- zio->io_error = ENOTSUP;
+ zio->io_error = SET_ERROR(ENOTSUP);
break;
}
@@ -494,7 +494,7 @@ vdev_disk_io_start(zio_t *zio)
break;
default:
- zio->io_error = ENOTSUP;
+ zio->io_error = SET_ERROR(ENOTSUP);
}
return (ZIO_PIPELINE_CONTINUE);
@@ -599,7 +599,7 @@ vdev_disk_read_rootlabel(char *devpath, char *devid, nvlist_t **config)
if (ldi_get_size(vd_lh, &s)) {
(void) ldi_close(vd_lh, FREAD, kcred);
- return (EIO);
+ return (SET_ERROR(EIO));
}
size = P2ALIGN_TYPED(s, sizeof (vdev_label_t), uint64_t);
@@ -641,7 +641,7 @@ vdev_disk_read_rootlabel(char *devpath, char *devid, nvlist_t **config)
kmem_free(label, sizeof (vdev_label_t));
(void) ldi_close(vd_lh, FREAD, kcred);
if (*config == NULL)
- error = EIDRM;
+ error = SET_ERROR(EIDRM);
return (error);
}
diff --git a/uts/common/fs/zfs/vdev_file.c b/uts/common/fs/zfs/vdev_file.c
index f7cfa9b..2e67544 100644
--- a/uts/common/fs/zfs/vdev_file.c
+++ b/uts/common/fs/zfs/vdev_file.c
@@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
#include <sys/zfs_context.h>
@@ -62,7 +62,7 @@ vdev_file_open(vdev_t *vd, uint64_t *psize, uint64_t *max_psize,
*/
if (vd->vdev_path == NULL || vd->vdev_path[0] != '/') {
vd->vdev_stat.vs_aux = VDEV_AUX_BAD_LABEL;
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
/*
@@ -100,7 +100,7 @@ vdev_file_open(vdev_t *vd, uint64_t *psize, uint64_t *max_psize,
*/
if (vp->v_type != VREG) {
vd->vdev_stat.vs_aux = VDEV_AUX_OPEN_FAILED;
- return (ENODEV);
+ return (SET_ERROR(ENODEV));
}
#endif
@@ -155,7 +155,7 @@ vdev_file_io_intr(buf_t *bp)
zio->io_error = (geterror(bp) != 0 ? EIO : 0);
if (zio->io_error == 0 && bp->b_resid != 0)
- zio->io_error = ENOSPC;
+ zio->io_error = SET_ERROR(ENOSPC);
kmem_free(vb, sizeof (vdev_buf_t));
zio_interrupt(zio);
@@ -194,7 +194,7 @@ vdev_file_io_start(zio_t *zio)
if (zio->io_type == ZIO_TYPE_IOCTL) {
/* XXPOLICY */
if (!vdev_readable(vd)) {
- zio->io_error = ENXIO;
+ zio->io_error = SET_ERROR(ENXIO);
return (ZIO_PIPELINE_CONTINUE);
}
@@ -204,7 +204,7 @@ vdev_file_io_start(zio_t *zio)
kcred, NULL);
break;
default:
- zio->io_error = ENOTSUP;
+ zio->io_error = SET_ERROR(ENOTSUP);
}
return (ZIO_PIPELINE_CONTINUE);
diff --git a/uts/common/fs/zfs/vdev_label.c b/uts/common/fs/zfs/vdev_label.c
index e573feb..5ee7c7d 100644
--- a/uts/common/fs/zfs/vdev_label.c
+++ b/uts/common/fs/zfs/vdev_label.c
@@ -21,7 +21,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
/*
@@ -663,14 +663,14 @@ vdev_label_init(vdev_t *vd, uint64_t crtxg, vdev_labeltype_t reason)
* Dead vdevs cannot be initialized.
*/
if (vdev_is_dead(vd))
- return (EIO);
+ return (SET_ERROR(EIO));
/*
* Determine if the vdev is in use.
*/
if (reason != VDEV_LABEL_REMOVE && reason != VDEV_LABEL_SPLIT &&
vdev_inuse(vd, crtxg, reason, &spare_guid, &l2cache_guid))
- return (EBUSY);
+ return (SET_ERROR(EBUSY));
/*
* If this is a request to add or replace a spare or l2cache device
@@ -1078,7 +1078,7 @@ vdev_label_sync_top_done(zio_t *zio)
uint64_t *good_writes = zio->io_private;
if (*good_writes == 0)
- zio->io_error = EIO;
+ zio->io_error = SET_ERROR(EIO);
kmem_free(good_writes, sizeof (uint64_t));
}
diff --git a/uts/common/fs/zfs/vdev_mirror.c b/uts/common/fs/zfs/vdev_mirror.c
index a28ca3e..fa3bc02 100644
--- a/uts/common/fs/zfs/vdev_mirror.c
+++ b/uts/common/fs/zfs/vdev_mirror.c
@@ -24,7 +24,7 @@
*/
/*
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
#include <sys/zfs_context.h>
@@ -139,7 +139,7 @@ vdev_mirror_open(vdev_t *vd, uint64_t *asize, uint64_t *max_asize,
if (vd->vdev_children == 0) {
vd->vdev_stat.vs_aux = VDEV_AUX_BAD_LABEL;
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
vdev_open_children(vd);
@@ -234,14 +234,14 @@ vdev_mirror_child_select(zio_t *zio)
if (mc->mc_tried || mc->mc_skipped)
continue;
if (!vdev_readable(mc->mc_vd)) {
- mc->mc_error = ENXIO;
+ mc->mc_error = SET_ERROR(ENXIO);
mc->mc_tried = 1; /* don't even try */
mc->mc_skipped = 1;
continue;
}
if (!vdev_dtl_contains(mc->mc_vd, DTL_MISSING, txg, 1))
return (c);
- mc->mc_error = ESTALE;
+ mc->mc_error = SET_ERROR(ESTALE);
mc->mc_skipped = 1;
mc->mc_speculative = 1;
}
@@ -426,7 +426,7 @@ vdev_mirror_io_done(zio_t *zio)
!vdev_dtl_contains(mc->mc_vd, DTL_PARTIAL,
zio->io_txg, 1))
continue;
- mc->mc_error = ESTALE;
+ mc->mc_error = SET_ERROR(ESTALE);
}
zio_nowait(zio_vdev_child_io(zio, zio->io_bp,
diff --git a/uts/common/fs/zfs/vdev_missing.c b/uts/common/fs/zfs/vdev_missing.c
index 3bd8c90..b9eb99d 100644
--- a/uts/common/fs/zfs/vdev_missing.c
+++ b/uts/common/fs/zfs/vdev_missing.c
@@ -24,7 +24,7 @@
*/
/*
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
/*
@@ -69,7 +69,7 @@ vdev_missing_close(vdev_t *vd)
static int
vdev_missing_io_start(zio_t *zio)
{
- zio->io_error = ENOTSUP;
+ zio->io_error = SET_ERROR(ENOTSUP);
return (ZIO_PIPELINE_CONTINUE);
}
diff --git a/uts/common/fs/zfs/vdev_raidz.c b/uts/common/fs/zfs/vdev_raidz.c
index 5c36753..1d6cac0 100644
--- a/uts/common/fs/zfs/vdev_raidz.c
+++ b/uts/common/fs/zfs/vdev_raidz.c
@@ -21,7 +21,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
#include <sys/zfs_context.h>
@@ -1457,7 +1457,7 @@ vdev_raidz_open(vdev_t *vd, uint64_t *asize, uint64_t *max_asize,
if (nparity > VDEV_RAIDZ_MAXPARITY ||
vd->vdev_children < nparity + 1) {
vd->vdev_stat.vs_aux = VDEV_AUX_BAD_LABEL;
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
vdev_open_children(vd);
@@ -1582,7 +1582,7 @@ vdev_raidz_io_start(zio_t *zio)
rm->rm_missingdata++;
else
rm->rm_missingparity++;
- rc->rc_error = ENXIO;
+ rc->rc_error = SET_ERROR(ENXIO);
rc->rc_tried = 1; /* don't even try */
rc->rc_skipped = 1;
continue;
@@ -1592,7 +1592,7 @@ vdev_raidz_io_start(zio_t *zio)
rm->rm_missingdata++;
else
rm->rm_missingparity++;
- rc->rc_error = ESTALE;
+ rc->rc_error = SET_ERROR(ESTALE);
rc->rc_skipped = 1;
continue;
}
@@ -1680,7 +1680,7 @@ raidz_parity_verify(zio_t *zio, raidz_map_t *rm)
continue;
if (bcmp(orig[c], rc->rc_data, rc->rc_size) != 0) {
raidz_checksum_error(zio, rc, orig[c]);
- rc->rc_error = ECKSUM;
+ rc->rc_error = SET_ERROR(ECKSUM);
ret++;
}
zio_buf_free(orig[c], rc->rc_size);
@@ -1804,7 +1804,7 @@ vdev_raidz_combrec(zio_t *zio, int total_errors, int data_errors)
if (rc->rc_tried)
raidz_checksum_error(zio, rc,
orig[i]);
- rc->rc_error = ECKSUM;
+ rc->rc_error = SET_ERROR(ECKSUM);
}
ret = code;
@@ -2080,7 +2080,7 @@ vdev_raidz_io_done(zio_t *zio)
* Start checksum ereports for all children which haven't
* failed, and the IO wasn't speculative.
*/
- zio->io_error = ECKSUM;
+ zio->io_error = SET_ERROR(ECKSUM);
if (!(zio->io_flags & ZIO_FLAG_SPECULATIVE)) {
for (c = 0; c < rm->rm_cols; c++) {
diff --git a/uts/common/fs/zfs/vdev_root.c b/uts/common/fs/zfs/vdev_root.c
index 1abc79d..a5442a5 100644
--- a/uts/common/fs/zfs/vdev_root.c
+++ b/uts/common/fs/zfs/vdev_root.c
@@ -24,7 +24,7 @@
*/
/*
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
#include <sys/zfs_context.h>
@@ -62,7 +62,7 @@ vdev_root_open(vdev_t *vd, uint64_t *asize, uint64_t *max_asize,
if (vd->vdev_children == 0) {
vd->vdev_stat.vs_aux = VDEV_AUX_BAD_LABEL;
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
vdev_open_children(vd);
diff --git a/uts/common/fs/zfs/zap.c b/uts/common/fs/zfs/zap.c
index 009f0a4..0e637d5 100644
--- a/uts/common/fs/zfs/zap.c
+++ b/uts/common/fs/zfs/zap.c
@@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
/*
@@ -325,7 +325,7 @@ zap_grow_ptrtbl(zap_t *zap, dmu_tx_t *tx)
* this is already an aberrant condition.
*/
if (zap->zap_f.zap_phys->zap_ptrtbl.zt_shift >= zap_hashbits(zap) - 2)
- return (ENOSPC);
+ return (SET_ERROR(ENOSPC));
if (zap->zap_f.zap_phys->zap_ptrtbl.zt_numblks == 0) {
/*
@@ -714,7 +714,7 @@ static int
fzap_checkname(zap_name_t *zn)
{
if (zn->zn_key_orig_numints * zn->zn_key_intlen > ZAP_MAXNAMELEN)
- return (ENAMETOOLONG);
+ return (SET_ERROR(ENAMETOOLONG));
return (0);
}
@@ -729,7 +729,7 @@ fzap_checksize(uint64_t integer_size, uint64_t num_integers)
case 8:
break;
default:
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
if (integer_size * num_integers > ZAP_MAXVALUELEN)
@@ -805,7 +805,7 @@ fzap_add_cd(zap_name_t *zn,
retry:
err = zap_leaf_lookup(l, zn, &zeh);
if (err == 0) {
- err = EEXIST;
+ err = SET_ERROR(EEXIST);
goto out;
}
if (err != ENOENT)
@@ -996,7 +996,7 @@ zap_join(objset_t *os, uint64_t fromobj, uint64_t intoobj, dmu_tx_t *tx)
zap_cursor_retrieve(&zc, &za) == 0;
(void) zap_cursor_advance(&zc)) {
if (za.za_integer_length != 8 || za.za_num_integers != 1)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
err = zap_add(os, intoobj, za.za_name,
8, 1, &za.za_first_integer, tx);
if (err)
@@ -1018,7 +1018,7 @@ zap_join_key(objset_t *os, uint64_t fromobj, uint64_t intoobj,
zap_cursor_retrieve(&zc, &za) == 0;
(void) zap_cursor_advance(&zc)) {
if (za.za_integer_length != 8 || za.za_num_integers != 1)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
err = zap_add(os, intoobj, za.za_name,
8, 1, &value, tx);
if (err)
@@ -1042,7 +1042,7 @@ zap_join_increment(objset_t *os, uint64_t fromobj, uint64_t intoobj,
uint64_t delta = 0;
if (za.za_integer_length != 8 || za.za_num_integers != 1)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
err = zap_lookup(os, intoobj, za.za_name, 8, 1, &delta);
if (err != 0 && err != ENOENT)
@@ -1250,7 +1250,7 @@ fzap_cursor_move_to_key(zap_cursor_t *zc, zap_name_t *zn)
zap_entry_handle_t zeh;
if (zn->zn_key_orig_numints * zn->zn_key_intlen > ZAP_MAXNAMELEN)
- return (ENAMETOOLONG);
+ return (SET_ERROR(ENAMETOOLONG));
err = zap_deref_leaf(zc->zc_zap, zn->zn_hash, NULL, RW_READER, &l);
if (err != 0)
diff --git a/uts/common/fs/zfs/zap_leaf.c b/uts/common/fs/zfs/zap_leaf.c
index b867ac4..30cb7d2 100644
--- a/uts/common/fs/zfs/zap_leaf.c
+++ b/uts/common/fs/zfs/zap_leaf.c
@@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
/*
@@ -434,7 +435,7 @@ again:
goto again;
}
- return (ENOENT);
+ return (SET_ERROR(ENOENT));
}
/* Return (h1,cd1 >= h2,cd2) */
@@ -492,14 +493,14 @@ zap_entry_read(const zap_entry_handle_t *zeh,
ASSERT3U(le->le_type, ==, ZAP_CHUNK_ENTRY);
if (le->le_value_intlen > integer_size)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
zap_leaf_array_read(zeh->zeh_leaf, le->le_value_chunk,
le->le_value_intlen, le->le_value_numints,
integer_size, num_integers, buf);
if (zeh->zeh_num_integers > num_integers)
- return (EOVERFLOW);
+ return (SET_ERROR(EOVERFLOW));
return (0);
}
@@ -520,7 +521,7 @@ zap_entry_read_name(zap_t *zap, const zap_entry_handle_t *zeh, uint16_t buflen,
le->le_name_numints, 1, buflen, buf);
}
if (le->le_name_numints > buflen)
- return (EOVERFLOW);
+ return (SET_ERROR(EOVERFLOW));
return (0);
}
@@ -536,7 +537,7 @@ zap_entry_update(zap_entry_handle_t *zeh,
ZAP_LEAF_ARRAY_NCHUNKS(le->le_value_numints * le->le_value_intlen);
if ((int)l->l_phys->l_hdr.lh_nfree < delta_chunks)
- return (EAGAIN);
+ return (SET_ERROR(EAGAIN));
zap_leaf_array_free(l, &le->le_value_chunk);
le->le_value_chunk =
@@ -626,7 +627,7 @@ zap_entry_create(zap_leaf_t *l, zap_name_t *zn, uint32_t cd,
}
if (l->l_phys->l_hdr.lh_nfree < numchunks)
- return (EAGAIN);
+ return (SET_ERROR(EAGAIN));
/* make the entry */
chunk = zap_leaf_chunk_alloc(l);
diff --git a/uts/common/fs/zfs/zap_micro.c b/uts/common/fs/zfs/zap_micro.c
index 62ea8a6..e790380 100644
--- a/uts/common/fs/zfs/zap_micro.c
+++ b/uts/common/fs/zfs/zap_micro.c
@@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
#include <sys/zio.h>
@@ -780,7 +780,7 @@ zap_lookup_norm(objset_t *os, uint64_t zapobj, const char *name,
zn = zap_name_alloc(zap, name, mt);
if (zn == NULL) {
zap_unlockdir(zap);
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
}
if (!zap->zap_ismicro) {
@@ -789,12 +789,12 @@ zap_lookup_norm(objset_t *os, uint64_t zapobj, const char *name,
} else {
mze = mze_find(zn);
if (mze == NULL) {
- err = ENOENT;
+ err = SET_ERROR(ENOENT);
} else {
if (num_integers < 1) {
- err = EOVERFLOW;
+ err = SET_ERROR(EOVERFLOW);
} else if (integer_size != 8) {
- err = EINVAL;
+ err = SET_ERROR(EINVAL);
} else {
*(uint64_t *)buf =
MZE_PHYS(zap, mze)->mze_value;
@@ -826,7 +826,7 @@ zap_prefetch_uint64(objset_t *os, uint64_t zapobj, const uint64_t *key,
zn = zap_name_alloc_uint64(zap, key, key_numints);
if (zn == NULL) {
zap_unlockdir(zap);
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
}
fzap_prefetch(zn);
@@ -849,7 +849,7 @@ zap_lookup_uint64(objset_t *os, uint64_t zapobj, const uint64_t *key,
zn = zap_name_alloc_uint64(zap, key, key_numints);
if (zn == NULL) {
zap_unlockdir(zap);
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
}
err = fzap_lookup(zn, integer_size, num_integers, buf,
@@ -884,14 +884,14 @@ zap_length(objset_t *os, uint64_t zapobj, const char *name,
zn = zap_name_alloc(zap, name, MT_EXACT);
if (zn == NULL) {
zap_unlockdir(zap);
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
}
if (!zap->zap_ismicro) {
err = fzap_length(zn, integer_size, num_integers);
} else {
mze = mze_find(zn);
if (mze == NULL) {
- err = ENOENT;
+ err = SET_ERROR(ENOENT);
} else {
if (integer_size)
*integer_size = 8;
@@ -918,7 +918,7 @@ zap_length_uint64(objset_t *os, uint64_t zapobj, const uint64_t *key,
zn = zap_name_alloc_uint64(zap, key, key_numints);
if (zn == NULL) {
zap_unlockdir(zap);
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
}
err = fzap_length(zn, integer_size, num_integers);
zap_name_free(zn);
@@ -987,7 +987,7 @@ zap_add(objset_t *os, uint64_t zapobj, const char *key,
zn = zap_name_alloc(zap, key, MT_EXACT);
if (zn == NULL) {
zap_unlockdir(zap);
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
}
if (!zap->zap_ismicro) {
err = fzap_add(zn, integer_size, num_integers, val, tx);
@@ -1001,7 +1001,7 @@ zap_add(objset_t *os, uint64_t zapobj, const char *key,
} else {
mze = mze_find(zn);
if (mze != NULL) {
- err = EEXIST;
+ err = SET_ERROR(EEXIST);
} else {
mzap_addent(zn, *intval);
}
@@ -1028,7 +1028,7 @@ zap_add_uint64(objset_t *os, uint64_t zapobj, const uint64_t *key,
zn = zap_name_alloc_uint64(zap, key, key_numints);
if (zn == NULL) {
zap_unlockdir(zap);
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
}
err = fzap_add(zn, integer_size, num_integers, val, tx);
zap = zn->zn_zap; /* fzap_add() may change zap */
@@ -1064,7 +1064,7 @@ zap_update(objset_t *os, uint64_t zapobj, const char *name,
zn = zap_name_alloc(zap, name, MT_EXACT);
if (zn == NULL) {
zap_unlockdir(zap);
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
}
if (!zap->zap_ismicro) {
err = fzap_update(zn, integer_size, num_integers, val, tx);
@@ -1109,7 +1109,7 @@ zap_update_uint64(objset_t *os, uint64_t zapobj, const uint64_t *key,
zn = zap_name_alloc_uint64(zap, key, key_numints);
if (zn == NULL) {
zap_unlockdir(zap);
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
}
err = fzap_update(zn, integer_size, num_integers, val, tx);
zap = zn->zn_zap; /* fzap_update() may change zap */
@@ -1140,14 +1140,14 @@ zap_remove_norm(objset_t *os, uint64_t zapobj, const char *name,
zn = zap_name_alloc(zap, name, mt);
if (zn == NULL) {
zap_unlockdir(zap);
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
}
if (!zap->zap_ismicro) {
err = fzap_remove(zn, tx);
} else {
mze = mze_find(zn);
if (mze == NULL) {
- err = ENOENT;
+ err = SET_ERROR(ENOENT);
} else {
zap->zap_m.zap_num_entries--;
bzero(&zap->zap_m.zap_phys->mz_chunk[mze->mze_chunkid],
@@ -1174,7 +1174,7 @@ zap_remove_uint64(objset_t *os, uint64_t zapobj, const uint64_t *key,
zn = zap_name_alloc_uint64(zap, key, key_numints);
if (zn == NULL) {
zap_unlockdir(zap);
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
}
err = fzap_remove(zn, tx);
zap_name_free(zn);
@@ -1252,7 +1252,7 @@ zap_cursor_retrieve(zap_cursor_t *zc, zap_attribute_t *za)
mzap_ent_t *mze;
if (zc->zc_hash == -1ULL)
- return (ENOENT);
+ return (SET_ERROR(ENOENT));
if (zc->zc_zap == NULL) {
int hb;
@@ -1278,8 +1278,6 @@ zap_cursor_retrieve(zap_cursor_t *zc, zap_attribute_t *za)
if (!zc->zc_zap->zap_ismicro) {
err = fzap_cursor_retrieve(zc->zc_zap, zc, za);
} else {
- err = ENOENT;
-
mze_tofind.mze_hash = zc->zc_hash;
mze_tofind.mze_cd = zc->zc_cd;
@@ -1302,6 +1300,7 @@ zap_cursor_retrieve(zap_cursor_t *zc, zap_attribute_t *za)
err = 0;
} else {
zc->zc_hash = -1ULL;
+ err = SET_ERROR(ENOENT);
}
}
rw_exit(&zc->zc_zap->zap_rwlock);
@@ -1335,7 +1334,7 @@ zap_cursor_move_to_key(zap_cursor_t *zc, const char *name, matchtype_t mt)
zn = zap_name_alloc(zc->zc_zap, name, mt);
if (zn == NULL) {
rw_exit(&zc->zc_zap->zap_rwlock);
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
}
if (!zc->zc_zap->zap_ismicro) {
@@ -1343,7 +1342,7 @@ zap_cursor_move_to_key(zap_cursor_t *zc, const char *name, matchtype_t mt)
} else {
mze = mze_find(zn);
if (mze == NULL) {
- err = ENOENT;
+ err = SET_ERROR(ENOENT);
goto out;
}
zc->zc_hash = mze->mze_hash;
diff --git a/uts/common/fs/zfs/zfeature.c b/uts/common/fs/zfs/zfeature.c
index d532ccc..638b141 100644
--- a/uts/common/fs/zfs/zfeature.c
+++ b/uts/common/fs/zfs/zfeature.c
@@ -20,7 +20,7 @@
*/
/*
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
#include <sys/zfs_context.h>
@@ -226,13 +226,13 @@ feature_get_refcount(objset_t *os, uint64_t read_obj, uint64_t write_obj,
* have been allocated yet. Act as though all features are disabled.
*/
if (zapobj == 0)
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
err = zap_lookup(os, zapobj, feature->fi_guid, sizeof (uint64_t), 1,
&refcount);
if (err != 0) {
if (err == ENOENT)
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
else
return (err);
}
@@ -273,16 +273,16 @@ feature_do_action(objset_t *os, uint64_t read_obj, uint64_t write_obj,
break;
case FEATURE_ACTION_INCR:
if (error == ENOENT)
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
if (refcount == UINT64_MAX)
- return (EOVERFLOW);
+ return (SET_ERROR(EOVERFLOW));
refcount++;
break;
case FEATURE_ACTION_DECR:
if (error == ENOENT)
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
if (refcount == 0)
- return (EOVERFLOW);
+ return (SET_ERROR(EOVERFLOW));
refcount--;
break;
default:
diff --git a/uts/common/fs/zfs/zfs_acl.c b/uts/common/fs/zfs/zfs_acl.c
index 2b93fc8..1b296b2 100644
--- a/uts/common/fs/zfs/zfs_acl.c
+++ b/uts/common/fs/zfs/zfs_acl.c
@@ -21,6 +21,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
#include <sys/types.h>
@@ -684,7 +685,7 @@ zfs_copy_ace_2_fuid(zfsvfs_t *zfsvfs, vtype_t obj_type, zfs_acl_t *aclp,
*/
if (zfs_ace_valid(obj_type, aclp, aceptr->z_hdr.z_type,
aceptr->z_hdr.z_flags) != B_TRUE)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
switch (acep->a_type) {
case ACE_ACCESS_ALLOWED_OBJECT_ACE_TYPE:
@@ -791,7 +792,7 @@ zfs_copy_ace_2_oldace(vtype_t obj_type, zfs_acl_t *aclp, ace_t *acep,
*/
if (zfs_ace_valid(obj_type, aclp, aceptr->z_type,
aceptr->z_flags) != B_TRUE)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
*size = (caddr_t)aceptr - (caddr_t)z_acl;
return (0);
@@ -1125,7 +1126,7 @@ zfs_acl_node_read(znode_t *zp, boolean_t have_lock, zfs_acl_t **aclpp,
zfs_acl_node_free(aclnode);
/* convert checksum errors into IO errors */
if (error == ECKSUM)
- error = EIO;
+ error = SET_ERROR(EIO);
goto done;
}
@@ -1780,7 +1781,7 @@ zfs_getacl(znode_t *zp, vsecattr_t *vsecp, boolean_t skipaclchk, cred_t *cr)
VSA_ACE_ACLFLAGS | VSA_ACE_ALLTYPES);
if (mask == 0)
- return (ENOSYS);
+ return (SET_ERROR(ENOSYS));
if (error = zfs_zaccess(zp, ACE_READ_ACL, 0, skipaclchk, cr))
return (error);
@@ -1874,7 +1875,7 @@ zfs_vsec_2_aclp(zfsvfs_t *zfsvfs, vtype_t obj_type,
int error;
if (vsecp->vsa_aclcnt > MAX_ACL_ENTRIES || vsecp->vsa_aclcnt <= 0)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
aclp = zfs_acl_alloc(zfs_acl_version(zfsvfs->z_version));
@@ -1936,10 +1937,10 @@ zfs_setacl(znode_t *zp, vsecattr_t *vsecp, boolean_t skipaclchk, cred_t *cr)
uint64_t acl_obj;
if (mask == 0)
- return (ENOSYS);
+ return (SET_ERROR(ENOSYS));
if (zp->z_pflags & ZFS_IMMUTABLE)
- return (EPERM);
+ return (SET_ERROR(EPERM));
if (error = zfs_zaccess(zp, ACE_WRITE_ACL, 0, skipaclchk, cr))
return (error);
@@ -2036,7 +2037,7 @@ zfs_zaccess_dataset_check(znode_t *zp, uint32_t v4_mode)
(zp->z_zfsvfs->z_vfs->vfs_flag & VFS_RDONLY) &&
(!IS_DEVVP(ZTOV(zp)) ||
(IS_DEVVP(ZTOV(zp)) && (v4_mode & WRITE_MASK_ATTRS)))) {
- return (EROFS);
+ return (SET_ERROR(EROFS));
}
/*
@@ -2047,17 +2048,17 @@ zfs_zaccess_dataset_check(znode_t *zp, uint32_t v4_mode)
(zp->z_pflags & (ZFS_READONLY | ZFS_IMMUTABLE))) ||
(ZTOV(zp)->v_type == VDIR &&
(zp->z_pflags & ZFS_IMMUTABLE)))) {
- return (EPERM);
+ return (SET_ERROR(EPERM));
}
if ((v4_mode & (ACE_DELETE | ACE_DELETE_CHILD)) &&
(zp->z_pflags & ZFS_NOUNLINK)) {
- return (EPERM);
+ return (SET_ERROR(EPERM));
}
if (((v4_mode & (ACE_READ_DATA|ACE_EXECUTE)) &&
(zp->z_pflags & ZFS_AV_QUARANTINED))) {
- return (EACCES);
+ return (SET_ERROR(EACCES));
}
return (0);
@@ -2165,7 +2166,7 @@ zfs_zaccess_aces_check(znode_t *zp, uint32_t *working_mode,
break;
} else {
mutex_exit(&zp->z_acl_lock);
- return (EIO);
+ return (SET_ERROR(EIO));
}
}
@@ -2199,7 +2200,7 @@ zfs_zaccess_aces_check(znode_t *zp, uint32_t *working_mode,
/* Put the found 'denies' back on the working mode */
if (deny_mask) {
*working_mode |= deny_mask;
- return (EACCES);
+ return (SET_ERROR(EACCES));
} else if (*working_mode) {
return (-1);
}
@@ -2266,7 +2267,7 @@ zfs_zaccess_append(znode_t *zp, uint32_t *working_mode, boolean_t *check_privs,
cred_t *cr)
{
if (*working_mode != ACE_WRITE_DATA)
- return (EACCES);
+ return (SET_ERROR(EACCES));
return (zfs_zaccess_common(zp, ACE_APPEND_DATA, working_mode,
check_privs, B_FALSE, cr));
@@ -2282,7 +2283,7 @@ zfs_fastaccesschk_execute(znode_t *zdp, cred_t *cr)
int error;
if (zdp->z_pflags & ZFS_AV_QUARANTINED)
- return (EACCES);
+ return (SET_ERROR(EACCES));
is_attr = ((zdp->z_pflags & ZFS_XATTR) &&
(ZTOV(zdp)->v_type == VDIR));
@@ -2478,7 +2479,7 @@ zfs_zaccess(znode_t *zp, int mode, int flags, boolean_t skipaclchk, cred_t *cr)
* for are still present. If so then return EACCES
*/
if (working_mode & ~(ZFS_CHECKED_MASKS)) {
- error = EACCES;
+ error = SET_ERROR(EACCES);
}
}
} else if (error == 0) {
@@ -2592,7 +2593,7 @@ zfs_zaccess_delete(znode_t *dzp, znode_t *zp, cred_t *cr)
*/
if (zp->z_pflags & (ZFS_IMMUTABLE | ZFS_NOUNLINK))
- return (EPERM);
+ return (SET_ERROR(EPERM));
/*
* First row
@@ -2659,7 +2660,7 @@ zfs_zaccess_rename(znode_t *sdzp, znode_t *szp, znode_t *tdzp,
int error;
if (szp->z_pflags & ZFS_AV_QUARANTINED)
- return (EACCES);
+ return (SET_ERROR(EACCES));
add_perm = (ZTOV(szp)->v_type == VDIR) ?
ACE_ADD_SUBDIRECTORY : ACE_ADD_FILE;
diff --git a/uts/common/fs/zfs/zfs_ctldir.c b/uts/common/fs/zfs/zfs_ctldir.c
index ef9a561..f915d21 100644
--- a/uts/common/fs/zfs/zfs_ctldir.c
+++ b/uts/common/fs/zfs/zfs_ctldir.c
@@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
/*
@@ -285,7 +285,7 @@ static int
zfsctl_common_open(vnode_t **vpp, int flags, cred_t *cr, caller_context_t *ct)
{
if (flags & FWRITE)
- return (EACCES);
+ return (SET_ERROR(EACCES));
return (0);
}
@@ -311,10 +311,10 @@ zfsctl_common_access(vnode_t *vp, int mode, int flags, cred_t *cr,
{
if (flags & V_ACE_MASK) {
if (mode & ACE_ALL_WRITE_PERMS)
- return (EACCES);
+ return (SET_ERROR(EACCES));
} else {
if (mode & VWRITE)
- return (EACCES);
+ return (SET_ERROR(EACCES));
}
return (0);
@@ -364,7 +364,7 @@ zfsctl_common_fid(vnode_t *vp, fid_t *fidp, caller_context_t *ct)
if (fidp->fid_len < SHORT_FID_LEN) {
fidp->fid_len = SHORT_FID_LEN;
ZFS_EXIT(zfsvfs);
- return (ENOSPC);
+ return (SET_ERROR(ENOSPC));
}
zfid = (zfid_short_t *)fidp;
@@ -395,7 +395,7 @@ zfsctl_shares_fid(vnode_t *vp, fid_t *fidp, caller_context_t *ct)
if (zfsvfs->z_shares_dir == 0) {
ZFS_EXIT(zfsvfs);
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
}
if ((error = zfs_zget(zfsvfs, zfsvfs->z_shares_dir, &dzp)) == 0) {
@@ -458,7 +458,7 @@ zfsctl_root_lookup(vnode_t *dvp, char *nm, vnode_t **vpp, pathname_t *pnp,
* No extended attributes allowed under .zfs
*/
if (flags & LOOKUP_XATTR)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
ZFS_ENTER(zfsvfs);
@@ -511,10 +511,10 @@ zfsctl_snapshot_zname(vnode_t *vp, const char *name, int len, char *zname)
objset_t *os = ((zfsvfs_t *)((vp)->v_vfsp->vfs_data))->z_os;
if (snapshot_namecheck(name, NULL, NULL) != 0)
- return (EILSEQ);
+ return (SET_ERROR(EILSEQ));
dmu_objset_name(os, zname);
if (strlen(zname) + 1 + strlen(name) >= len)
- return (ENAMETOOLONG);
+ return (SET_ERROR(ENAMETOOLONG));
(void) strcat(zname, "@");
(void) strcat(zname, name);
return (0);
@@ -649,7 +649,7 @@ zfsctl_snapdir_rename(vnode_t *sdvp, char *snm, vnode_t *tdvp, char *tnm,
* Cannot move snapshots out of the snapdir.
*/
if (sdvp != tdvp)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
if (strcmp(snm, tnm) == 0)
return (0);
@@ -659,7 +659,7 @@ zfsctl_snapdir_rename(vnode_t *sdvp, char *snm, vnode_t *tdvp, char *tnm,
search.se_name = (char *)snm;
if ((sep = avl_find(&sdp->sd_snaps, &search, &where)) == NULL) {
mutex_exit(&sdp->sd_lock);
- return (ENOENT);
+ return (SET_ERROR(ENOENT));
}
err = dsl_dataset_rename_snapshot(fsname, snm, tnm, B_FALSE);
@@ -719,7 +719,7 @@ zfsctl_snapdir_remove(vnode_t *dvp, char *name, vnode_t *cwd, cred_t *cr,
else
err = dsl_destroy_snapshot(snapname, B_FALSE);
} else {
- err = ENOENT;
+ err = SET_ERROR(ENOENT);
}
mutex_exit(&sdp->sd_lock);
@@ -742,7 +742,7 @@ zfsctl_snapdir_mkdir(vnode_t *dvp, char *dirname, vattr_t *vap, vnode_t **vpp,
static enum uio_seg seg = UIO_SYSSPACE;
if (snapshot_namecheck(dirname, NULL, NULL) != 0)
- return (EILSEQ);
+ return (SET_ERROR(EILSEQ));
dmu_objset_name(zfsvfs->z_os, name);
@@ -790,7 +790,7 @@ zfsctl_snapdir_lookup(vnode_t *dvp, char *nm, vnode_t **vpp, pathname_t *pnp,
* No extended attributes allowed under .zfs
*/
if (flags & LOOKUP_XATTR)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
ASSERT(dvp->v_type == VDIR);
@@ -801,7 +801,7 @@ zfsctl_snapdir_lookup(vnode_t *dvp, char *nm, vnode_t **vpp, pathname_t *pnp,
* add some flag to domount() to tell it not to do this lookup.
*/
if (MUTEX_HELD(&sdp->sd_lock))
- return (ENOENT);
+ return (SET_ERROR(ENOENT));
ZFS_ENTER(zfsvfs);
@@ -873,7 +873,7 @@ zfsctl_snapdir_lookup(vnode_t *dvp, char *nm, vnode_t **vpp, pathname_t *pnp,
if (dmu_objset_hold(snapname, FTAG, &snap) != 0) {
mutex_exit(&sdp->sd_lock);
ZFS_EXIT(zfsvfs);
- return (ENOENT);
+ return (SET_ERROR(ENOENT));
}
sep = kmem_alloc(sizeof (zfs_snapentry_t), KM_SLEEP);
@@ -959,7 +959,7 @@ zfsctl_shares_lookup(vnode_t *dvp, char *nm, vnode_t **vpp, pathname_t *pnp,
if (zfsvfs->z_shares_dir == 0) {
ZFS_EXIT(zfsvfs);
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
}
if ((error = zfs_zget(zfsvfs, zfsvfs->z_shares_dir, &dzp)) == 0)
error = VOP_LOOKUP(ZTOV(dzp), nm, vpp, pnp,
@@ -1030,14 +1030,14 @@ zfsctl_shares_readdir(vnode_t *vp, uio_t *uiop, cred_t *cr, int *eofp,
if (zfsvfs->z_shares_dir == 0) {
ZFS_EXIT(zfsvfs);
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
}
if ((error = zfs_zget(zfsvfs, zfsvfs->z_shares_dir, &dzp)) == 0) {
error = VOP_READDIR(ZTOV(dzp), uiop, cr, eofp, ct, flags);
VN_RELE(ZTOV(dzp));
} else {
*eofp = 1;
- error = ENOENT;
+ error = SET_ERROR(ENOENT);
}
ZFS_EXIT(zfsvfs);
@@ -1096,7 +1096,7 @@ zfsctl_shares_getattr(vnode_t *vp, vattr_t *vap, int flags, cred_t *cr,
ZFS_ENTER(zfsvfs);
if (zfsvfs->z_shares_dir == 0) {
ZFS_EXIT(zfsvfs);
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
}
if ((error = zfs_zget(zfsvfs, zfsvfs->z_shares_dir, &dzp)) == 0) {
error = VOP_GETATTR(ZTOV(dzp), vap, flags, cr, ct);
@@ -1288,14 +1288,14 @@ zfsctl_lookup_objset(vfs_t *vfsp, uint64_t objsetid, zfsvfs_t **zfsvfsp)
error = traverse(&vp);
if (error == 0) {
if (vp == sep->se_root)
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
else
*zfsvfsp = VTOZ(vp)->z_zfsvfs;
}
mutex_exit(&sdp->sd_lock);
VN_RELE(vp);
} else {
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
mutex_exit(&sdp->sd_lock);
}
diff --git a/uts/common/fs/zfs/zfs_dir.c b/uts/common/fs/zfs/zfs_dir.c
index b06d29a..439420b 100644
--- a/uts/common/fs/zfs/zfs_dir.c
+++ b/uts/common/fs/zfs/zfs_dir.c
@@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
#include <sys/types.h>
@@ -154,7 +155,7 @@ zfs_dirent_lock(zfs_dirlock_t **dlpp, znode_t *dzp, char *name, znode_t **zpp,
if (name[0] == '.' &&
(name[1] == '\0' || (name[1] == '.' && name[2] == '\0')) ||
zfs_has_ctldir(dzp) && strcmp(name, ZFS_CTLDIR_NAME) == 0)
- return (EEXIST);
+ return (SET_ERROR(EEXIST));
/*
* Case sensitivity and normalization preferences are set when
@@ -225,7 +226,7 @@ zfs_dirent_lock(zfs_dirlock_t **dlpp, znode_t *dzp, char *name, znode_t **zpp,
mutex_exit(&dzp->z_lock);
if (!(flag & ZHAVELOCK))
rw_exit(&dzp->z_name_lock);
- return (ENOENT);
+ return (SET_ERROR(ENOENT));
}
for (dl = dzp->z_dirlocks; dl != NULL; dl = dl->dl_next) {
if ((u8_strcmp(name, dl->dl_name, 0, cmpflags,
@@ -236,7 +237,7 @@ zfs_dirent_lock(zfs_dirlock_t **dlpp, znode_t *dzp, char *name, znode_t **zpp,
mutex_exit(&dzp->z_lock);
if (!(flag & ZHAVELOCK))
rw_exit(&dzp->z_name_lock);
- return (ENOENT);
+ return (SET_ERROR(ENOENT));
}
if (dl == NULL) {
/*
@@ -296,12 +297,12 @@ zfs_dirent_lock(zfs_dirlock_t **dlpp, znode_t *dzp, char *name, znode_t **zpp,
vp = dnlc_lookup(ZTOV(dzp), name);
if (vp == DNLC_NO_VNODE) {
VN_RELE(vp);
- error = ENOENT;
+ error = SET_ERROR(ENOENT);
} else if (vp) {
if (flag & ZNEW) {
zfs_dirent_unlock(dl);
VN_RELE(vp);
- return (EEXIST);
+ return (SET_ERROR(EEXIST));
}
*dlpp = dl;
*zpp = VTOZ(vp);
@@ -319,7 +320,7 @@ zfs_dirent_lock(zfs_dirlock_t **dlpp, znode_t *dzp, char *name, znode_t **zpp,
} else {
if (flag & ZNEW) {
zfs_dirent_unlock(dl);
- return (EEXIST);
+ return (SET_ERROR(EEXIST));
}
error = zfs_zget(zfsvfs, zoid, zpp);
if (error) {
@@ -714,7 +715,7 @@ zfs_link_create(zfs_dirlock_t *dl, znode_t *zp, dmu_tx_t *tx, int flag)
if (zp->z_unlinked) { /* no new links to unlinked zp */
ASSERT(!(flag & (ZNEW | ZEXISTS)));
mutex_exit(&zp->z_lock);
- return (ENOENT);
+ return (SET_ERROR(ENOENT));
}
zp->z_links++;
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_LINKS(zfsvfs), NULL,
@@ -815,11 +816,11 @@ zfs_link_destroy(zfs_dirlock_t *dl, znode_t *zp, dmu_tx_t *tx, int flag,
if (!(flag & ZRENAMING)) {
if (vn_vfswlock(vp)) /* prevent new mounts on zp */
- return (EBUSY);
+ return (SET_ERROR(EBUSY));
if (vn_ismntpt(vp)) { /* don't remove mount point */
vn_vfsunlock(vp);
- return (EBUSY);
+ return (SET_ERROR(EBUSY));
}
mutex_enter(&zp->z_lock);
@@ -827,7 +828,7 @@ zfs_link_destroy(zfs_dirlock_t *dl, znode_t *zp, dmu_tx_t *tx, int flag,
if (zp_is_dir && !zfs_dirempty(zp)) {
mutex_exit(&zp->z_lock);
vn_vfsunlock(vp);
- return (EEXIST);
+ return (SET_ERROR(EEXIST));
}
/*
@@ -933,7 +934,7 @@ zfs_make_xattrdir(znode_t *zp, vattr_t *vap, vnode_t **xvpp, cred_t *cr)
return (error);
if (zfs_acl_ids_overquota(zfsvfs, &acl_ids)) {
zfs_acl_ids_free(&acl_ids);
- return (EDQUOT);
+ return (SET_ERROR(EDQUOT));
}
top:
@@ -1016,12 +1017,12 @@ top:
if (!(flags & CREATE_XATTR_DIR)) {
zfs_dirent_unlock(dl);
- return (ENOENT);
+ return (SET_ERROR(ENOENT));
}
if (zfsvfs->z_vfs->vfs_flag & VFS_RDONLY) {
zfs_dirent_unlock(dl);
- return (EROFS);
+ return (SET_ERROR(EROFS));
}
/*
diff --git a/uts/common/fs/zfs/zfs_ioctl.c b/uts/common/fs/zfs/zfs_ioctl.c
index caad34c..7d02bb6 100644
--- a/uts/common/fs/zfs/zfs_ioctl.c
+++ b/uts/common/fs/zfs/zfs_ioctl.c
@@ -24,7 +24,7 @@
* Portions Copyright 2011 Martin Matuska
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2012, Joyent, Inc. All rights reserved.
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
* Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
*/
@@ -408,7 +408,7 @@ zfs_secpolicy_read(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
zone_dataset_visible(zc->zc_name, NULL))
return (0);
- return (ENOENT);
+ return (SET_ERROR(ENOENT));
}
static int
@@ -422,7 +422,7 @@ zfs_dozonecheck_impl(const char *dataset, uint64_t zoned, cred_t *cr)
*/
if (!INGLOBALZONE(curproc) &&
!zone_dataset_visible(dataset, &writable))
- return (ENOENT);
+ return (SET_ERROR(ENOENT));
if (INGLOBALZONE(curproc)) {
/*
@@ -430,17 +430,17 @@ zfs_dozonecheck_impl(const char *dataset, uint64_t zoned, cred_t *cr)
* global zone.
*/
if (secpolicy_zfs(cr) && zoned)
- return (EPERM);
+ return (SET_ERROR(EPERM));
} else {
/*
* If we are in a local zone, the 'zoned' property must be set.
*/
if (!zoned)
- return (EPERM);
+ return (SET_ERROR(EPERM));
/* must be writable by this zone */
if (!writable)
- return (EPERM);
+ return (SET_ERROR(EPERM));
}
return (0);
}
@@ -451,7 +451,7 @@ zfs_dozonecheck(const char *dataset, cred_t *cr)
uint64_t zoned;
if (dsl_prop_get_integer(dataset, "zoned", &zoned, NULL))
- return (ENOENT);
+ return (SET_ERROR(ENOENT));
return (zfs_dozonecheck_impl(dataset, zoned, cr));
}
@@ -462,7 +462,7 @@ zfs_dozonecheck_ds(const char *dataset, dsl_dataset_t *ds, cred_t *cr)
uint64_t zoned;
if (dsl_prop_get_int_ds(ds, "zoned", &zoned))
- return (ENOENT);
+ return (SET_ERROR(ENOENT));
return (zfs_dozonecheck_impl(dataset, zoned, cr));
}
@@ -525,14 +525,14 @@ zfs_set_slabel_policy(const char *name, char *strval, cred_t *cr)
error = dsl_prop_get(name, zfs_prop_to_name(ZFS_PROP_MLSLABEL),
1, sizeof (ds_hexsl), &ds_hexsl, NULL);
if (error != 0)
- return (EPERM);
+ return (SET_ERROR(EPERM));
if (strcasecmp(strval, ZFS_MLSLABEL_DEFAULT) == 0)
new_default = TRUE;
/* The label must be translatable */
if (!new_default && (hexstr_to_label(strval, &new_sl) != 0))
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
/*
* In a non-global zone, disallow attempts to set a label that
@@ -541,7 +541,7 @@ zfs_set_slabel_policy(const char *name, char *strval, cred_t *cr)
*/
if (!INGLOBALZONE(curproc)) {
if (new_default || !blequal(&new_sl, CR_SL(CRED())))
- return (EPERM);
+ return (SET_ERROR(EPERM));
return (0);
}
@@ -552,10 +552,10 @@ zfs_set_slabel_policy(const char *name, char *strval, cred_t *cr)
*/
if (dsl_prop_get_integer(name,
zfs_prop_to_name(ZFS_PROP_ZONED), &zoned, NULL))
- return (EPERM);
+ return (SET_ERROR(EPERM));
if (!zoned) {
if (zfs_check_global_label(name, strval) != 0)
- return (EPERM);
+ return (SET_ERROR(EPERM));
}
/*
@@ -575,7 +575,7 @@ zfs_set_slabel_policy(const char *name, char *strval, cred_t *cr)
error = dmu_objset_own(name, DMU_OST_ZFS, B_TRUE,
setsl_tag, &os);
if (error != 0)
- return (EPERM);
+ return (SET_ERROR(EPERM));
dmu_objset_disown(os, setsl_tag);
@@ -585,7 +585,7 @@ zfs_set_slabel_policy(const char *name, char *strval, cred_t *cr)
}
if (hexstr_to_label(strval, &new_sl) != 0)
- return (EPERM);
+ return (SET_ERROR(EPERM));
if (blstrictdom(&ds_sl, &new_sl))
needed_priv = PRIV_FILE_DOWNGRADE_SL;
@@ -618,7 +618,7 @@ zfs_secpolicy_setprop(const char *dsname, zfs_prop_t prop, nvpair_t *propval,
* Disallow setting of 'zoned' from within a local zone.
*/
if (!INGLOBALZONE(curproc))
- return (EPERM);
+ return (SET_ERROR(EPERM));
break;
case ZFS_PROP_QUOTA:
@@ -632,15 +632,15 @@ zfs_secpolicy_setprop(const char *dsname, zfs_prop_t prop, nvpair_t *propval,
*/
if (dsl_prop_get_integer(dsname, "zoned", &zoned,
setpoint))
- return (EPERM);
+ return (SET_ERROR(EPERM));
if (!zoned || strlen(dsname) <= strlen(setpoint))
- return (EPERM);
+ return (SET_ERROR(EPERM));
}
break;
case ZFS_PROP_MLSLABEL:
if (!is_system_labeled())
- return (EPERM);
+ return (SET_ERROR(EPERM));
if (nvpair_value_string(propval, &strval) == 0) {
int err;
@@ -695,7 +695,7 @@ zfs_secpolicy_send(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
*/
cp = strchr(zc->zc_name, '@');
if (cp == NULL)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
error = dsl_pool_hold(zc->zc_name, FTAG, &dp);
if (error != 0)
return (error);
@@ -741,7 +741,7 @@ zfs_secpolicy_deleg_share(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
(strcmp((char *)refstr_value(vp->v_vfsp->vfs_resource),
zc->zc_name) != 0)) {
VN_RELE(vp);
- return (EPERM);
+ return (SET_ERROR(EPERM));
}
VN_RELE(vp);
@@ -753,7 +753,7 @@ int
zfs_secpolicy_share(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
{
if (!INGLOBALZONE(curproc))
- return (EPERM);
+ return (SET_ERROR(EPERM));
if (secpolicy_nfs(cr) == 0) {
return (0);
@@ -766,7 +766,7 @@ int
zfs_secpolicy_smb_acl(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
{
if (!INGLOBALZONE(curproc))
- return (EPERM);
+ return (SET_ERROR(EPERM));
if (secpolicy_smb(cr) == 0) {
return (0);
@@ -790,7 +790,7 @@ zfs_get_parent(const char *datasetname, char *parent, int parentsize)
} else {
cp = strrchr(parent, '/');
if (cp == NULL)
- return (ENOENT);
+ return (SET_ERROR(ENOENT));
cp[0] = '\0';
}
@@ -829,7 +829,7 @@ zfs_secpolicy_destroy_snaps(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
int error = 0;
if (nvlist_lookup_nvlist(innvl, "snaps", &snaps) != 0)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
for (pair = nvlist_next_nvpair(snaps, NULL); pair != NULL;
pair = nextpair) {
dsl_pool_t *dp;
@@ -987,14 +987,14 @@ zfs_secpolicy_snapshot(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
nvpair_t *pair;
if (nvlist_lookup_nvlist(innvl, "snaps", &snaps) != 0)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
for (pair = nvlist_next_nvpair(snaps, NULL); pair != NULL;
pair = nvlist_next_nvpair(snaps, pair)) {
char *name = nvpair_name(pair);
char *atp = strchr(name, '@');
if (atp == NULL) {
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
break;
}
*atp = '\0';
@@ -1015,7 +1015,7 @@ zfs_secpolicy_log_history(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
* to log to.
*/
if (tsd_get(zfs_allow_log_key) == NULL)
- return (EPERM);
+ return (SET_ERROR(EPERM));
return (0);
}
@@ -1052,7 +1052,7 @@ static int
zfs_secpolicy_config(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
{
if (secpolicy_sys_config(cr, B_FALSE) != 0)
- return (EPERM);
+ return (SET_ERROR(EPERM));
return (0);
}
@@ -1091,7 +1091,7 @@ zfs_secpolicy_inherit_prop(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
if (prop == ZPROP_INVAL) {
if (!zfs_prop_user(zc->zc_value))
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
return (zfs_secpolicy_write_perms(zc->zc_name,
ZFS_DELEG_PERM_USERPROP, cr));
} else {
@@ -1108,7 +1108,7 @@ zfs_secpolicy_userspace_one(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
return (err);
if (zc->zc_objset_type >= ZFS_NUM_USERQUOTA_PROPS)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
if (zc->zc_value[0] == 0) {
/*
@@ -1137,7 +1137,7 @@ zfs_secpolicy_userspace_many(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
return (err);
if (zc->zc_objset_type >= ZFS_NUM_USERQUOTA_PROPS)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
return (zfs_secpolicy_write_perms(zc->zc_name,
userquota_perms[zc->zc_objset_type], cr));
@@ -1161,7 +1161,7 @@ zfs_secpolicy_hold(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
error = nvlist_lookup_nvlist(innvl, "holds", &holds);
if (error != 0)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
for (pair = nvlist_next_nvpair(holds, NULL); pair != NULL;
pair = nvlist_next_nvpair(holds, pair)) {
@@ -1239,7 +1239,7 @@ get_nvlist(uint64_t nvl, uint64_t size, int iflag, nvlist_t **nvp)
* Read in and unpack the user-supplied nvlist.
*/
if (size == 0)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
packed = kmem_alloc(size, KM_SLEEP);
@@ -1278,7 +1278,7 @@ nvlist_smush(nvlist_t *errors, size_t max)
int n = 0;
if (max < 1024)
- return (ENOMEM);
+ return (SET_ERROR(ENOMEM));
fnvlist_add_int32(errors, ZPROP_N_MORE_ERRORS, 0);
more_errors = nvlist_prev_nvpair(errors, NULL);
@@ -1309,12 +1309,12 @@ put_nvlist(zfs_cmd_t *zc, nvlist_t *nvl)
size = fnvlist_size(nvl);
if (size > zc->zc_nvlist_dst_size) {
- error = ENOMEM;
+ error = SET_ERROR(ENOMEM);
} else {
packed = fnvlist_pack(nvl, &size);
if (ddi_copyout(packed, (void *)(uintptr_t)zc->zc_nvlist_dst,
size, zc->zc_iflags) != 0)
- error = EFAULT;
+ error = SET_ERROR(EFAULT);
fnvlist_pack_free(packed, size);
}
@@ -1334,7 +1334,7 @@ getzfsvfs(const char *dsname, zfsvfs_t **zfvp)
return (error);
if (dmu_objset_type(os) != DMU_OST_ZFS) {
dmu_objset_rele(os, FTAG);
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
mutex_enter(&os->os_user_ptr_lock);
@@ -1342,7 +1342,7 @@ getzfsvfs(const char *dsname, zfsvfs_t **zfvp)
if (*zfvp) {
VFS_HOLD((*zfvp)->z_vfs);
} else {
- error = ESRCH;
+ error = SET_ERROR(ESRCH);
}
mutex_exit(&os->os_user_ptr_lock);
dmu_objset_rele(os, FTAG);
@@ -1372,7 +1372,7 @@ zfsvfs_hold(const char *name, void *tag, zfsvfs_t **zfvp, boolean_t writer)
* objset from the zfsvfs.
*/
rrw_exit(&(*zfvp)->z_teardown_lock, tag);
- return (EBUSY);
+ return (SET_ERROR(EBUSY));
}
}
return (error);
@@ -1417,7 +1417,7 @@ zfs_ioc_pool_create(zfs_cmd_t *zc)
(void) nvlist_lookup_uint64(props,
zpool_prop_to_name(ZPOOL_PROP_VERSION), &version);
if (!SPA_VERSION_IS_SUPPORTED(version)) {
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
goto pool_props_bad;
}
(void) nvlist_lookup_nvlist(props, ZPOOL_ROOTFS_PROPS, &nvl);
@@ -1486,7 +1486,7 @@ zfs_ioc_pool_import(zfs_cmd_t *zc)
if (nvlist_lookup_uint64(config, ZPOOL_CONFIG_POOL_GUID, &guid) != 0 ||
guid != zc->zc_guid)
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
else
error = spa_import(zc->zc_name, config, props, zc->zc_cookie);
@@ -1526,7 +1526,7 @@ zfs_ioc_pool_configs(zfs_cmd_t *zc)
int error;
if ((configs = spa_all_configs(&zc->zc_cookie)) == NULL)
- return (EEXIST);
+ return (SET_ERROR(EEXIST));
error = put_nvlist(zc, configs);
@@ -1590,7 +1590,7 @@ zfs_ioc_pool_tryimport(zfs_cmd_t *zc)
nvlist_free(tryconfig);
if (config == NULL)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
error = put_nvlist(zc, config);
nvlist_free(config);
@@ -1648,7 +1648,7 @@ zfs_ioc_pool_upgrade(zfs_cmd_t *zc)
if (zc->zc_cookie < spa_version(spa) ||
!SPA_VERSION_IS_SUPPORTED(zc->zc_cookie)) {
spa_close(spa, FTAG);
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
spa_upgrade(spa, zc->zc_cookie);
@@ -1666,14 +1666,14 @@ zfs_ioc_pool_get_history(zfs_cmd_t *zc)
int error;
if ((size = zc->zc_history_len) == 0)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0)
return (error);
if (spa_version(spa) < SPA_VERSION_ZPOOL_HISTORY) {
spa_close(spa, FTAG);
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
}
hist_buf = kmem_alloc(size, KM_SLEEP);
@@ -1728,7 +1728,7 @@ zfs_ioc_obj_to_path(zfs_cmd_t *zc)
return (error);
if (dmu_objset_type(os) != DMU_OST_ZFS) {
dmu_objset_rele(os, FTAG);
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
error = zfs_obj_to_path(os, zc->zc_obj, zc->zc_value,
sizeof (zc->zc_value));
@@ -1757,7 +1757,7 @@ zfs_ioc_obj_to_stats(zfs_cmd_t *zc)
return (error);
if (dmu_objset_type(os) != DMU_OST_ZFS) {
dmu_objset_rele(os, FTAG);
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
error = zfs_obj_to_stats(os, zc->zc_obj, &zc->zc_stat, zc->zc_value,
sizeof (zc->zc_value));
@@ -1799,7 +1799,7 @@ zfs_ioc_vdev_add(zfs_cmd_t *zc)
if (spa_bootfs(spa) != 0 && nl2cache == 0 && nspares == 0) {
nvlist_free(config);
spa_close(spa, FTAG);
- return (EDOM);
+ return (SET_ERROR(EDOM));
}
if (error == 0) {
@@ -1865,7 +1865,7 @@ zfs_ioc_vdev_set_state(zfs_cmd_t *zc)
break;
default:
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
}
zc->zc_cookie = newstate;
spa_close(spa, FTAG);
@@ -2059,7 +2059,7 @@ zfs_ioc_objset_recvd_props(zfs_cmd_t *zc)
* SPA_VERSION_RECVD_PROPS.
*/
if (!dsl_prop_get_hasrecvd(zc->zc_name))
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
if (zc->zc_nvlist_dst != 0 &&
(error = dsl_prop_get_received(zc->zc_name, &nv)) == 0) {
@@ -2125,7 +2125,7 @@ zfs_ioc_objset_zplprops(zfs_cmd_t *zc)
err = put_nvlist(zc, nv);
nvlist_free(nv);
} else {
- err = ENOENT;
+ err = SET_ERROR(ENOENT);
}
dmu_objset_rele(os, FTAG);
return (err);
@@ -2172,7 +2172,7 @@ zfs_ioc_dataset_list_next(zfs_cmd_t *zc)
top:
if (error = dmu_objset_hold(zc->zc_name, FTAG, &os)) {
if (error == ENOENT)
- error = ESRCH;
+ error = SET_ERROR(ESRCH);
return (error);
}
@@ -2186,7 +2186,7 @@ top:
sizeof (zc->zc_name) - (p - zc->zc_name), p,
NULL, &zc->zc_cookie);
if (error == ENOENT)
- error = ESRCH;
+ error = SET_ERROR(ESRCH);
} while (error == 0 && dataset_name_hidden(zc->zc_name));
dmu_objset_rele(os, FTAG);
@@ -2234,7 +2234,7 @@ zfs_ioc_snapshot_list_next(zfs_cmd_t *zc)
*/
if (strlcat(zc->zc_name, "@", sizeof (zc->zc_name)) >= MAXNAMELEN) {
dmu_objset_rele(os, FTAG);
- return (ESRCH);
+ return (SET_ERROR(ESRCH));
}
error = dmu_snapshot_list_next(os,
@@ -2256,7 +2256,7 @@ zfs_ioc_snapshot_list_next(zfs_cmd_t *zc)
dsl_dataset_rele(ds, FTAG);
}
} else if (error == ENOENT) {
- error = ESRCH;
+ error = SET_ERROR(ESRCH);
}
dmu_objset_rele(os, FTAG);
@@ -2285,7 +2285,7 @@ zfs_prop_set_userquota(const char *dsname, nvpair_t *pair)
VERIFY(nvpair_value_nvlist(pair, &attrs) == 0);
if (nvlist_lookup_nvpair(attrs, ZPROP_VALUE,
&pair) != 0)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
/*
@@ -2295,7 +2295,7 @@ zfs_prop_set_userquota(const char *dsname, nvpair_t *pair)
if ((dash = strchr(propname, '-')) == NULL ||
nvpair_value_uint64_array(pair, &valary, &vallen) != 0 ||
vallen != 3)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
domain = dash + 1;
type = valary[0];
@@ -2457,25 +2457,25 @@ retry:
attrs = fnvpair_value_nvlist(pair);
if (nvlist_lookup_nvpair(attrs, ZPROP_VALUE,
&propval) != 0)
- err = EINVAL;
+ err = SET_ERROR(EINVAL);
}
/* Validate value type */
if (err == 0 && prop == ZPROP_INVAL) {
if (zfs_prop_user(propname)) {
if (nvpair_type(propval) != DATA_TYPE_STRING)
- err = EINVAL;
+ err = SET_ERROR(EINVAL);
} else if (zfs_prop_userquota(propname)) {
if (nvpair_type(propval) !=
DATA_TYPE_UINT64_ARRAY)
- err = EINVAL;
+ err = SET_ERROR(EINVAL);
} else {
- err = EINVAL;
+ err = SET_ERROR(EINVAL);
}
} else if (err == 0) {
if (nvpair_type(propval) == DATA_TYPE_STRING) {
if (zfs_prop_get_type(prop) != PROP_TYPE_STRING)
- err = EINVAL;
+ err = SET_ERROR(EINVAL);
} else if (nvpair_type(propval) == DATA_TYPE_UINT64) {
const char *unused;
@@ -2485,19 +2485,19 @@ retry:
case PROP_TYPE_NUMBER:
break;
case PROP_TYPE_STRING:
- err = EINVAL;
+ err = SET_ERROR(EINVAL);
break;
case PROP_TYPE_INDEX:
if (zfs_prop_index_to_string(prop,
intval, &unused) != 0)
- err = EINVAL;
+ err = SET_ERROR(EINVAL);
break;
default:
cmn_err(CE_PANIC,
"unknown property type");
}
} else {
- err = EINVAL;
+ err = SET_ERROR(EINVAL);
}
}
@@ -2594,14 +2594,14 @@ zfs_check_userprops(const char *fsname, nvlist_t *nvl)
if (!zfs_prop_user(propname) ||
nvpair_type(pair) != DATA_TYPE_STRING)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
if (error = zfs_secpolicy_write_perms(fsname,
ZFS_DELEG_PERM_USERPROP, CRED()))
return (error);
if (strlen(propname) >= ZAP_MAXNAMELEN)
- return (ENAMETOOLONG);
+ return (SET_ERROR(ENAMETOOLONG));
VERIFY(nvpair_value_string(pair, &valstr) == 0);
if (strlen(valstr) >= ZAP_MAXVALUELEN)
@@ -2725,12 +2725,12 @@ zfs_ioc_inherit_prop(zfs_cmd_t *zc)
*/
if (prop == ZPROP_INVAL) {
if (!zfs_prop_user(propname))
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
type = PROP_TYPE_STRING;
} else if (prop == ZFS_PROP_VOLSIZE ||
prop == ZFS_PROP_VERSION) {
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
} else {
type = zfs_prop_get_type(prop);
}
@@ -2747,7 +2747,7 @@ zfs_ioc_inherit_prop(zfs_cmd_t *zc)
break;
default:
nvlist_free(dummy);
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
pair = nvlist_next_nvpair(dummy, NULL);
@@ -2763,7 +2763,7 @@ zfs_ioc_inherit_prop(zfs_cmd_t *zc)
* they are not considered inheritable.
*/
if (prop != ZPROP_INVAL && !zfs_prop_inheritable(prop))
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
/* property name has been validated by zfs_secpolicy_inherit_prop() */
@@ -2840,7 +2840,7 @@ zfs_ioc_pool_get_props(zfs_cmd_t *zc)
if (error == 0 && zc->zc_nvlist_dst != NULL)
error = put_nvlist(zc, nvp);
else
- error = EFAULT;
+ error = SET_ERROR(EFAULT);
nvlist_free(nvp);
return (error);
@@ -2869,7 +2869,7 @@ zfs_ioc_set_fsacl(zfs_cmd_t *zc)
*/
if ((error = zfs_deleg_verify_nvlist(fsaclnv)) != 0) {
nvlist_free(fsaclnv);
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
/*
@@ -3016,7 +3016,7 @@ zfs_fill_zplprops_impl(objset_t *os, uint64_t zplver,
(zplver < ZPL_VERSION_NORMALIZATION &&
(norm != ZFS_PROP_UNDEFINED || u8 != ZFS_PROP_UNDEFINED ||
sense != ZFS_PROP_UNDEFINED)))
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
/*
* Put the version in the zplprops
@@ -3128,7 +3128,7 @@ zfs_ioc_create(const char *fsname, nvlist_t *innvl, nvlist_t *outnvl)
boolean_t is_insensitive = B_FALSE;
if (nvlist_lookup_int32(innvl, "type", &type32) != 0)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
type = type32;
(void) nvlist_lookup_nvlist(innvl, "props", &nvprops);
@@ -3147,26 +3147,26 @@ zfs_ioc_create(const char *fsname, nvlist_t *innvl, nvlist_t *outnvl)
}
if (strchr(fsname, '@') ||
strchr(fsname, '%'))
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
zct.zct_props = nvprops;
if (cbfunc == NULL)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
if (type == DMU_OST_ZVOL) {
uint64_t volsize, volblocksize;
if (nvprops == NULL)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
if (nvlist_lookup_uint64(nvprops,
zfs_prop_to_name(ZFS_PROP_VOLSIZE), &volsize) != 0)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
if ((error = nvlist_lookup_uint64(nvprops,
zfs_prop_to_name(ZFS_PROP_VOLBLOCKSIZE),
&volblocksize)) != 0 && error != ENOENT)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
if (error != 0)
volblocksize = zfs_prop_default_numeric(
@@ -3228,15 +3228,15 @@ zfs_ioc_clone(const char *fsname, nvlist_t *innvl, nvlist_t *outnvl)
char *origin_name;
if (nvlist_lookup_string(innvl, "origin", &origin_name) != 0)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
(void) nvlist_lookup_nvlist(innvl, "props", &nvprops);
if (strchr(fsname, '@') ||
strchr(fsname, '%'))
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
if (dataset_namecheck(origin_name, NULL, NULL) != 0)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
error = dmu_objset_clone(fsname, origin_name);
if (error != 0)
return (error);
@@ -3275,10 +3275,10 @@ zfs_ioc_snapshot(const char *poolname, nvlist_t *innvl, nvlist_t *outnvl)
if (!nvlist_empty(props) &&
zfs_earlier_version(poolname, SPA_VERSION_SNAP_PROPS))
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
if (nvlist_lookup_nvlist(innvl, "snaps", &snaps) != 0)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
poollen = strlen(poolname);
for (pair = nvlist_next_nvpair(snaps, NULL); pair != NULL;
pair = nvlist_next_nvpair(snaps, pair)) {
@@ -3290,21 +3290,21 @@ zfs_ioc_snapshot(const char *poolname, nvlist_t *innvl, nvlist_t *outnvl)
* contain only valid characters.
*/
if (cp == NULL || snapshot_namecheck(cp + 1, NULL, NULL) != 0)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
/*
* The snap must be in the specified pool.
*/
if (strncmp(name, poolname, poollen) != 0 ||
(name[poollen] != '/' && name[poollen] != '@'))
- return (EXDEV);
+ return (SET_ERROR(EXDEV));
/* This must be the only snap of this fs. */
for (nvpair_t *pair2 = nvlist_next_nvpair(snaps, pair);
pair2 != NULL; pair2 = nvlist_next_nvpair(snaps, pair2)) {
if (strncmp(name, nvpair_name(pair2), cp - name + 1)
== 0) {
- return (EXDEV);
+ return (SET_ERROR(EXDEV));
}
}
}
@@ -3341,12 +3341,12 @@ zfs_ioc_log_history(const char *unused, nvlist_t *innvl, nvlist_t *outnvl)
if (nvlist_lookup_string(innvl, "message", &message) != 0) {
spa_close(spa, FTAG);
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
if (spa_version(spa) < SPA_VERSION_ZPOOL_HISTORY) {
spa_close(spa, FTAG);
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
}
error = spa_history_log(spa, message);
@@ -3441,7 +3441,7 @@ zfs_ioc_destroy_snaps(const char *poolname, nvlist_t *innvl, nvlist_t *outnvl)
boolean_t defer;
if (nvlist_lookup_nvlist(innvl, "snaps", &snaps) != 0)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
defer = nvlist_exists(innvl, "defer");
poollen = strlen(poolname);
@@ -3454,7 +3454,7 @@ zfs_ioc_destroy_snaps(const char *poolname, nvlist_t *innvl, nvlist_t *outnvl)
*/
if (strncmp(name, poolname, poollen) != 0 ||
(name[poollen] != '/' && name[poollen] != '@'))
- return (EXDEV);
+ return (SET_ERROR(EXDEV));
zfs_unmount_snap(name);
}
@@ -3542,13 +3542,13 @@ zfs_ioc_rename(zfs_cmd_t *zc)
zc->zc_value[sizeof (zc->zc_value) - 1] = '\0';
if (dataset_namecheck(zc->zc_value, NULL, NULL) != 0 ||
strchr(zc->zc_value, '%'))
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
at = strchr(zc->zc_name, '@');
if (at != NULL) {
/* snaps must be in same fs */
if (strncmp(zc->zc_name, zc->zc_value, at - zc->zc_name + 1))
- return (EXDEV);
+ return (SET_ERROR(EXDEV));
*at = '\0';
if (zc->zc_objset_type == DMU_OST_ZFS) {
int error = dmu_objset_find(zc->zc_name,
@@ -3598,7 +3598,7 @@ zfs_check_settable(const char *dsname, nvpair_t *pair, cred_t *cr)
perm = ZFS_DELEG_PERM_GROUPQUOTA;
} else {
/* USERUSED and GROUPUSED are read-only */
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
if (err = zfs_secpolicy_write_perms(dsname, perm, cr))
@@ -3606,11 +3606,11 @@ zfs_check_settable(const char *dsname, nvpair_t *pair, cred_t *cr)
return (0);
}
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
if (issnap)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
if (nvpair_type(pair) == DATA_TYPE_NVLIST) {
/*
@@ -3639,13 +3639,13 @@ zfs_check_settable(const char *dsname, nvpair_t *pair, cred_t *cr)
intval <= ZIO_COMPRESS_GZIP_9 &&
zfs_earlier_version(dsname,
SPA_VERSION_GZIP_COMPRESSION)) {
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
}
if (intval == ZIO_COMPRESS_ZLE &&
zfs_earlier_version(dsname,
SPA_VERSION_ZLE_COMPRESSION))
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
if (intval == ZIO_COMPRESS_LZ4) {
zfeature_info_t *feature =
@@ -3658,7 +3658,7 @@ zfs_check_settable(const char *dsname, nvpair_t *pair, cred_t *cr)
if (!spa_feature_is_enabled(spa, feature)) {
spa_close(spa, FTAG);
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
}
spa_close(spa, FTAG);
}
@@ -3672,24 +3672,24 @@ zfs_check_settable(const char *dsname, nvpair_t *pair, cred_t *cr)
*/
if (zfs_is_bootfs(dsname) &&
!BOOTFS_COMPRESS_VALID(intval)) {
- return (ERANGE);
+ return (SET_ERROR(ERANGE));
}
}
break;
case ZFS_PROP_COPIES:
if (zfs_earlier_version(dsname, SPA_VERSION_DITTO_BLOCKS))
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
break;
case ZFS_PROP_DEDUP:
if (zfs_earlier_version(dsname, SPA_VERSION_DEDUP))
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
break;
case ZFS_PROP_SHARESMB:
if (zpl_earlier_version(dsname, ZPL_VERSION_FUID))
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
break;
case ZFS_PROP_ACLINHERIT:
@@ -3698,7 +3698,7 @@ zfs_check_settable(const char *dsname, nvpair_t *pair, cred_t *cr)
if (intval == ZFS_ACL_PASSTHROUGH_X &&
zfs_earlier_version(dsname,
SPA_VERSION_PASSTHROUGH_X))
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
}
break;
}
@@ -3719,7 +3719,7 @@ zfs_prop_activate_feature_check(void *arg, dmu_tx_t *tx)
if (!spa_feature_is_active(spa, feature))
return (0);
else
- return (EBUSY);
+ return (SET_ERROR(EBUSY));
}
/*
@@ -3927,7 +3927,7 @@ zfs_ioc_recv(zfs_cmd_t *zc)
if (dataset_namecheck(zc->zc_value, NULL, NULL) != 0 ||
strchr(zc->zc_value, '@') == NULL ||
strchr(zc->zc_value, '%'))
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
(void) strcpy(tofs, zc->zc_value);
tosnap = strchr(tofs, '@');
@@ -3942,7 +3942,7 @@ zfs_ioc_recv(zfs_cmd_t *zc)
fp = getf(fd);
if (fp == NULL) {
nvlist_free(props);
- return (EBADF);
+ return (SET_ERROR(EBADF));
}
VERIFY(nvlist_alloc(&errors, NV_UNIQUE_NAME, KM_SLEEP) == 0);
@@ -4011,7 +4011,7 @@ zfs_ioc_recv(zfs_cmd_t *zc)
* Caller made zc->zc_nvlist_dst less than the minimum expected
* size or supplied an invalid address.
*/
- props_error = EINVAL;
+ props_error = SET_ERROR(EINVAL);
}
off = fp->f_offset;
@@ -4173,7 +4173,7 @@ zfs_ioc_send(zfs_cmd_t *zc)
} else {
file_t *fp = getf(zc->zc_cookie);
if (fp == NULL)
- return (EBADF);
+ return (SET_ERROR(EBADF));
off = fp->f_offset;
error = dmu_send_obj(zc->zc_name, zc->zc_sendobj,
@@ -4230,7 +4230,7 @@ zfs_ioc_send_progress(zfs_cmd_t *zc)
if (dsp != NULL)
zc->zc_cookie = *(dsp->dsa_off);
else
- error = ENOENT;
+ error = SET_ERROR(ENOENT);
mutex_exit(&ds->ds_sendstream_lock);
dsl_dataset_rele(ds, FTAG);
@@ -4308,7 +4308,7 @@ zfs_ioc_clear(zfs_cmd_t *zc)
spa = spa_lookup(zc->zc_name);
if (spa == NULL) {
mutex_exit(&spa_namespace_lock);
- return (EIO);
+ return (SET_ERROR(EIO));
}
if (spa_get_log_state(spa) == SPA_LOG_MISSING) {
/* we need to let spa_open/spa_load clear the chains */
@@ -4324,7 +4324,7 @@ zfs_ioc_clear(zfs_cmd_t *zc)
nvlist_t *config = NULL;
if (zc->zc_nvlist_src == NULL)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
if ((error = get_nvlist(zc->zc_nvlist_src,
zc->zc_nvlist_src_size, zc->zc_iflags, &policy)) == 0) {
@@ -4353,7 +4353,7 @@ zfs_ioc_clear(zfs_cmd_t *zc)
if (vd == NULL) {
(void) spa_vdev_state_exit(spa, NULL, ENODEV);
spa_close(spa, FTAG);
- return (ENODEV);
+ return (SET_ERROR(ENODEV));
}
}
@@ -4365,7 +4365,7 @@ zfs_ioc_clear(zfs_cmd_t *zc)
* Resume any suspended I/Os.
*/
if (zio_resume(spa) != 0)
- error = EIO;
+ error = SET_ERROR(EIO);
spa_close(spa, FTAG);
@@ -4442,7 +4442,7 @@ zfs_ioc_userspace_one(zfs_cmd_t *zc)
int error;
if (zc->zc_objset_type >= ZFS_NUM_USERQUOTA_PROPS)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
error = zfsvfs_hold(zc->zc_name, FTAG, &zfsvfs, B_FALSE);
if (error != 0)
@@ -4473,7 +4473,7 @@ zfs_ioc_userspace_many(zfs_cmd_t *zc)
int bufsize = zc->zc_nvlist_dst_size;
if (bufsize <= 0)
- return (ENOMEM);
+ return (SET_ERROR(ENOMEM));
int error = zfsvfs_hold(zc->zc_name, FTAG, &zfsvfs, B_FALSE);
if (error != 0)
@@ -4565,12 +4565,12 @@ zfs_init_sharefs()
if (sharefs_mod == NULL && ((sharefs_mod =
ddi_modopen("fs/sharefs",
KRTLD_MODE_FIRST, &error)) == NULL)) {
- return (ENOSYS);
+ return (SET_ERROR(ENOSYS));
}
if (zshare_fs == NULL && ((zshare_fs =
(int (*)(enum sharefs_sys_op, share_t *, uint32_t))
ddi_modsym(sharefs_mod, "sharefs_impl", &error)) == NULL)) {
- return (ENOSYS);
+ return (SET_ERROR(ENOSYS));
}
return (0);
}
@@ -4589,19 +4589,19 @@ zfs_ioc_share(zfs_cmd_t *zc)
if (nfs_mod == NULL && ((nfs_mod = ddi_modopen("fs/nfs",
KRTLD_MODE_FIRST, &error)) == NULL)) {
mutex_exit(&zfs_share_lock);
- return (ENOSYS);
+ return (SET_ERROR(ENOSYS));
}
if (znfsexport_fs == NULL &&
((znfsexport_fs = (int (*)(void *))
ddi_modsym(nfs_mod,
"nfs_export", &error)) == NULL)) {
mutex_exit(&zfs_share_lock);
- return (ENOSYS);
+ return (SET_ERROR(ENOSYS));
}
error = zfs_init_sharefs();
if (error != 0) {
mutex_exit(&zfs_share_lock);
- return (ENOSYS);
+ return (SET_ERROR(ENOSYS));
}
zfs_nfsshare_inited = 1;
mutex_exit(&zfs_share_lock);
@@ -4615,25 +4615,25 @@ zfs_ioc_share(zfs_cmd_t *zc)
ddi_modopen("drv/smbsrv",
KRTLD_MODE_FIRST, &error)) == NULL)) {
mutex_exit(&zfs_share_lock);
- return (ENOSYS);
+ return (SET_ERROR(ENOSYS));
}
if (zsmbexport_fs == NULL && ((zsmbexport_fs =
(int (*)(void *, boolean_t))ddi_modsym(smbsrv_mod,
"smb_server_share", &error)) == NULL)) {
mutex_exit(&zfs_share_lock);
- return (ENOSYS);
+ return (SET_ERROR(ENOSYS));
}
error = zfs_init_sharefs();
if (error != 0) {
mutex_exit(&zfs_share_lock);
- return (ENOSYS);
+ return (SET_ERROR(ENOSYS));
}
zfs_smbshare_inited = 1;
mutex_exit(&zfs_share_lock);
}
break;
default:
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
switch (zc->zc_share.z_sharetype) {
@@ -4752,7 +4752,7 @@ zfs_ioc_diff(zfs_cmd_t *zc)
fp = getf(zc->zc_cookie);
if (fp == NULL)
- return (EBADF);
+ return (SET_ERROR(EBADF));
off = fp->f_offset;
@@ -4811,7 +4811,7 @@ zfs_ioc_smb_acl(zfs_cmd_t *zc)
(strcmp((char *)refstr_value(vp->v_vfsp->vfs_resource),
zc->zc_name) != 0)) {
VN_RELE(vp);
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
dzp = VTOZ(vp);
@@ -4902,7 +4902,7 @@ zfs_ioc_smb_acl(zfs_cmd_t *zc)
break;
default:
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
break;
}
@@ -4936,7 +4936,7 @@ zfs_ioc_hold(const char *pool, nvlist_t *args, nvlist_t *errlist)
error = nvlist_lookup_nvlist(args, "holds", &holds);
if (error != 0)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
if (nvlist_lookup_int32(args, "cleanup_fd", &cleanup_fd) == 0) {
error = zfs_onexit_fd_hold(cleanup_fd, &minor);
@@ -5054,7 +5054,7 @@ zfs_ioc_space_snaps(const char *lastsnap, nvlist_t *innvl, nvlist_t *outnvl)
uint64_t used, comp, uncomp;
if (nvlist_lookup_string(innvl, "firstsnap", &firstsnap) != 0)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
error = dsl_pool_hold(lastsnap, FTAG, &dp);
if (error != 0)
@@ -5101,13 +5101,13 @@ zfs_ioc_send_new(const char *snapname, nvlist_t *innvl, nvlist_t *outnvl)
error = nvlist_lookup_int32(innvl, "fd", &fd);
if (error != 0)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
(void) nvlist_lookup_string(innvl, "fromsnap", &fromname);
file_t *fp = getf(fd);
if (fp == NULL)
- return (EBADF);
+ return (SET_ERROR(EBADF));
off = fp->f_offset;
error = dmu_send(snapname, fromname, fd, fp->f_vnode, &off);
@@ -5473,9 +5473,9 @@ pool_status_check(const char *name, zfs_ioc_namecheck_t type,
error = spa_open(name, &spa, FTAG);
if (error == 0) {
if ((check & POOL_CHECK_SUSPENDED) && spa_suspended(spa))
- error = EAGAIN;
+ error = SET_ERROR(EAGAIN);
else if ((check & POOL_CHECK_READONLY) && !spa_writeable(spa))
- error = EROFS;
+ error = SET_ERROR(EROFS);
spa_close(spa, FTAG);
}
return (error);
@@ -5515,10 +5515,10 @@ zfs_ctldev_init(dev_t *devp)
minor = zfsdev_minor_alloc();
if (minor == 0)
- return (ENXIO);
+ return (SET_ERROR(ENXIO));
if (ddi_soft_state_zalloc(zfsdev_state, minor) != DDI_SUCCESS)
- return (EAGAIN);
+ return (SET_ERROR(EAGAIN));
*devp = makedevice(getemajor(*devp), minor);
@@ -5608,14 +5608,14 @@ zfsdev_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cr, int *rvalp)
ASSERT3U(getmajor(dev), ==, ddi_driver_major(zfs_dip));
if (vecnum >= sizeof (zfs_ioc_vec) / sizeof (zfs_ioc_vec[0]))
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
vec = &zfs_ioc_vec[vecnum];
zc = kmem_zalloc(sizeof (zfs_cmd_t), KM_SLEEP);
error = ddi_copyin((void *)arg, zc, sizeof (zfs_cmd_t), flag);
if (error != 0) {
- error = EFAULT;
+ error = SET_ERROR(EFAULT);
goto out;
}
@@ -5635,7 +5635,7 @@ zfsdev_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cr, int *rvalp)
switch (vec->zvec_namecheck) {
case POOL_NAME:
if (pool_namecheck(zc->zc_name, NULL, NULL) != 0)
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
else
error = pool_status_check(zc->zc_name,
vec->zvec_namecheck, vec->zvec_pool_check);
@@ -5643,7 +5643,7 @@ zfsdev_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cr, int *rvalp)
case DATASET_NAME:
if (dataset_namecheck(zc->zc_name, NULL, NULL) != 0)
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
else
error = pool_status_check(zc->zc_name,
vec->zvec_namecheck, vec->zvec_pool_check);
@@ -5723,7 +5723,7 @@ out:
nvlist_free(innvl);
rc = ddi_copyout(zc, (void *)arg, sizeof (zfs_cmd_t), flag);
if (error == 0 && rc != 0)
- error = EFAULT;
+ error = SET_ERROR(EFAULT);
if (error == 0 && vec->zvec_allow_log) {
char *s = tsd_get(zfs_allow_log_key);
if (s != NULL)
@@ -5888,7 +5888,7 @@ _fini(void)
int error;
if (spa_busy() || zfs_busy() || zvol_busy() || zio_injection_enabled)
- return (EBUSY);
+ return (SET_ERROR(EBUSY));
if ((error = mod_remove(&modlinkage)) != 0)
return (error);
diff --git a/uts/common/fs/zfs/zfs_onexit.c b/uts/common/fs/zfs/zfs_onexit.c
index 9706de2..4ae8dc2 100644
--- a/uts/common/fs/zfs/zfs_onexit.c
+++ b/uts/common/fs/zfs/zfs_onexit.c
@@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
#include <sys/types.h>
@@ -108,7 +109,7 @@ zfs_onexit_minor_to_state(minor_t minor, zfs_onexit_t **zo)
{
*zo = zfsdev_get_soft_state(minor, ZSST_CTLDEV);
if (*zo == NULL)
- return (EBADF);
+ return (SET_ERROR(EBADF));
return (0);
}
@@ -127,7 +128,7 @@ zfs_onexit_fd_hold(int fd, minor_t *minorp)
fp = getf(fd);
if (fp == NULL)
- return (EBADF);
+ return (SET_ERROR(EBADF));
*minorp = getminor(fp->f_vnode->v_rdev);
return (zfs_onexit_minor_to_state(*minorp, &zo));
@@ -210,7 +211,7 @@ zfs_onexit_del_cb(minor_t minor, uint64_t action_handle, boolean_t fire)
kmem_free(ap, sizeof (zfs_onexit_action_node_t));
} else {
mutex_exit(&zo->zo_lock);
- error = ENOENT;
+ error = SET_ERROR(ENOENT);
}
return (error);
@@ -239,7 +240,7 @@ zfs_onexit_cb_data(minor_t minor, uint64_t action_handle, void **data)
if (ap != NULL)
*data = ap->za_data;
else
- error = ENOENT;
+ error = SET_ERROR(ENOENT);
mutex_exit(&zo->zo_lock);
return (error);
diff --git a/uts/common/fs/zfs/zfs_replay.c b/uts/common/fs/zfs/zfs_replay.c
index 9fb3368..3f98aae 100644
--- a/uts/common/fs/zfs/zfs_replay.c
+++ b/uts/common/fs/zfs/zfs_replay.c
@@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
#include <sys/types.h>
@@ -70,7 +71,7 @@ zfs_init_vattr(vattr_t *vap, uint64_t mask, uint64_t mode,
static int
zfs_replay_error(zfsvfs_t *zfsvfs, lr_t *lr, boolean_t byteswap)
{
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
}
static void
@@ -385,7 +386,7 @@ zfs_replay_create_acl(zfsvfs_t *zfsvfs,
&vp, kcred, NULL, vflg, &vsec);
break;
default:
- error = ENOTSUP;
+ error = SET_ERROR(ENOTSUP);
}
bail:
@@ -511,7 +512,7 @@ zfs_replay_create(zfsvfs_t *zfsvfs, lr_create_t *lr, boolean_t byteswap)
link, kcred, NULL, vflg);
break;
default:
- error = ENOTSUP;
+ error = SET_ERROR(ENOTSUP);
}
out:
@@ -551,7 +552,7 @@ zfs_replay_remove(zfsvfs_t *zfsvfs, lr_remove_t *lr, boolean_t byteswap)
error = VOP_RMDIR(ZTOV(dzp), name, NULL, kcred, NULL, vflg);
break;
default:
- error = ENOTSUP;
+ error = SET_ERROR(ENOTSUP);
}
VN_RELE(ZTOV(dzp));
diff --git a/uts/common/fs/zfs/zfs_vfsops.c b/uts/common/fs/zfs/zfs_vfsops.c
index 42486ea..108a0b4 100644
--- a/uts/common/fs/zfs/zfs_vfsops.c
+++ b/uts/common/fs/zfs/zfs_vfsops.c
@@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
/* Portions Copyright 2010 Robert Milkowski */
@@ -600,7 +600,7 @@ zfs_space_delta_cb(dmu_object_type_t bonustype, void *data,
* Is it a valid type of object to track?
*/
if (bonustype != DMU_OT_ZNODE && bonustype != DMU_OT_SA)
- return (ENOENT);
+ return (SET_ERROR(ENOENT));
/*
* If we have a NULL data pointer
@@ -609,7 +609,7 @@ zfs_space_delta_cb(dmu_object_type_t bonustype, void *data,
* use the same ids
*/
if (data == NULL)
- return (EEXIST);
+ return (SET_ERROR(EEXIST));
if (bonustype == DMU_OT_ZNODE) {
znode_phys_t *znp = data;
@@ -699,7 +699,7 @@ zfs_userspace_many(zfsvfs_t *zfsvfs, zfs_userquota_prop_t type,
uint64_t obj;
if (!dmu_objset_userspace_present(zfsvfs->z_os))
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
obj = zfs_userquota_prop_to_obj(zfsvfs, type);
if (obj == 0) {
@@ -743,7 +743,7 @@ id_to_fuidstr(zfsvfs_t *zfsvfs, const char *domain, uid_t rid,
if (domain && domain[0]) {
domainid = zfs_fuid_find_by_domain(zfsvfs, domain, NULL, addok);
if (domainid == -1)
- return (ENOENT);
+ return (SET_ERROR(ENOENT));
}
fuid = FUID_ENCODE(domainid, rid);
(void) sprintf(buf, "%llx", (longlong_t)fuid);
@@ -761,7 +761,7 @@ zfs_userspace_one(zfsvfs_t *zfsvfs, zfs_userquota_prop_t type,
*valp = 0;
if (!dmu_objset_userspace_present(zfsvfs->z_os))
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
obj = zfs_userquota_prop_to_obj(zfsvfs, type);
if (obj == 0)
@@ -788,10 +788,10 @@ zfs_set_userquota(zfsvfs_t *zfsvfs, zfs_userquota_prop_t type,
boolean_t fuid_dirtied;
if (type != ZFS_PROP_USERQUOTA && type != ZFS_PROP_GROUPQUOTA)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
if (zfsvfs->z_version < ZPL_VERSION_USERSPACE)
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
objp = (type == ZFS_PROP_USERQUOTA) ? &zfsvfs->z_userquota_obj :
&zfsvfs->z_groupquota_obj;
@@ -919,7 +919,7 @@ zfsvfs_create(const char *osname, zfsvfs_t **zfvp)
"on a version %lld pool\n. Pool must be upgraded to mount "
"this file system.", (u_longlong_t)zfsvfs->z_version,
(u_longlong_t)spa_version(dmu_objset_spa(os)));
- error = ENOTSUP;
+ error = SET_ERROR(ENOTSUP);
goto out;
}
if ((error = zfs_get_zplprop(os, ZFS_PROP_NORMALIZE, &zval)) != 0)
@@ -1172,7 +1172,7 @@ zfs_domount(vfs_t *vfsp, char *osname)
vfsp->vfs_data = NULL;
if (zfs_create_unique_device(&mount_dev) == -1) {
- error = ENODEV;
+ error = SET_ERROR(ENODEV);
goto out;
}
ASSERT(vfs_devismounted(mount_dev) == 0);
@@ -1302,7 +1302,7 @@ str_to_uint64(char *str, uint64_t *objnum)
while (*str) {
if (*str < '0' || *str > '9')
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
num = num*10 + *str++ - '0';
}
@@ -1324,7 +1324,7 @@ zfs_parse_bootfs(char *bpath, char *outpath)
int error;
if (*bpath == 0 || *bpath == '/')
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
(void) strcpy(outpath, bpath);
@@ -1369,10 +1369,10 @@ zfs_check_global_label(const char *dsname, const char *hexsl)
if (dsl_prop_get_integer(dsname,
zfs_prop_to_name(ZFS_PROP_READONLY), &rdonly, NULL))
- return (EACCES);
+ return (SET_ERROR(EACCES));
return (rdonly ? 0 : EACCES);
}
- return (EACCES);
+ return (SET_ERROR(EACCES));
}
/*
@@ -1404,7 +1404,7 @@ zfs_mount_label_policy(vfs_t *vfsp, char *osname)
error = dsl_prop_get(osname, zfs_prop_to_name(ZFS_PROP_MLSLABEL),
1, sizeof (ds_hexsl), &ds_hexsl, NULL);
if (error)
- return (EACCES);
+ return (SET_ERROR(EACCES));
/*
* If labeling is NOT enabled, then disallow the mount of datasets
@@ -1414,7 +1414,7 @@ zfs_mount_label_policy(vfs_t *vfsp, char *osname)
if (!is_system_labeled()) {
if (strcasecmp(ds_hexsl, ZFS_MLSLABEL_DEFAULT) == 0)
return (0);
- return (EACCES);
+ return (SET_ERROR(EACCES));
}
/*
@@ -1431,7 +1431,7 @@ zfs_mount_label_policy(vfs_t *vfsp, char *osname)
if (dsl_prop_get_integer(osname,
zfs_prop_to_name(ZFS_PROP_ZONED), &zoned, NULL))
- return (EACCES);
+ return (SET_ERROR(EACCES));
if (!zoned)
return (zfs_check_global_label(osname, ds_hexsl));
else
@@ -1501,7 +1501,7 @@ zfs_mountroot(vfs_t *vfsp, enum whymountroot why)
*/
if (why == ROOT_INIT) {
if (zfsrootdone++)
- return (EBUSY);
+ return (SET_ERROR(EBUSY));
/*
* the process of doing a spa_load will require the
* clock to be set before we could (for example) do
@@ -1513,7 +1513,7 @@ zfs_mountroot(vfs_t *vfsp, enum whymountroot why)
if ((zfs_bootfs = spa_get_bootprop("zfs-bootfs")) == NULL) {
cmn_err(CE_NOTE, "spa_get_bootfs: can not get "
"bootfs name");
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
zfs_devid = spa_get_bootprop("diskdevid");
error = spa_import_rootpool(rootfs.bo_name, zfs_devid);
@@ -1582,7 +1582,7 @@ out:
* if "why" is equal to anything else other than ROOT_INIT,
* ROOT_REMOUNT, or ROOT_UNMOUNT, we do not support it.
*/
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
}
/*ARGSUSED*/
@@ -1597,14 +1597,14 @@ zfs_mount(vfs_t *vfsp, vnode_t *mvp, struct mounta *uap, cred_t *cr)
int canwrite;
if (mvp->v_type != VDIR)
- return (ENOTDIR);
+ return (SET_ERROR(ENOTDIR));
mutex_enter(&mvp->v_lock);
if ((uap->flags & MS_REMOUNT) == 0 &&
(uap->flags & MS_OVERLAY) == 0 &&
(mvp->v_count != 1 || (mvp->v_flag & VROOT))) {
mutex_exit(&mvp->v_lock);
- return (EBUSY);
+ return (SET_ERROR(EBUSY));
}
mutex_exit(&mvp->v_lock);
@@ -1615,7 +1615,7 @@ zfs_mount(vfs_t *vfsp, vnode_t *mvp, struct mounta *uap, cred_t *cr)
* can be interrogated.
*/
if ((uap->flags & MS_DATA) && uap->datalen > 0)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
/*
* Get the objset name (the "special" mount argument).
@@ -1663,7 +1663,7 @@ zfs_mount(vfs_t *vfsp, vnode_t *mvp, struct mounta *uap, cred_t *cr)
*/
if (!INGLOBALZONE(curproc) &&
(!zone_dataset_visible(osname, &canwrite) || !canwrite)) {
- error = EPERM;
+ error = SET_ERROR(EPERM);
goto out;
}
@@ -1819,7 +1819,7 @@ zfsvfs_teardown(zfsvfs_t *zfsvfs, boolean_t unmounting)
if (!unmounting && (zfsvfs->z_unmounted || zfsvfs->z_os == NULL)) {
rw_exit(&zfsvfs->z_teardown_inactive_lock);
rrw_exit(&zfsvfs->z_teardown_lock, FTAG);
- return (EIO);
+ return (SET_ERROR(EIO));
}
/*
@@ -1918,11 +1918,11 @@ zfs_umount(vfs_t *vfsp, int fflag, cred_t *cr)
*/
if (zfsvfs->z_ctldir == NULL) {
if (vfsp->vfs_count > 1)
- return (EBUSY);
+ return (SET_ERROR(EBUSY));
} else {
if (vfsp->vfs_count > 2 ||
zfsvfs->z_ctldir->v_count > 1)
- return (EBUSY);
+ return (SET_ERROR(EBUSY));
}
}
@@ -1988,7 +1988,7 @@ zfs_vget(vfs_t *vfsp, vnode_t **vpp, fid_t *fidp)
err = zfsctl_lookup_objset(vfsp, objsetid, &zfsvfs);
if (err)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
ZFS_ENTER(zfsvfs);
}
@@ -2002,7 +2002,7 @@ zfs_vget(vfs_t *vfsp, vnode_t **vpp, fid_t *fidp)
fid_gen |= ((uint64_t)zfid->zf_gen[i]) << (8 * i);
} else {
ZFS_EXIT(zfsvfs);
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
/* A zero fid_gen means we are in the .zfs control directories */
@@ -2036,7 +2036,7 @@ zfs_vget(vfs_t *vfsp, vnode_t **vpp, fid_t *fidp)
dprintf("znode gen (%u) != fid gen (%u)\n", zp_gen, fid_gen);
VN_RELE(ZTOV(zp));
ZFS_EXIT(zfsvfs);
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
*vpp = ZTOV(zp);
@@ -2237,14 +2237,14 @@ zfs_set_version(zfsvfs_t *zfsvfs, uint64_t newvers)
dmu_tx_t *tx;
if (newvers < ZPL_VERSION_INITIAL || newvers > ZPL_VERSION)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
if (newvers < zfsvfs->z_version)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
if (zfs_spa_version_map(newvers) >
spa_version(dmu_objset_spa(zfsvfs->z_os)))
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
tx = dmu_tx_create(os);
dmu_tx_hold_zap(tx, MASTER_NODE_OBJ, B_FALSE, ZPL_VERSION_STR);
diff --git a/uts/common/fs/zfs/zfs_vnops.c b/uts/common/fs/zfs/zfs_vnops.c
index 7d7168f..76408bb 100644
--- a/uts/common/fs/zfs/zfs_vnops.c
+++ b/uts/common/fs/zfs/zfs_vnops.c
@@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
/* Portions Copyright 2007 Jeremy Teo */
@@ -183,7 +183,7 @@ zfs_open(vnode_t **vpp, int flag, cred_t *cr, caller_context_t *ct)
if ((flag & FWRITE) && (zp->z_pflags & ZFS_APPENDONLY) &&
((flag & FAPPEND) == 0)) {
ZFS_EXIT(zfsvfs);
- return (EPERM);
+ return (SET_ERROR(EPERM));
}
if (!zfs_has_ctldir(zp) && zp->z_zfsvfs->z_vscan &&
@@ -191,7 +191,7 @@ zfs_open(vnode_t **vpp, int flag, cred_t *cr, caller_context_t *ct)
!(zp->z_pflags & ZFS_AV_QUARANTINED) && zp->z_size > 0) {
if (fs_vscan(*vpp, cr, 0) != 0) {
ZFS_EXIT(zfsvfs);
- return (EACCES);
+ return (SET_ERROR(EACCES));
}
}
@@ -248,7 +248,7 @@ zfs_holey(vnode_t *vp, int cmd, offset_t *off)
file_sz = zp->z_size;
if (noff >= file_sz) {
- return (ENXIO);
+ return (SET_ERROR(ENXIO));
}
if (cmd == _FIO_SEEK_HOLE)
@@ -267,7 +267,7 @@ zfs_holey(vnode_t *vp, int cmd, offset_t *off)
*off = file_sz;
return (0);
}
- return (ENXIO);
+ return (SET_ERROR(ENXIO));
}
if (noff < *off)
@@ -301,7 +301,7 @@ zfs_ioctl(vnode_t *vp, int com, intptr_t data, int flag, cred_t *cred,
case _FIO_SEEK_DATA:
case _FIO_SEEK_HOLE:
if (ddi_copyin((void *)data, &off, sizeof (off), flag))
- return (EFAULT);
+ return (SET_ERROR(EFAULT));
zp = VTOZ(vp);
zfsvfs = zp->z_zfsvfs;
@@ -314,10 +314,10 @@ zfs_ioctl(vnode_t *vp, int com, intptr_t data, int flag, cred_t *cred,
if (error)
return (error);
if (ddi_copyout(&off, (void *)data, sizeof (off), flag))
- return (EFAULT);
+ return (SET_ERROR(EFAULT));
return (0);
}
- return (ENOTTY);
+ return (SET_ERROR(ENOTTY));
}
/*
@@ -457,7 +457,7 @@ zfs_read(vnode_t *vp, uio_t *uio, int ioflag, cred_t *cr, caller_context_t *ct)
if (zp->z_pflags & ZFS_AV_QUARANTINED) {
ZFS_EXIT(zfsvfs);
- return (EACCES);
+ return (SET_ERROR(EACCES));
}
/*
@@ -465,7 +465,7 @@ zfs_read(vnode_t *vp, uio_t *uio, int ioflag, cred_t *cr, caller_context_t *ct)
*/
if (uio->uio_loffset < (offset_t)0) {
ZFS_EXIT(zfsvfs);
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
/*
@@ -550,7 +550,7 @@ zfs_read(vnode_t *vp, uio_t *uio, int ioflag, cred_t *cr, caller_context_t *ct)
if (error) {
/* convert checksum errors into IO errors */
if (error == ECKSUM)
- error = EIO;
+ error = SET_ERROR(EIO);
break;
}
@@ -638,7 +638,7 @@ zfs_write(vnode_t *vp, uio_t *uio, int ioflag, cred_t *cr, caller_context_t *ct)
((zp->z_pflags & ZFS_APPENDONLY) && !(ioflag & FAPPEND) &&
(uio->uio_loffset < zp->z_size))) {
ZFS_EXIT(zfsvfs);
- return (EPERM);
+ return (SET_ERROR(EPERM));
}
zilog = zfsvfs->z_log;
@@ -649,7 +649,7 @@ zfs_write(vnode_t *vp, uio_t *uio, int ioflag, cred_t *cr, caller_context_t *ct)
woff = ioflag & FAPPEND ? zp->z_size : uio->uio_loffset;
if (woff < 0) {
ZFS_EXIT(zfsvfs);
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
/*
@@ -704,7 +704,7 @@ zfs_write(vnode_t *vp, uio_t *uio, int ioflag, cred_t *cr, caller_context_t *ct)
if (woff >= limit) {
zfs_range_unlock(rl);
ZFS_EXIT(zfsvfs);
- return (EFBIG);
+ return (SET_ERROR(EFBIG));
}
if ((woff + n) > limit || woff > (limit - n))
@@ -728,7 +728,7 @@ again:
zfs_owner_overquota(zfsvfs, zp, B_TRUE)) {
if (abuf != NULL)
dmu_return_arcbuf(abuf);
- error = EDQUOT;
+ error = SET_ERROR(EDQUOT);
break;
}
@@ -988,7 +988,7 @@ zfs_get_data(void *arg, lr_write_t *lr, char *buf, zio_t *zio)
* Nothing to do if the file has been removed
*/
if (zfs_zget(zfsvfs, object, &zp) != 0)
- return (ENOENT);
+ return (SET_ERROR(ENOENT));
if (zp->z_unlinked) {
/*
* Release the vnode asynchronously as we currently have the
@@ -996,7 +996,7 @@ zfs_get_data(void *arg, lr_write_t *lr, char *buf, zio_t *zio)
*/
VN_RELE_ASYNC(ZTOV(zp),
dsl_pool_vnrele_taskq(dmu_objset_pool(os)));
- return (ENOENT);
+ return (SET_ERROR(ENOENT));
}
zgd = (zgd_t *)kmem_zalloc(sizeof (zgd_t), KM_SLEEP);
@@ -1014,7 +1014,7 @@ zfs_get_data(void *arg, lr_write_t *lr, char *buf, zio_t *zio)
zgd->zgd_rl = zfs_range_lock(zp, offset, size, RL_READER);
/* test for truncation needs to be done while range locked */
if (offset >= zp->z_size) {
- error = ENOENT;
+ error = SET_ERROR(ENOENT);
} else {
error = dmu_read(os, object, offset, size, buf,
DMU_READ_NO_PREFETCH);
@@ -1041,10 +1041,10 @@ zfs_get_data(void *arg, lr_write_t *lr, char *buf, zio_t *zio)
}
/* test for truncation needs to be done while range locked */
if (lr->lr_offset >= zp->z_size)
- error = ENOENT;
+ error = SET_ERROR(ENOENT);
#ifdef DEBUG
if (zil_fault_io) {
- error = EIO;
+ error = SET_ERROR(EIO);
zil_fault_io = 0;
}
#endif
@@ -1125,7 +1125,7 @@ specvp_check(vnode_t **vpp, cred_t *cr)
svp = specvp(*vpp, (*vpp)->v_rdev, (*vpp)->v_type, cr);
VN_RELE(*vpp);
if (svp == NULL)
- error = ENOSYS;
+ error = SET_ERROR(ENOSYS);
*vpp = svp;
}
return (error);
@@ -1168,9 +1168,9 @@ zfs_lookup(vnode_t *dvp, char *nm, vnode_t **vpp, struct pathname *pnp,
if (!(flags & (LOOKUP_XATTR | FIGNORECASE))) {
if (dvp->v_type != VDIR) {
- return (ENOTDIR);
+ return (SET_ERROR(ENOTDIR));
} else if (zdp->z_sa_hdl == NULL) {
- return (EIO);
+ return (SET_ERROR(EIO));
}
if (nm[0] == 0 || (nm[0] == '.' && nm[1] == '\0')) {
@@ -1192,7 +1192,7 @@ zfs_lookup(vnode_t *dvp, char *nm, vnode_t **vpp, struct pathname *pnp,
}
if (tvp == DNLC_NO_VNODE) {
VN_RELE(tvp);
- return (ENOENT);
+ return (SET_ERROR(ENOENT));
} else {
*vpp = tvp;
return (specvp_check(vpp, cr));
@@ -1214,7 +1214,7 @@ zfs_lookup(vnode_t *dvp, char *nm, vnode_t **vpp, struct pathname *pnp,
*/
if (!(zfsvfs->z_vfs->vfs_flag & VFS_XATTR)) {
ZFS_EXIT(zfsvfs);
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
/*
@@ -1223,7 +1223,7 @@ zfs_lookup(vnode_t *dvp, char *nm, vnode_t **vpp, struct pathname *pnp,
*/
if (zdp->z_pflags & ZFS_XATTR) {
ZFS_EXIT(zfsvfs);
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
if (error = zfs_get_xattrdir(VTOZ(dvp), vpp, cr, flags)) {
@@ -1247,7 +1247,7 @@ zfs_lookup(vnode_t *dvp, char *nm, vnode_t **vpp, struct pathname *pnp,
if (dvp->v_type != VDIR) {
ZFS_EXIT(zfsvfs);
- return (ENOTDIR);
+ return (SET_ERROR(ENOTDIR));
}
/*
@@ -1262,7 +1262,7 @@ zfs_lookup(vnode_t *dvp, char *nm, vnode_t **vpp, struct pathname *pnp,
if (zfsvfs->z_utf8 && u8_validate(nm, strlen(nm),
NULL, U8_VALIDATE_ENTIRE, &error) < 0) {
ZFS_EXIT(zfsvfs);
- return (EILSEQ);
+ return (SET_ERROR(EILSEQ));
}
error = zfs_dirlook(zdp, nm, vpp, flags, direntflags, realpnp);
@@ -1332,7 +1332,7 @@ zfs_create(vnode_t *dvp, char *name, vattr_t *vap, vcexcl_t excl,
if (zfsvfs->z_use_fuids == B_FALSE &&
(vsecp || (vap->va_mask & AT_XVATTR) ||
IS_EPHEMERAL(uid) || IS_EPHEMERAL(gid)))
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
ZFS_ENTER(zfsvfs);
ZFS_VERIFY_ZP(dzp);
@@ -1342,7 +1342,7 @@ zfs_create(vnode_t *dvp, char *name, vattr_t *vap, vcexcl_t excl,
if (zfsvfs->z_utf8 && u8_validate(name, strlen(name),
NULL, U8_VALIDATE_ENTIRE, &error) < 0) {
ZFS_EXIT(zfsvfs);
- return (EILSEQ);
+ return (SET_ERROR(EILSEQ));
}
if (vap->va_mask & AT_XVATTR) {
@@ -1379,7 +1379,7 @@ top:
if (have_acl)
zfs_acl_ids_free(&acl_ids);
if (strcmp(name, "..") == 0)
- error = EISDIR;
+ error = SET_ERROR(EISDIR);
ZFS_EXIT(zfsvfs);
return (error);
}
@@ -1407,7 +1407,7 @@ top:
(vap->va_type != VREG)) {
if (have_acl)
zfs_acl_ids_free(&acl_ids);
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
goto out;
}
@@ -1418,7 +1418,7 @@ top:
if (zfs_acl_ids_overquota(zfsvfs, &acl_ids)) {
zfs_acl_ids_free(&acl_ids);
- error = EDQUOT;
+ error = SET_ERROR(EDQUOT);
goto out;
}
@@ -1477,14 +1477,14 @@ top:
* Can't truncate an existing file if in exclusive mode.
*/
if (excl == EXCL) {
- error = EEXIST;
+ error = SET_ERROR(EEXIST);
goto out;
}
/*
* Can't open a directory for writing.
*/
if ((ZTOV(zp)->v_type == VDIR) && (mode & S_IWRITE)) {
- error = EISDIR;
+ error = SET_ERROR(EISDIR);
goto out;
}
/*
@@ -1608,7 +1608,7 @@ top:
* Need to use rmdir for removing directories.
*/
if (vp->v_type == VDIR) {
- error = EPERM;
+ error = SET_ERROR(EPERM);
goto out;
}
@@ -1817,7 +1817,7 @@ zfs_mkdir(vnode_t *dvp, char *dirname, vattr_t *vap, vnode_t **vpp, cred_t *cr,
if (zfsvfs->z_use_fuids == B_FALSE &&
(vsecp || (vap->va_mask & AT_XVATTR) ||
IS_EPHEMERAL(uid) || IS_EPHEMERAL(gid)))
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
ZFS_ENTER(zfsvfs);
ZFS_VERIFY_ZP(dzp);
@@ -1825,13 +1825,13 @@ zfs_mkdir(vnode_t *dvp, char *dirname, vattr_t *vap, vnode_t **vpp, cred_t *cr,
if (dzp->z_pflags & ZFS_XATTR) {
ZFS_EXIT(zfsvfs);
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
if (zfsvfs->z_utf8 && u8_validate(dirname,
strlen(dirname), NULL, U8_VALIDATE_ENTIRE, &error) < 0) {
ZFS_EXIT(zfsvfs);
- return (EILSEQ);
+ return (SET_ERROR(EILSEQ));
}
if (flags & FIGNORECASE)
zf |= ZCILOOK;
@@ -1877,7 +1877,7 @@ top:
zfs_acl_ids_free(&acl_ids);
zfs_dirent_unlock(dl);
ZFS_EXIT(zfsvfs);
- return (EDQUOT);
+ return (SET_ERROR(EDQUOT));
}
/*
@@ -2003,12 +2003,12 @@ top:
}
if (vp->v_type != VDIR) {
- error = ENOTDIR;
+ error = SET_ERROR(ENOTDIR);
goto out;
}
if (vp == cwd) {
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
goto out;
}
@@ -2144,7 +2144,7 @@ zfs_readdir(vnode_t *vp, uio_t *uio, cred_t *cr, int *eofp,
*/
if (uio->uio_iov->iov_len <= 0) {
ZFS_EXIT(zfsvfs);
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
/*
@@ -2242,7 +2242,7 @@ zfs_readdir(vnode_t *vp, uio_t *uio, cred_t *cr, int *eofp,
"entry, obj = %lld, offset = %lld\n",
(u_longlong_t)zp->z_id,
(u_longlong_t)offset);
- error = ENXIO;
+ error = SET_ERROR(ENXIO);
goto update;
}
@@ -2286,7 +2286,7 @@ zfs_readdir(vnode_t *vp, uio_t *uio, cred_t *cr, int *eofp,
* Did we manage to fit anything in the buffer?
*/
if (!outcount) {
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
goto update;
}
break;
@@ -2650,7 +2650,7 @@ zfs_setattr(vnode_t *vp, vattr_t *vap, int flags, cred_t *cr,
return (0);
if (mask & AT_NOSET)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
ZFS_ENTER(zfsvfs);
ZFS_VERIFY_ZP(zp);
@@ -2667,17 +2667,17 @@ zfs_setattr(vnode_t *vp, vattr_t *vap, int flags, cred_t *cr,
((mask & AT_GID) && IS_EPHEMERAL(vap->va_gid)) ||
(mask & AT_XVATTR))) {
ZFS_EXIT(zfsvfs);
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
if (mask & AT_SIZE && vp->v_type == VDIR) {
ZFS_EXIT(zfsvfs);
- return (EISDIR);
+ return (SET_ERROR(EISDIR));
}
if (mask & AT_SIZE && vp->v_type != VREG && vp->v_type != VFIFO) {
ZFS_EXIT(zfsvfs);
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
/*
@@ -2695,12 +2695,12 @@ zfs_setattr(vnode_t *vp, vattr_t *vap, int flags, cred_t *cr,
((mask & (AT_SIZE|AT_UID|AT_GID|AT_MTIME|AT_MODE)) ||
((mask & AT_XVATTR) && XVA_ISSET_REQ(xvap, XAT_CREATETIME)))) {
ZFS_EXIT(zfsvfs);
- return (EPERM);
+ return (SET_ERROR(EPERM));
}
if ((mask & AT_SIZE) && (zp->z_pflags & ZFS_READONLY)) {
ZFS_EXIT(zfsvfs);
- return (EPERM);
+ return (SET_ERROR(EPERM));
}
/*
@@ -2713,7 +2713,7 @@ zfs_setattr(vnode_t *vp, vattr_t *vap, int flags, cred_t *cr,
if (((mask & AT_ATIME) && TIMESPEC_OVERFLOW(&vap->va_atime)) ||
((mask & AT_MTIME) && TIMESPEC_OVERFLOW(&vap->va_mtime))) {
ZFS_EXIT(zfsvfs);
- return (EOVERFLOW);
+ return (SET_ERROR(EOVERFLOW));
}
}
@@ -2724,7 +2724,7 @@ top:
/* Can this be moved to before the top label? */
if (zfsvfs->z_vfs->vfs_flag & VFS_RDONLY) {
ZFS_EXIT(zfsvfs);
- return (EROFS);
+ return (SET_ERROR(EROFS));
}
/*
@@ -2887,7 +2887,7 @@ top:
if (XVA_ISSET_REQ(xvap, XAT_REPARSE)) {
mutex_exit(&zp->z_lock);
ZFS_EXIT(zfsvfs);
- return (EPERM);
+ return (SET_ERROR(EPERM));
}
if (need_policy == FALSE &&
@@ -2959,7 +2959,7 @@ top:
zfs_fuid_overquota(zfsvfs, B_FALSE, new_uid)) {
if (attrzp)
VN_RELE(ZTOV(attrzp));
- err = EDQUOT;
+ err = SET_ERROR(EDQUOT);
goto out2;
}
}
@@ -2971,7 +2971,7 @@ top:
zfs_fuid_overquota(zfsvfs, B_TRUE, new_gid)) {
if (attrzp)
VN_RELE(ZTOV(attrzp));
- err = EDQUOT;
+ err = SET_ERROR(EDQUOT);
goto out2;
}
}
@@ -2985,7 +2985,7 @@ top:
if (zp->z_zfsvfs->z_acl_mode == ZFS_ACL_RESTRICTED &&
!(zp->z_pflags & ZFS_ACL_TRIVIAL)) {
- err = EPERM;
+ err = SET_ERROR(EPERM);
goto out;
}
@@ -3313,7 +3313,7 @@ zfs_rename_lock(znode_t *szp, znode_t *tdzp, znode_t *sdzp, zfs_zlock_t **zlpp)
*zlpp = zl;
if (oidp == szp->z_id) /* We're a descendant of szp */
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
if (oidp == rootid) /* We've hit the top */
return (0);
@@ -3381,7 +3381,7 @@ zfs_rename(vnode_t *sdvp, char *snm, vnode_t *tdvp, char *tnm, cred_t *cr,
if (tdvp->v_vfsp != sdvp->v_vfsp || zfsctl_is_node(tdvp)) {
ZFS_EXIT(zfsvfs);
- return (EXDEV);
+ return (SET_ERROR(EXDEV));
}
tdzp = VTOZ(tdvp);
@@ -3389,7 +3389,7 @@ zfs_rename(vnode_t *sdvp, char *snm, vnode_t *tdvp, char *tnm, cred_t *cr,
if (zfsvfs->z_utf8 && u8_validate(tnm,
strlen(tnm), NULL, U8_VALIDATE_ENTIRE, &error) < 0) {
ZFS_EXIT(zfsvfs);
- return (EILSEQ);
+ return (SET_ERROR(EILSEQ));
}
if (flags & FIGNORECASE)
@@ -3407,7 +3407,7 @@ top:
*/
if ((tdzp->z_pflags & ZFS_XATTR) != (sdzp->z_pflags & ZFS_XATTR)) {
ZFS_EXIT(zfsvfs);
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
/*
@@ -3507,7 +3507,7 @@ top:
rw_exit(&sdzp->z_name_lock);
if (strcmp(snm, "..") == 0)
- serr = EINVAL;
+ serr = SET_ERROR(EINVAL);
ZFS_EXIT(zfsvfs);
return (serr);
}
@@ -3519,7 +3519,7 @@ top:
rw_exit(&sdzp->z_name_lock);
if (strcmp(tnm, "..") == 0)
- terr = EINVAL;
+ terr = SET_ERROR(EINVAL);
ZFS_EXIT(zfsvfs);
return (terr);
}
@@ -3552,12 +3552,12 @@ top:
*/
if (ZTOV(szp)->v_type == VDIR) {
if (ZTOV(tzp)->v_type != VDIR) {
- error = ENOTDIR;
+ error = SET_ERROR(ENOTDIR);
goto out;
}
} else {
if (ZTOV(tzp)->v_type == VDIR) {
- error = EISDIR;
+ error = SET_ERROR(EISDIR);
goto out;
}
}
@@ -3731,14 +3731,14 @@ zfs_symlink(vnode_t *dvp, char *name, vattr_t *vap, char *link, cred_t *cr,
if (zfsvfs->z_utf8 && u8_validate(name, strlen(name),
NULL, U8_VALIDATE_ENTIRE, &error) < 0) {
ZFS_EXIT(zfsvfs);
- return (EILSEQ);
+ return (SET_ERROR(EILSEQ));
}
if (flags & FIGNORECASE)
zflg |= ZCILOOK;
if (len > MAXPATHLEN) {
ZFS_EXIT(zfsvfs);
- return (ENAMETOOLONG);
+ return (SET_ERROR(ENAMETOOLONG));
}
if ((error = zfs_acl_ids_create(dzp, 0,
@@ -3768,7 +3768,7 @@ top:
zfs_acl_ids_free(&acl_ids);
zfs_dirent_unlock(dl);
ZFS_EXIT(zfsvfs);
- return (EDQUOT);
+ return (SET_ERROR(EDQUOT));
}
tx = dmu_tx_create(zfsvfs->z_os);
fuid_dirtied = zfsvfs->z_fuid_dirty;
@@ -3931,12 +3931,12 @@ zfs_link(vnode_t *tdvp, vnode_t *svp, char *name, cred_t *cr,
*/
if (svp->v_type == VDIR) {
ZFS_EXIT(zfsvfs);
- return (EPERM);
+ return (SET_ERROR(EPERM));
}
if (svp->v_vfsp != tdvp->v_vfsp || zfsctl_is_node(svp)) {
ZFS_EXIT(zfsvfs);
- return (EXDEV);
+ return (SET_ERROR(EXDEV));
}
szp = VTOZ(svp);
@@ -3951,13 +3951,13 @@ zfs_link(vnode_t *tdvp, vnode_t *svp, char *name, cred_t *cr,
}
if (parent == zfsvfs->z_shares_dir) {
ZFS_EXIT(zfsvfs);
- return (EPERM);
+ return (SET_ERROR(EPERM));
}
if (zfsvfs->z_utf8 && u8_validate(name,
strlen(name), NULL, U8_VALIDATE_ENTIRE, &error) < 0) {
ZFS_EXIT(zfsvfs);
- return (EILSEQ);
+ return (SET_ERROR(EILSEQ));
}
if (flags & FIGNORECASE)
zf |= ZCILOOK;
@@ -3970,14 +3970,14 @@ zfs_link(vnode_t *tdvp, vnode_t *svp, char *name, cred_t *cr,
*/
if ((szp->z_pflags & ZFS_XATTR) != (dzp->z_pflags & ZFS_XATTR)) {
ZFS_EXIT(zfsvfs);
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
owner = zfs_fuid_map_id(zfsvfs, szp->z_uid, cr, ZFS_OWNER);
if (owner != crgetuid(cr) && secpolicy_basic_link(cr) != 0) {
ZFS_EXIT(zfsvfs);
- return (EPERM);
+ return (SET_ERROR(EPERM));
}
if (error = zfs_zaccess(dzp, ACE_ADD_FILE, 0, B_FALSE, cr)) {
@@ -4117,7 +4117,7 @@ zfs_putapage(vnode_t *vp, page_t *pp, u_offset_t *offp,
if (zfs_owner_overquota(zfsvfs, zp, B_FALSE) ||
zfs_owner_overquota(zfsvfs, zp, B_TRUE)) {
- err = EDQUOT;
+ err = SET_ERROR(EDQUOT);
goto out;
}
top:
@@ -4385,7 +4385,7 @@ zfs_frlock(vnode_t *vp, int cmd, flock64_t *bfp, int flag, offset_t offset,
*/
if (zp->z_mapcnt > 0 && MANDMODE(zp->z_mode)) {
ZFS_EXIT(zfsvfs);
- return (EAGAIN);
+ return (SET_ERROR(EAGAIN));
}
ZFS_EXIT(zfsvfs);
return (fs_frlock(vp, cmd, bfp, flag, offset, flk_cbp, cr, ct));
@@ -4449,7 +4449,7 @@ zfs_fillpage(vnode_t *vp, u_offset_t off, struct seg *seg,
pvn_read_done(pp, B_ERROR);
/* convert checksum errors into IO errors */
if (err == ECKSUM)
- err = EIO;
+ err = SET_ERROR(EIO);
return (err);
}
cur_pp = cur_pp->p_next;
@@ -4599,28 +4599,28 @@ zfs_map(vnode_t *vp, offset_t off, struct as *as, caddr_t *addrp,
if ((prot & PROT_WRITE) && (zp->z_pflags &
(ZFS_IMMUTABLE | ZFS_READONLY | ZFS_APPENDONLY))) {
ZFS_EXIT(zfsvfs);
- return (EPERM);
+ return (SET_ERROR(EPERM));
}
if ((prot & (PROT_READ | PROT_EXEC)) &&
(zp->z_pflags & ZFS_AV_QUARANTINED)) {
ZFS_EXIT(zfsvfs);
- return (EACCES);
+ return (SET_ERROR(EACCES));
}
if (vp->v_flag & VNOMAP) {
ZFS_EXIT(zfsvfs);
- return (ENOSYS);
+ return (SET_ERROR(ENOSYS));
}
if (off < 0 || len > MAXOFFSET_T - off) {
ZFS_EXIT(zfsvfs);
- return (ENXIO);
+ return (SET_ERROR(ENXIO));
}
if (vp->v_type != VREG) {
ZFS_EXIT(zfsvfs);
- return (ENODEV);
+ return (SET_ERROR(ENODEV));
}
/*
@@ -4628,7 +4628,7 @@ zfs_map(vnode_t *vp, offset_t off, struct as *as, caddr_t *addrp,
*/
if (MANDMODE(zp->z_mode) && vn_has_flocks(vp)) {
ZFS_EXIT(zfsvfs);
- return (EAGAIN);
+ return (SET_ERROR(EAGAIN));
}
as_rangelock(as);
@@ -4743,7 +4743,7 @@ zfs_space(vnode_t *vp, int cmd, flock64_t *bfp, int flag,
if (cmd != F_FREESP) {
ZFS_EXIT(zfsvfs);
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
if (error = convoff(vp, bfp, 0, offset)) {
@@ -4753,7 +4753,7 @@ zfs_space(vnode_t *vp, int cmd, flock64_t *bfp, int flag,
if (bfp->l_len < 0) {
ZFS_EXIT(zfsvfs);
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
off = bfp->l_start;
@@ -4792,7 +4792,7 @@ zfs_fid(vnode_t *vp, fid_t *fidp, caller_context_t *ct)
if (fidp->fid_len < size) {
fidp->fid_len = size;
ZFS_EXIT(zfsvfs);
- return (ENOSPC);
+ return (SET_ERROR(ENOSPC));
}
zfid = (zfid_short_t *)fidp;
@@ -4965,7 +4965,7 @@ zfs_reqzcbuf(vnode_t *vp, enum uio_rw ioflag, xuio_t *xuio, cred_t *cr,
int preamble, postamble;
if (xuio->xu_type != UIOTYPE_ZEROCOPY)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
ZFS_ENTER(zfsvfs);
ZFS_VERIFY_ZP(zp);
@@ -4978,7 +4978,7 @@ zfs_reqzcbuf(vnode_t *vp, enum uio_rw ioflag, xuio_t *xuio, cred_t *cr,
blksz = max_blksz;
if (size < blksz || zp->z_blksz != blksz) {
ZFS_EXIT(zfsvfs);
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
/*
* Caller requests buffers for write before knowing where the
@@ -5046,7 +5046,7 @@ zfs_reqzcbuf(vnode_t *vp, enum uio_rw ioflag, xuio_t *xuio, cred_t *cr,
/* avoid potential complexity of dealing with it */
if (blksz > max_blksz) {
ZFS_EXIT(zfsvfs);
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
maxsize = zp->z_size - uio->uio_loffset;
@@ -5055,12 +5055,12 @@ zfs_reqzcbuf(vnode_t *vp, enum uio_rw ioflag, xuio_t *xuio, cred_t *cr,
if (size < blksz || vn_has_cached_data(vp)) {
ZFS_EXIT(zfsvfs);
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
break;
default:
ZFS_EXIT(zfsvfs);
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
uio->uio_extflg = UIO_XUIO;
@@ -5107,13 +5107,13 @@ static int zfs_isdir();
static int
zfs_inval()
{
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
static int
zfs_isdir()
{
- return (EISDIR);
+ return (SET_ERROR(EISDIR));
}
/*
* Directory vnode operations template
diff --git a/uts/common/fs/zfs/zfs_znode.c b/uts/common/fs/zfs/zfs_znode.c
index 92dc05f..7d4f308 100644
--- a/uts/common/fs/zfs/zfs_znode.c
+++ b/uts/common/fs/zfs/zfs_znode.c
@@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
/* Portions Copyright 2007 Jeremy Teo */
@@ -1127,7 +1127,7 @@ zfs_zget(zfsvfs_t *zfsvfs, uint64_t obj_num, znode_t **zpp)
doi.doi_bonus_size < sizeof (znode_phys_t)))) {
sa_buf_rele(db, NULL);
ZFS_OBJ_HOLD_EXIT(zfsvfs, obj_num);
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
hdl = dmu_buf_get_user(db);
@@ -1146,7 +1146,7 @@ zfs_zget(zfsvfs_t *zfsvfs, uint64_t obj_num, znode_t **zpp)
mutex_enter(&zp->z_lock);
ASSERT3U(zp->z_id, ==, obj_num);
if (zp->z_unlinked) {
- err = ENOENT;
+ err = SET_ERROR(ENOENT);
} else {
VN_HOLD(ZTOV(zp));
*zpp = zp;
@@ -1172,7 +1172,7 @@ zfs_zget(zfsvfs_t *zfsvfs, uint64_t obj_num, znode_t **zpp)
zp = zfs_znode_alloc(zfsvfs, db, doi.doi_data_block_size,
doi.doi_bonus_type, NULL);
if (zp == NULL) {
- err = ENOENT;
+ err = SET_ERROR(ENOENT);
} else {
*zpp = zp;
}
@@ -1216,7 +1216,7 @@ zfs_rezget(znode_t *zp)
doi.doi_bonus_size < sizeof (znode_phys_t)))) {
sa_buf_rele(db, NULL);
ZFS_OBJ_HOLD_EXIT(zfsvfs, obj_num);
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
zfs_znode_sa_init(zfsvfs, zp, db, doi.doi_bonus_type, NULL);
@@ -1242,7 +1242,7 @@ zfs_rezget(znode_t *zp)
if (sa_bulk_lookup(zp->z_sa_hdl, bulk, count)) {
zfs_znode_dmu_fini(zp);
ZFS_OBJ_HOLD_EXIT(zfsvfs, obj_num);
- return (EIO);
+ return (SET_ERROR(EIO));
}
zp->z_mode = mode;
@@ -1250,7 +1250,7 @@ zfs_rezget(znode_t *zp)
if (gen != zp->z_gen) {
zfs_znode_dmu_fini(zp);
ZFS_OBJ_HOLD_EXIT(zfsvfs, obj_num);
- return (EIO);
+ return (SET_ERROR(EIO));
}
zp->z_unlinked = (zp->z_links == 0);
@@ -1923,7 +1923,7 @@ zfs_grab_sa_handle(objset_t *osp, uint64_t obj, sa_handle_t **hdlp,
doi.doi_bonus_type == DMU_OT_ZNODE &&
doi.doi_bonus_size < sizeof (znode_phys_t)) {
sa_buf_rele(*db, tag);
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
}
error = sa_handle_get(osp, obj, NULL, SA_HDL_PRIVATE, hdlp);
@@ -1992,7 +1992,7 @@ zfs_obj_to_pobj(objset_t *osp, sa_handle_t *hdl, sa_attr_type_t *sa_table,
* Otherwise the parent must be a directory.
*/
if (!*is_xattrdir && !S_ISDIR(parent_mode))
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
*pobjp = parent;
diff --git a/uts/common/fs/zfs/zil.c b/uts/common/fs/zfs/zil.c
index e9616f8..8142e24 100644
--- a/uts/common/fs/zfs/zil.c
+++ b/uts/common/fs/zfs/zil.c
@@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
/* Portions Copyright 2010 Robert Milkowski */
@@ -142,7 +142,7 @@ zil_bp_tree_add(zilog_t *zilog, const blkptr_t *bp)
avl_index_t where;
if (avl_find(t, dva, &where) != NULL)
- return (EEXIST);
+ return (SET_ERROR(EEXIST));
zn = kmem_alloc(sizeof (zil_bp_node_t), KM_SLEEP);
zn->zn_dva = *dva;
@@ -213,7 +213,7 @@ zil_read_log_block(zilog_t *zilog, const blkptr_t *bp, blkptr_t *nbp, void *dst,
if (bcmp(&cksum, &zilc->zc_next_blk.blk_cksum,
sizeof (cksum)) || BP_IS_HOLE(&zilc->zc_next_blk)) {
- error = ECKSUM;
+ error = SET_ERROR(ECKSUM);
} else {
bcopy(lr, dst, len);
*end = (char *)dst + len;
@@ -227,7 +227,7 @@ zil_read_log_block(zilog_t *zilog, const blkptr_t *bp, blkptr_t *nbp, void *dst,
if (bcmp(&cksum, &zilc->zc_next_blk.blk_cksum,
sizeof (cksum)) || BP_IS_HOLE(&zilc->zc_next_blk) ||
(zilc->zc_nused > (size - sizeof (*zilc)))) {
- error = ECKSUM;
+ error = SET_ERROR(ECKSUM);
} else {
bcopy(lr, dst, zilc->zc_nused);
*end = (char *)dst + zilc->zc_nused;
@@ -1849,7 +1849,7 @@ zil_suspend(const char *osname, void **cookiep)
if (zh->zh_flags & ZIL_REPLAY_NEEDED) { /* unplayed log */
mutex_exit(&zilog->zl_lock);
dmu_objset_rele(os, suspend_tag);
- return (EBUSY);
+ return (SET_ERROR(EBUSY));
}
/*
@@ -2110,6 +2110,6 @@ zil_vdev_offline(const char *osname, void *arg)
error = zil_suspend(osname, NULL);
if (error != 0)
- return (EEXIST);
+ return (SET_ERROR(EEXIST));
return (0);
}
diff --git a/uts/common/fs/zfs/zio.c b/uts/common/fs/zfs/zio.c
index 7940e20..84f3028 100644
--- a/uts/common/fs/zfs/zio.c
+++ b/uts/common/fs/zfs/zio.c
@@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
* Copyright (c) 2011 Nexenta Systems, Inc. All rights reserved.
*/
@@ -345,7 +345,7 @@ zio_decompress(zio_t *zio, void *data, uint64_t size)
if (zio->io_error == 0 &&
zio_decompress_data(BP_GET_COMPRESS(zio->io_bp),
zio->io_data, data, zio->io_size, size) != 0)
- zio->io_error = EIO;
+ zio->io_error = SET_ERROR(EIO);
}
/*
@@ -2012,7 +2012,7 @@ zio_ddt_collision(zio_t *zio, ddt_t *ddt, ddt_entry_t *dde)
if (arc_buf_size(abuf) != zio->io_orig_size ||
bcmp(abuf->b_data, zio->io_orig_data,
zio->io_orig_size) != 0)
- error = EEXIST;
+ error = SET_ERROR(EEXIST);
VERIFY(arc_buf_remove_ref(abuf, &abuf));
}
@@ -2474,7 +2474,7 @@ zio_vdev_io_start(zio_t *zio)
return (ZIO_PIPELINE_STOP);
if (!vdev_accessible(vd, zio)) {
- zio->io_error = ENXIO;
+ zio->io_error = SET_ERROR(ENXIO);
zio_interrupt(zio);
return (ZIO_PIPELINE_STOP);
}
@@ -2511,7 +2511,7 @@ zio_vdev_io_done(zio_t *zio)
if (zio->io_error) {
if (!vdev_accessible(vd, zio)) {
- zio->io_error = ENXIO;
+ zio->io_error = SET_ERROR(ENXIO);
} else {
unexpected_error = B_TRUE;
}
@@ -2596,7 +2596,7 @@ zio_vdev_io_assess(zio_t *zio)
*/
if (zio->io_error && vd != NULL && vd->vdev_ops->vdev_op_leaf &&
!vdev_accessible(vd, zio))
- zio->io_error = ENXIO;
+ zio->io_error = SET_ERROR(ENXIO);
/*
* If we can't write to an interior vdev (mirror or RAID-Z),
diff --git a/uts/common/fs/zfs/zio_checksum.c b/uts/common/fs/zfs/zio_checksum.c
index c8fe20f2..bc73317 100644
--- a/uts/common/fs/zfs/zio_checksum.c
+++ b/uts/common/fs/zfs/zio_checksum.c
@@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
#include <sys/zfs_context.h>
@@ -201,7 +202,7 @@ zio_checksum_error(zio_t *zio, zio_bad_cksum_t *info)
zio_cksum_t actual_cksum, expected_cksum, verifier;
if (checksum >= ZIO_CHECKSUM_FUNCTIONS || ci->ci_func[0] == NULL)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
if (ci->ci_eck) {
zio_eck_t *eck;
@@ -216,10 +217,10 @@ zio_checksum_error(zio_t *zio, zio_bad_cksum_t *info)
else if (eck->zec_magic == BSWAP_64(ZEC_MAGIC))
nused = BSWAP_64(zilc->zc_nused);
else
- return (ECKSUM);
+ return (SET_ERROR(ECKSUM));
if (nused > size)
- return (ECKSUM);
+ return (SET_ERROR(ECKSUM));
size = P2ROUNDUP_TYPED(nused, ZIL_MIN_BLKSZ, uint64_t);
} else {
@@ -261,7 +262,7 @@ zio_checksum_error(zio_t *zio, zio_bad_cksum_t *info)
info->zbc_has_cksum = 1;
if (!ZIO_CHECKSUM_EQUAL(actual_cksum, expected_cksum))
- return (ECKSUM);
+ return (SET_ERROR(ECKSUM));
if (zio_injection_enabled && !zio->io_error &&
(error = zio_handle_fault_injection(zio, ECKSUM)) != 0) {
diff --git a/uts/common/fs/zfs/zio_compress.c b/uts/common/fs/zfs/zio_compress.c
index 1dc780d..d3c6ae1 100644
--- a/uts/common/fs/zfs/zio_compress.c
+++ b/uts/common/fs/zfs/zio_compress.c
@@ -27,6 +27,10 @@
* Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
*/
+/*
+ * Copyright (c) 2013 by Delphix. All rights reserved.
+ */
+
#include <sys/zfs_context.h>
#include <sys/compress.h>
#include <sys/spa.h>
@@ -130,7 +134,7 @@ zio_decompress_data(enum zio_compress c, void *src, void *dst,
zio_compress_info_t *ci = &zio_compress_table[c];
if ((uint_t)c >= ZIO_COMPRESS_FUNCTIONS || ci->ci_decompress == NULL)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
return (ci->ci_decompress(src, dst, s_len, d_len, ci->ci_level));
}
diff --git a/uts/common/fs/zfs/zio_inject.c b/uts/common/fs/zfs/zio_inject.c
index a9d4ab4..9f3db70 100644
--- a/uts/common/fs/zfs/zio_inject.c
+++ b/uts/common/fs/zfs/zio_inject.c
@@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
/*
@@ -276,7 +276,7 @@ zio_handle_device_injection(vdev_t *vd, zio_t *zio, int error)
break;
}
if (handler->zi_record.zi_error == ENXIO) {
- ret = EIO;
+ ret = SET_ERROR(EIO);
break;
}
}
@@ -416,7 +416,7 @@ zio_inject_fault(char *name, int flags, int *id, zinject_record_t *record)
* still allowing it to be unloaded.
*/
if ((spa = spa_inject_addref(name)) == NULL)
- return (ENOENT);
+ return (SET_ERROR(ENOENT));
handler = kmem_alloc(sizeof (inject_handler_t), KM_SLEEP);
@@ -468,7 +468,7 @@ zio_inject_list_next(int *id, char *name, size_t buflen,
(void) strncpy(name, spa_name(handler->zi_spa), buflen);
ret = 0;
} else {
- ret = ENOENT;
+ ret = SET_ERROR(ENOENT);
}
rw_exit(&inject_lock);
@@ -495,7 +495,7 @@ zio_clear_fault(int id)
if (handler == NULL) {
rw_exit(&inject_lock);
- return (ENOENT);
+ return (SET_ERROR(ENOENT));
}
list_remove(&inject_handlers, handler);
diff --git a/uts/common/fs/zfs/zvol.c b/uts/common/fs/zfs/zvol.c
index 5911fd3..5fad8cf 100644
--- a/uts/common/fs/zfs/zvol.c
+++ b/uts/common/fs/zfs/zvol.c
@@ -24,7 +24,7 @@
* Portions Copyright 2010 Robert Milkowski
*
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
/*
@@ -164,14 +164,14 @@ int
zvol_check_volsize(uint64_t volsize, uint64_t blocksize)
{
if (volsize == 0)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
if (volsize % blocksize != 0)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
#ifdef _ILP32
if (volsize - 1 > SPEC_MAXOFFSET_T)
- return (EOVERFLOW);
+ return (SET_ERROR(EOVERFLOW));
#endif
return (0);
}
@@ -182,7 +182,7 @@ zvol_check_volblocksize(uint64_t volblocksize)
if (volblocksize < SPA_MINBLOCKSIZE ||
volblocksize > SPA_MAXBLOCKSIZE ||
!ISP2(volblocksize))
- return (EDOM);
+ return (SET_ERROR(EDOM));
return (0);
}
@@ -252,7 +252,7 @@ zvol_map_block(spa_t *spa, zilog_t *zilog, const blkptr_t *bp,
/* Abort immediately if we have encountered gang blocks */
if (BP_IS_GANG(bp))
- return (EFRAGS);
+ return (SET_ERROR(EFRAGS));
/*
* See if the block is at the end of the previous extent.
@@ -409,7 +409,7 @@ zvol_replay_write(zvol_state_t *zv, lr_write_t *lr, boolean_t byteswap)
static int
zvol_replay_err(zvol_state_t *zv, lr_t *lr, boolean_t byteswap)
{
- return (ENOTSUP);
+ return (SET_ERROR(ENOTSUP));
}
/*
@@ -470,7 +470,7 @@ zvol_create_minor(const char *name)
if (zvol_minor_lookup(name) != NULL) {
mutex_exit(&zfsdev_state_lock);
- return (EEXIST);
+ return (SET_ERROR(EEXIST));
}
/* lie and say we're read-only */
@@ -484,13 +484,13 @@ zvol_create_minor(const char *name)
if ((minor = zfsdev_minor_alloc()) == 0) {
dmu_objset_disown(os, FTAG);
mutex_exit(&zfsdev_state_lock);
- return (ENXIO);
+ return (SET_ERROR(ENXIO));
}
if (ddi_soft_state_zalloc(zfsdev_state, minor) != DDI_SUCCESS) {
dmu_objset_disown(os, FTAG);
mutex_exit(&zfsdev_state_lock);
- return (EAGAIN);
+ return (SET_ERROR(EAGAIN));
}
(void) ddi_prop_update_string(minor, zfs_dip, ZVOL_PROP_NAME,
(char *)name);
@@ -502,7 +502,7 @@ zvol_create_minor(const char *name)
ddi_soft_state_free(zfsdev_state, minor);
dmu_objset_disown(os, FTAG);
mutex_exit(&zfsdev_state_lock);
- return (EAGAIN);
+ return (SET_ERROR(EAGAIN));
}
(void) snprintf(blkbuf, sizeof (blkbuf), "%u", minor);
@@ -513,7 +513,7 @@ zvol_create_minor(const char *name)
ddi_soft_state_free(zfsdev_state, minor);
dmu_objset_disown(os, FTAG);
mutex_exit(&zfsdev_state_lock);
- return (EAGAIN);
+ return (SET_ERROR(EAGAIN));
}
zs = ddi_get_soft_state(zfsdev_state, minor);
@@ -562,7 +562,7 @@ zvol_remove_zv(zvol_state_t *zv)
ASSERT(MUTEX_HELD(&zfsdev_state_lock));
if (zv->zv_total_opens != 0)
- return (EBUSY);
+ return (SET_ERROR(EBUSY));
(void) snprintf(nmbuf, sizeof (nmbuf), "%u,raw", minor);
ddi_remove_minor_node(zfs_dip, nmbuf);
@@ -590,7 +590,7 @@ zvol_remove_minor(const char *name)
mutex_enter(&zfsdev_state_lock);
if ((zv = zvol_minor_lookup(name)) == NULL) {
mutex_exit(&zfsdev_state_lock);
- return (ENXIO);
+ return (SET_ERROR(ENXIO));
}
rc = zvol_remove_zv(zv);
mutex_exit(&zfsdev_state_lock);
@@ -671,7 +671,7 @@ zvol_prealloc(zvol_state_t *zv)
/* Check the space usage before attempting to allocate the space */
dmu_objset_space(os, &refd, &avail, &usedobjs, &availobjs);
if (avail < zv->zv_volsize)
- return (ENOSPC);
+ return (SET_ERROR(ENOSPC));
/* Free old extents if they exist */
zvol_free_extents(zv);
@@ -816,7 +816,7 @@ zvol_set_volsize(const char *name, uint64_t volsize)
if (error != 0)
return (error);
if (readonly)
- return (EROFS);
+ return (SET_ERROR(EROFS));
mutex_enter(&zfsdev_state_lock);
zv = zvol_minor_lookup(name);
@@ -864,7 +864,7 @@ zvol_open(dev_t *devp, int flag, int otyp, cred_t *cr)
zv = zfsdev_get_soft_state(getminor(*devp), ZSST_ZVOL);
if (zv == NULL) {
mutex_exit(&zfsdev_state_lock);
- return (ENXIO);
+ return (SET_ERROR(ENXIO));
}
if (zv->zv_total_opens == 0)
@@ -874,16 +874,16 @@ zvol_open(dev_t *devp, int flag, int otyp, cred_t *cr)
return (err);
}
if ((flag & FWRITE) && (zv->zv_flags & ZVOL_RDONLY)) {
- err = EROFS;
+ err = SET_ERROR(EROFS);
goto out;
}
if (zv->zv_flags & ZVOL_EXCL) {
- err = EBUSY;
+ err = SET_ERROR(EBUSY);
goto out;
}
if (flag & FEXCL) {
if (zv->zv_total_opens != 0) {
- err = EBUSY;
+ err = SET_ERROR(EBUSY);
goto out;
}
zv->zv_flags |= ZVOL_EXCL;
@@ -916,7 +916,7 @@ zvol_close(dev_t dev, int flag, int otyp, cred_t *cr)
zv = zfsdev_get_soft_state(minor, ZSST_ZVOL);
if (zv == NULL) {
mutex_exit(&zfsdev_state_lock);
- return (ENXIO);
+ return (SET_ERROR(ENXIO));
}
if (zv->zv_flags & ZVOL_EXCL) {
@@ -1125,9 +1125,9 @@ zvol_dumpio_vdev(vdev_t *vd, void *addr, uint64_t offset, uint64_t size,
return (numerrors < vd->vdev_children ? 0 : EIO);
if (doread && !vdev_readable(vd))
- return (EIO);
+ return (SET_ERROR(EIO));
else if (!doread && !vdev_writeable(vd))
- return (EIO);
+ return (SET_ERROR(EIO));
dvd = vd->vdev_tsd;
ASSERT3P(dvd, !=, NULL);
@@ -1136,7 +1136,7 @@ zvol_dumpio_vdev(vdev_t *vd, void *addr, uint64_t offset, uint64_t size,
if (ddi_in_panic() || isdump) {
ASSERT(!doread);
if (doread)
- return (EIO);
+ return (SET_ERROR(EIO));
return (ldi_dump(dvd->vd_lh, addr, lbtodb(offset),
lbtodb(size)));
} else {
@@ -1157,7 +1157,7 @@ zvol_dumpio(zvol_state_t *zv, void *addr, uint64_t offset, uint64_t size,
/* Must be sector aligned, and not stradle a block boundary. */
if (P2PHASE(offset, DEV_BSIZE) || P2PHASE(size, DEV_BSIZE) ||
P2BOUNDARY(offset, size, zv->zv_volblocksize)) {
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
}
ASSERT(size <= zv->zv_volblocksize);
@@ -1169,7 +1169,7 @@ zvol_dumpio(zvol_state_t *zv, void *addr, uint64_t offset, uint64_t size,
}
if (ze == NULL)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
if (!ddi_in_panic())
spa_config_enter(spa, SCL_STATE, FTAG, RW_READER);
@@ -1200,13 +1200,13 @@ zvol_strategy(buf_t *bp)
boolean_t sync;
if (getminor(bp->b_edev) == 0) {
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
} else {
zs = ddi_get_soft_state(zfsdev_state, getminor(bp->b_edev));
if (zs == NULL)
- error = ENXIO;
+ error = SET_ERROR(ENXIO);
else if (zs->zss_type != ZSST_ZVOL)
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
}
if (error) {
@@ -1276,7 +1276,7 @@ zvol_strategy(buf_t *bp)
if (error) {
/* convert checksum errors into IO errors */
if (error == ECKSUM)
- error = EIO;
+ error = SET_ERROR(EIO);
break;
}
off += size;
@@ -1322,10 +1322,10 @@ zvol_dump(dev_t dev, caddr_t addr, daddr_t blkno, int nblocks)
zv = zfsdev_get_soft_state(minor, ZSST_ZVOL);
if (zv == NULL)
- return (ENXIO);
+ return (SET_ERROR(ENXIO));
if ((zv->zv_flags & ZVOL_DUMPIFIED) == 0)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
boff = ldbtob(blkno);
resid = ldbtob(nblocks);
@@ -1357,12 +1357,12 @@ zvol_read(dev_t dev, uio_t *uio, cred_t *cr)
zv = zfsdev_get_soft_state(minor, ZSST_ZVOL);
if (zv == NULL)
- return (ENXIO);
+ return (SET_ERROR(ENXIO));
volsize = zv->zv_volsize;
if (uio->uio_resid > 0 &&
(uio->uio_loffset < 0 || uio->uio_loffset >= volsize))
- return (EIO);
+ return (SET_ERROR(EIO));
if (zv->zv_flags & ZVOL_DUMPIFIED) {
error = physio(zvol_strategy, NULL, dev, B_READ,
@@ -1383,7 +1383,7 @@ zvol_read(dev_t dev, uio_t *uio, cred_t *cr)
if (error) {
/* convert checksum errors into IO errors */
if (error == ECKSUM)
- error = EIO;
+ error = SET_ERROR(EIO);
break;
}
}
@@ -1404,12 +1404,12 @@ zvol_write(dev_t dev, uio_t *uio, cred_t *cr)
zv = zfsdev_get_soft_state(minor, ZSST_ZVOL);
if (zv == NULL)
- return (ENXIO);
+ return (SET_ERROR(ENXIO));
volsize = zv->zv_volsize;
if (uio->uio_resid > 0 &&
(uio->uio_loffset < 0 || uio->uio_loffset >= volsize))
- return (EIO);
+ return (SET_ERROR(EIO));
if (zv->zv_flags & ZVOL_DUMPIFIED) {
error = physio(zvol_strategy, NULL, dev, B_WRITE,
@@ -1461,7 +1461,7 @@ zvol_getefi(void *arg, int flag, uint64_t vs, uint8_t bs)
char *ptr;
if (ddi_copyin(arg, &efi, sizeof (dk_efi_t), flag))
- return (EFAULT);
+ return (SET_ERROR(EFAULT));
ptr = (char *)(uintptr_t)efi.dki_data_64;
length = efi.dki_length;
/*
@@ -1472,7 +1472,7 @@ zvol_getefi(void *arg, int flag, uint64_t vs, uint8_t bs)
* PMBR.
*/
if (efi.dki_lba < 1 || efi.dki_lba > 2 || length <= 0)
- return (EINVAL);
+ return (SET_ERROR(EINVAL));
gpe.efi_gpe_StartingLBA = LE_64(34ULL);
gpe.efi_gpe_EndingLBA = LE_64((vs >> bs) - 1);
@@ -1497,13 +1497,13 @@ zvol_getefi(void *arg, int flag, uint64_t vs, uint8_t bs)
gpt.efi_gpt_HeaderCRC32 = LE_32(~crc);
if (ddi_copyout(&gpt, ptr, MIN(sizeof (gpt), length),
flag))
- return (EFAULT);
+ return (SET_ERROR(EFAULT));
ptr += sizeof (gpt);
length -= sizeof (gpt);
}
if (length > 0 && ddi_copyout(&gpe, ptr, MIN(sizeof (gpe),
length), flag))
- return (EFAULT);
+ return (SET_ERROR(EFAULT));
return (0);
}
@@ -1523,9 +1523,9 @@ zvol_get_volume_params(minor_t minor, uint64_t *blksize,
zv = zfsdev_get_soft_state(minor, ZSST_ZVOL);
if (zv == NULL)
- return (ENXIO);
+ return (SET_ERROR(ENXIO));
if (zv->zv_flags & ZVOL_DUMPIFIED)
- return (ENXIO);
+ return (SET_ERROR(ENXIO));
ASSERT(blksize && max_xfer_len && minor_hdl &&
objset_hdl && zil_hdl && rl_hdl && bonus_hdl);
@@ -1624,7 +1624,7 @@ zvol_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cr, int *rvalp)
if (zv == NULL) {
mutex_exit(&zfsdev_state_lock);
- return (ENXIO);
+ return (SET_ERROR(ENXIO));
}
ASSERT(zv->zv_total_opens > 0);
@@ -1639,7 +1639,7 @@ zvol_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cr, int *rvalp)
dki.dki_maxtransfer = 1 << (SPA_MAXBLOCKSHIFT - zv->zv_min_bs);
mutex_exit(&zfsdev_state_lock);
if (ddi_copyout(&dki, (void *)arg, sizeof (dki), flag))
- error = EFAULT;
+ error = SET_ERROR(EFAULT);
return (error);
case DKIOCGMEDIAINFO:
@@ -1649,7 +1649,7 @@ zvol_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cr, int *rvalp)
dkm.dki_media_type = DK_UNKNOWN;
mutex_exit(&zfsdev_state_lock);
if (ddi_copyout(&dkm, (void *)arg, sizeof (dkm), flag))
- error = EFAULT;
+ error = SET_ERROR(EFAULT);
return (error);
case DKIOCGETEFI:
@@ -1677,7 +1677,7 @@ zvol_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cr, int *rvalp)
int wce = (zv->zv_flags & ZVOL_WCE) ? 1 : 0;
if (ddi_copyout(&wce, (void *)arg, sizeof (int),
flag))
- error = EFAULT;
+ error = SET_ERROR(EFAULT);
break;
}
case DKIOCSETWCE:
@@ -1685,7 +1685,7 @@ zvol_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cr, int *rvalp)
int wce;
if (ddi_copyin((void *)arg, &wce, sizeof (int),
flag)) {
- error = EFAULT;
+ error = SET_ERROR(EFAULT);
break;
}
if (wce) {
@@ -1705,7 +1705,7 @@ zvol_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cr, int *rvalp)
* commands using these (like prtvtoc) expect ENOTSUP
* since we're emulating an EFI label
*/
- error = ENOTSUP;
+ error = SET_ERROR(ENOTSUP);
break;
case DKIOCDUMPINIT:
@@ -1730,7 +1730,7 @@ zvol_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cr, int *rvalp)
dmu_tx_t *tx;
if (ddi_copyin((void *)arg, &df, sizeof (df), flag)) {
- error = EFAULT;
+ error = SET_ERROR(EFAULT);
break;
}
@@ -1784,7 +1784,7 @@ zvol_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cr, int *rvalp)
}
default:
- error = ENOTTY;
+ error = SET_ERROR(ENOTTY);
break;
}
@@ -1929,7 +1929,7 @@ zvol_dumpify(zvol_state_t *zv)
objset_t *os = zv->zv_objset;
if (zv->zv_flags & ZVOL_RDONLY)
- return (EROFS);
+ return (SET_ERROR(EROFS));
if (zap_lookup(zv->zv_objset, ZVOL_ZAP_OBJ, ZVOL_DUMPSIZE,
8, 1, &dumpsize) != 0 || dumpsize != zv->zv_volsize) {
OpenPOWER on IntegriCloud