zfs.git
12 years agoFix autoconf variable substitution in udev rules.
Darik Horn [Fri, 17 Jun 2011 15:02:36 +0000 (10:02 -0500)]
Fix autoconf variable substitution in udev rules.

Change the variable substitution in the udev rule templates
according to the method described in the Autoconf manual;
Chapter 4.7.2: Installation Directory Variables.

The udev rules are improperly generated if the bindir parameter
overrides the prefix parameter during configure. For example:

  # ./configure --prefix=/usr/local --bindir=/opt/zfs/bin

The udev helper is installed as /opt/zfs/bin/zpool_id, but the
corresponding udev rule has a different path:

  # /usr/local/etc/udev/rules.d/60-zpool.rules
  ENV{DEVTYPE}=="disk", IMPORT{program}="/usr/local/bin/zpool_id -d %p"

The @bindir@ variable expands to "${exec_prefix}/bin", so it cannot
be used instead of @prefix@ directly.

This also applies to the zvol_id helper.

Closes #283.

12 years agoHandle /etc/mtab -> /proc/mounts symlink
Brian Behlendorf [Tue, 14 Jun 2011 23:25:29 +0000 (16:25 -0700)]
Handle /etc/mtab -> /proc/mounts symlink

Under Fedora 15 /etc/mtab is now a symlink to /proc/mounts by
default.  When /etc/mtab is a symlink the mount.zfs helper
should not update it.   There was code in place to handle this
case but it used stat() which traverses the link and then issues
the stat on /proc/mounts.  We need to use lstat() to prevent the
link traversal and instead stat /etc/mtab.

Closes #270

12 years agoAlways check -Wno-unused-but-set-variable gcc support
Brian Behlendorf [Tue, 14 Jun 2011 22:09:05 +0000 (15:09 -0700)]
Always check -Wno-unused-but-set-variable gcc support

The previous commit 8a7e1ceefa430988c8f888ca708ab307333b4464 wasn't
quite right.  This check applies to both the user and kernel space
build and as such we must make sure it runs regardless of what
the --with-config option is set too.

For example, if --with-config=kernel then the autoconf test does
not run and we generate build warnings when compiling the kernel
packages.

12 years agoCheck for -Wno-unused-but-set-variable gcc support
Brian Behlendorf [Tue, 14 Jun 2011 18:02:13 +0000 (11:02 -0700)]
Check for -Wno-unused-but-set-variable gcc support

Gcc versions 4.3.2 and earlier do not support the compiler flag
-Wno-unused-but-set-variable.  This can lead to build failures
on older Linux platforms such as Debian Lenny.  Since this is
an optional build argument this changes add a new autoconf check
for the option.  If it is supported by the installed version of
gcc then it is used otherwise it is omited.

See commit's 12c1acde76683108441827ae9affba1872f3afe5 and
79713039a2b6e0ed223d141b4a8a8455f282d2f2 for the reason the
-Wno-unused-but-set-variable options was originally added.

12 years agoAdd default stack checking
Brian Behlendorf [Sun, 12 Jun 2011 05:48:49 +0000 (22:48 -0700)]
Add default stack checking

When your kernel is built with kernel stack tracing enabled and you
have the debugfs filesystem mounted.  Then the zfs.sh script will clear
the worst observed kernel stack depth on module load and check the worst
case usage on module removal.  If the stack depth ever exceeds 7000
bytes the full stack will be printed for debugging.  This is dangerously
close to overrunning the default 8k stack.

This additional advisory debugging is particularly valuable when running
the regression tests on a kernel built with 16k stacks.  In this case,
almost no matter how bad the stack overrun is you will see be able to
get a clean stack trace for debugging.  Since the worst case stack usage
can be highly variable it's helpful to always check the worst case usage.

12 years agoPass -f option for import
Brian Behlendorf [Fri, 10 Jun 2011 18:20:34 +0000 (11:20 -0700)]
Pass -f option for import

If a pool was not cleanly exported passing the -f flag may be required
at 'zpool import' time.  Since this test is simply validating that the
pool can be successfully imported in the absense of the cache file
always pass the -f to ensure it succeeds.  This failure was observed
under RHEL6.1.

12 years agoFix 'zfs send -D' segfault
Brian Behlendorf [Thu, 9 Jun 2011 20:41:55 +0000 (13:41 -0700)]
Fix 'zfs send -D' segfault

Sending pools with dedup results in a segfault due to a Solaris
portability issue.  Under Solaris the pipe(2) library call
creates a bidirectional data channel.  Unfortunately, on Linux
pipe(2) call creates unidirection data channel.  The fix is to
use the socketpair(2) function to create the expected
bidirectional channel.

Seth Heeren did the original leg work on this issue for zfs-fuse.
We finally just rediscovered the same portability issue and
dfurphy was able to point me at the original issue for the fix.

Closes #268

13 years agoSanatize zpios-sanity.sh environment
Brian Behlendorf [Fri, 3 Jun 2011 22:08:49 +0000 (15:08 -0700)]
Sanatize zpios-sanity.sh environment

Just like zconfig.sh the zpios-sanity.sh tests should run in a
sanatized environment.  This ensures they never conflict with an
installed /etc/zfs/zpool.cache file.

This commit additionally improves the -c cleanup option.  It now
removes the modules stack if loaded and destroys relevant md devices.
This behavior is now identical to zconfig.sh.

13 years agoDelay before destroying loopback devices
Brian Behlendorf [Fri, 3 Jun 2011 21:13:25 +0000 (14:13 -0700)]
Delay before destroying loopback devices

Generally I don't approve of just adding an arbitrary delay to
avoid a problem but in this case I'm going to let it slide.  We
may need to delay briefly after 'zpool destroy' returns to ensure
the loopback devices are closed.  If they aren't closed than
losetup -d will not be able to destroy them.  Unfortunately,
there's no easy state the check so we'll have to make due with
a simple delay.

13 years agoAlways unload zpios.ko on exit
Brian Behlendorf [Thu, 2 Jun 2011 17:25:35 +0000 (10:25 -0700)]
Always unload zpios.ko on exit

We should always unload zpios.ko on exit.  This ensures
that subsequent calls to 'zfs.sh -u' from other utilities
will be able to unload the module stack and properly
cleanup.  This is important for the the --cleanup option
which can be passed to zconfig.sh and zfault.sh.

13 years agoFix zpios-sanity.sh return code
Brian Behlendorf [Thu, 2 Jun 2011 17:13:15 +0000 (10:13 -0700)]
Fix zpios-sanity.sh return code

The zpios-sanity.sh script should return failure when any
of the individual zpios.sh tests fail.  The previous code
would always return success suppressing real failures.

13 years agoFix stack ddt_class_contains()
Brian Behlendorf [Wed, 25 May 2011 20:56:40 +0000 (13:56 -0700)]
Fix stack ddt_class_contains()

Stack usage for ddt_class_contains() reduced from 524 bytes to 68
bytes.  This large stack allocation significantly contributed to
the likelyhood of a stack overflow when scrubbing/resilvering
dedup pools.

13 years agoFix stack ddt_zap_lookup()
Brian Behlendorf [Wed, 25 May 2011 21:13:18 +0000 (14:13 -0700)]
Fix stack ddt_zap_lookup()

