]> git.proxmox.com Git - mirror_zfs-debian.git/log
mirror_zfs-debian.git
13 years agoAdd FAILFAST support
Brian Behlendorf [Fri, 1 Oct 2010 17:57:56 +0000 (10:57 -0700)]
Add FAILFAST support

ZFS works best when it is notified as soon as possible when a device
failure occurs.  This allows it to immediately start any recovery
actions which may be needed.  In theory Linux supports a flag which
can be set on bio's called FAILFAST which provides this quick
notification by disabling the retry logic in the lower scsi layers.

That's the theory at least.  In practice is turns out that while the
flag exists you oddly have to set it with the BIO_RW_AHEAD flag.
And even when it's set it you may get retries in the low level
drivers decides that's the right behavior, or if you don't get the
right error codes reported to the scsi midlayer.

Unfortunately, without additional kernels patchs there's not much
which can be done to improve this.  Basically, this just means that
it may take 2-3 minutes before a ZFS is notified properly that a
device has failed.  This can be improved and I suspect I'll be
submitting patches upstream to handle this.

13 years agoFix 'zpool events' formatting for awk
Brian Behlendorf [Tue, 28 Sep 2010 23:30:54 +0000 (16:30 -0700)]
Fix 'zpool events' formatting for awk

To make the 'zpool events' output simple to parse with awk the extra
newline after embedded nvlists has been dropped.  This allows the
entire event to be parsed as a single whitespace seperated record.

The -H option has been added to operate in scripted mode.  For the
'zpool events' command this means don't print the header.  The usage
of -H is consistent with scripted mode for other zpool commands.

13 years agoGenerate zevents for speculative and soft errors
Brian Behlendorf [Mon, 27 Sep 2010 23:55:05 +0000 (16:55 -0700)]
Generate zevents for speculative and soft errors

By default the Solaris code does not log speculative or soft io errors
in either 'zpool status' or post an event.  Under Linux we don't want
to change the expected behavior of 'zpool status' so these io errors
are still suppressed there.

However, since we do need to know about these events for Linux FMA and
the 'zpool events' interface is new we do post the events.  With the
addition of the zio_flags field the posted events now contain enough
information that a user space consumer can identify and discard these
events if it sees fit.

13 years agoFix negative zio->io_error which must be positive.
Brian Behlendorf [Mon, 27 Sep 2010 22:30:14 +0000 (15:30 -0700)]
Fix negative zio->io_error which must be positive.

All the upper layers of zfs expect zio->io_error to be positive.  I was
careful but I missed one instance in vdev_disk_physio_completion() which
could return a negative error.  To ensure all cases are always caught I
had additionally added an ASSERT() to check this before zio_interpret().

Finally, as a debugging aid when zfs is build with --enable-debug all
errors from the backing block devices will be reported to the console
with an error message like this:

ZFS: zio error=5 type=1 offset=4217856 size=8192 flags=60440

13 years agoSuppress large kmem_alloc() warning.
Brian Behlendorf [Mon, 27 Sep 2010 22:04:24 +0000 (15:04 -0700)]
Suppress large kmem_alloc() warning.

Observed during failure mode testing, dsl_scan_setup_sync() allocates
73920 bytes.  This is way over the limit of what is wise to do with a
kmem_alloc() and it should probably be moved to a slab.  For now I'm
just flagging it with KM_NODEBUG to quiet the error until this can be
revisited.

13 years agoFix undersized buffer in is_shorthand_path()
Ned Bass [Mon, 11 Oct 2010 21:48:52 +0000 (14:48 -0700)]
Fix undersized buffer in is_shorthand_path()

The string array 'char dirs[5][8]' was too small to accomodate the terminating
NUL character in "by-label". This change adds the needed additional byte.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoMake commands load zfs module on demand
Ned Bass [Thu, 7 Oct 2010 01:00:55 +0000 (18:00 -0700)]
Make commands load zfs module on demand

This commit modifies libzfs_init() to attempt to load the zfs kernel module if
it is not already loaded.  This is done to simplify initialization by letting
users simply import their zpools without having to first load the module.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoStrip partition from device name for whole disks
Ned Bass [Fri, 1 Oct 2010 19:00:58 +0000 (12:00 -0700)]
Strip partition from device name for whole disks

Under Solaris, the slice number is chopped off when displaying the device name
if the vdev is a whole disk.  Under Linux we should similarly discard the
partition number.  This commit adds the logic to perform the name truncation
for devices ending in -partX, XpX, or X, where X is a string of digits.  The
second case handles devices like md0p0. The third case is limited to scsi and
ide disks, i.e. those beginning with "sd" or "hd", in order to avoid stripping
the number from names like "loop0".

This commit removes the Solaris-specific code for removing slices, since we no
longer reasonably expect our changes to be merged in upstream.  The partition
stripping code was moved off to a helper function to improve readability.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoUse stored whole_disk property when opening a vdev
Ned Bass [Mon, 4 Oct 2010 20:08:24 +0000 (13:08 -0700)]
Use stored whole_disk property when opening a vdev

This commit fixes a bug in vdev_disk_open() in which the whole_disk property
was getting set to 0 for disk devices, even when it was stored as a 1 when the
zpool was created.  The whole_disk property lets us detect when the partition
suffix should be stripped from the device name in CLI output.  It is also used
to determine how writeback cache should be set for a device.

