5349 verify that block pointer is plausible before reading
Reviewed by: Alex Reece <alex.reece@delphix.com>
Reviewed by: Christopher Siden <christopher.siden@delphix.com>
Reviewed by: Dan McDonald <danmcd@omniti.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Richard Lowe <richlowe@richlowe.net>
Reviewed by: Xin Li <delphij@FreeBSD.org>
Reviewed by: Josef 'Jeff' Sipek <josef.sipek@nexenta.com>
Approved by: Gordon Ross <gwr@nexenta.com>
5367 complex.h /* #if !defined(__cplusplus) */  comment foils gcc fixincludes
Reviewed by: Josef 'Jeff' Sipek <josef.sipek@nexenta.com>
Approved by: Dan McDonald <danmcd@omniti.com>
5262 libm needs to be carefully unifdef'd
5268 libm doesn't need to hide symbols which are already local
Reviewed by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
Reviewed by: Igor Kozhukhov <ikozhukhov@gmail.com>
Reviewed by: Gordon Ross <gwr@nexenta.com>
Approved by: Gordon Ross <gwr@nexenta.com>
5261 libm should stop using synonyms.h
5298 fabs is 0-sized, confuses dis(1) and others
Reviewed by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
Approved by: Gordon Ross <gwr@nexenta.com>
5271 matherr(3M) is designed for interposition, should not be direct bound
Reviewed by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
Approved by: Gordon Ross <gwr@nexenta.com>
5344 etc/ftpusers breaks some incrementals
Reviewed by: Igor Kozhukhov <ikozhukhov@gmail.com>
Reviewed by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
Approved by: Gordon Ross <gwr@nexenta.com>
5362 invalid conversion when using asm/thread.h in c++ code
Reviewed by: Josef 'Jeff' Sipek <josef.sipek@nexenta.com>
Reviewed by: Jason King <jason.brian.king@gmail.com>
Approved by: Dan McDonald <danmcd@omniti.com>
4937 SunSSH should support EOW extension
Reviewed by: Dan McDonald <danmcd@omniti.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
5317 SMB server delivers old modification time
Reviewed by: Bayard Bell <bayard.bell@nexenta.com>
Reviewed by: Hans Rosenfeld <hans.rosenfeld@nexenta.com>
Reviewed by: Albert Lee <trisk@nexenta.com>
Reviewed by: Thomas Keiser <thomas.keiser@nexenta.com>
Approved by: Robert Mustacchi <rm@joyent.com>
5318 Panic with smbtorture raw.scan-eamax
Reviewed by: Albert lee <trisk@nexenta.com>
Reviewed by: Ilya Usvyatsky <Ilya.Usvyatsky@nexenta.com>
Reviewed by: Kevin Crowe <kevin.crowe@nexenta.com>
Reviewed by: Dan McDonald <danmcd@nexenta.com>
Approved by: Robert Mustacchi <rm@joyent.com>
5319 smb_oplock_acquire thread deadlock
Reviewed by: Dan McDonald <danmcd@nexenta.com>
Reviewed by: Sarah Jelinek <Sarah.Jelinek@nexenta.com>
Reviewed by: Jeffry Molanus <jeffry.molanus@nexenta.com>
Approved by: Robert Mustacchi <rm@joyent.com>
5320 panic in smb_com_locking_andx
Reviewed by: Alek Pinchuk <pinchuk.alek@gmail.com>
Reviewed by: Bayard Bell <bayard.bell@nexenta.com>
Approved by: Robert Mustacchi <rm@joyent.com>
5345 ctype.h is missing tolower_l and toupper_l
Reviewed by: Garrett D'Amore <garrett@damore.org>
Approved by: Richard Lowe <richlowe@richlowe.net>
2732 consistent use of #pragma align would please GCC
Reviewed by: Richard Lowe <richlowe@richlowe.net>
Approved by: Dan McDonald <danmcd@omniti.com>
3124 Remove any existing references to utmp, use utmpx instead
Reviewed by: Josef 'Jeff' Sipek <josef.sipek@nexenta.com>
Reviewed by: Marcel Telka <marcel@telka.sk>
Approved by: Dan McDonald <danmcd@omniti.com>
Remove "dbuf phys" db->db_data pointer aliases.

Use function accessors that cast db->db_data to the appropriate
"phys" type, removing the need for clients of the dmu buf user
API to keep properly typed pointer aliases to db->db_data in order
to conveniently access their data.

cmd/mdb/common/modules/zfs/Makefile.zfs:
cmd/mdb/intel/amd64/libzpool/Makefile:
cmd/mdb/intel/amd64/zfs/Makefile:
cmd/mdb/intel/ia32/libzpool/Makefile:
cmd/mdb/intel/ia32/zfs/Makefile:
cmd/mdb/sparc/v7/libzpool/Makefile:
cmd/mdb/sparc/v9/libzpool/Makefile:
cmd/mdb/sparc/v9/zfs/Makefile:
cmd/zdb/Makefile.com:
	Silence E_STATIC_UNUSED lint warnings.