Stack usage for ddt_zap_lookup() reduced from 368 bytes to 120
bytes.  This large stack allocation significantly contributed to
the likelyhood of a stack overflow when scrubbing/resilvering
dedup pools.

13 years agoRevert "Fix stack traverse_visitbp()"
Brian Behlendorf [Wed, 25 May 2011 23:09:57 +0000 (16:09 -0700)]
Revert "Fix stack traverse_visitbp()"

This abomination is no longer required because the zio's issued
during this recursive call path will now be handled asynchronously
by the taskq thread pool.

This reverts commit 6656bf56216f36805731298ee0f4de87ae6b6b3d.

13 years agoMake tgx_sync_thread zio's async
Brian Behlendorf [Wed, 25 May 2011 22:22:04 +0000 (15:22 -0700)]
Make tgx_sync_thread zio's async

The majority of the recursive operations performed by the dsl
are done either in the context of the tgx_sync_thread or during
pool import.  It is these recursive operations which contribute
greatly to the stack depth.  When this recursion is coupled with
a synchronous I/O in the same context overflow becomes possible.

Previously to handle this case I have focused on keeping the
individual stack frames as light as possible.  This is a good
idea as long as it can be done in a way which doesn't overly
complicate the code.  However, there is a better solution.

If we treat all zio's issued by the tgx_sync_thread as async then
we can use the tgx_sync_thread stack for the recursive parts, and
the zio_* threads for the I/O parts.  This effectively doubles our
available stack space with the only drawback being a small delay
to schedule the I/O.  However, in practice the scheduling time
is so much smaller than the actual I/O time this isn't an issue.
Another benefit of making the zio async is that the zio pipeline
is now parallel.  That should mean for CPU intensive pipelines
such as compression or dedup performance may be improved.

With this change in place the worst case stack usage observed so
far is 6902 bytes.  This is still higher than I'd like but
significantly improved.  Additional changes to specific functions
should improve this further.  This change allows us to revent
commit 6656bf5 which did some horrible things to the recursive
traverse_visitbp() callpath in the name of saving stack.

13 years agoFix 4K sector support
Brian Behlendorf [Thu, 26 May 2011 23:48:16 +0000 (16:48 -0700)]
Fix 4K sector support

Yesterday I ran across a 3TB drive which exposed 4K sectors to
Linux.  While I thought I had gotten this support correct it
turns out there were 2 subtle bugs which prevented it from
working.

  sudo ./cmd/zpool/zpool create -f large-sector /dev/sda
  cannot create 'large-sector': one or more devices is currently unavailable

1) The first issue was that it was possible that bdev_capacity()
would return the number of 512 byte sectors rather than the number
of 4096 sectors.  Internally, certain Linux functions only operate
with 512 byte sectors so you need to be careful.  To avoid any
confusion in the future I've updated bdev_capacity() to simply
return the device (or partition) capacity in bytes.  The higher
levels of ZFS want the value in bytes anyway so this is cleaner.

2) When creating a bio the ->bi_sector count must always be
expressed in 512 byte sectors.  The existing code would scale
the byte offset by the logical sector size.   Until now this was
always 512 so it never caused problems.  Trying a 4K sector drive
clearly exposed the issue.  The problem has been fixed by
hard coding the 512 byte sector which is exactly what the bio
code does internally.

With these changes I'm now able to create ZFS pools using 4K
sector drives.  No issues were observed during fairly extensive
testing.  This is also a low risk change if your using 512b
sectors devices because none of the logic changes.

Closes #256

13 years agoUse vmem_alloc() for zfs_ioc_userspace_many()
Brian Behlendorf [Fri, 20 May 2011 21:23:18 +0000 (14:23 -0700)]
Use vmem_alloc() for zfs_ioc_userspace_many()

The default buffer size when requesting multiple quota entries
is 100 times the zfs_useracct_t size.  In practice this works out
to exactly 27200 bytes.  Since this will be a short lived buffer
in a non-performance critical path it is preferable to vmem_alloc()
the needed memory.

13 years agoDefault to internal 'zfs userspace' implementation
Brian Behlendorf [Fri, 20 May 2011 17:25:41 +0000 (10:25 -0700)]
Default to internal 'zfs userspace' implementation

We will never bring over the pyzfs.py helper script from Solaris
to Linux.  Instead the missing functionality will be directly
integrated in to the zfs commands and libraries.  To avoid
confusion remove the warning about the missing pyzfs.py utility
and simply use the default internal support.

The Illumous developers are of the same mind and have proposed an
initial patch to do this which has been integrated in to the 'allow'
development branch.  After some additional testing this code
can be merged in to master as the right long term solution.

13 years agoPass caller's credential in zfsdev_ioctl()
Brian Behlendorf [Fri, 20 May 2011 17:12:25 +0000 (10:12 -0700)]
Pass caller's credential in zfsdev_ioctl()

Initially when zfsdev_ioctl() was ported to Linux we didn't have
any credential support implemented.  So at the time we simply
passed NULL which wasn't much of a problem since most of the
secpolicy code was disabled.

However, one exception is quota handling which does require the
credential.  Now that proper credentials are supported we can
safely start passing the callers credential.  This is also an
initial step towards fully implemented the zfs secpolicy.

13 years agoFix 'negative objects to delete' warning
Brian Behlendorf [Mon, 9 May 2011 19:18:46 +0000 (12:18 -0700)]
Fix 'negative objects to delete' warning

Normally when the arc_shrinker_func() function is called the return
value should be:

   >=0 - To indicate the number of freeable objects in the cache, or
   -1  - To indicate this cache should be skipped

However, when the shrinker callback is called with 'nr_to_scan' equal
to zero.  The caller simply wants the number of freeable objects in
the cache and we must never return -1.  This patch reorders the
first two conditionals in arc_shrinker_func() to ensure this behavior.

This patch also now explictly casts arc_size and arc_c_min to signed
int64_t types so MAX(x, 0) works as expected.  As unsigned types
we would never see an negative value which defeated the purpose of
the MAX() lower bound and broke the shrinker logic.

Finally, when nr_to_scan is non-zero we explictly prevent all reclaim
below arc_c_min.  This is done to prevent the Linux page cache from
completely crowding out the ARC.  This limit is tunable and some
experimentation is likely going to be required to set it exactly right.
For now we're sticking with the OpenSolaris defaults.

Closes #218
Closes #243

13 years agoFix distribution detection for gentoo
Alexey Shvetsov [Sat, 14 May 2011 14:25:37 +0000 (18:25 +0400)]
Fix distribution detection for gentoo

Also this may fix other distros because some of them also provide
/etc/lsb-release not only ubuntu.

Closes #244

13 years agoUpdate synchronous open zfs_close() comment
Brian Behlendorf [Fri, 13 May 2011 15:16:10 +0000 (08:16 -0700)]
Update synchronous open zfs_close() comment

The comment in zfs_close() pertaining to decrementing the synchronous
open count needs to be updated for Linux.  The code was already
updated to be correct, but the comment was missed and is now misleading.
Under Linux the zfs_close() hook is only called once when the final
reference is dropped.  This differs from Solaris where zfs_close()
is called for each close.