When an existing zpool is imported its configuration is read from the vdev
label by user space in zpool_read_label().  The whole_disk property is saved in
the nvlist which gets passed into the kernel, where it in turn gets saved in
the vdev struct in vdev_alloc().  Therefore, this value is available in
vdev_disk_open() and should not be overridden by checking the provided device
path, since that path will likely point to a partition and the check will
return the wrong result.

We also add an ASSERT that the whole_disk property is set.  We are not aware of
any cases where vdev_disk_open() should be called with a config that doesn't
have this property set.  The ASSERT is there so that when debugging is enabled
we can identify any legitimate cases that we are missing.  If we never hit the
ASSERT, we can at some point remove it along with the conditional whole_disk
check.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoRegister the space accounting callback even when we don't have the ZPL.
Ricardo M. Correia [Mon, 4 Oct 2010 17:19:17 +0000 (10:19 -0700)]
Register the space accounting callback even when we don't have the ZPL.

This callback is needed for properly accounting the per-uid and per-gid
space usage.  Even if we don't have the ZPL, we still need this callback
in order to have proper on-disk ZPL compatibility and to be able to use
Lustre quotas.

Fortunately, the callback doesn't have any ZPL/VFS dependencies so we
can just move it out of #ifdef HAVE_ZPL.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoFix missing vdev names in zpool status output
Ned Bass [Thu, 23 Sep 2010 01:53:59 +0000 (18:53 -0700)]
Fix missing vdev names in zpool status output

Top-level vdev names in zpool status output should follow a <type-id> naming
convention.  In the case of raidz devices, the type portion of the name was
missing.

This commit fixes a bug in zpool_vdev_name() where in this snprintf call

(void) snprintf(buf, sizeof (buf), "%s-%llu", path,
(u_longlong_t)id);

buf and path may point to the same location.  The result is that buf ends up
containing only the "-id" part.  This only occurred for raidz devices because
the code for appending the parity level to the type string stored its result in
buf then set path to point there.  To fix this we allocate a new temporary
buffer on the stack instead of reusing buf.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #57

13 years agoExport ZFS symbols needed by Lustre.
Ricardo M. Correia [Fri, 17 Sep 2010 23:07:24 +0000 (16:07 -0700)]
Export ZFS symbols needed by Lustre.

Required for the DB_DNODE_ENTER()/DB_DNODE_EXIT() helpers.

Signed-off-by: Ricardo M. Correia <ricardo.correia@oracle.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoQuiet down very frequent large allocation warning in ZFS.
Ricardo M. Correia [Fri, 17 Sep 2010 23:08:56 +0000 (16:08 -0700)]
Quiet down very frequent large allocation warning in ZFS.

In my machine, dnode_hold_impl() allocates 9992 bytes in DEBUG mode and it
causes a large stream of stack traces in the logs. Instead, use KM_NODEBUG
to quiet down this known large alloc.

Signed-off-by: Ricardo M. Correia <ricardo.correia@oracle.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoAdd missing Makefile.in from zpool_layout commit
Brian Behlendorf [Fri, 17 Sep 2010 23:22:08 +0000 (16:22 -0700)]
Add missing Makefile.in from zpool_layout commit

The scripts/zpool-layout/Makefile.in file generated by autogen.sh
was accidentally omitted from the previous commit.  Add it.

13 years agoAdd [-m map] option to zpool_layout
Brian Behlendorf [Wed, 15 Sep 2010 22:32:27 +0000 (15:32 -0700)]
Add [-m map] option to zpool_layout

By default the zpool_layout command would always use the slot
number assigned by Linux when generating the zdev.conf file.
This is a reasonable default there are cases when it makes
sense to remap the slot id assigned by Linux using your own
custom mapping.

This commit adds support to zpool_layout to provide a custom
slot mapping file.  The file contains in the first column the
Linux slot it and in the second column the custom slot mapping.
By passing this map file with '-m map' to zpool_config the
mapping will be applied when generating zdev.conf.

Additionally, two sample mapping have been added which reflect
different ways to map the slots in the dragon drawers.

13 years agoFix markdown rendering
Brian Behlendorf [Wed, 15 Sep 2010 16:09:37 +0000 (09:09 -0700)]
Fix markdown rendering

These two lines were being rendered incorrectly on the GitHub
site.  To fix the issue there needs to be leading whitespace
before each line to ensure each command is rendered on its
own line.

$ ./configure
$ make pkg

13 years agoReference new zfsonlinux.org website
Brian Behlendorf [Tue, 14 Sep 2010 22:58:25 +0000 (15:58 -0700)]
Reference new zfsonlinux.org website

The wiki contents have been converted to html and made available
at their new home http://zfsonlinux.org.  The wiki has also been
disabled the html pages are now the official documentation.

13 years agoWait up to timeout seconds for udev device
Brian Behlendorf [Sat, 11 Sep 2010 04:44:17 +0000 (21:44 -0700)]
Wait up to timeout seconds for udev device

Occasional failures were observed in zconfig.sh because udev
could be delayed for a few seconds.  To handle this the wait_udev
function has been added to wait for timeout seconds for an
expected device before returning an error.  By default callers
currently use a 30 seconds timeout which should be much longer
than udev ever needs but not so long to worry the test suite
is hung.

13 years agoReduce volume size in zconfig.sh
Brian Behlendorf [Sat, 11 Sep 2010 04:35:27 +0000 (21:35 -0700)]
Reduce volume size in zconfig.sh

Due to occasional ENOSPC failures on certain platforms I've reduced
the size of the ZVOL from 400M to 300M for the zvol+ext2 clone tests.

