# HG changeset patch # User Matthew Ahrens # Date 1362768088 28800 # Node ID d7059eb1884c9d90881e6e782efbf17e68b3d9fc # Parent b01a4832cdf92bb3d9fee7f4d6630643be5d7dc9 3598 want to dtrace when errors are generated in zfs Reviewed by: Dan Kimmel Reviewed by: Adam Leventhal Reviewed by: Christopher Siden Approved by: Garrett D'Amore diff -r b01a4832cdf9 -r d7059eb1884c usr/src/lib/libzpool/Makefile.com --- a/usr/src/lib/libzpool/Makefile.com Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/lib/libzpool/Makefile.com Fri Mar 08 10:41:28 2013 -0800 @@ -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. # LIBRARY= libzpool.a @@ -29,6 +29,7 @@ # include the list of ZFS sources include ../../../uts/common/Makefile.files KERNEL_OBJS = kernel.o taskq.o util.o +DTRACE_OBJS = zfs.o OBJECTS=$(ZFS_COMMON_OBJS) $(ZFS_SHARED_OBJS) $(KERNEL_OBJS) @@ -52,7 +53,10 @@ INCS += -I../../../common/zfs INCS += -I../../../common +CLEANFILES += ../common/zfs.h + $(LINTLIB) := SRCS= $(SRCDIR)/$(LINTSRC) +$(LINTLIB): ../common/zfs.h C99MODE= -xc99=%all C99LMODE= -Xc99=%all @@ -79,10 +83,19 @@ include ../../Makefile.targ -pics/%.o: ../../../uts/common/fs/zfs/%.c +EXTPICS= $(DTRACE_OBJS:%=pics/%) + +pics/%.o: ../../../uts/common/fs/zfs/%.c ../common/zfs.h $(COMPILE.c) -o $@ $< $(POST_PROCESS_O) -pics/%.o: ../../../common/zfs/%.c +pics/%.o: ../../../common/zfs/%.c ../common/zfs.h $(COMPILE.c) -o $@ $< $(POST_PROCESS_O) + +pics/%.o: ../common/%.d $(PICS) + $(COMPILE.d) -C -s $< -o $@ $(PICS) + $(POST_PROCESS_O) + +../common/%.h: ../common/%.d + $(DTRACE) -xnolibs -h -s $< -o $@ diff -r b01a4832cdf9 -r d7059eb1884c usr/src/lib/libzpool/common/sys/zfs_context.h --- a/usr/src/lib/libzpool/common/sys/zfs_context.h Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/lib/libzpool/common/sys/zfs_context.h Fri Mar 08 10:41:28 2013 -0800 @@ -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. */ @@ -81,6 +81,7 @@ #include #include #include +#include "zfs.h" /* * Debugging @@ -121,28 +122,43 @@ #ifdef DTRACE_PROBE #undef DTRACE_PROBE -#define DTRACE_PROBE(a) ((void)0) #endif /* DTRACE_PROBE */ +#define DTRACE_PROBE(a) \ + ZFS_PROBE0(#a) #ifdef DTRACE_PROBE1 #undef DTRACE_PROBE1 -#define DTRACE_PROBE1(a, b, c) ((void)0) #endif /* DTRACE_PROBE1 */ +#define DTRACE_PROBE1(a, b, c) \ + ZFS_PROBE1(#a, (unsigned long)c) #ifdef DTRACE_PROBE2 #undef DTRACE_PROBE2 -#define DTRACE_PROBE2(a, b, c, d, e) ((void)0) #endif /* DTRACE_PROBE2 */ +#define DTRACE_PROBE2(a, b, c, d, e) \ + ZFS_PROBE2(#a, (unsigned long)c, (unsigned long)e) #ifdef DTRACE_PROBE3 #undef DTRACE_PROBE3 -#define DTRACE_PROBE3(a, b, c, d, e, f, g) ((void)0) #endif /* DTRACE_PROBE3 */ +#define DTRACE_PROBE3(a, b, c, d, e, f, g) \ + ZFS_PROBE3(#a, (unsigned long)c, (unsigned long)e, (unsigned long)g) #ifdef DTRACE_PROBE4 #undef DTRACE_PROBE4 -#define DTRACE_PROBE4(a, b, c, d, e, f, g, h, i) ((void)0) #endif /* DTRACE_PROBE4 */ +#define DTRACE_PROBE4(a, b, c, d, e, f, g, h, i) \ + ZFS_PROBE4(#a, (unsigned long)c, (unsigned long)e, (unsigned long)g, \ + (unsigned long)i) + +/* + * We use the comma operator so that this macro can be used without much + * additional code. For example, "return (EINVAL);" becomes + * "return (SET_ERROR(EINVAL));". Note that the argument will be evaluated + * twice, so it should not have side effects (e.g. something like: + * "return (SET_ERROR(log_error(EINVAL, info)));" would log the error twice). + */ +#define SET_ERROR(err) (ZFS_SET_ERROR(err), err) /* * Threads diff -r b01a4832cdf9 -r d7059eb1884c usr/src/lib/libzpool/common/zfs.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usr/src/lib/libzpool/common/zfs.d Fri Mar 08 10:41:28 2013 -0800 @@ -0,0 +1,36 @@ +/* + * CDDL HEADER START + * + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2013 by Delphix. All rights reserved. + */ + +provider zfs { + probe probe0(char *probename); + probe probe1(char *probename, unsigned long arg1); + probe probe2(char *probename, unsigned long arg1, unsigned long arg2); + probe probe3(char *probename, unsigned long arg1, unsigned long arg2, + unsigned long arg3); + probe probe4(char *probename, unsigned long arg1, unsigned long arg2, + unsigned long arg3, unsigned long arg4); + + probe set__error(int err); +}; + +#pragma D attributes Evolving/Evolving/ISA provider zfs provider +#pragma D attributes Private/Private/Unknown provider zfs module +#pragma D attributes Private/Private/Unknown provider zfs function +#pragma D attributes Evolving/Evolving/ISA provider zfs name +#pragma D attributes Evolving/Evolving/ISA provider zfs args diff -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/arc.c --- a/usr/src/uts/common/fs/zfs/arc.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/arc.c Fri Mar 08 10:41:28 2013 -0800 @@ -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 @@ */ 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 @@ 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 @@ */ 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_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 @@ 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 -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/dbuf.c --- a/usr/src/uts/common/fs/zfs/dbuf.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/dbuf.c Fri Mar 08 10:41:28 2013 -0800 @@ -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 @@ -598,7 +598,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/ddt.c --- a/usr/src/uts/common/fs/zfs/ddt.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/ddt.c Fri Mar 08 10:41:28 2013 -0800 @@ -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 @@ -160,7 +160,7 @@ 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 @@ 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 @@ ddb->ddb_type = 0; } while (++ddb->ddb_class < DDT_CLASSES); - return (ENOENT); + return (SET_ERROR(ENOENT)); } diff -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/dmu.c --- a/usr/src/uts/common/fs/zfs/dmu.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/dmu.c Fri Mar 08 10:41:28 2013 -0800 @@ -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 @@ -143,7 +143,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ (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 @@ 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 @@ 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_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 @@ * 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 @@ * 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 @@ * 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 -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/dmu_diff.c --- a/usr/src/uts/common/fs/zfs/dmu_diff.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/dmu_diff.c Fri Mar 08 10:41:28 2013 -0800 @@ -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 @@ -113,7 +113,7 @@ 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 @@ 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 @@ 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 @@ 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 -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/dmu_object.c --- a/usr/src/uts/common/fs/zfs/dmu_object.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/dmu_object.c Fri Mar 08 10:41:28 2013 -0800 @@ -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 @@ -90,7 +91,7 @@ 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 @@ 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 -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/dmu_objset.c --- a/usr/src/uts/common/fs/zfs/dmu_objset.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/dmu_objset.c Fri Mar 08 10:41:28 2013 -0800 @@ -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 @@ 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 @@ 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 @@ 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 @@ 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 @@ /* 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ /* 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 @@ 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 @@ { 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 -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/dmu_send.c --- a/usr/src/uts/common/fs/zfs/dmu_send.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/dmu_send.c Fri Mar 08 10:41:28 2013 -0800 @@ -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 @@ 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 @@ /* 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ /* 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ ptr++) *ptr = 0x2f5baddb10c; } else { - return (EIO); + return (SET_ERROR(EIO)); } } @@ -407,7 +407,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ /* 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 @@ /* 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 @@ 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 @@ 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 @@ 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_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 @@ /* 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 @@ * 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ drro->drr_bonustype, drro->drr_bonuslen); } if (err != 0) { - return (EINVAL); + return (SET_ERROR(EINVAL)); } tx = dmu_tx_create(os); @@ -1173,7 +1173,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ * 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 @@ break; } default: - ra.err = EINVAL; + ra.err = SET_ERROR(EINVAL); goto out; } pcksum = ra.cksum; diff -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/dmu_traverse.c --- a/usr/src/uts/common/fs/zfs/dmu_traverse.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/dmu_traverse.c Fri Mar 08 10:41:28 2013 -0800 @@ -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 @@ -434,7 +434,7 @@ 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 -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/dmu_tx.c --- a/usr/src/uts/common/fs/zfs/dmu_tx.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/dmu_tx.c Fri Mar 08 10:41:28 2013 -0800 @@ -160,7 +160,7 @@ 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 @@ 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 @@ */ 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 @@ 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 -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/dnode.c --- a/usr/src/uts/common/fs/zfs/dnode.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/dnode.c Fri Mar 08 10:41:28 2013 -0800 @@ -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 @@ -1031,12 +1031,12 @@ 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 @@ } 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 @@ 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 @@ 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 @@ * 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 @@ * 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 @@ *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 @@ *offset = start; } if (i < 0 || i >= epb) - error = ESRCH; + error = SET_ERROR(ESRCH); } if (db) @@ -1961,7 +1961,7 @@ 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 @@ if (flags & DNODE_FIND_HOLE) *offset = dn->dn_datablksz; } else { - error = ESRCH; + error = SET_ERROR(ESRCH); } goto out; } @@ -1991,7 +1991,7 @@ 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 -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/dsl_dataset.c --- a/usr/src/uts/common/fs/zfs/dsl_dataset.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/dsl_dataset.c Fri Mar 08 10:41:28 2013 -0800 @@ -357,7 +357,7 @@ /* 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ * 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 @@ 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 @@ atp = strchr(snapname, '@'); if (atp == NULL) { - error = EINVAL; + error = SET_ERROR(EINVAL); break; } (void) strlcpy(fsname, snapname, atp - snapname + 1); @@ -1268,7 +1268,7 @@ 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 @@ /* 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 @@ /* 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 @@ 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 @@ 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 @@ if (hds->ds_phys->ds_flags & DS_FLAG_NOPROMOTE) { promote_rele(ddpa, FTAG); - return (EXDEV); + return (SET_ERROR(EXDEV)); } /* @@ -1853,7 +1853,7 @@ * the objset. */ if (dsl_dataset_long_held(ds)) { - err = EBUSY; + err = SET_ERROR(EBUSY); goto out; } @@ -1862,7 +1862,7 @@ 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 @@ 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 @@ /* 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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_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 @@ if (snap != new) dsl_dataset_rele(snap, FTAG); if (snapobj == 0) { - err = EINVAL; + err = SET_ERROR(EINVAL); break; } @@ -2861,7 +2861,7 @@ 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 -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/dsl_deleg.c --- a/usr/src/uts/common/fs/zfs/dsl_deleg.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/dsl_deleg.c Fri Mar 08 10:41:28 2013 -0800 @@ -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 @@ 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 @@ 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 @@ 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 @@ 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 @@ return (0); } - return (EPERM); + return (SET_ERROR(EPERM)); } /* @@ -555,11 +555,11 @@ 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 @@ if (error == 0) goto success; } - error = EPERM; + error = SET_ERROR(EPERM); success: cookie = NULL; diff -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/dsl_destroy.c --- a/usr/src/uts/common/fs/zfs/dsl_destroy.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/dsl_destroy.c Fri Mar 08 10:41:28 2013 -0800 @@ -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 @@ -52,10 +52,10 @@ 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 @@ 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 @@ * 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 @@ 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 @@ */ 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 @@ 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 -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/dsl_dir.c --- a/usr/src/uts/common/fs/zfs/dsl_dir.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/dsl_dir.c Fri Mar 08 10:41:28 2013 -0800 @@ -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 @@ -249,12 +249,12 @@ 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 @@ */ 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 @@ * 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 @@ /* 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 @@ /* 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 @@ 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 @@ 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 @@ 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 @@ 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_dataset_name(ds, namebuf); if (strlen(namebuf) + *deltap >= MAXNAMELEN) - return (ENAMETOOLONG); + return (SET_ERROR(ENAMETOOLONG)); return (0); } @@ -1183,14 +1183,14 @@ 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 @@ 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 @@ 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 -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/dsl_pool.c --- a/usr/src/uts/common/fs/zfs/dsl_pool.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/dsl_pool.c Fri Mar 08 10:41:28 2013 -0800 @@ -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 @@ -608,7 +608,7 @@ + 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_create_obj(dp, tx); zapobj = dp->dp_tmp_userrefs_obj; } else { - return (ENOENT); + return (SET_ERROR(ENOENT)); } } diff -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/dsl_prop.c --- a/usr/src/uts/common/fs/zfs/dsl_prop.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/dsl_prop.c Fri Mar 08 10:41:28 2013 -0800 @@ -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 @@ -52,16 +52,16 @@ */ 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 @@ * 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 @@ 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 @@ 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 @@ 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 -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/dsl_scan.c --- a/usr/src/uts/common/fs/zfs/dsl_scan.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/dsl_scan.c Fri Mar 08 10:41:28 2013 -0800 @@ -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 @@ -159,7 +159,7 @@ 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_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 @@ 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 -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/dsl_synctask.c --- a/usr/src/uts/common/fs/zfs/dsl_synctask.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/dsl_synctask.c Fri Mar 08 10:41:28 2013 -0800 @@ -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 @@ -155,7 +155,7 @@ 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 -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/dsl_userhold.c --- a/usr/src/uts/common/fs/zfs/dsl_userhold.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/dsl_userhold.c Fri Mar 08 10:41:28 2013 -0800 @@ -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 @@ -67,7 +67,7 @@ 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 @@ 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 @@ /* 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 @@ *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 @@ 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 @@ /* 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 @@ 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 -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/metaslab.c --- a/usr/src/uts/common/fs/zfs/metaslab.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/metaslab.c Fri Mar 08 10:41:28 2013 -0800 @@ -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 @@ * 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 @@ bzero(&dva[d], sizeof (dva_t)); - return (ENOSPC); + return (SET_ERROR(ENOSPC)); } /* @@ -1742,7 +1742,7 @@ 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 @@ 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 @@ 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 -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/sa.c --- a/usr/src/uts/common/fs/zfs/sa.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/sa.c Fri Mar 08 10:41:28 2013 -0800 @@ -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 @@ -373,7 +373,7 @@ 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 @@ 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_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 @@ &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 @@ */ 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 @@ 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 @@ */ if (error || (error == 0 && layout_count == 0)) { if (error == 0) - error = EINVAL; + error = SET_ERROR(EINVAL); goto fail; } diff -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/spa.c --- a/usr/src/uts/common/fs/zfs/spa.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/spa.c Fri Mar 08 10:41:28 2013 -0800 @@ -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 @@ switch (prop) { case ZPROP_INVAL: if (!zpool_prop_feature(propname)) { - error = EINVAL; + error = SET_ERROR(EINVAL); break; } @@ -409,23 +409,23 @@ * 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 @@ (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 @@ 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 @@ * the bootfs property cannot be set. */ if (spa_version(spa) < SPA_VERSION_BOOTFS) { - error = ENOTSUP; + error = SET_ERROR(ENOTSUP); break; } @@ -465,7 +465,7 @@ * 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 @@ /* 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 @@ 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 @@ */ if (!error && spa_suspended(spa)) { spa->spa_failmode = intval; - error = EIO; + error = SET_ERROR(EIO); } break; @@ -536,7 +536,7 @@ break; if (strval[0] != '/') { - error = EINVAL; + error = SET_ERROR(EINVAL); break; } @@ -545,7 +545,7 @@ 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 @@ * there is an easy-to-use kernel isprint(). */ if (*check >= 0x7f) { - error = EINVAL; + error = SET_ERROR(EINVAL); break; } check++; @@ -570,12 +570,12 @@ 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_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 @@ if (error) { vdev_free(*vdp); *vdp = NULL; - return (EINVAL); + return (SET_ERROR(EINVAL)); } for (int c = 0; c < children; c++) { @@ -1872,7 +1872,7 @@ if (error) { if (error != ENXIO && error != EIO) - error = EIO; + error = SET_ERROR(EIO); return (error); } @@ -2000,7 +2000,7 @@ 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 @@ 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->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 @@ return (error); if (rvd->vdev_state <= VDEV_STATE_CANT_OPEN) - return (ENXIO); + return (SET_ERROR(ENXIO)); } /* @@ -2380,7 +2380,7 @@ "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 @@ * 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 @@ 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_remove(spa); if (locked) mutex_exit(&spa_namespace_lock); - return (ENOENT); + return (SET_ERROR(ENOENT)); } if (error) { @@ -3195,14 +3195,14 @@ 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 @@ if (!vd->vdev_ops->vdev_op_leaf) { vdev_free(vd); - error = EINVAL; + error = SET_ERROR(EINVAL); goto out; } @@ -3229,7 +3229,7 @@ #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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ "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 @@ 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 @@ *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 @@ 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_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->spa_root_vdev->vdev_child[c]->vdev_islog) { continue; } else { - error = EINVAL; + error = SET_ERROR(EINVAL); break; } } @@ -4843,14 +4843,14 @@ /* 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 @@ 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 @@ 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_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 @@ /* * 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 @@ { 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 @@ 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 -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/spa_errlog.c --- a/usr/src/uts/common/fs/zfs/spa_errlog.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/spa_errlog.c Fri Mar 08 10:41:28 2013 -0800 @@ -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 @@ if (*count == 0) { zap_cursor_fini(&zc); - return (ENOMEM); + return (SET_ERROR(ENOMEM)); } name_to_bookmark(za.za_name, &zb); @@ -183,7 +184,7 @@ 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 @@ 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 -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/spa_history.c --- a/usr/src/uts/common/fs/zfs/spa_history.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/spa_history.c Fri Mar 08 10:41:28 2013 -0800 @@ -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 @@ -304,7 +304,7 @@ 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 @@ * 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 -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/spa_misc.c --- a/usr/src/uts/common/fs/zfs/spa_misc.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/spa_misc.c Fri Mar 08 10:41:28 2013 -0800 @@ -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 @@ 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 -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/uberblock.c --- a/usr/src/uts/common/fs/zfs/uberblock.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/uberblock.c Fri Mar 08 10:41:28 2013 -0800 @@ -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 @@ -33,7 +34,7 @@ byteswap_uint64_array(ub, sizeof (uberblock_t)); if (ub->ub_magic != UBERBLOCK_MAGIC) - return (EINVAL); + return (SET_ERROR(EINVAL)); return (0); } diff -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/vdev.c --- a/usr/src/uts/common/fs/zfs/vdev.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/vdev.c Fri Mar 08 10:41:28 2013 -0800 @@ -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 @@ -350,10 +350,10 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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_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 @@ 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 @@ 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 @@ 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 -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/vdev_cache.c --- a/usr/src/uts/common/fs/zfs/vdev_cache.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/vdev_cache.c Fri Mar 08 10:41:28 2013 -0800 @@ -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 #include @@ -259,16 +262,16 @@ 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 @@ 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 @@ 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 -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/vdev_disk.c --- a/usr/src/uts/common/fs/zfs/vdev_disk.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/vdev_disk.c Fri Mar 08 10:41:28 2013 -0800 @@ -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 @@ -145,7 +145,7 @@ */ 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 @@ 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 @@ 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 @@ */ 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 @@ int error = 0; if (vd_lh == NULL) - return (EINVAL); + return (SET_ERROR(EINVAL)); ASSERT(flags & B_READ || flags & B_WRITE); @@ -383,7 +383,7 @@ 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 @@ 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 @@ 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 @@ break; if (vd->vdev_nowritecache) { - zio->io_error = ENOTSUP; + zio->io_error = SET_ERROR(ENOTSUP); break; } @@ -494,7 +494,7 @@ break; default: - zio->io_error = ENOTSUP; + zio->io_error = SET_ERROR(ENOTSUP); } return (ZIO_PIPELINE_CONTINUE); @@ -599,7 +599,7 @@ 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 @@ 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 -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/vdev_file.c --- a/usr/src/uts/common/fs/zfs/vdev_file.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/vdev_file.c Fri Mar 08 10:41:28 2013 -0800 @@ -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 @@ -62,7 +62,7 @@ */ 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 @@ */ 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 @@ 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 @@ 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 @@ kcred, NULL); break; default: - zio->io_error = ENOTSUP; + zio->io_error = SET_ERROR(ENOTSUP); } return (ZIO_PIPELINE_CONTINUE); diff -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/vdev_label.c --- a/usr/src/uts/common/fs/zfs/vdev_label.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/vdev_label.c Fri Mar 08 10:41:28 2013 -0800 @@ -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 @@ * 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 @@ 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 -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/vdev_mirror.c --- a/usr/src/uts/common/fs/zfs/vdev_mirror.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/vdev_mirror.c Fri Mar 08 10:41:28 2013 -0800 @@ -24,7 +24,7 @@ */ /* - * Copyright (c) 2012 by Delphix. All rights reserved. + * Copyright (c) 2013 by Delphix. All rights reserved. */ #include @@ -139,7 +139,7 @@ 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 @@ 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_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 -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/vdev_missing.c --- a/usr/src/uts/common/fs/zfs/vdev_missing.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/vdev_missing.c Fri Mar 08 10:41:28 2013 -0800 @@ -24,7 +24,7 @@ */ /* - * Copyright (c) 2012 by Delphix. All rights reserved. + * Copyright (c) 2013 by Delphix. All rights reserved. */ /* @@ -69,7 +69,7 @@ static int vdev_missing_io_start(zio_t *zio) { - zio->io_error = ENOTSUP; + zio->io_error = SET_ERROR(ENOTSUP); return (ZIO_PIPELINE_CONTINUE); } diff -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/vdev_raidz.c --- a/usr/src/uts/common/fs/zfs/vdev_raidz.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/vdev_raidz.c Fri Mar 08 10:41:28 2013 -0800 @@ -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 @@ -1457,7 +1457,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ * 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 -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/vdev_root.c --- a/usr/src/uts/common/fs/zfs/vdev_root.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/vdev_root.c Fri Mar 08 10:41:28 2013 -0800 @@ -24,7 +24,7 @@ */ /* - * Copyright (c) 2012 by Delphix. All rights reserved. + * Copyright (c) 2013 by Delphix. All rights reserved. */ #include @@ -62,7 +62,7 @@ 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 -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/zap.c --- a/usr/src/uts/common/fs/zfs/zap.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/zap.c Fri Mar 08 10:41:28 2013 -0800 @@ -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 @@ * 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 @@ 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 @@ case 8: break; default: - return (EINVAL); + return (SET_ERROR(EINVAL)); } if (integer_size * num_integers > ZAP_MAXVALUELEN) @@ -805,7 +805,7 @@ 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_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_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 @@ 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 @@ 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 -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/zap_leaf.c --- a/usr/src/uts/common/fs/zfs/zap_leaf.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/zap_leaf.c Fri Mar 08 10:41:28 2013 -0800 @@ -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 @@ goto again; } - return (ENOENT); + return (SET_ERROR(ENOENT)); } /* Return (h1,cd1 >= h2,cd2) */ @@ -492,14 +493,14 @@ 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 @@ 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_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 @@ } 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 -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/zap_micro.c --- a/usr/src/uts/common/fs/zfs/zap_micro.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/zap_micro.c Fri Mar 08 10:41:28 2013 -0800 @@ -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 @@ -780,7 +780,7 @@ 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 @@ } 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ } else { mze = mze_find(zn); if (mze != NULL) { - err = EEXIST; + err = SET_ERROR(EEXIST); } else { mzap_addent(zn, *intval); } @@ -1028,7 +1028,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ err = 0; } else { zc->zc_hash = -1ULL; + err = SET_ERROR(ENOENT); } } rw_exit(&zc->zc_zap->zap_rwlock); @@ -1335,7 +1334,7 @@ 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 @@ } else { mze = mze_find(zn); if (mze == NULL) { - err = ENOENT; + err = SET_ERROR(ENOENT); goto out; } zc->zc_hash = mze->mze_hash; diff -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/zfeature.c --- a/usr/src/uts/common/fs/zfs/zfeature.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/zfeature.c Fri Mar 08 10:41:28 2013 -0800 @@ -20,7 +20,7 @@ */ /* - * Copyright (c) 2012 by Delphix. All rights reserved. + * Copyright (c) 2013 by Delphix. All rights reserved. */ #include @@ -226,13 +226,13 @@ * 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 @@ 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 -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/zfs_acl.c --- a/usr/src/uts/common/fs/zfs/zfs_acl.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/zfs_acl.c Fri Mar 08 10:41:28 2013 -0800 @@ -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 @@ -684,7 +685,7 @@ */ 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 @@ */ 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_free(aclnode); /* convert checksum errors into IO errors */ if (error == ECKSUM) - error = EIO; + error = SET_ERROR(EIO); goto done; } @@ -1780,7 +1781,7 @@ 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 @@ 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 @@ 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 @@ (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 @@ (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 @@ break; } else { mutex_exit(&zp->z_acl_lock); - return (EIO); + return (SET_ERROR(EIO)); } } @@ -2199,7 +2200,7 @@ /* 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 @@ 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 @@ 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 @@ * 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 @@ */ if (zp->z_pflags & (ZFS_IMMUTABLE | ZFS_NOUNLINK)) - return (EPERM); + return (SET_ERROR(EPERM)); /* * First row @@ -2659,7 +2660,7 @@ 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 -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/zfs_ctldir.c --- a/usr/src/uts/common/fs/zfs/zfs_ctldir.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/zfs_ctldir.c Fri Mar 08 10:41:28 2013 -0800 @@ -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 @@ 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 @@ { 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 @@ 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 @@ 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 @@ * No extended attributes allowed under .zfs */ if (flags & LOOKUP_XATTR) - return (EINVAL); + return (SET_ERROR(EINVAL)); ZFS_ENTER(zfsvfs); @@ -511,10 +511,10 @@ 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 @@ * 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 @@ 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 @@ else err = dsl_destroy_snapshot(snapname, B_FALSE); } else { - err = ENOENT; + err = SET_ERROR(ENOENT); } mutex_exit(&sdp->sd_lock); @@ -742,7 +742,7 @@ 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 @@ * 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 @@ * 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/zfs_dir.c --- a/usr/src/uts/common/fs/zfs/zfs_dir.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/zfs_dir.c Fri Mar 08 10:41:28 2013 -0800 @@ -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 @@ -154,7 +155,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ } 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/zfs_ioctl.c --- a/usr/src/uts/common/fs/zfs/zfs_ioctl.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/zfs_ioctl.c Fri Mar 08 10:41:28 2013 -0800 @@ -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 @@ zone_dataset_visible(zc->zc_name, NULL)) return (0); - return (ENOENT); + return (SET_ERROR(ENOENT)); } static int @@ -422,7 +422,7 @@ */ if (!INGLOBALZONE(curproc) && !zone_dataset_visible(dataset, &writable)) - return (ENOENT); + return (SET_ERROR(ENOENT)); if (INGLOBALZONE(curproc)) { /* @@ -430,17 +430,17 @@ * 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 @@ 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 @@ 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 @@ 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 @@ */ if (!INGLOBALZONE(curproc)) { if (new_default || !blequal(&new_sl, CR_SL(CRED()))) - return (EPERM); + return (SET_ERROR(EPERM)); return (0); } @@ -552,10 +552,10 @@ */ 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 @@ 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 @@ } 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 @@ * 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 @@ */ 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 @@ */ 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 @@ (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 @@ 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 @@ 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 @@ } else { cp = strrchr(parent, '/'); if (cp == NULL) - return (ENOENT); + return (SET_ERROR(ENOENT)); cp[0] = '\0'; } @@ -829,7 +829,7 @@ 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 @@ 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 @@ * to log to. */ if (tsd_get(zfs_allow_log_key) == NULL) - return (EPERM); + return (SET_ERROR(EPERM)); return (0); } @@ -1052,7 +1052,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ * 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ * objset from the zfsvfs. */ rrw_exit(&(*zfvp)->z_teardown_lock, tag); - return (EBUSY); + return (SET_ERROR(EBUSY)); } } return (error); @@ -1417,7 +1417,7 @@ (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 @@ 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 @@ 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 @@ nvlist_free(tryconfig); if (config == NULL) - return (EINVAL); + return (SET_ERROR(EINVAL)); error = put_nvlist(zc, config); nvlist_free(config); @@ -1648,7 +1648,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ break; default: - error = EINVAL; + error = SET_ERROR(EINVAL); } zc->zc_cookie = newstate; spa_close(spa, FTAG); @@ -2059,7 +2059,7 @@ * 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 @@ 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 @@ 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 @@ 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 @@ */ 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 @@ dsl_dataset_rele(ds, FTAG); } } else if (error == ENOENT) { - error = ESRCH; + error = SET_ERROR(ESRCH); } dmu_objset_rele(os, FTAG); @@ -2285,7 +2285,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ */ 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 @@ break; default: nvlist_free(dummy); - return (EINVAL); + return (SET_ERROR(EINVAL)); } pair = nvlist_next_nvpair(dummy, NULL); @@ -2763,7 +2763,7 @@ * 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 @@ 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 @@ */ if ((error = zfs_deleg_verify_nvlist(fsaclnv)) != 0) { nvlist_free(fsaclnv); - return (EINVAL); + return (SET_ERROR(EINVAL)); } /* @@ -3016,7 +3016,7 @@ (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 @@ 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 @@ } 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 @@ 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 @@ 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 @@ * 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 @@ 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 @@ 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 @@ */ if (strncmp(name, poolname, poollen) != 0 || (name[poollen] != '/' && name[poollen] != '@')) - return (EXDEV); + return (SET_ERROR(EXDEV)); zfs_unmount_snap(name); } @@ -3542,13 +3542,13 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ */ 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 @@ 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 @@ if (!spa_feature_is_active(spa, feature)) return (0); else - return (EBUSY); + return (SET_ERROR(EBUSY)); } /* @@ -3927,7 +3927,7 @@ 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 @@ 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 @@ * 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 @@ } 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ * Resume any suspended I/Os. */ if (zio_resume(spa) != 0) - error = EIO; + error = SET_ERROR(EIO); spa_close(spa, FTAG); @@ -4442,7 +4442,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ fp = getf(zc->zc_cookie); if (fp == NULL) - return (EBADF); + return (SET_ERROR(EBADF)); off = fp->f_offset; @@ -4811,7 +4811,7 @@ (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 @@ break; default: - error = EINVAL; + error = SET_ERROR(EINVAL); break; } @@ -4936,7 +4936,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/zfs_onexit.c --- a/usr/src/uts/common/fs/zfs/zfs_onexit.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/zfs_onexit.c Fri Mar 08 10:41:28 2013 -0800 @@ -20,6 +20,7 @@ */ /* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013 by Delphix. All rights reserved. */ #include @@ -108,7 +109,7 @@ { *zo = zfsdev_get_soft_state(minor, ZSST_CTLDEV); if (*zo == NULL) - return (EBADF); + return (SET_ERROR(EBADF)); return (0); } @@ -127,7 +128,7 @@ 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 @@ 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 @@ if (ap != NULL) *data = ap->za_data; else - error = ENOENT; + error = SET_ERROR(ENOENT); mutex_exit(&zo->zo_lock); return (error); diff -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/zfs_replay.c --- a/usr/src/uts/common/fs/zfs/zfs_replay.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/zfs_replay.c Fri Mar 08 10:41:28 2013 -0800 @@ -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 @@ -70,7 +71,7 @@ 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 @@ &vp, kcred, NULL, vflg, &vsec); break; default: - error = ENOTSUP; + error = SET_ERROR(ENOTSUP); } bail: @@ -511,7 +512,7 @@ link, kcred, NULL, vflg); break; default: - error = ENOTSUP; + error = SET_ERROR(ENOTSUP); } out: @@ -551,7 +552,7 @@ error = VOP_RMDIR(ZTOV(dzp), name, NULL, kcred, NULL, vflg); break; default: - error = ENOTSUP; + error = SET_ERROR(ENOTSUP); } VN_RELE(ZTOV(dzp)); diff -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/zfs_vfsops.c --- a/usr/src/uts/common/fs/zfs/zfs_vfsops.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/zfs_vfsops.c Fri Mar 08 10:41:28 2013 -0800 @@ -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 @@ * 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 @@ * 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 @@ 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 @@ 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 @@ *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 @@ 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 @@ "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 @@ 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 @@ while (*str) { if (*str < '0' || *str > '9') - return (EINVAL); + return (SET_ERROR(EINVAL)); num = num*10 + *str++ - '0'; } @@ -1324,7 +1324,7 @@ int error; if (*bpath == 0 || *bpath == '/') - return (EINVAL); + return (SET_ERROR(EINVAL)); (void) strcpy(outpath, bpath); @@ -1369,10 +1369,10 @@ 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 @@ 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 @@ if (!is_system_labeled()) { if (strcasecmp(ds_hexsl, ZFS_MLSLABEL_DEFAULT) == 0) return (0); - return (EACCES); + return (SET_ERROR(EACCES)); } /* @@ -1431,7 +1431,7 @@ 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 @@ */ 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 @@ 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 @@ * 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 @@ 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 @@ * 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 @@ */ if (!INGLOBALZONE(curproc) && (!zone_dataset_visible(osname, &canwrite) || !canwrite)) { - error = EPERM; + error = SET_ERROR(EPERM); goto out; } @@ -1819,7 +1819,7 @@ 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 @@ */ 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 @@ err = zfsctl_lookup_objset(vfsp, objsetid, &zfsvfs); if (err) - return (EINVAL); + return (SET_ERROR(EINVAL)); ZFS_ENTER(zfsvfs); } @@ -2002,7 +2002,7 @@ 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 @@ 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 @@ 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 -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/zfs_vnops.c --- a/usr/src/uts/common/fs/zfs/zfs_vnops.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/zfs_vnops.c Fri Mar 08 10:41:28 2013 -0800 @@ -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 @@ 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 @@ !(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 @@ file_sz = zp->z_size; if (noff >= file_sz) { - return (ENXIO); + return (SET_ERROR(ENXIO)); } if (cmd == _FIO_SEEK_HOLE) @@ -267,7 +267,7 @@ *off = file_sz; return (0); } - return (ENXIO); + return (SET_ERROR(ENXIO)); } if (noff < *off) @@ -301,7 +301,7 @@ 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 @@ 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 @@ if (zp->z_pflags & ZFS_AV_QUARANTINED) { ZFS_EXIT(zfsvfs); - return (EACCES); + return (SET_ERROR(EACCES)); } /* @@ -465,7 +465,7 @@ */ if (uio->uio_loffset < (offset_t)0) { ZFS_EXIT(zfsvfs); - return (EINVAL); + return (SET_ERROR(EINVAL)); } /* @@ -550,7 +550,7 @@ if (error) { /* convert checksum errors into IO errors */ if (error == ECKSUM) - error = EIO; + error = SET_ERROR(EIO); break; } @@ -638,7 +638,7 @@ ((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 @@ 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 @@ 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 @@ 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 @@ * 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 @@ */ 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 @@ 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 @@ } /* 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 @@ 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 @@ 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 @@ } 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 @@ */ if (!(zfsvfs->z_vfs->vfs_flag & VFS_XATTR)) { ZFS_EXIT(zfsvfs); - return (EINVAL); + return (SET_ERROR(EINVAL)); } /* @@ -1223,7 +1223,7 @@ */ 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 @@ if (dvp->v_type != VDIR) { ZFS_EXIT(zfsvfs); - return (ENOTDIR); + return (SET_ERROR(ENOTDIR)); } /* @@ -1262,7 +1262,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ (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 @@ 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 @@ * 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 @@ * Need to use rmdir for removing directories. */ if (vp->v_type == VDIR) { - error = EPERM; + error = SET_ERROR(EPERM); goto out; } @@ -1817,7 +1817,7 @@ 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 @@ 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 @@ zfs_acl_ids_free(&acl_ids); zfs_dirent_unlock(dl); ZFS_EXIT(zfsvfs); - return (EDQUOT); + return (SET_ERROR(EDQUOT)); } /* @@ -2003,12 +2003,12 @@ } 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 @@ */ if (uio->uio_iov->iov_len <= 0) { ZFS_EXIT(zfsvfs); - return (EINVAL); + return (SET_ERROR(EINVAL)); } /* @@ -2242,7 +2242,7 @@ "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 @@ * Did we manage to fit anything in the buffer? */ if (!outcount) { - error = EINVAL; + error = SET_ERROR(EINVAL); goto update; } break; @@ -2650,7 +2650,7 @@ return (0); if (mask & AT_NOSET) - return (EINVAL); + return (SET_ERROR(EINVAL)); ZFS_ENTER(zfsvfs); ZFS_VERIFY_ZP(zp); @@ -2667,17 +2667,17 @@ ((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 @@ ((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 @@ 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 @@ /* 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ *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 @@ 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 @@ 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 @@ */ if ((tdzp->z_pflags & ZFS_XATTR) != (sdzp->z_pflags & ZFS_XATTR)) { ZFS_EXIT(zfsvfs); - return (EINVAL); + return (SET_ERROR(EINVAL)); } /* @@ -3507,7 +3507,7 @@ 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 @@ 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 @@ */ 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 @@ 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 @@ 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 @@ */ 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 @@ } 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 @@ */ 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 @@ 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 @@ */ 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 @@ 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 @@ 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 @@ */ 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 @@ if (cmd != F_FREESP) { ZFS_EXIT(zfsvfs); - return (EINVAL); + return (SET_ERROR(EINVAL)); } if (error = convoff(vp, bfp, 0, offset)) { @@ -4753,7 +4753,7 @@ if (bfp->l_len < 0) { ZFS_EXIT(zfsvfs); - return (EINVAL); + return (SET_ERROR(EINVAL)); } off = bfp->l_start; @@ -4792,7 +4792,7 @@ 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 @@ 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 @@ 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 @@ /* 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 @@ 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_inval() { - return (EINVAL); + return (SET_ERROR(EINVAL)); } static int zfs_isdir() { - return (EISDIR); + return (SET_ERROR(EISDIR)); } /* * Directory vnode operations template diff -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/zfs_znode.c --- a/usr/src/uts/common/fs/zfs/zfs_znode.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/zfs_znode.c Fri Mar 08 10:41:28 2013 -0800 @@ -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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ * Otherwise the parent must be a directory. */ if (!*is_xattrdir && !S_ISDIR(parent_mode)) - return (EINVAL); + return (SET_ERROR(EINVAL)); *pobjp = parent; diff -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/zil.c --- a/usr/src/uts/common/fs/zfs/zil.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/zil.c Fri Mar 08 10:41:28 2013 -0800 @@ -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 @@ 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 @@ 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 @@ 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 @@ 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 @@ error = zil_suspend(osname, NULL); if (error != 0) - return (EEXIST); + return (SET_ERROR(EEXIST)); return (0); } diff -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/zio.c --- a/usr/src/uts/common/fs/zfs/zio.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/zio.c Fri Mar 08 10:41:28 2013 -0800 @@ -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 @@ 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 @@ 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 @@ 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 @@ 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 @@ */ 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 -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/zio_checksum.c --- a/usr/src/uts/common/fs/zfs/zio_checksum.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/zio_checksum.c Fri Mar 08 10:41:28 2013 -0800 @@ -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 @@ -201,7 +202,7 @@ 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 @@ 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 @@ 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 -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/zio_compress.c --- a/usr/src/uts/common/fs/zfs/zio_compress.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/zio_compress.c Fri Mar 08 10:41:28 2013 -0800 @@ -27,6 +27,10 @@ * Copyright (c) 2013 by Saso Kiselkov. All rights reserved. */ +/* + * Copyright (c) 2013 by Delphix. All rights reserved. + */ + #include #include #include @@ -130,7 +134,7 @@ 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 -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/zio_inject.c --- a/usr/src/uts/common/fs/zfs/zio_inject.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/zio_inject.c Fri Mar 08 10:41:28 2013 -0800 @@ -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 @@ break; } if (handler->zi_record.zi_error == ENXIO) { - ret = EIO; + ret = SET_ERROR(EIO); break; } } @@ -416,7 +416,7 @@ * 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 @@ (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 @@ if (handler == NULL) { rw_exit(&inject_lock); - return (ENOENT); + return (SET_ERROR(ENOENT)); } list_remove(&inject_handlers, handler); diff -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/fs/zfs/zvol.c --- a/usr/src/uts/common/fs/zfs/zvol.c Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/zvol.c Fri Mar 08 10:41:28 2013 -0800 @@ -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 @@ 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 @@ if (volblocksize < SPA_MINBLOCKSIZE || volblocksize > SPA_MAXBLOCKSIZE || !ISP2(volblocksize)) - return (EDOM); + return (SET_ERROR(EDOM)); return (0); } @@ -252,7 +252,7 @@ /* 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ /* 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ /* 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 @@ } 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 @@ 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 @@ if (error) { /* convert checksum errors into IO errors */ if (error == ECKSUM) - error = EIO; + error = SET_ERROR(EIO); break; } off += size; @@ -1322,10 +1322,10 @@ 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 @@ 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 @@ if (error) { /* convert checksum errors into IO errors */ if (error == ECKSUM) - error = EIO; + error = SET_ERROR(EIO); break; } } @@ -1404,12 +1404,12 @@ 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 @@ 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 @@ * 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 @@ 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 @@ 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 @@ if (zv == NULL) { mutex_exit(&zfsdev_state_lock); - return (ENXIO); + return (SET_ERROR(ENXIO)); } ASSERT(zv->zv_total_opens > 0); @@ -1639,7 +1639,7 @@ 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 @@ 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 @@ 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 @@ int wce; if (ddi_copyin((void *)arg, &wce, sizeof (int), flag)) { - error = EFAULT; + error = SET_ERROR(EFAULT); break; } if (wce) { @@ -1705,7 +1705,7 @@ * 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 @@ dmu_tx_t *tx; if (ddi_copyin((void *)arg, &df, sizeof (df), flag)) { - error = EFAULT; + error = SET_ERROR(EFAULT); break; } @@ -1784,7 +1784,7 @@ } default: - error = ENOTTY; + error = SET_ERROR(ENOTTY); break; } @@ -1929,7 +1929,7 @@ 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) { diff -r b01a4832cdf9 -r d7059eb1884c usr/src/uts/common/sys/sdt.h --- a/usr/src/uts/common/sys/sdt.h Wed Mar 06 17:57:09 2013 -0800 +++ b/usr/src/uts/common/sys/sdt.h Fri Mar 08 10:41:28 2013 -0800 @@ -20,11 +20,14 @@ */ /* * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013 by Delphix. All rights reserved. */ #ifndef _SYS_SDT_H #define _SYS_SDT_H +#include + #ifdef __cplusplus extern "C" { #endif @@ -94,7 +97,7 @@ (uintptr_t)(arg3)); \ } -#define DTRACE_PROBE4(name, type1, arg1, type2, arg2, \ +#define DTRACE_PROBE4(name, type1, arg1, type2, arg2, \ type3, arg3, type4, arg4) { \ extern void __dtrace_probe_##name(uintptr_t, uintptr_t, \ uintptr_t, uintptr_t); \ @@ -102,7 +105,7 @@ (uintptr_t)(arg3), (uintptr_t)(arg4)); \ } -#define DTRACE_PROBE5(name, type1, arg1, type2, arg2, \ +#define DTRACE_PROBE5(name, type1, arg1, type2, arg2, \ type3, arg3, type4, arg4, type5, arg5) { \ extern void __dtrace_probe_##name(uintptr_t, uintptr_t, \ uintptr_t, uintptr_t, uintptr_t); \ @@ -110,7 +113,7 @@ (uintptr_t)(arg3), (uintptr_t)(arg4), (uintptr_t)(arg5)); \ } -#define DTRACE_PROBE6(name, type1, arg1, type2, arg2, \ +#define DTRACE_PROBE6(name, type1, arg1, type2, arg2, \ type3, arg3, type4, arg4, type5, arg5, type6, arg6) { \ extern void __dtrace_probe_##name(uintptr_t, uintptr_t, \ uintptr_t, uintptr_t, uintptr_t, uintptr_t); \ @@ -150,9 +153,9 @@ #define DTRACE_SCHED3(name, type1, arg1, type2, arg2, type3, arg3) \ DTRACE_PROBE3(__sched_##name, type1, arg1, type2, arg2, type3, arg3); -#define DTRACE_SCHED4(name, type1, arg1, type2, arg2, \ +#define DTRACE_SCHED4(name, type1, arg1, type2, arg2, \ type3, arg3, type4, arg4) \ - DTRACE_PROBE4(__sched_##name, type1, arg1, type2, arg2, \ + DTRACE_PROBE4(__sched_##name, type1, arg1, type2, arg2, \ type3, arg3, type4, arg4); #define DTRACE_PROC(name) \ @@ -167,9 +170,9 @@ #define DTRACE_PROC3(name, type1, arg1, type2, arg2, type3, arg3) \ DTRACE_PROBE3(__proc_##name, type1, arg1, type2, arg2, type3, arg3); -#define DTRACE_PROC4(name, type1, arg1, type2, arg2, \ +#define DTRACE_PROC4(name, type1, arg1, type2, arg2, \ type3, arg3, type4, arg4) \ - DTRACE_PROBE4(__proc_##name, type1, arg1, type2, arg2, \ + DTRACE_PROBE4(__proc_##name, type1, arg1, type2, arg2, \ type3, arg3, type4, arg4); #define DTRACE_IO(name) \ @@ -184,9 +187,9 @@ #define DTRACE_IO3(name, type1, arg1, type2, arg2, type3, arg3) \ DTRACE_PROBE3(__io_##name, type1, arg1, type2, arg2, type3, arg3); -#define DTRACE_IO4(name, type1, arg1, type2, arg2, \ +#define DTRACE_IO4(name, type1, arg1, type2, arg2, \ type3, arg3, type4, arg4) \ - DTRACE_PROBE4(__io_##name, type1, arg1, type2, arg2, \ + DTRACE_PROBE4(__io_##name, type1, arg1, type2, arg2, \ type3, arg3, type4, arg4); #define DTRACE_ISCSI_2(name, type1, arg1, type2, arg2) \ @@ -223,11 +226,11 @@ type3, arg3, type4, arg4, type5, arg5, type6, arg6, \ type7, arg7, type8, arg8); -#define DTRACE_NFSV3_3(name, type1, arg1, type2, arg2, \ +#define DTRACE_NFSV3_3(name, type1, arg1, type2, arg2, \ type3, arg3) \ DTRACE_PROBE3(__nfsv3_##name, type1, arg1, type2, arg2, \ type3, arg3); -#define DTRACE_NFSV3_4(name, type1, arg1, type2, arg2, \ +#define DTRACE_NFSV3_4(name, type1, arg1, type2, arg2, \ type3, arg3, type4, arg4) \ DTRACE_PROBE4(__nfsv3_##name, type1, arg1, type2, arg2, \ type3, arg3, type4, arg4); @@ -259,24 +262,24 @@ #define DTRACE_IP3(name, type1, arg1, type2, arg2, type3, arg3) \ DTRACE_PROBE3(__ip_##name, type1, arg1, type2, arg2, type3, arg3); -#define DTRACE_IP4(name, type1, arg1, type2, arg2, \ +#define DTRACE_IP4(name, type1, arg1, type2, arg2, \ type3, arg3, type4, arg4) \ - DTRACE_PROBE4(__ip_##name, type1, arg1, type2, arg2, \ + DTRACE_PROBE4(__ip_##name, type1, arg1, type2, arg2, \ type3, arg3, type4, arg4); -#define DTRACE_IP5(name, type1, arg1, type2, arg2, \ +#define DTRACE_IP5(name, type1, arg1, type2, arg2, \ type3, arg3, type4, arg4, type5, arg5) \ - DTRACE_PROBE5(__ip_##name, type1, arg1, type2, arg2, \ + DTRACE_PROBE5(__ip_##name, type1, arg1, type2, arg2, \ type3, arg3, type4, arg4, type5, arg5); -#define DTRACE_IP6(name, type1, arg1, type2, arg2, \ +#define DTRACE_IP6(name, type1, arg1, type2, arg2, \ type3, arg3, type4, arg4, type5, arg5, type6, arg6) \ - DTRACE_PROBE6(__ip_##name, type1, arg1, type2, arg2, \ + DTRACE_PROBE6(__ip_##name, type1, arg1, type2, arg2, \ type3, arg3, type4, arg4, type5, arg5, type6, arg6); #define DTRACE_IP7(name, type1, arg1, type2, arg2, type3, arg3, \ type4, arg4, type5, arg5, type6, arg6, type7, arg7) \ - DTRACE_PROBE7(__ip_##name, type1, arg1, type2, arg2, \ + DTRACE_PROBE7(__ip_##name, type1, arg1, type2, arg2, \ type3, arg3, type4, arg4, type5, arg5, type6, arg6, \ type7, arg7); @@ -347,7 +350,7 @@ #define DTRACE_XPV4(name, type1, arg1, type2, arg2, type3, arg3, \ type4, arg4) \ - DTRACE_PROBE4(__xpv_##name, type1, arg1, type2, arg2, \ + DTRACE_PROBE4(__xpv_##name, type1, arg1, type2, arg2, \ type3, arg3, type4, arg4); #define DTRACE_FC_1(name, type1, arg1) \ @@ -363,7 +366,7 @@ DTRACE_PROBE4(__fc_##name, type1, arg1, type2, arg2, type3, arg3, \ type4, arg4); -#define DTRACE_FC_5(name, type1, arg1, type2, arg2, type3, arg3, \ +#define DTRACE_FC_5(name, type1, arg1, type2, arg2, type3, arg3, \ type4, arg4, type5, arg5) \ DTRACE_PROBE5(__fc_##name, type1, arg1, type2, arg2, type3, arg3, \ type4, arg4, type5, arg5); @@ -379,30 +382,46 @@ #define DTRACE_SRP_4(name, type1, arg1, type2, arg2, type3, arg3, \ type4, arg4) \ - DTRACE_PROBE4(__srp_##name, type1, arg1, type2, arg2, \ + DTRACE_PROBE4(__srp_##name, type1, arg1, type2, arg2, \ type3, arg3, type4, arg4); #define DTRACE_SRP_5(name, type1, arg1, type2, arg2, type3, arg3, \ type4, arg4, type5, arg5) \ - DTRACE_PROBE5(__srp_##name, type1, arg1, type2, arg2, \ + DTRACE_PROBE5(__srp_##name, type1, arg1, type2, arg2, \ type3, arg3, type4, arg4, type5, arg5); #define DTRACE_SRP_6(name, type1, arg1, type2, arg2, type3, arg3, \ type4, arg4, type5, arg5, type6, arg6) \ - DTRACE_PROBE6(__srp_##name, type1, arg1, type2, arg2, \ + DTRACE_PROBE6(__srp_##name, type1, arg1, type2, arg2, \ type3, arg3, type4, arg4, type5, arg5, type6, arg6); #define DTRACE_SRP_7(name, type1, arg1, type2, arg2, type3, arg3, \ type4, arg4, type5, arg5, type6, arg6, type7, arg7) \ - DTRACE_PROBE7(__srp_##name, type1, arg1, type2, arg2, \ + DTRACE_PROBE7(__srp_##name, type1, arg1, type2, arg2, \ type3, arg3, type4, arg4, type5, arg5, type6, arg6, type7, arg7); #define DTRACE_SRP_8(name, type1, arg1, type2, arg2, type3, arg3, \ type4, arg4, type5, arg5, type6, arg6, type7, arg7, type8, arg8) \ - DTRACE_PROBE8(__srp_##name, type1, arg1, type2, arg2, \ + DTRACE_PROBE8(__srp_##name, type1, arg1, type2, arg2, \ type3, arg3, type4, arg4, type5, arg5, type6, arg6, \ type7, arg7, type8, arg8); +/* + * the set-error SDT probe is extra static, in that we declare its fake + * function literally, rather than with the DTRACE_PROBE1() macro. This is + * necessary so that SET_ERROR() can evaluate to a value, which wouldn't + * be possible if it required multiple statements (to declare the function + * and then call it). + * + * SET_ERROR() uses the comma operator so that it can be used without much + * additional code. For example, "return (EINVAL);" becomes + * "return (SET_ERROR(EINVAL));". Note that the argument will be evaluated + * twice, so it should not have side effects (e.g. something like: + * "return (SET_ERROR(log_error(EINVAL, info)));" would log the error twice). + */ +extern void __dtrace_probe_set__error(uintptr_t); +#define SET_ERROR(err) (__dtrace_probe_set__error(err), err) + #endif /* _KERNEL */ extern const char *sdt_prefix;