Closes #237

13 years agoRemove root 'ls' after mount workaround
Alexey Shvetsov [Thu, 12 May 2011 21:54:03 +0000 (14:54 -0700)]
Remove root 'ls' after mount workaround

This workaround was introduced to workaround issue #164.  This
issue was fixed by commit 5f35b19 so the workaround can be safely
dropped from both the zfs.fedora and zfs.gentoo init scripts.

13 years agoFix zfs.gentoo init script logic
Alexey Shvetsov [Tue, 10 May 2011 20:22:35 +0000 (00:22 +0400)]
Fix zfs.gentoo init script logic

* Fix zfs.ko module check
* Check 'zfs umount -a' return value

13 years agoMake zfs.gentoo init script more gentoo style.
Alexey Shvetsov [Tue, 10 May 2011 19:45:19 +0000 (23:45 +0400)]
Make zfs.gentoo init script more gentoo style.

* Improved compatibility with openrc
* Removed LOCKFILE
* Improved checksystem() function
* Remove /etc/mtab check for /
* General cleanup

13 years agoMerge pull request #235 from nedbass/rdev
Brian Behlendorf [Mon, 9 May 2011 23:41:28 +0000 (16:41 -0700)]
Merge pull request #235 from nedbass/rdev

Don't store rdev in SA for FIFOs and sockets

13 years agoDon't store rdev in SA for FIFOs and sockets
Ned A. Bass [Mon, 9 May 2011 19:31:56 +0000 (12:31 -0700)]
Don't store rdev in SA for FIFOs and sockets

Update the handling of named pipes and sockets to be consistent with
other platforms with regard to the rdev attribute.  While all ZFS
ipmlementations store the rdev for device files in a system attribute
(SA), this is not the case for FIFOs and sockets.  Indeed, Linux always
passes rdev=0 to mknod() for FIFOs and sockets, so the value is not
needed.  Add an ASSERT that rdev==0 for FIFOs and sockets to detect if
the expected behavior ever changes.

Closes #216

13 years agoDisable direct reclaim for z_wr_* threads
Brian Behlendorf [Fri, 6 May 2011 22:12:15 +0000 (15:12 -0700)]
Disable direct reclaim for z_wr_* threads

The direct reclaim path in the z_wr_* threads must be disabled
to ensure forward progress is always maintained for txg processing.
This ensures that a txg will never get stuck waiting on itself
because it entered the following memory reclaim callpath.

  ->prune_icache()->dispose_list()->zpl_clear_inode()->zfs_inactive()
  ->dmu_tx_assign()->dmu_tx_wait()->tgx_wait_open()

It would be preferable to target this exact code path but the
kernel offers no way to do this without custom patches.  To avoid
this we are forced to disable all reclaim for these threads.  It
should not be necessary to do this for other other z_* threads
because they will not hold a txg open.

Closes #232

13 years agoHandle NULL in nfsd .fsync() hook
Brian Behlendorf [Fri, 6 May 2011 19:23:34 +0000 (12:23 -0700)]
Handle NULL in nfsd .fsync() hook

How nfsd handles .fsync() has been changed a couple of times in the
recent kernels.  But basically there are three cases we need to
consider.

Linux 2.6.12 - 2.6.33
* The .fsync() hook takes 3 arguments
* The nfsd will call .fsync() with a NULL file struct pointer.

Linux 2.6.34
* The .fsync() hook takes 3 arguments
* The nfsd no longer calls .fsync() but instead used sync_inode()

Linux 2.6.35 - 2.6.x
* The .fsync() hook takes 2 arguments
* The nfsd no longer calls .fsync() but instead used sync_inode()

For once it looks like we've gotten lucky.  The first two cases can
actually be collased in to one if we stop using the file struct
pointer entirely.  Since the dentry is still passed in both cases
this is possible.  The last case can then be safely handled by
unconditionally using the dentry in the file struct pointer now
that we know the nfsd caller has been removed.

Closes #230

13 years agoFix awk usage
Brian Behlendorf [Fri, 6 May 2011 17:16:04 +0000 (10:16 -0700)]
Fix awk usage

The zpool_id and zpool_layout helper scripts have been updated to
use the more common /usr/bin/awk symlink.  On Fedora/Redhat systems
there are both /bin/awk and /usr/bin/awk symlinks to your installed
version of awk.  On Debian/Ubuntu systems only the /usr/bin/awk
symlink exists.

Additionally, add the '\<' token to the beginning of the regex
pattern to prevent partial matches.  This pattern only appears to
work with gawk despite the mawk man page claiming to support this
extended regex.  Thus you will need to have gawk installed to use
these optional helper scripts.  A comment has been added to the
script to reflect this reality.

13 years agoUse vmem_alloc() for zfs_ioc_pool_get_history()
Brian Behlendorf [Fri, 6 May 2011 16:59:52 +0000 (09:59 -0700)]
Use vmem_alloc() for zfs_ioc_pool_get_history()

The default buffer size when requesting history is 128k.  This
is far to large for a kmem_alloc() so instead use the slower
vmem_alloc().  This path has no performance concerns and the
buffer is immediately free'd after its contents are copied to
the user space buffer.

13 years agoAllow mounting of read-only snapshots
Brian Behlendorf [Thu, 5 May 2011 16:40:57 +0000 (09:40 -0700)]
Allow mounting of read-only snapshots

With the addition of the mount helper we accidentally regressed
the ability to manually mount snapshots.  This commit updates
the mount helper to expect the possibility of a ZFS_TYPE_SNAPSHOT.
All snapshot will be automatically treated as 'legacy' type mounts
so they can be mounted manually.

13 years agoAdd missing ZFS tunables
Brian Behlendorf [Tue, 3 May 2011 22:09:28 +0000 (15:09 -0700)]
Add missing ZFS tunables

This commit adds module options for all existing zfs tunables.
Ideally the average user should never need to modify any of these
values.  However, in practice sometimes you do need to tweak these
values for one reason or another.  In those cases it's nice not to
have to resort to rebuilding from source.  All tunables are visable
to modinfo and the list is as follows:

$ modinfo module/zfs/zfs.ko
filename:       module/zfs/zfs.ko
license:        CDDL
author:         Sun Microsystems/Oracle, Lawrence Livermore National Laboratory
description:    ZFS
srcversion:     8EAB1D71DACE05B5AA61567
depends:        spl,znvpair,zcommon,zunicode,zavl
vermagic:       2.6.32-131.0.5.el6.x86_64 SMP mod_unload modversions
parm:           zvol_major:Major number for zvol device (uint)
parm:           zvol_threads:Number of threads for zvol device (uint)
parm:           zio_injection_enabled:Enable fault injection (int)
parm:           zio_bulk_flags:Additional flags to pass to bulk buffers (int)
parm:           zio_delay_max:Max zio millisec delay before posting event (int)
parm:           zio_requeue_io_start_cut_in_line:Prioritize requeued I/O (bool)
parm:           zil_replay_disable:Disable intent logging replay (int)
parm:           zfs_nocacheflush:Disable cache flushes (bool)
parm:           zfs_read_chunk_size:Bytes to read per chunk (long)
parm:           zfs_vdev_max_pending:Max pending per-vdev I/Os (int)
parm:           zfs_vdev_min_pending:Min pending per-vdev I/Os (int)
parm:           zfs_vdev_aggregation_limit:Max vdev I/O aggregation size (int)
parm:           zfs_vdev_time_shift:Deadline time shift for vdev I/O (int)
parm:           zfs_vdev_ramp_rate:Exponential I/O issue ramp-up rate (int)
parm:           zfs_vdev_read_gap_limit:Aggregate read I/O over gap (int)
parm:           zfs_vdev_write_gap_limit:Aggregate write I/O over gap (int)
parm:           zfs_vdev_scheduler:I/O scheduler (charp)
parm:           zfs_vdev_cache_max:Inflate reads small than max (int)
parm:           zfs_vdev_cache_size:Total size of the per-disk cache (int)
parm:           zfs_vdev_cache_bshift:Shift size to inflate reads too (int)
parm:           zfs_scrub_limit:Max scrub/resilver I/O per leaf vdev (int)
parm:           zfs_recover:Set to attempt to recover from fatal errors (int)
parm:           spa_config_path:SPA config file (/etc/zfs/zpool.cache) (charp)
parm:           zfs_zevent_len_max:Max event queue length (int)
parm:           zfs_zevent_cols:Max event column width (int)
parm:           zfs_zevent_console:Log events to the console (int)
parm:           zfs_top_maxinflight:Max I/Os per top-level (int)
parm:           zfs_resilver_delay:Number of ticks to delay resilver (int)
parm:           zfs_scrub_delay:Number of ticks to delay scrub (int)
parm:           zfs_scan_idle:Idle window in clock ticks (int)
parm:           zfs_scan_min_time_ms:Min millisecs to scrub per txg (int)
parm:           zfs_free_min_time_ms:Min millisecs to free per txg (int)
parm:           zfs_resilver_min_time_ms:Min millisecs to resilver per txg (int)
parm:           zfs_no_scrub_io:Set to disable scrub I/O (bool)
parm:           zfs_no_scrub_prefetch:Set to disable scrub prefetching (bool)
parm:           zfs_txg_timeout:Max seconds worth of delta per txg (int)
parm:           zfs_no_write_throttle:Disable write throttling (int)
parm:           zfs_write_limit_shift:log2(fraction of memory) per txg (int)
parm:           zfs_txg_synctime_ms:Target milliseconds between tgx sync (int)
parm:           zfs_write_limit_min:Min tgx write limit (ulong)
parm:           zfs_write_limit_max:Max tgx write limit (ulong)
parm:           zfs_write_limit_inflated:Inflated tgx write limit (ulong)
parm:           zfs_write_limit_override:Override tgx write limit (ulong)
parm:           zfs_prefetch_disable:Disable all ZFS prefetching (int)
parm:           zfetch_max_streams:Max number of streams per zfetch (uint)
parm:           zfetch_min_sec_reap:Min time before stream reclaim (uint)
parm:           zfetch_block_cap:Max number of blocks to fetch at a time (uint)
parm:           zfetch_array_rd_sz:Number of bytes in a array_read (ulong)
parm:           zfs_pd_blks_max:Max number of blocks to prefetch (int)
parm:           zfs_dedup_prefetch:Enable prefetching dedup-ed blks (int)
parm:           zfs_arc_min:Min arc size (ulong)
parm:           zfs_arc_max:Max arc size (ulong)
parm:           zfs_arc_meta_limit:Meta limit for arc size (ulong)
parm:           zfs_arc_reduce_dnlc_percent:Meta reclaim percentage (int)
parm:           zfs_arc_grow_retry:Seconds before growing arc size (int)
parm:           zfs_arc_shrink_shift:log2(fraction of arc to reclaim) (int)
parm:           zfs_arc_p_min_shift:arc_c shift to calc min/max arc_p (int)

13 years agoPrep zfs-0.6.0-rc4 tag
Brian Behlendorf [Tue, 3 May 2011 17:29:05 +0000 (10:29 -0700)]
Prep zfs-0.6.0-rc4 tag

Create the fourth 0.6.0 release candidate tag (rc4).

13 years agoAdd Gentoo/Lunar/Redhat Init Scripts
Brian Behlendorf [Mon, 2 May 2011 22:39:59 +0000 (15:39 -0700)]
Add Gentoo/Lunar/Redhat Init Scripts

Every distribution has slightly different requirements for their
init scripts.  Because of this the zfs package contains several
init scripts for various distributions.  These scripts have been
contributed by, and are supported by, the larger zfs community.
Init scripts for Gentoo/Lunar/Redhat have been contributed by:

  Gentoo - devsk <devsku@gmail.com>
  Lunar  - Jean-Michel Bruenn <jean.bruenn@ip-minds.de>
  Redhat - Fajar A. Nugraha <list@fajar.net>

13 years agoFully update inode when created
Brian Behlendorf [Mon, 2 May 2011 21:04:19 +0000 (14:04 -0700)]
Fully update inode when created

When a new znode/inode pair is created both the znode and the inode
should be immediately updated to the correct values.  This was done
for the znode and for most of the values in the inode, but not all
of them.  This normally wasn't a problem because most subsequent
operations would cause the inode to be immediately updated.  This
change ensures the inode is now fully updated before it is inserted
in to the inode hash.

Closes #116
Closes #146
Closes #164

13 years agoFix 'zfs set volsize=N pool/dataset'
Brian Behlendorf [Fri, 25 Feb 2011 07:36:01 +0000 (14:36 +0700)]
Fix 'zfs set volsize=N pool/dataset'

This change fixes a kernel panic which would occur when resizing
a dataset which was not open.  The objset_t stored in the
zvol_state_t will be set to NULL when the block device is closed.
To avoid this issue we pass the correct objset_t as the third arg.

The code has also been updated to correctly notify the kernel
when the block device capacity changes.  For 2.6.28 and newer
kernels the capacity change will be immediately detected.  For
earlier kernels the capacity change will be detected when the
device is next opened.  This is a known limitation of older
kernels.

Online ext3 resize test case passes on 2.6.28+ kernels:
$ dd if=/dev/zero of=/tmp/zvol bs=1M count=1 seek=1023
$ zpool create tank /tmp/zvol
$ zfs create -V 500M tank/zd0
$ mkfs.ext3 /dev/zd0
$ mkdir /mnt/zd0
$ mount /dev/zd0 /mnt/zd0
$ df -h /mnt/zd0
$ zfs set volsize=800M tank/zd0
$ resize2fs /dev/zd0
$ df -h /mnt/zd0

Original-patch-by: Fajar A. Nugraha <github@fajar.net>
Closes #68
Closes #84

13 years agoAdd zpl_export.c to the list of targets.
Alejandro R. Sedeño [Sat, 30 Apr 2011 02:13:23 +0000 (22:13 -0400)]
Add zpl_export.c to the list of targets.

13 years agoCorrect MAXUID
Brian Behlendorf [Fri, 29 Apr 2011 21:03:12 +0000 (14:03 -0700)]
Correct MAXUID