13 years agoUse top level object directory in zfs-module.spec
Brian Behlendorf [Fri, 10 Sep 2010 19:33:31 +0000 (12:33 -0700)]
Use top level object directory in zfs-module.spec

Commit 6283f55ea1b91e680386388c17d14b89e344fa8d updated _almost_
everything to use the correct top level object directory.  This
was done to correctly supporting building in custom directories.
Unfortunately, I missed this one instance in the zfs-module.spec.in
rpm spec file.  Fix it.

13 years agoExclude atomic.S source from dist rules
Brian Behlendorf [Fri, 10 Sep 2010 18:43:12 +0000 (11:43 -0700)]
Exclude atomic.S source from dist rules

The zfs package supports the option --with-config=srpm which
is used to bootstrap configure to allow the 'make srpm' target
to work.  This has the advantage of allowing creation of source
rpms without having all your -devel packages installed.  This
source package can then be feed back in to an automated build
farm which only installs the required packages listed by the
srpm.  This ensures that all proper dependencies are expressed
by the source package, because if they are not you will get
configure/build failures.

The trouble here is that --with-config=srpm prevents the
architecture check from running resulting in TARGET_ASM_DIR
being set to the default asm-generic.  The 'make dist' rule
then fails because there is no asm-generic/atomic.S file
because it is generated at build time.  To handle this I
have added an empty file asm-generic/atomic.S simply as a
place holder for 'make dist'.

13 years agoUse linux __KERNEL__ define
Brian Behlendorf [Fri, 10 Sep 2010 16:36:39 +0000 (09:36 -0700)]
Use linux __KERNEL__ define

Previously the project contained who zfs_context.h files,
one for user space builds and one for kernel space builds.
It was the responsibility of the source including the file
to ensure the right one was included based on the order of
the include paths.

This was the way it was done in OpenSolaris but for our
purposes I felt it was overly obscure.  The user and kernel
zfs_context.h files have been combined in to a single file
and a #define determines if you get the user or kernel
context.

The issue here was that I used the _KERNEL macro which is
defined as part of the spl which will only be defined for
most builds after you include the right zfs_context.  It is
safer to use the __KERNEL__ macro which is automatically
defined as part of the kernel build process and passed as
a command line compiler option.  It will always be defined
if your building in the kernel and never for user space.

13 years agoFix "format not a string literal" warning
Brian Behlendorf [Thu, 9 Sep 2010 04:39:28 +0000 (21:39 -0700)]
Fix "format not a string literal" warning

Under Ubuntu 10.04 the default compiler flags include -Wformat
and -Wformat-security which cause the above warning.  In particular,
cases where "%s" was forgotten as part of the format specifier.

https://wiki.ubuntu.com/CompilerFlags

13 years agoSupport custom build directories and move includes
Brian Behlendorf [Sat, 4 Sep 2010 20:26:23 +0000 (13:26 -0700)]
Support custom build directories and move includes

One of the neat tricks an autoconf style project is capable of
is allow configurion/building in a directory other than the
source directory.  The major advantage to this is that you can
build the project various different ways while making changes
in a single source tree.

For example, this project is designed to work on various different
Linux distributions each of which work slightly differently.  This
means that changes need to verified on each of those supported
distributions perferably before the change is committed to the
public git repo.

Using nfs and custom build directories makes this much easier.
I now have a single source tree in nfs mounted on several different
systems each running a supported distribution.  When I make a
change to the source base I suspect may break things I can
concurrently build from the same source on all the systems each
in their own subdirectory.

wget -c http://github.com/downloads/behlendorf/zfs/zfs-x.y.z.tar.gz
tar -xzf zfs-x.y.z.tar.gz
cd zfs-x-y-z

------------------------- run concurrently ----------------------
<ubuntu system>  <fedora system>  <debian system>  <rhel6 system>
mkdir ubuntu     mkdir fedora     mkdir debian     mkdir rhel6
cd ubuntu        cd fedora        cd debian        cd rhel6
../configure     ../configure     ../configure     ../configure
make             make             make             make
make check       make check       make check       make check

This change also moves many of the include headers from individual
incude/sys directories under the modules directory in to a single
top level include directory.  This has the advantage of making
the build rules cleaner and logically it makes a bit more sense.

13 years agoFix spl version check
Brian Behlendorf [Fri, 3 Sep 2010 03:44:41 +0000 (20:44 -0700)]
Fix spl version check

The spl_config.h file is checked to determine the spl version.
However, the zfs code was looking for it in the source directory
and not the build directory.

13 years agoRemove zfs-x.y.z.zip creation in 'make dist'
Brian Behlendorf [Thu, 2 Sep 2010 20:18:17 +0000 (13:18 -0700)]
Remove zfs-x.y.z.zip creation in 'make dist'

Do no create a zfs-x.y.z.zip file as part of 'make dist'.  Simply
create the standard zfs-x.y.z.tar.gz file.

13 years agoPrep for zfs-0.5.1 tag
Brian Behlendorf [Wed, 1 Sep 2010 18:23:32 +0000 (11:23 -0700)]
Prep for zfs-0.5.1 tag

13 years agoFix zfsdev_compat_ioctl() case
Brian Behlendorf [Wed, 1 Sep 2010 22:58:09 +0000 (15:58 -0700)]
Fix zfsdev_compat_ioctl() case

For the !CONFIG_COMPAT case fix the zfsdev_compat_ioctl()
compatibility function name.  This was caught by the
chaos4.3 builder.

13 years agoMinor packaging fixes
Brian Behlendorf [Wed, 1 Sep 2010 19:54:51 +0000 (12:54 -0700)]
Minor packaging fixes