cmd/mdb/common/modules/zfs/zfs.c:
uts/common/fs/zfs/zap_leaf.c:
	In zap_leaf() and zap_leaf_byteswap, now that the pointer alias
	field l_phys has been removed, use the db_data field in an on
	stack dmu_buf_t to point to the leaf's phys data.

uts/common/fs/zfs/dbuf.c:
	Remove the db_user_data_ptr_ptr field from dbuf and all logic
	to maintain it.

uts/common/fs/zfs/dbuf.c:
uts/common/fs/zfs/dnode.c:
uts/common/fs/zfs/sys/dbuf.h:
uts/common/fs/zfs/sys/dmu.h:
uts/common/fs/zfs/dsl_dataset.c:
uts/common/fs/zfs/dsl_dir.c:
uts/common/fs/zfs/sa.c:
uts/common/fs/zfs/zap.c:
uts/common/fs/zfs/zap_micro.c:
	Modify the DMU buf user API to remove the ability to specify
	a db_data aliasing pointer (db_user_data_ptr_ptr).

cmd/zdb/zdb.c:
uts/common/fs/zfs/dmu_diff.c:
uts/common/fs/zfs/dmu_objset.c:
uts/common/fs/zfs/dmu_send.c:
uts/common/fs/zfs/dmu_traverse.c:
uts/common/fs/zfs/dmu_tx.c:
uts/common/fs/zfs/dsl_bookmark.c:
uts/common/fs/zfs/dsl_dataset.c:
uts/common/fs/zfs/dsl_deadlist.c:
uts/common/fs/zfs/dsl_deleg.c:
uts/common/fs/zfs/dsl_destroy.c:
uts/common/fs/zfs/dsl_dir.c:
uts/common/fs/zfs/dsl_pool.c:
uts/common/fs/zfs/dsl_prop.c:
uts/common/fs/zfs/dsl_scan.c:
uts/common/fs/zfs/dsl_synctask.c:
uts/common/fs/zfs/dsl_userhold.c:
uts/common/fs/zfs/sa.c:
uts/common/fs/zfs/spa.c:
uts/common/fs/zfs/spa_history.c:
uts/common/fs/zfs/zap.c:
uts/common/fs/zfs/zap_leaf.c:
uts/common/fs/zfs/zap_micro.c:
uts/common/fs/zfs/zfs_ioctl.c:
uts/common/fs/zfs/sys/dsl_dataset.h:
uts/common/fs/zfs/sys/dsl_dir.h:
uts/common/fs/zfs/sys/zap_impl.h:
uts/common/fs/zfs/sys/zap_leaf.h:
	Create and use the new "phys data" accessor functions
	dsl_dir_phys(), dsl_dataset_phys(), zap_m_phys(),
	zap_f_phys(), and zap_leaf_phys().

uts/common/fs/zfs/sys/dsl_dataset.h:
uts/common/fs/zfs/sys/dsl_dir.h:
uts/common/fs/zfs/sys/zap_impl.h:
uts/common/fs/zfs/sys/zap_leaf.h:
	Remove now unused "phys pointer" aliases to db->db_data
	from clients of the DMU buf user API.
Various improvements the dmu buf user API.

Submitted by:	Justin Gibbs <justing@spectralogic.com>
Submitted by:	Will Andrews <willa@spectralogic.com>
Sponsored by:	Spectra Logic Corporation

Collect dmu buf user API support data into a new structure,
dmu_buf_user_t.  Consumers of this interface must include a
dmu_buf_user_t as a member of the user data structure that will be
attached to a dmu buffer.  This reduces the size of dmu_buf_impl_t
by two pointers.

Queue dmu buf user eviction processing and defer it until after locks
are dropped.  This prevents FreeBSD witness(4) lock-order reversal
warnings and potential deadlocks.

Convert objset eviction from a synchronous to an asynchronous process
to accomodate the asynchronous invocation, via dmu buf user eviction,
of dnode_buf_pageout().

Modify existing users of the dmu buf user API to never access the dbuf to
which their data was attached after user eviction has occurred.  Accessing
the dbuf from the callback is no longer safe now that callbacks occur
without the locks that used to protect them.  Enforce this in ZFS_DEBUG
kernel builds by clearing the user's pointer to the dbuf, if any, at
the time of eviction.  Callbacks have also been modified to clear their
dbuf pointer so most errors are caught even on non ZFS_DEBUG kernels.
However, this will not catch accesses from other contexts that occur
between the time of eviction and the processing of the callback.

Clarify programmer intent and improve readability by providing
specialized functions for the common user data update actions "remove"
and "replace".

Provide code-comment documentation for each API call.

Perform runtime validation of proper API usage on ZFS_DEBUG kernels.