The uid_t on most systems is in fact and unsigned 32-bit value.
This is almost always correct, however you could compile your
kernel to use an unsigned 16-bit value for uid_t.  In practice
I've never encountered a distribution which does this so I'm
willing to overlook this corner case for now.

Closes #165

13 years agoImplemented NFS export_operations.
Gunnar Beutner [Thu, 28 Apr 2011 16:35:50 +0000 (18:35 +0200)]
Implemented NFS export_operations.

Implemented the required NFS operations for exporting ZFS datasets
using the in-kernel NFS daemon.

13 years agoSuppress 'vdev_metaslab_init' memory warning
Brian Behlendorf [Wed, 27 Apr 2011 16:32:51 +0000 (09:32 -0700)]
Suppress 'vdev_metaslab_init' memory warning

The vdev_metaslab_init() function has been observed to allocate
larger than 8k chunks.  However, they are not much larger than 8k
and it does this infrequently so it is allowed and the warning is
supressed.

13 years agoConserve stack in dsl_scan_visit()
Brian Behlendorf [Tue, 26 Apr 2011 21:56:04 +0000 (14:56 -0700)]
Conserve stack in dsl_scan_visit()

The dsl_scan_visit() function is a little heavy weight taking 464
bytes on the stack.  This can be easily reduced for little cost by
moving zap_cursor_t and zap_attribute_t off the stack and on to the
heap.  After this change dsl_scan_visit() has been reduced in size
by 320 bytes.

This change was made to reduce stack usage in the dsl_scan_sync()
callpath which is recursive and has been observed to overflow the
stack.

Issue #174

13 years agoConserve stack in dsl_scan_visitbp()
Brian Behlendorf [Tue, 26 Apr 2011 22:43:07 +0000 (15:43 -0700)]
Conserve stack in dsl_scan_visitbp()

This function is called recursively so everything possible must be
done to limit its stack consumption.  The dprintf_bp() debugging
function adds 30 bytes of local variables to the function we cannot
afford.  By commenting out this debugging we save 30 bytes per
recursion and depths of 13 are not uncommon.  This yeilds a total
stack saving of 390 bytes on our 8k stack.

Issue #174

13 years agoConserve stack in dsl_scan_visitbp()
Brian Behlendorf [Fri, 22 Apr 2011 17:12:49 +0000 (10:12 -0700)]
Conserve stack in dsl_scan_visitbp()

The recursive call chain dsl_scan_visitbp() -> dsl_scan_recurse() ->
dsl_scan_visitdnode() -> dsl_scan_visitbp has been observed to consume
considerable stack resulting in a stack overflow (>8k).  The cleanest
way I see to fix this with minimal impact to the existing flow of
code, and with the fewest performance concerns, is to always inline
dsl_scan_recurse() and dsl_scan_visitdnode().  While this will increase
the function size of dsl_scan_visitbp(), by 4660 bytes, it also reduces
the stack requirements by removing the function call overhead.

Issue #174

13 years agoMerged pull request #212 from dajhorn/hostid.
Brian Behlendorf [Tue, 26 Apr 2011 20:30:27 +0000 (13:30 -0700)]
Merged pull request #212 from dajhorn/hostid.

Use gethostid in the Linux convention.

13 years agoFix zvol deadlock
Brian Behlendorf [Tue, 26 Apr 2011 19:56:35 +0000 (12:56 -0700)]
Fix zvol deadlock

It's possible for a zvol_write thread to enter direct memory reclaim
while holding open a transaction group.  This results in the system
attempting to write out data to the disk to free memory.  Unfortunately,
this can't succeed because the the thread doing reclaim is holding open
the txg which must be closed to be synced to disk.  To prevent this
the offending allocation is marked KM_PUSHPAGE which will prevent it
from attempting writeback.

Closes #191

13 years agoUse gethostid in the Linux convention.
Darik Horn [Mon, 25 Apr 2011 15:18:07 +0000 (10:18 -0500)]
Use gethostid in the Linux convention.

Disable the gethostid() override for Solaris behavior because Linux systems
implement the POSIX standard in a way that allows a negative result.

Mask the gethostid() result to the lower four bytes, like coreutils does in
/usr/bin/hostid, to prevent junk bits or sign-extension on systems that have an
eight byte long type. This can cause a spurious hostid mismatch that prevents
zpool import on 64-bit systems.

13 years agoFix 32-bit MAXOFFSET_T definition
Brian Behlendorf [Fri, 22 Apr 2011 23:21:26 +0000 (16:21 -0700)]
Fix 32-bit MAXOFFSET_T definition

Having MAXOFFSET_T defined to 0x7fffffffl was artificially limiting
the maximum file size on 32-bit systems.  In reality MAXOFFSET_T is
used when working with 'long long' types and as such we now define
it as LLONG_MAX.  This resolves the 2GB file size limit for files
and additionally allows zvols greater than 2GB on 32-bit systems.

Closes #136
Closes #81

13 years agoFix spurious -EFAULT when setting I/O scheduler
Brian Behlendorf [Fri, 22 Apr 2011 20:50:17 +0000 (13:50 -0700)]
Fix spurious -EFAULT when setting I/O scheduler

Occasionally we would see an -EFAULT returned when setting the
I/O scheduler on a vdev.  This was caused an improperly formatted
user mode helper command.

This commit restructures the command to something simpler, allocates
space for it dynamically to save stack, and removes the retry logic
which is no longer needed.

Closes #169

13 years agoEnforce ARC meta-data limits
Brian Behlendorf [Thu, 31 Mar 2011 01:59:17 +0000 (18:59 -0700)]
Enforce ARC meta-data limits

This change ensures the ARC meta-data limits are enforced.  Without
this enforcement meta-data can grow to consume all of the ARC cache
pushing out data and hurting performance.  The cache is aggressively
reclaimed but this is a soft and not a hard limit.  The cache may
exceed the set limit briefly before being brought under control.

By default 25% of the ARC capacity can be used for meta-data.  This
limit can be tuned by setting the 'zfs_arc_meta_limit' module option.
Once this limit is exceeded meta-data reclaim will occur in 3 percent
chunks, or may be tuned using 'arc_reduce_dnlc_percent'.

Closes #193

13 years agoFixed a use-after-free bug in zfs_zget().
Gunnar Beutner [Thu, 14 Apr 2011 20:07:24 +0000 (22:07 +0200)]
Fixed a use-after-free bug in zfs_zget().

Fixed a bug where zfs_zget could access a stale znode pointer when
the inode had already been removed from the inode cache via iput ->
iput_final -> ... -> zfs_zinactive but the corresponding SA handle
was still alive.

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

13 years agoSuppress 'zfs receive' memory warning
Brian Behlendorf [Wed, 20 Apr 2011 17:18:56 +0000 (10:18 -0700)]
Suppress 'zfs receive' memory warning

As part of zfs_ioc_recv() a zfs_cmd_t is allocated in the kernel
which is 17808 bytes in size.  This sort of thing in general should
be avoided.  However, since this should be an infrequent event for
now we allow it and simply suppress the warning with the KM_NODEBUG
flag.  This can be revisited latter if/when it becomes an issue.

Closes #178