The GIT file was removed from the tree because I have stopped
using TopGit.  Because of this is must also be removed from
the top level Makefile.am as will as the zfs.spec.in file
which referenced it.

Fix type in lib/libzpool/Makefile.am which was preventing
the needed zrlock.h header from being included by 'make dist'.
I simply had the name wrong in the Makefile.am.

Regenerated autogen.sh build products.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoRemove scripts/common.sh
Brian Behlendorf [Wed, 1 Sep 2010 19:50:44 +0000 (12:50 -0700)]
Remove scripts/common.sh

This script is now dynamically generated at configure time
from scripts/common.sh.in.  This change was made by commit
26e61dd074df64f9e1d779273efd56fa9d92cdc5 but we accidentally
kept the common.sh file around.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoAdd quick build instructions
Brian Behlendorf [Wed, 1 Sep 2010 18:23:13 +0000 (11:23 -0700)]
Add quick build instructions

Full update to date build information will stay on the wiki for
now, but there is no harm in adding the bare bones instructions
to the README.  They shouldn't change and are a reasonable
quick start.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoAdd initial autoconf products
Brian Behlendorf [Thu, 26 Aug 2010 19:28:14 +0000 (12:28 -0700)]
Add initial autoconf products

Add the initial products from autogen.sh.  These products will
be updated incrementally after this point as development occurs.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoAdd linux ztest support
Brian Behlendorf [Thu, 26 Aug 2010 18:59:11 +0000 (11:59 -0700)]
Add linux ztest support

Minor changes to ztest for this environment.  These including
updating ztest to run in the local development tree, as well
as relocating some local variables in this function to the heap.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoAdd linux zpios support
Brian Behlendorf [Thu, 26 Aug 2010 18:58:00 +0000 (11:58 -0700)]
Add linux zpios support

Linux kernel implementation of PIOS test app.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoAdd linux user util support
Brian Behlendorf [Thu, 26 Aug 2010 18:57:29 +0000 (11:57 -0700)]
Add linux user util support

This topic branch contains required changes to the user space
utilities to allow them to integrate cleanly with Linux.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoAdd linux user disk support
Brian Behlendorf [Thu, 26 Aug 2010 18:56:53 +0000 (11:56 -0700)]
Add linux user disk support

This topic branch contains all the changes needed to integrate the user
side zfs tools with Linux style devices.  Primarily this includes fixing
up the Solaris libefi library to be Linux friendly, and integrating with
the libblkid library which is provided by e2fsprogs.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoAdd linux unused code tracking
Brian Behlendorf [Thu, 26 Aug 2010 18:55:32 +0000 (11:55 -0700)]
Add linux unused code tracking

Track various large hunks which have been dropped simply
because they are not relevant to this port.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoAdd linux topology support
Brian Behlendorf [Thu, 26 Aug 2010 18:55:19 +0000 (11:55 -0700)]
Add linux topology support

Solaris recently introduced the idea of drive topology because
where a drive is located does matter.  I have already handled
this with udev/blkid integration under Linux so I'm hopeful
this case can simply be removed but for now I've just stubbed
out what is needed in libspl and commented out the rest here.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoAdd linux compatibility
Brian Behlendorf [Thu, 26 Aug 2010 18:54:51 +0000 (11:54 -0700)]
Add linux compatibility

Resolve minor Linux compatibility issues.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoAdd linux spa thread support
Brian Behlendorf [Thu, 26 Aug 2010 18:52:20 +0000 (11:52 -0700)]
Add linux spa thread support

Disable the spa thread under Linux until it can be implemented.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoAdd linux sha2 support
Brian Behlendorf [Thu, 26 Aug 2010 18:52:05 +0000 (11:52 -0700)]
Add linux sha2 support

The upstream ZFS code has correctly moved to a faster native sha2
implementation.  Unfortunately, under Linux that's going to be a little
problematic so we revert the code to the more portable version contained
in earlier ZFS releases.  Using the native sha2 implementation in Linux
is possible but the API is slightly different in kernel version user
space depending on which libraries are used.  Ideally, we need a fast
implementation of SHA256 which builds as part of ZFS this shouldn't be
that hard to do but it will take some effort.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoAdd linux libspl support
Brian Behlendorf [Thu, 26 Aug 2010 18:50:56 +0000 (11:50 -0700)]
Add linux libspl support

All changes needed for the libspl layer.  This includes modifications
to files directly copied from OpenSolaris and the addition of new
files needed to fill in the gaps.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoAdd linux kernel module support
Brian Behlendorf [Thu, 26 Aug 2010 18:49:16 +0000 (11:49 -0700)]
Add linux kernel module support

Setup linux kernel module support, this includes:
- zfs context for kernel/user
- kernel module build system integration
- kernel module macros
- kernel module symbol export
- kernel module options

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoAdd linux kernel memory support
Brian Behlendorf [Thu, 26 Aug 2010 18:46:09 +0000 (11:46 -0700)]
Add linux kernel memory support

Required kmem/vmem changes

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoAdd linux kernel disk support
Brian Behlendorf [Thu, 26 Aug 2010 18:45:02 +0000 (11:45 -0700)]
Add linux kernel disk support

Native Linux vdev disk interfaces

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoAdd linux kernel device support
Brian Behlendorf [Thu, 26 Aug 2010 18:44:39 +0000 (11:44 -0700)]
Add linux kernel device support

This branch contains the majority of the changes required to cleanly
intergrate with Linux style special devices (/dev/zfs).  Mainly this
means dropping all the Solaris style callbacks and replacing them
with the Linux equivilants.