uts/common/fs/zfs/sys/dbuf.h:
uts/common/fs/zfs/dbuf.c:
	Add dbuf_verify_user() and call it from the dbuf user API and
	during dbuf eviction processing to verify dbuf user API state.

	Replace calls to dbuf_set_data(db, NULL) with more explicit
	db_clear_data().  dbuf_set_data() now asserts that its buffer
	is never NULL.

	Implement new dmu buf API functions.

	Add the dmu_evict_taskq for processing dmu buf user evictions.
	Add dmu_buf_user_evict_wait() which allows the spa and zfs fini
	functions to drain pending user evictions.

	In dbuf_rele_and_unlock(), immediately evict dbufs with a zero
	refcount for an objset that is being evicted.

uts/common/fs/zfs/dmu.c:
	Drain any active user evictions prior to tearing down DMU
	subsystems.

uts/common/fs/zfs/sys/dmu_objset.h:
uts/common/fs/zfs/dmu_objset.c:
	End the practice of including special dnodes in os->os_dnodes.
	This allows os->os_dnodes to be managed completely by one
	eviction path: dnode_buf_pageout()->dnode_destroy().

	Split objset eviction processing into two pieces.  The first
	marks the objset as evicting, evicts any dbufs that have a
	refcount of zero, and then queues up the objset for the second
	phase of eviction.  Once os->os_dnodes has been cleared by
	dnode_buf_pageout()/dnode_destroy(), the second phase is executed.
	The second phase closes the special dnodes, dequeues the objset
	from the list of those undergoing eviction, and finally frees
	the objset.

	NOTE: Due to asynchronous eviction processing (i.e. invocation
	      of dnode_buf_pageout()), it is possible for the meta dnode
	      for the objset to have no holds even though os->os_dnodes
	      is not empty.

uts/common/fs/zfs/sys/dnode.h:
uts/common/fs/zfs/dnode.c:
	Collapse the initialization of a dnode from dnode_hold_impl()
	into dnode_create().  Since we already grab os_lock, use it to
	provide mutual exclusion for dnh->dnh_dnode and to arbitrate
	the winner of the initial open race.  The only way to unset the
	handle is to page out an entire set of dnodes, which uses the
	user eviction mechanism to arbitrate.

	In dnode_destroy(), invoke final stage of objset eviction if
	the destroyed dnode is the last regular dnode in the objset.

	Modify dnode_buf_pageout() so that it doesn't reference the
	evicted dbuf.

uts/common/fs/zfs/dnode_sync.c:
	In dnode_evict_dbufs(), remove multiple passes over dn->dn_dbufs.
	This is possible now that objset eviction is asynchronously
	completed in a different context once dbuf eviction completes.

	In the case of objset eviction, any dbufs held by children will
	be evicted via dbuf_rele_and_unlock() once their refcounts go
	to zero.  Even when objset eviction is not active, the ordering
	of the avl tree guarantees that children will be released before
	parents, allowing the parent's refcounts to naturally drop to
	zero before they are inspected in this single loop.

uts/common/fs/zfs/sys/spa.h:
uts/common/fs/zfs/sys/spa_impl.h:
uts/common/fs/zfs/spa.c:
uts/common/fs/zfs/spa_misc.c:
	Track evicting objsets in the spa.

	When recording or validating the min spa reference count, wait
	of objset eviction processing to complete so that the reference
	count is stable.

	Remove ASSERT() in spa_close().  Eviction processing is
	asynchronous so we can no longer use the namespace_lock as an
	indication that the spa is being exported and that reference
	counts can safely drop below spa_minref.

uts/common/fs/zfs/dsl_deadlist.c:
uts/common/fs/zfs/dsl_dataset.c:
	Modify dsl_dataset_evict() so that it doesn't reference the
	evicted dbuf to determine if the deadlist needs to be closed.
	This is achieved by checking ds->ds_deadlist.dl_os instead
	which is now properly cleared when a deadlist is closed prior
	to eviction.

uts/common/fs/zfs/dmu_objset.c:
	Modify dmu_objset_evict() so that it doesn't reference the
	evicted dbuf via dsl_dataset_is_snapshot().

uts/common/fs/zfs/dsl_dir.c:
uts/common/fs/zfs/sys/dsl_dir.h:
uts/common/fs/zfs/dsl_dataset.c:
uts/common/fs/zfs/sys/dsl_dataset.h:
uts/common/fs/zfs/dsl_dir.c:
uts/common/fs/zfs/dsl_prop.c:
uts/common/fs/zfs/sa.c:
uts/common/fs/zfs/sys/sa_impl.h:
uts/common/fs/zfs/zap.c:
uts/common/fs/zfs/sys/zap_impl.h:
uts/common/fs/zfs/sys/zap_leaf.h:
uts/common/fs/zfs/zap_micro.c:
	Conform to new dbuf user API.

uts/common/fs/zfs/sys/dmu.h:
	Add prototypes, data structures, and code comment documentation
	for the dmu buf user api.

	Pull in ASSERT() via zfs_context.h.

uts/common/fs/zfs/zfs_sa.c:
	Use zfs_context.h instead of manual includes of sys/types.h
	and sys/params.h so this file is compatible with the use of
	zfs_context.h in sys/dmu.h.