13 years agoAdded required runlevel info for init on Debian
Aniruddha Shankar [Wed, 20 Apr 2011 00:45:21 +0000 (06:15 +0530)]
Added required runlevel info for init on Debian

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

13 years agoUpdate zconfig.sh to use new zvol names
Brian Behlendorf [Tue, 19 Apr 2011 23:14:15 +0000 (16:14 -0700)]
Update zconfig.sh to use new zvol names

This change should have occured when we commited the new udev
rules for zvols.  Basically, the test script is just out of date.
We need to update it to use the /dev/zvol/ device names, and
to expect the more common -partN suffixes.

I added a udev_trigger() call in zconfig_partition() and
zconfig_zvol_device_stat() to ensure that all the udev rules have
run before.  This ensures the devices are available to subsequent
commands and closes a small race.

Finally, I was forced added a small 'sleep 1' to test 10.  I
was observing occassional failures in my VM due to the device
still claiming to be busy.  Delaying betwen the various methods
of adding/removing a vdev avoids the issue.

Closes #207

13 years agoAdd parted and lsscsi dependencies to zfs-test
Brian Behlendorf [Tue, 19 Apr 2011 22:01:37 +0000 (15:01 -0700)]
Add parted and lsscsi dependencies to zfs-test

The zfault.sh and zconfig.sh test scripts requires the parted
utility, the lsscsi utility, and the scsi_debug module.  To
ensure the utilities are available they have been added as
dependencies to zfs-test package.  Checking for scsi_debug
is a little more problematic because if it's missing you will
need to build it.  For clarity the documention has been updated
to mention this.

Closes #205
Closes #206

13 years agoAdd Gunnar Beutner to AUTHORS for his contributions
Brian Behlendorf [Tue, 19 Apr 2011 21:12:08 +0000 (14:12 -0700)]
Add Gunnar Beutner to AUTHORS for his contributions

13 years agoTruncate the xattr znode when updating existing attributes.
Gunnar Beutner [Sun, 17 Apr 2011 18:31:33 +0000 (20:31 +0200)]
Truncate the xattr znode when updating existing attributes.

If the attribute's new value was shorter than the old one the old
code would leave parts of the old value in the xattr znode.

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

13 years agoAdded missing initialization for va.va_dentry in zfs_get_xattrdir.
Gunnar Beutner [Sun, 17 Apr 2011 17:42:33 +0000 (19:42 +0200)]
Added missing initialization for va.va_dentry in zfs_get_xattrdir.

Without this we may mistakenly believe we have a dentry and try to
d_instantiate() it.  This will result in the following BUG.  It's
important to note that while the xattr directory has an inode
assoicated with it we never create a dentry for it.

  kernel BUG at fs/dcache.c:1418!

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

13 years agoSupport IEC base-2 prefixes
Richard Laager [Sun, 10 Apr 2011 23:08:53 +0000 (18:08 -0500)]
Support IEC base-2 prefixes

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoCleanup various Sun/Solaris-isms
Richard Laager [Sat, 9 Apr 2011 03:54:47 +0000 (22:54 -0500)]
Cleanup various Sun/Solaris-isms

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoUpdate the version in the zpool upgrade example
Richard Laager [Sat, 9 Apr 2011 03:51:04 +0000 (22:51 -0500)]
Update the version in the zpool upgrade example

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoNormalize the deferred destruction language
Richard Laager [Sat, 9 Apr 2011 03:47:11 +0000 (22:47 -0500)]
Normalize the deferred destruction language

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoImprove the wording about hot spares
Richard Laager [Sat, 9 Apr 2011 03:41:40 +0000 (22:41 -0500)]
Improve the wording about hot spares

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoImprove some quoting consistency
Richard Laager [Sat, 9 Apr 2011 03:39:36 +0000 (22:39 -0500)]
Improve some quoting consistency

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoRemove a stray tab
Richard Laager [Sat, 9 Apr 2011 03:37:37 +0000 (22:37 -0500)]
Remove a stray tab

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoLinux has "partitions", not "slices"
Richard Laager [Sat, 9 Apr 2011 03:34:37 +0000 (22:34 -0500)]
Linux has "partitions", not "slices"

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoUse Linux disk names in zpool.8
Richard Laager [Sat, 9 Apr 2011 03:27:25 +0000 (22:27 -0500)]
Use Linux disk names in zpool.8

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoMore and correct an example in zpool.8
Richard Laager [Sat, 9 Apr 2011 02:54:05 +0000 (21:54 -0500)]
More and correct an example in zpool.8

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoChange /dev/dsk -> /dev in the man pages
Richard Laager [Sat, 9 Apr 2011 02:45:13 +0000 (21:45 -0500)]
Change /dev/dsk -> /dev in the man pages

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoCorrect man page section numbers for Linux
Richard Laager [Sat, 9 Apr 2011 02:31:11 +0000 (21:31 -0500)]
Correct man page section numbers for Linux

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoSet -Wno-unused-but-set-variable globally
Brian Behlendorf [Tue, 19 Apr 2011 17:39:31 +0000 (10:39 -0700)]
Set -Wno-unused-but-set-variable globally

As of gcc-4.6 the option -Wunused-but-set-variable is enabled by
default.  While this is a useful warning there are numerous places
in the ZFS code when a variable is set and then only checked in an
ASSERT().  To avoid having to update every instance of this in the
code we now set -Wno-unused-but-set-variable to suppress the warning.

Additionally, when building with --enable-debug and -Werror set these
warning also become fatal.  We can reevaluate the suppression of these
error at a later time if it becomes an issue.  For now we are basically
just reverting to the previous gcc behavior.

13 years agoFix gcc configure warnings
Brian Behlendorf [Tue, 19 Apr 2011 17:02:21 +0000 (10:02 -0700)]
Fix gcc configure warnings

Newer versions of gcc are getting smart enough to detect the sloppy
syntax used for the autoconf tests.  It is now generating warnings
for unused/undeclared variables.  Newer version of gcc even have
the -Wunused-but-set-variable option set by default.  This isn't a
problem except when -Werror is set and they get promoted to an error.
In this case the autoconf test will return an incorrect result which
will result in a build failure latter on.

To handle this I'm tightening up many of the autoconf tests to
explicitly mark variables as unused to suppress the gcc warning.
Remember, all of the autoconf code can never actually be run we
just want to get a clean build error to detect which APIs are
available.  Never using a variable is absolutely fine for this.

Closes #176

13 years agoFix gcc compiler warning, parse_option()
Brian Behlendorf [Mon, 18 Apr 2011 23:44:22 +0000 (16:44 -0700)]
Fix gcc compiler warning, parse_option()

When compiling ZFS in user space gcc-4.6.0 correctly identifies
the variable 'value' as being set but never used.  This generates a
warning and a build failure when using --enable-debug.  Once again
this is correct but I'm reluctant to remove 'value' because we are
breaking the string in to name/value pairs.  While it is not used
now there's a good chance it will be soon and I'd rather not have
to reinvent this.  To suppress the warning with just as a VERIFY().
This was observed under Fedora 15.

  cmd/mount_zfs/mount_zfs.c: In function ‘parse_option’:
  cmd/mount_zfs/mount_zfs.c:112:21: error: variable ‘value’ set but not
  used [-Werror=unused-but-set-variable]