This patch also adds the onexit infrastructure needed to track
some minimal state between ioctls.  Under Linux it would be easy
to do this simply using the file->private_data.  But under Solaris
they apparent need to pass the file descriptor as part of the ioctl
data and then perform a lookup in the kernel.  Once again to keep
code change to a minimum I've implemented the Solaris solution.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoAdd linux spl debug support
Brian Behlendorf [Thu, 26 Aug 2010 18:44:12 +0000 (11:44 -0700)]
Add linux spl debug support

Use spl debug if HAVE_SPL defined

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoAdd linux mntent support
Brian Behlendorf [Thu, 26 Aug 2010 18:43:58 +0000 (11:43 -0700)]
Add linux mntent support

Use mount entry if HAVE_SETMNTENT defined

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoAdd linux mlslabel support
Brian Behlendorf [Thu, 26 Aug 2010 18:43:42 +0000 (11:43 -0700)]
Add linux mlslabel support

The ZFS update to onnv_141 brought with it support for a
security label attribute called mlslabel.  This feature
depends on zones to work correctly and thus I am disabling
it under Linux.  Equivilant functionality could be added
at some point in the future.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoAdd linux idmap support
Brian Behlendorf [Thu, 26 Aug 2010 18:43:07 +0000 (11:43 -0700)]
Add linux idmap support

Use idmap service if available.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoAdd linux events
Brian Behlendorf [Thu, 26 Aug 2010 18:42:43 +0000 (11:42 -0700)]
Add linux events

This topic branch leverages the Solaris style FMA call points
in ZFS to create a user space visible event notification system
under Linux.  This new system is called zevent and it unifies
all previous Solaris style ereports and sysevent notifications.

Under this Linux specific scheme when a sysevent or ereport event
occurs an nvlist describing the event is created which looks almost
exactly like a Solaris ereport.  These events are queued up in the
kernel when they occur and conditionally logged to the console.
It is then up to a user space application to consume the events
and do whatever it likes with them.

To make this possible the existing /dev/zfs ABI has been extended
with two new ioctls which behave as follows.

* ZFS_IOC_EVENTS_NEXT
Get the next pending event.  The kernel will keep track of the last
event consumed by the file descriptor and provide the next one if
available.  If no new events are available the ioctl() will block
waiting for the next event.  This ioctl may also be called in a
non-blocking mode by setting zc.zc_guid = ZEVENT_NONBLOCK.  In the
non-blocking case if no events are available ENOENT will be returned.
It is possible that ESHUTDOWN will be returned if the ioctl() is
called while module unloading is in progress.  And finally ENOMEM
may occur if the provided nvlist buffer is not large enough to
contain the entire event.

* ZFS_IOC_EVENTS_CLEAR
Clear are events queued by the kernel.  The kernel will keep a fairly
large number of recent events queued, use this ioctl to clear the
in kernel list.  This will effect all user space processes consuming
events.

The zpool command has been extended to use this events ABI with the
'events' subcommand.  You may run 'zpool events -v' to output a
verbose log of all recent events.  This is very similar to the
Solaris 'fmdump -ev' command with the key difference being it also
includes what would be considered sysevents under Solaris.  You
may also run in follow mode with the '-f' option.  To clear the
in kernel event queue use the '-c' option.

$ sudo cmd/zpool/zpool events -fv
TIME                        CLASS
May 13 2010 16:31:15.777711000 ereport.fs.zfs.config.sync
        class = "ereport.fs.zfs.config.sync"
        ena = 0x40982b7897700001
        detector = (embedded nvlist)
                version = 0x0
                scheme = "zfs"
                pool = 0xed976600de75dfa6
        (end detector)

        time = 0x4bec8bc3 0x2e5aed98
        pool = "zpios"
        pool_guid = 0xed976600de75dfa6
        pool_context = 0x0

While the 'zpool events' command is handy for interactive debugging
it is not expected to be the primary consumer of zevents.  This ABI
was primarily added to facilitate the addition of a user space
monitoring daemon.  This daemon would consume all events posted by
the kernel and based on the type of event perform an action.  For
most events simply forwarding them on to syslog is likely enough.
But this interface also cleanly allows for more sophisticated
actions to be taken such as generating an email for a failed drive.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoAdd build system
Brian Behlendorf [Thu, 26 Aug 2010 18:22:58 +0000 (11:22 -0700)]
Add build system

