Skip to content

Commit

Permalink
3598 want to dtrace when errors are generated in zfs
Browse files Browse the repository at this point in the history
Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Christopher Siden <christopher.siden@delphix.com>
Approved by: Garrett D'Amore <garrett@damore.org>
  • Loading branch information
ahrens authored and Christopher Siden committed Mar 8, 2013
1 parent efb4a87 commit be6fd75
Show file tree
Hide file tree
Showing 59 changed files with 993 additions and 893 deletions.
19 changes: 16 additions & 3 deletions usr/src/lib/libzpool/Makefile.com
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -29,6 +29,7 @@ VERS= .1
# 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)

Expand All @@ -52,7 +53,10 @@ INCS += -I../../../uts/common/fs/zfs
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
Expand All @@ -79,10 +83,19 @@ lint: $(LINTLIB)

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 $@
28 changes: 22 additions & 6 deletions usr/src/lib/libzpool/common/sys/zfs_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/

Expand Down Expand Up @@ -81,6 +81,7 @@ extern "C" {
#include <sys/sysevent/dev.h>
#include <sys/sunddi.h>
#include <sys/debug.h>
#include "zfs.h"

/*
* Debugging
Expand Down Expand Up @@ -121,28 +122,43 @@ extern int aok;

#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
Expand Down
36 changes: 36 additions & 0 deletions usr/src/lib/libzpool/common/zfs.d
Original file line number Diff line number Diff line change
@@ -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
16 changes: 8 additions & 8 deletions usr/src/uts/common/fs/zfs/arc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/

/*
Expand Down Expand Up @@ -3466,14 +3466,14 @@ arc_memory_throttle(uint64_t reserve, uint64_t inflight_data, uint64_t txg)
*/
if (curproc == proc_pageout) {
if (page_load > MAX(ptob(minfree), available_memory) / 4)
return (ERESTART);
return (SET_ERROR(ERESTART));
/* Note: reserve is inflated, so we deflate */
page_load += reserve / 8;
return (0);
} else if (page_load > 0 && arc_reclaim_needed()) {
/* memory is low, delay before restarting */
ARCSTAT_INCR(arcstat_memory_throttle_count, 1);
return (EAGAIN);
return (SET_ERROR(EAGAIN));
}
page_load = 0;

Expand All @@ -3488,7 +3488,7 @@ arc_memory_throttle(uint64_t reserve, uint64_t inflight_data, uint64_t txg)

if (inflight_data > available_memory / 4) {
ARCSTAT_INCR(arcstat_memory_throttle_count, 1);
return (ERESTART);
return (SET_ERROR(ERESTART));
}
#endif
return (0);
Expand All @@ -3513,13 +3513,13 @@ arc_tempreserve_space(uint64_t reserve, uint64_t txg)
*/
if (spa_get_random(10000) == 0) {
dprintf("forcing random failure\n");
return (ERESTART);
return (SET_ERROR(ERESTART));
}
#endif
if (reserve > arc_c/4 && !arc_no_grow)
arc_c = MIN(arc_c_max, reserve * 4);
if (reserve > arc_c)
return (ENOMEM);
return (SET_ERROR(ENOMEM));

/*
* Don't count loaned bufs as in flight dirty data to prevent long
Expand Down Expand Up @@ -3552,7 +3552,7 @@ arc_tempreserve_space(uint64_t reserve, uint64_t txg)
arc_anon->arcs_lsize[ARC_BUFC_METADATA]>>10,
arc_anon->arcs_lsize[ARC_BUFC_DATA]>>10,
reserve>>10, arc_c>>10);
return (ERESTART);
return (SET_ERROR(ERESTART));
}
atomic_add_64(&arc_tempreserve, reserve);
return (0);
Expand Down Expand Up @@ -4145,7 +4145,7 @@ l2arc_read_done(zio_t *zio)
if (zio->io_error != 0) {
ARCSTAT_BUMP(arcstat_l2_io_error);
} else {
zio->io_error = EIO;
zio->io_error = SET_ERROR(EIO);
}
if (!equal)
ARCSTAT_BUMP(arcstat_l2_cksum_bad);
Expand Down
12 changes: 6 additions & 6 deletions usr/src/uts/common/fs/zfs/dbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2012 by Delphix. All rights reserved.
* Copyright (c) 2013 by Delphix. All rights reserved.
*/

#include <sys/zfs_context.h>
Expand Down Expand Up @@ -598,7 +598,7 @@ dbuf_read(dmu_buf_impl_t *db, zio_t *zio, uint32_t flags)
ASSERT(!refcount_is_zero(&db->db_holds));

if (db->db_state == DB_NOFILL)
return (EIO);
return (SET_ERROR(EIO));

DB_DNODE_ENTER(db);
dn = DB_DNODE(db);
Expand Down Expand Up @@ -655,7 +655,7 @@ dbuf_read(dmu_buf_impl_t *db, zio_t *zio, uint32_t flags)
cv_wait(&db->db_changed, &db->db_mtx);
}
if (db->db_state == DB_UNCACHED)
err = EIO;
err = SET_ERROR(EIO);
}
mutex_exit(&db->db_mtx);
}
Expand Down Expand Up @@ -1593,7 +1593,7 @@ dbuf_findbp(dnode_t *dn, int level, uint64_t blkid, int fail_sparse,
if (level >= nlevels ||
(blkid > (dn->dn_phys->dn_maxblkid >> (level * epbs)))) {
/* the buffer has no parent yet */
return (ENOENT);
return (SET_ERROR(ENOENT));
} else if (level < nlevels-1) {
/* this block is referenced from an indirect block */
int err = dbuf_hold_impl(dn, level+1,
Expand Down Expand Up @@ -1844,7 +1844,7 @@ dbuf_hold_impl(dnode_t *dn, uint8_t level, uint64_t blkid, int fail_sparse,
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);
Expand Down Expand Up @@ -1941,7 +1941,7 @@ dbuf_spill_set_blksz(dmu_buf_t *db_fake, uint64_t blksz, dmu_tx_t *tx)
dnode_t *dn;

if (db->db_blkid != DMU_SPILL_BLKID)
return (ENOTSUP);
return (SET_ERROR(ENOTSUP));
if (blksz == 0)
blksz = SPA_MINBLOCKSIZE;
if (blksz > SPA_MAXBLOCKSIZE)
Expand Down
8 changes: 4 additions & 4 deletions usr/src/uts/common/fs/zfs/ddt.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

/*
* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012 by Delphix. All rights reserved.
* Copyright (c) 2013 by Delphix. All rights reserved.
*/

#include <sys/zfs_context.h>
Expand Down Expand Up @@ -160,7 +160,7 @@ ddt_object_lookup(ddt_t *ddt, enum ddt_type type, enum ddt_class class,
ddt_entry_t *dde)
{
if (!ddt_object_exists(ddt, type, class))
return (ENOENT);
return (SET_ERROR(ENOENT));

return (ddt_ops[type]->ddt_op_lookup(ddt->ddt_os,
ddt->ddt_object[type][class], dde));
Expand Down Expand Up @@ -221,7 +221,7 @@ ddt_object_info(ddt_t *ddt, enum ddt_type type, enum ddt_class class,
dmu_object_info_t *doi)
{
if (!ddt_object_exists(ddt, type, class))
return (ENOENT);
return (SET_ERROR(ENOENT));

return (dmu_object_info(ddt->ddt_os, ddt->ddt_object[type][class],
doi));
Expand Down Expand Up @@ -1141,5 +1141,5 @@ ddt_walk(spa_t *spa, ddt_bookmark_t *ddb, ddt_entry_t *dde)
ddb->ddb_type = 0;
} while (++ddb->ddb_class < DDT_CLASSES);

return (ENOENT);
return (SET_ERROR(ENOENT));
}
Loading

0 comments on commit be6fd75

Please sign in to comment.