13 years agoFix gcc compiler warning, dsl_pool_create()
Brian Behlendorf [Mon, 18 Apr 2011 23:27:45 +0000 (16:27 -0700)]
Fix gcc compiler warning, dsl_pool_create()

When compiling ZFS in user space gcc-4.6.0 correctly identifies
the variable 'os' as being set but never used.  This generates a
warning and a build failure when using --enable-debug.  However,
the code is correct we only want to use 'os' for the kernel space
builds.  To suppress the warning the call was wrapped with a
VERIFY() which has the nice side effect of ensuring the 'os'
actually never is NULL.  This was observed under Fedora 15.

  module/zfs/dsl_pool.c: In function ‘dsl_pool_create’:
  module/zfs/dsl_pool.c:229:12: error: variable ‘os’ set but not used
  [-Werror=unused-but-set-variable]

13 years agoLinux 2.6.39 compat, invalidate_inodes()
Brian Behlendorf [Mon, 18 Apr 2011 21:12:28 +0000 (14:12 -0700)]
Linux 2.6.39 compat, invalidate_inodes()

Update code to use the spl_invalidate_inodes() wrapper.  This hides
some of the complexity of determining if invalidate_inodes() was
exported, and if so what is its prototype.  The second argument
of spl_invalidate_inodes() determined the behavior of how dirty
inodes are handled.  By passing a zero we are indicated that we
want those inodes to be treated as busy and skipped.

13 years agoAutogen refresh for kernel-insert-inode-locked.m4
Brian Behlendorf [Mon, 18 Apr 2011 19:48:44 +0000 (12:48 -0700)]
Autogen refresh for kernel-insert-inode-locked.m4

Several Makefile.in's were accidentally not updated when the
kernel-insert-inode-locked.m4 check was added.  This change simply
refreshes the missed files.

13 years agoFix rebuildable RPMs for el6/ch5
Brian Behlendorf [Fri, 8 Apr 2011 17:22:42 +0000 (10:22 -0700)]
Fix rebuildable RPMs for el6/ch5

When rebuilding the source RPM under el5 you need to append the
target_cpu.  However, under el6/ch5 things are packaged correctly
and the arch is already part of kver.  For this reason it also
needs to be stripped from kver when setting kverpkg.

13 years agoAlign closing fi in mount-zfs.sh
Ned Bass [Fri, 8 Apr 2011 16:41:41 +0000 (09:41 -0700)]
Align closing fi in mount-zfs.sh

13 years agoUse consistent indentation in mount-zfs.sh
Ned Bass [Thu, 7 Apr 2011 20:45:57 +0000 (13:45 -0700)]
Use consistent indentation in mount-zfs.sh

13 years agoFix a couple comments
Richard Laager [Thu, 7 Apr 2011 06:47:02 +0000 (23:47 -0700)]
Fix a couple comments

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoLinux 2.6.29 compat, credentials
Brian Behlendorf [Thu, 7 Apr 2011 21:23:45 +0000 (14:23 -0700)]
Linux 2.6.29 compat, credentials

The .sync_fs fix as applied did not use the updated SPL credential
API.  This broke builds on Debian Lenny, this change applies the
needed fix to use the portable API.  The original credential changes
are part of commit 81e97e21872a9c38ad66c37fafe1436ee25abee3.

13 years agoPrep zfs-0.6.0-rc3 tag
Brian Behlendorf [Thu, 7 Apr 2011 17:49:55 +0000 (10:49 -0700)]
Prep zfs-0.6.0-rc3 tag

Create the third 0.6.0 release candidate tag (rc3).

13 years agoUpdate zfs.fedora init script
Manuel Amador (Rudd-O) [Thu, 7 Apr 2011 17:34:20 +0000 (10:34 -0700)]
Update zfs.fedora init script

Apply all of Rudd-O's changes for the Fedora init script.  The
initial init script was one I threw together based on Rudd-O's
original work.  It worked for me but it has some flaws.

Rudd-O has invested considerable time updating it to be significantly
smarter.  It now handles using ZFS as your root filesystem plus
various other quirks.  Since he is familiar with the right
way to do things on Fedora and has tested this init script we
are integrating all of his changes.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoPermit both mountpoint=legacy and mountpoint=/ in initrd
Manuel Amador (Rudd-O) [Wed, 6 Apr 2011 16:52:58 +0000 (09:52 -0700)]
Permit both mountpoint=legacy and mountpoint=/ in initrd

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoAdded .gitignore for mount.zfs and zvol_id
Manuel Amador (Rudd-O) [Wed, 23 Mar 2011 05:18:07 +0000 (22:18 -0700)]
Added .gitignore for mount.zfs and zvol_id

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoFix ASSERTION(!dsl_pool_sync_context(tx->tx_pool))
Brian Behlendorf [Thu, 31 Mar 2011 17:05:58 +0000 (10:05 -0700)]
Fix ASSERTION(!dsl_pool_sync_context(tx->tx_pool))

Disable the normal reclaim path for the txg_sync thread.  This
ensures the thread will never enter dmu_tx_assign() which can
otherwise occur due to direct reclaim.  If this is allowed to
happen the system can deadlock.  Direct reclaim call path:

  ->shrink_icache_memory->prune_icache->dispose_list->
  clear_inode->zpl_clear_inode->zfs_inactive->dmu_tx_assign

13 years agoAdd direct+indirect ARC reclaim
Brian Behlendorf [Wed, 30 Mar 2011 01:08:59 +0000 (18:08 -0700)]
Add direct+indirect ARC reclaim

Under OpenSolaris all memory reclaim is done asyncronously.  Under
Linux memory reclaim is done asynchronously _and_ synchronously.
When a process allocates memory with GFP_KERNEL it explicitly allows
the kernel to do reclaim on its behalf to satify the allocation.
If that GFP_KERNEL allocation fails the kernel may take more drastic
measures to reclaim the memory such as killing user space processes.

This was observed to happen with ZFS because the ARC could consume
a large fraction of the system memory but no synchronous reclaim
could be performed on it.  The result was GFP_KERNEL allocations
could fail resulting in OOM events, and only moments latter the
arc_reclaim thread would free unused memory from the ARC.

This change leaves the arc_thread in place to manage the fundamental
ARC behavior.  But it adds a synchronous (direct) reclaim path for
the ARC which can be called when memory is badly needed.  It also
adds an asynchronous (indirect) reclaim path which is called
much more frequently to prune the ARC slab caches.

13 years agoAdd missing arcstats
Brian Behlendorf [Thu, 24 Mar 2011 19:13:55 +0000 (12:13 -0700)]
Add missing arcstats

The following useful values were missing the arcstats.  This change
adds them in to provide greater visibility in to the arcs behavior.

arc_no_grow                     4    0
arc_tempreserve                 4    0
arc_loaned_bytes                4    0
arc_meta_used                   4    624774592
arc_meta_limit                  4    400785408
arc_meta_max                    4    625594176

13 years agoCall d_instantiate before unlocking inode
Brian Behlendorf [Wed, 30 Mar 2011 06:04:39 +0000 (23:04 -0700)]
Call d_instantiate before unlocking inode