Add autoconf style build infrastructure to the ZFS tree.  This
includes autogen.sh, configure.ac, m4 macros, some scripts/*,
and makefiles for all the core ZFS components.

13 years agoFix stack ztest
Brian Behlendorf [Thu, 26 Aug 2010 18:13:05 +0000 (11:13 -0700)]
Fix stack ztest

While ztest does run in user space we run it with the same stack
restrictions it would have in kernel space.  This ensures that any
stack related issues which would be hit in the kernel can be caught
and debugged in user space instead.

This patch is a first pass to limit the stack usage of every ztest
function to 1024 bytes.  Subsequent updates can further reduce this.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoFix stack traverse_visitbp()
Brian Behlendorf [Fri, 27 Aug 2010 23:48:18 +0000 (16:48 -0700)]
Fix stack traverse_visitbp()

Due to  limited stack space recursive functions are frowned upon in
the Linux kernel.  However, they often are the most elegant solution
to a problem.  The following code preserves the recursive function
traverse_visitbp() but moves the local variables AND function
arguments to the heap to minimize the stack frame size.  Enough
space is initially allocated on the stack for 20 levels of recursion.
This change does ugly-up-the-code but it reduces the worst case
usage from roughly 4160 bytes to 960 bytes on x86_64 archs.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoFix stack zio_execute()
Ned Bass [Thu, 26 Aug 2010 18:38:38 +0000 (11:38 -0700)]
Fix stack zio_execute()

Implement zio_execute() as a wrapper around the static function
__zio_execute() so that we can force  __zio_execute() to be inlined.
This reduces stack overhead which is important because __zio_execute()
is called recursively in several zio code paths.  zio_execute() itself
cannot be inlined because it is externally visible.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoFix stack zio_done()
Brian Behlendorf [Thu, 26 Aug 2010 18:04:17 +0000 (11:04 -0700)]
Fix stack zio_done()

Eliminated local variables pointing to members of the zio struct.
Just refer to the struct members directly.  This saved about 32 bytes per
call, but this function can be called recurisvely up to 19 levels deep,
so we potentially save up to 608 bytes.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoFix stack vn_open()
Brian Behlendorf [Thu, 26 Aug 2010 18:03:04 +0000 (11:03 -0700)]
Fix stack vn_open()

We should not put a 4k maxpathlen buffer on the stack, instead
locate it to the heap.  Even in user space we run ztest with 8K
stacks to verify correctness

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoFix stack vdev_cache_read()
Brian Behlendorf [Thu, 26 Aug 2010 18:00:46 +0000 (11:00 -0700)]
Fix stack vdev_cache_read()

Moving the vdev_cache_entry_t struct ve_search from the stack to
the heap saves ~100 bytes.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoFix stack traverse_impl()
Brian Behlendorf [Thu, 26 Aug 2010 17:58:47 +0000 (10:58 -0700)]
Fix stack traverse_impl()

Stack use reduced from 560 bytes to 128 bytes.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoFix stack noinline
Brian Behlendorf [Thu, 26 Aug 2010 17:58:36 +0000 (10:58 -0700)]
Fix stack noinline

Certain function must never be automatically inlined by gcc because
they are stack heavy or called recursively.  This patch flags all
such functions I've found as 'noinline' to prevent gcc from making
the optimization.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoFix stack lzjb
Brian Behlendorf [Thu, 26 Aug 2010 17:58:19 +0000 (10:58 -0700)]
Fix stack lzjb

Reduce kernel stack usage by lzjb_compress() by moving uint16 array
off the stack and on to the heap.  The exact performance implications
of this I have not measured but we absolutely need to keep stack
usage to a minimum.  If/when this becomes and issue we optimize.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoFix stack inline
Brian Behlendorf [Thu, 26 Aug 2010 17:58:00 +0000 (10:58 -0700)]
Fix stack inline

Decrease stack usage for various call paths by forcing certain
functions to be inlined.  By inlining the functions the overhead
of a new stack frame is removed at the cost of increased code size.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoFix stack dsl_scan_visitbp()
Brian Behlendorf [Thu, 26 Aug 2010 17:53:43 +0000 (10:53 -0700)]
Fix stack dsl_scan_visitbp()

To reduce stack overhead this topic branch moves the 128 byte
blkptr_t data strucutre in dsl_scan_visitbp() to the heap.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoFix stack dsl_dir_open_spa()
Brian Behlendorf [Thu, 26 Aug 2010 17:53:31 +0000 (10:53 -0700)]
Fix stack dsl_dir_open_spa()

Reduce stack usage by 256 bytes by moving buf char array from
the stack to the heap.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoFix stack dsl_deleg_get()
Brian Behlendorf [Thu, 26 Aug 2010 17:53:19 +0000 (10:53 -0700)]
Fix stack dsl_deleg_get()

Reduce stack usage in dsl_deleg_get, gcc flagged it as consuming a
whopping 1040 bytes or potentially 1/4 of a 4K stack.  This patch
moves all the large structures and buffer off the stack and on to
the heap.  This includes 2 zap_cursor_t structs each 52 bytes in
size, 2 zap_attribute_t structs each 280 bytes in size, and 1
256 byte char array.  The total saves on the stack is 880 bytes
after you account for the 5 new pointers added.

Also the source buffer length has been increased from MAXNAMELEN
to MAXNAMELEN+strlen(MOS_DIR_NAME)+1 as described by the comment in
dsl_dir_name().  A buffer overrun may have been possible with the
slightly smaller buffer.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoFix stack dsl_dataset_destroy()
Brian Behlendorf [Thu, 26 Aug 2010 17:52:40 +0000 (10:52 -0700)]
Fix stack dsl_dataset_destroy()

Move dsl_dataset_t local variable from the stack to the heap.
This reduces the stack usage of this function from 2048 bytes
to 176 bytes for x84_64 arches.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoFix stack dmu_objset_snapshot()
Brian Behlendorf [Thu, 26 Aug 2010 17:52:23 +0000 (10:52 -0700)]
Fix stack dmu_objset_snapshot()

Reduce stack usage by 276 bytes by moving the snaparg struct from the
stack to the heap.  We have limited stack space we must not waste.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoFix stack dbuf_hold_impl()
Brian Behlendorf [Thu, 26 Aug 2010 17:52:00 +0000 (10:52 -0700)]
Fix stack dbuf_hold_impl()

This commit preserves the recursive function dbuf_hold_impl() but moves
the local variables and function arguments to the heap to minimize
the stack frame size.  Enough space is initially allocated on the
stack for 20 levels of recursion.  This technique was based on commit
34229a2f2ac07363f64ddd63e014964fff2f0671 which reduced stack usage of
traverse_visitbp().

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoFix dnode_move() scope
Brian Behlendorf [Fri, 27 Aug 2010 17:55:07 +0000 (10:55 -0700)]
Fix dnode_move() scope

The dnode_move() functionality is only used in the kernel build.
As such we should be careful to wrap all of the related code
with '#ifdef _KERNEL' to avoid gcc warnings about unused code.

13 years agoFix Solaris thread dependency by using pthreads
Brian Behlendorf [Thu, 26 Aug 2010 17:43:27 +0000 (10:43 -0700)]
Fix Solaris thread dependency by using pthreads

This is a portability change which removes the dependence of the Solaris
thread library.  All locations where Solaris thread API was used before
have been replaced with equivilant Solaris kernel style thread calls.
In user space the kernel style threading API is implemented in term of
the portable pthreads library.  This includes all threads, mutexs,
condition variables, reader/writer locks, and taskqs.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoFix zfs_ioc_objset_stats
Brian Behlendorf [Thu, 26 Aug 2010 17:34:33 +0000 (10:34 -0700)]
Fix zfs_ioc_objset_stats

Interestingly this looks like an upstream bug as well.  If for some
reason we are unable to get a zvols statistics, because perhaps the
zpool is hopelessly corrupt, we would trigger the VERIFY.  This
commit adds the proper error handling just to propagate the error
back to user space.  Now the user space tools still must handle this
properly but in the worst case the tool will crash or perhaps have
some missing output.  That's far far better than crashing the host.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoFix zio_taskq_dispatch to use TQ_NOSLEEP
Brian Behlendorf [Thu, 26 Aug 2010 17:32:23 +0000 (10:32 -0700)]
Fix zio_taskq_dispatch to use TQ_NOSLEEP

The zio_taskq_dispatch() function may be called at interrupt time
and it is critical that we never sleep.

Additionally, wrap taskq_dispatch() in a while loop because it may
fail.  This is non optimal but is OK for now.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoFix strncat usage
Brian Behlendorf [Thu, 26 Aug 2010 17:31:53 +0000 (10:31 -0700)]
Fix strncat usage

This look like a typo.  The intention was to use strlcat() however
strncat() was used instead accidentally this may lead to a buffer
overflow.  This was caught by gcc -D_FORTIFY_SOURCE=2.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoFix rw_init() usage
Brian Behlendorf [Thu, 26 Aug 2010 17:30:13 +0000 (10:30 -0700)]
Fix rw_init() usage

Properly initialize rwlock primitives.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoFix zmod.h usage in userspace
Brian Behlendorf [Thu, 26 Aug 2010 17:29:11 +0000 (10:29 -0700)]
Fix zmod.h usage in userspace

Do not use zmod.h in userspace.

This has also been filed with the ZFS team. It makes the userspace
libzpool code use the zlib API, instead of the Solaris-only and
non-standard zmod.h.  The zlib API is almost identical and is a de
facto standard, so this is a no-brainer.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoFix missing newlines
Brian Behlendorf [Thu, 26 Aug 2010 17:28:31 +0000 (10:28 -0700)]
Fix missing newlines

Add missing \n's to dprintf()s

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoFix metaslab
Brian Behlendorf [Thu, 26 Aug 2010 17:27:53 +0000 (10:27 -0700)]
Fix metaslab

If your only going to allow one allocator to be used and it is defined
at compile time there is no point including the others in the build.
This patch could/should be refined for Linux to make the metaslab
configurable at run time.  That might be a bit tricky however since
you would need to quiese all IO.  Short of that making it configurable
as a module load option would be a reasonable compromise.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoFix list handling to only use the API
Brian Behlendorf [Thu, 26 Aug 2010 17:26:44 +0000 (10:26 -0700)]
Fix list handling to only use the API

Remove all instances of list handling where the API is not used
and instead list data members are directly accessed.  Doing this
sort of thing is bad for portability.

Additionally, ensure that list_link_init() is called on newly
created list nodes.  This ensures the node is properly initialized
and does not rely on the assumption that zero'ing the list_node_t
via kmem_zalloc() is the same as proper initialization.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoFix kstat xuio
Brian Behlendorf [Thu, 26 Aug 2010 17:26:05 +0000 (10:26 -0700)]
Fix kstat xuio

Move xiou stat structures from a header to the dmu.c source as is
done with all the other kstat interfaces.  This information is local
to dmu.c registered the xuio kstat and should stay that way.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoFix dbuf eviction assertion
Brian Behlendorf [Thu, 26 Aug 2010 17:24:44 +0000 (10:24 -0700)]
Fix dbuf eviction assertion

Replace non-fatal assertion with warning.  This was being observed
during testing and it should not be fatal.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoFix vn_open/vn_rdwr error handling
Ricardo M. Correia [Thu, 26 Aug 2010 17:21:44 +0000 (10:21 -0700)]
Fix vn_open/vn_rdwr error handling

1) In vn_open(), if fstat64() returned an error, the real errno
was being obscured by calling close().

2) Add error handling for both pwrite64() calls in vn_rdwr().

Signed-off-by: Ricardo M. Correia <Ricardo.M.Correia@Sun.COM>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoFix deadcode
Brian Behlendorf [Thu, 26 Aug 2010 17:19:48 +0000 (10:19 -0700)]
Fix deadcode

Remove deadcode.  It's possible the code should be in use
somewhere, but as the source code is laid out it currently
is not.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoFix dbuf_dirty_record_t leaks
Brian Behlendorf [Thu, 26 Aug 2010 17:19:04 +0000 (10:19 -0700)]
Fix dbuf_dirty_record_t leaks

Fix two leaks with dbuf_dirty_record_t

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoFix variables named current
Brian Behlendorf [Thu, 26 Aug 2010 17:18:06 +0000 (10:18 -0700)]
Fix variables named current

In the linux kernel 'current' is defined to mean the current process
and can never be used as a local variable in a function.  Simply
replace all usage of 'current' with 'curr' in this function.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoFix commit callbacks
Ricardo M. Correia [Thu, 26 Aug 2010 17:17:18 +0000 (10:17 -0700)]
Fix commit callbacks

The upstream commit cb code had a few bugs:

1) The arguments of the list_move_tail() call in txg_dispatch_callbacks()
were reversed by mistake. This caused the commit callbacks to not be
called at all.

2) ztest had a bug in ztest_dmu_commit_callbacks() where "error" was not
initialized correctly. This seems to have caused the test to always take
the simulated error code path, which made ztest unable to detect whether
commit cbs were being called for transactions that successfuly complete.

3) ztest had another bug in ztest_dmu_commit_callbacks() where the commit
cb threshold was not being compared correctly.

4) The commit cb taskq was using 'max_ncpus * 2' as the maxalloc argument
of taskq_create(), which could have caused unnecessary delays in the txg
sync thread.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoFix minor acl issue
Brian Behlendorf [Thu, 26 Aug 2010 17:10:35 +0000 (10:10 -0700)]
Fix minor acl issue

Minor fixes for newly introduced acl support.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoFix gcc uninitialized variable warnings
Brian Behlendorf [Thu, 26 Aug 2010 16:58:04 +0000 (09:58 -0700)]
Fix gcc uninitialized variable warnings

Gcc -Wall warn: 'uninitialized variable'

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoFix gcc unused variable warnings
Brian Behlendorf [Thu, 26 Aug 2010 16:53:00 +0000 (09:53 -0700)]
Fix gcc unused variable warnings

Gcc -Wall warn: 'unused variable'

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoFix gcc missing parenthesis warnings
Brian Behlendorf [Thu, 26 Aug 2010 16:52:42 +0000 (09:52 -0700)]
Fix gcc missing parenthesis warnings

Gcc -Wall warn: 'missing parenthesis'

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoFix gcc missing case warnings
Brian Behlendorf [Thu, 26 Aug 2010 16:52:41 +0000 (09:52 -0700)]
Fix gcc missing case warnings

Gcc ASSERT() missing cases are impossible

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoFix gcc missing braces warnings
Brian Behlendorf [Thu, 26 Aug 2010 16:52:41 +0000 (09:52 -0700)]
Fix gcc missing braces warnings

Resolve compiler warnings concerning missing braces.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoFix gcc invalid prototype warnings
Brian Behlendorf [Thu, 26 Aug 2010 16:52:41 +0000 (09:52 -0700)]
Fix gcc invalid prototype warnings

Gcc -Wall warn: 'invalid prototype'

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoFix gcc init pragma warnings
Brian Behlendorf [Thu, 26 Aug 2010 16:52:40 +0000 (09:52 -0700)]
Fix gcc init pragma warnings

Use constructor attribute on non-Solaris platforms.

The #pragma init/fini ->__attribute__((constructor/destructor))
conversions, these should go upstream.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoFix gcc ident pragma warnings
Ricardo M. Correia [Thu, 26 Aug 2010 16:52:40 +0000 (09:52 -0700)]
Fix gcc ident pragma warnings

Remove all ident pragmas which are unknown to gcc.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoFix gcc fortify source warnings
Brian Behlendorf [Thu, 26 Aug 2010 16:52:40 +0000 (09:52 -0700)]
Fix gcc fortify source warnings

Resolve issues uncovered by -D_FORTIFY_SOURCE=2, the default redhat
macro's file adds this option to the cflags.  This causes warnings
of the following type designed to keep the developer honest:

        warning: ignoring return value of 'foo', declared
                 with attribute warn_unused_result

The short term fix is to wrap these calls in VERIFY() to check the
return code.  The code was already assusing these would never fail.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoFix gcc useless debug warnings
Brian Behlendorf [Thu, 26 Aug 2010 16:52:40 +0000 (09:52 -0700)]
Fix gcc useless debug warnings

Gcc useless debugging.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoFix gcc cast warnings
Brian Behlendorf [Thu, 26 Aug 2010 16:52:39 +0000 (09:52 -0700)]
Fix gcc cast warnings

Gcc -Wall warn: 'lacks a cast'
Gcc -Wall warn: 'comparison between pointer and integer'

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoFix gcc c90 compliance warnings
Brian Behlendorf [Thu, 26 Aug 2010 16:52:39 +0000 (09:52 -0700)]
Fix gcc c90 compliance warnings

Fix non-c90 compliant code, for the most part these changes
simply deal with where a particular variable is declared.
Under c90 it must alway be done at the very start of a block.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoFix gcc 64-bit constant warnings
Ricardo M. Correia [Thu, 26 Aug 2010 16:52:39 +0000 (09:52 -0700)]
Fix gcc 64-bit constant warnings

Add 'ull' suffix to 64-bit constants.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoUpdate to onnv_147
Brian Behlendorf [Thu, 26 Aug 2010 21:24:34 +0000 (14:24 -0700)]
Update to onnv_147

This is the last official OpenSolaris tag before the public
development tree was closed.