Under Linux a dentry referencing an inode must be instantiated before
the inode is unlocked.  To accomplish this without overly modifing
the core ZFS code the dentry it passed via the vattr_t.  There are
cases such as replay when a dentry is not available.  In which case
it is obviously not initialized at inode creation time, if a dentry
is needed it will be spliced as when required via d_lookup().

13 years agoFix `make distclean` for `./configure --with-config=user
Brian Behlendorf [Tue, 5 Apr 2011 20:13:01 +0000 (13:13 -0700)]
Fix `make distclean` for `./configure --with-config=user

    Making distclean in module
    make[1]: Entering directory `/zfs/module'
    make -C  SUBDIRS=`pwd`  clean
    make: Entering an unknown directory
    make: *** SUBDIRS=/zfs/module: No such file or directory.  Stop.

When using --with-config=user the 'distclean' target would fail
because it assumes the kernel configuration infrastrure is set up.
This is not the case, nor does it need to be, because the
'--with-config=user' option will prune the entire ./module subtree
from SUBDIRS.  This prevents most build rules from operating in the
./module directory.

However, the 'dist*' rules will still traverse this directory
because it is listed in DIST_SUBDIRS.  This is correct because we
need to ensure the dist rules package the directory contents
regardless of the configuration for the 'dist' rule.  The correct
way to handle this is to only invoke the kernel build system as
part of the 'clean' rule when CONFIG_KERNEL_TRUE is set.

Initial fix provided by Darik Horn <dajhorn@vanadac.com>.
This commit is a slightly refined form of the original.

13 years agoCall udevadm trigger more safely
Ned Bass [Fri, 1 Apr 2011 16:47:05 +0000 (09:47 -0700)]
Call udevadm trigger more safely

Some udev hooks are not designed to be idempotent, so calling udevadm
trigger outside of the distribution's initialization scripts can have
unexpected (and potentially dangerous) side effects.  For example, the
system time may change or devices may appear multiple times.  See Ubuntu
launchpad bug 320200 and this mailing list post for more details:

https://lists.ubuntu.com/archives/ubuntu-devel/2009-January/027260.html

To avoid these problems we call udevadm trigger with --action=change
--subsystem-match=block.  The first argument tells udev just to refresh
devices, and make sure everything's as it should be.  The second
argument limits the scope to block devices, so devices belonging to
other subsystems cannot be affected.

This doesn't fix the problem on older udev implementations that don't
provide udevadm but instead have udevtrigger as a standalone program.
In this case the above options aren't available so there's no way to
call call udevtrigger safely.  But we can live with that since this
issue only exists in optional test and helper scripts, and most
zfs-on-linux users are running newer systems anyways.

13 years agoUpdate CHAOS 5 Packaging
Brian Behlendorf [Thu, 31 Mar 2011 20:43:49 +0000 (13:43 -0700)]
Update CHAOS 5 Packaging

The CHAOS 5 kernels are now packaged identially to the RHEL6 kernels.
Therefore we can simply use the RHEL6 rules in the spec file when
building packages.

13 years agoFix libzpool cv_* build error
Brian Behlendorf [Thu, 31 Mar 2011 19:16:24 +0000 (12:16 -0700)]
Fix libzpool cv_* build error

This build failure was accidentally introduced by previous commit
bfd214a which fixed the load average.  Unfortunately, the wrapper
for cv_wait_interruptible was not available in the zfs_context.h
user compatibility code.  I failed to notice this because I didn't
rebuild everything cleanly before committing.

  undefined reference to `cv_wait_interruptible'
  collect2: ld returned 1 exit status

Closes #181

13 years agoFix inflated load average
Brian Behlendorf [Fri, 1 Apr 2011 00:07:12 +0000 (17:07 -0700)]
Fix inflated load average

Kernel threads which sleep uninterruptibly on Linux are marked in the (D)
state.  These threads are usually in the process of performing IO and are
thus counted against the load average.  The txg_quiesce and txg_sync threads
were always sleeping uninterruptibly and thus inflating the load average.

This change makes them sleep interruptibly.  Some care is required however
because these threads may now be woken early by signals.  In this case the
callers are all careful to check that the required conditions are met after
waking up.  If we're woken early due to a signal they will simply go back
to sleep.  In this case these changes are safe.

Closes #175

13 years agoSpec file compat, %{datadir}
Fajar A. Nugraha [Fri, 25 Mar 2011 17:01:28 +0000 (10:01 -0700)]
Spec file compat, %{datadir}

The dracut change caused an error during "make rpm".  The cause
is simple, RHEL5 does not recognize the %{datarootdir} macro in
zfs.spec.  It was changed to %{datadir} which fixes the build.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoSet cmd paths in udev rules using --prefix
Brian Behlendorf [Thu, 24 Mar 2011 18:34:41 +0000 (11:34 -0700)]
Set cmd paths in udev rules using --prefix

The udev/rules.d scripts must use absolute paths to their support
binaries.  However, where those binaries get installed depends
on what --prefix was set to when the package was configured.
This change makes the udev/rules.d helpers to *.in files which
are processed by configure.  This allows them to be dynamically
updated to include the specified --prefix.

Additionally, this change updates 60-zvol.rules to handle both
the 'add' and 'change' actions.  This ensures that that all
valid zvol devices are correctly linked.

13 years agoFixes to enable zvol symlink creation
Fajar A. Nugraha [Thu, 24 Mar 2011 08:22:52 +0000 (15:22 +0700)]
Fixes to enable zvol symlink creation

This commit fixes issue on
https://github.com/behlendorf/zfs/issues/#issue/172
Changes:
- update BLKZNAME to use _IOR instead of _IO.  Kernel 2.6.32 allows
read parameters (copy_to_user) with _IO, while newer kernels (tested
Archlinux's 2.6.37 kernel) enforces _IOR (which is correct)
- fix return code and message on error

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoLinux 2.6.29 compat, .freeze_fs/.unfreeze_fs
Brian Behlendorf [Tue, 22 Mar 2011 18:22:49 +0000 (11:22 -0700)]
Linux 2.6.29 compat, .freeze_fs/.unfreeze_fs

The .freeze_fs/.unfreeze_fs hooks were not added until Linux 2.6.29
Since these hooks are currently unused they are being removed to
allow support of older kernels.

13 years agoLinux 2.6.29 compat, credentials
Brian Behlendorf [Tue, 22 Mar 2011 18:13:41 +0000 (11:13 -0700)]
Linux 2.6.29 compat, credentials

As of Linux 2.6.29 a clean credential API was added to the Linux kernel.
Previously the credential was embedded in the task_struct.  Because the
SPL already has considerable support for handling this API change the
ZPL code has been updated to use the Solaris credential API.

13 years agoLinux 2.6.28 compat, insert_inode_locked()
Brian Behlendorf [Tue, 22 Mar 2011 16:55:09 +0000 (09:55 -0700)]
Linux 2.6.28 compat, insert_inode_locked()

Added insert_inode_locked() helper function, prior to this most callers
used insert_inode_hash().  The older method doesn't check for collisions
in the inode_hashtable but it still acceptible for use.  Fallback to
using insert_inode_hash() when insert_inode_locked() is unavailable.