zfs.git
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.

13 years agoLinux 2.6.27 compat, blk_queue_stackable()
Brian Behlendorf [Tue, 22 Mar 2011 16:26:38 +0000 (09:26 -0700)]
Linux 2.6.27 compat, blk_queue_stackable()

The blk_queue_stackable() queue flag was added in 2.6.27 to handle dm
stacking drivers.  Prior to this request stacking drivers were detected
by checking (q->request_fn == NULL), for earlier kernels we revert to
this legacy behavior.

13 years agoLinux compat, umount2(2) flags
Brian Behlendorf [Mon, 21 Mar 2011 23:54:59 +0000 (16:54 -0700)]
Linux compat, umount2(2) flags

Older glibc <sys/mount.h> headers did not define all the available
umount2(2) flags.  Both MNT_FORCE and MNT_DETACH are supported in the
kernel back to 2.4.11 so we define them correctly if they are missing.

Closes #95

13 years agoFix evict() deadlock
Brian Behlendorf [Mon, 21 Mar 2011 17:19:30 +0000 (10:19 -0700)]
Fix evict() deadlock

Now that KM_SLEEP is not defined as GFP_NOFS there is the possibility
of synchronous reclaim deadlocks.  These deadlocks never existed in the
original OpenSolaris code because all memory reclaim on Solaris is done
asyncronously.  Linux does both synchronous (direct) and asynchronous
(indirect) reclaim.

This commit addresses a deadlock caused by inode eviction.  A KM_SLEEP
allocation may trigger direct memory reclaim and shrink the inode cache.
This can occur while a mutex in the array of ZFS_OBJ_HOLD mutexes is
held.  Through the ->shrink_icache_memory()->evict()->zfs_inactive()->
zfs_zinactive() call path the same mutex may be reacquired resulting
in a deadlock.  To avoid this deadlock the process must not reacquire
the mutex when it is already holding it.

This is a reasonable fix for now but longer term the ZFS_OBJ_HOLD
mutex locking should be reevaluated.  This infrastructure already
prevents us from ever using the Linux lock dependency analysis tools,
and it may limit scalability.

13 years agoUse KM_PUSHPAGE instead of KM_SLEEP
Brian Behlendorf [Sat, 19 Mar 2011 21:34:30 +0000 (14:34 -0700)]
Use KM_PUSHPAGE instead of KM_SLEEP

It used to be the case that all KM_SLEEP allocations were GFS_NOFS.
Unfortunately this often resulted in the kernel being unable to
reclaim the ARC, inode, and dentry caches in a timely manor.
The fix was to make KM_SLEEP a GFP_KERNEL allocation in the SPL.

However, this increases the posibility of deadlocking the system
on a zfs write thread.  If a zfs write thread attempts to perform
an allocation it may trigger synchronous reclaim.  This reclaim
may attempt to flush dirty data/inode to disk to free memory.
Unforunately, this write cannot finish because the write thread
which would handle it is holding the previous transaction open.
Deadlock.

To avoid this all allocations in the zfs write thread path must
use KM_PUSHPAGE which prohibits synchronous reclaim for that
thread.  In this way forward progress in ensured.  The risk
with this change is I missed updating an allocation for the
write threads leaving an increased posibility of deadlock.  If
any deadlocks remain they will be unlikely but we'll have to
make sure they all get fixed.

13 years agoMerge branch 'dracut'
Brian Behlendorf [Tue, 22 Mar 2011 19:13:04 +0000 (12:13 -0700)]
Merge branch 'dracut'

13 years agoFix 'LDFLAGS=-Wl,--as-needed' build error
Brian Behlendorf [Fri, 18 Mar 2011 21:47:19 +0000 (14:47 -0700)]
Fix 'LDFLAGS=-Wl,--as-needed' build error

Compiling with 'LDFLAGS=-Wl,--as-needed' exposed the fact that
there were some library linking problems introduced by mount_zfs.
In particular, the libzfs library does use nvpair symbols, and
mount_zfs contains no dependencies on libzpool.

Closes #161
Closes #162

13 years agoFix getcwd() warning
Brian Behlendorf [Fri, 18 Mar 2011 20:54:27 +0000 (13:54 -0700)]
Fix getcwd() warning

New versions glibc declare getcwd() with the warn_unused_result attribute.
This results in a warning because the updated mount helper was not
checking this return value.  This issue was fixed by checking the return
type and in the case of an error simply returning the passed dataset.
One possible, but unlikely, error would be having your cwd directory
unlinked while the mount command was running.

  cmd/mount_zfs/mount_zfs.c: In function ‘parse_dataset’:
  cmd/mount_zfs/mount_zfs.c:223:2: error: ignoring return value of
      ‘getcwd’, declared with attribute warn_unused_result

13 years agoAdd dracut support
Manuel Amador (Rudd-O) [Thu, 17 Mar 2011 22:18:13 +0000 (15:18 -0700)]
Add dracut support

To simplify the process of using zfs as your root filesystem a
zfs-drucat sub-package has been added.  This sub-package adds a zfs
dracut module which allows your initramfs to be rebuilt with zfs
support.  The process for doing this is still complicated but there
is clearly interest from the community about getting this working
well and documented.  This should help lay some of the groundwork.

Longer term these changes should be pushed in the upstream dracut
package.  Once that occurs this subpackage will no longer be
required for new systems, however we may want to conditionally
build this package in the future for systems running older
dracut versions.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoAdd init scripts
Brian Behlendorf [Thu, 17 Mar 2011 22:02:28 +0000 (15:02 -0700)]
Add init scripts

To support automatically mounting your zfs on filesystem on boot
a basic init script is needed.  Unfortunately, every distribution
has their own idea of the _right_ way to do things.  Rather than
write one very complicated portable init script, which would be
invariably replaced by the distributions own anyway.  I have
instead added support to provide multiple distribution specific
init scripts.

The correct init script for your distribution will be selected
by ZFS_AC_DEFAULT_PACKAGE which will set DEFAULT_INIT_SCRIPT.
During 'make install' the correct script for your system will
be installed from zfs/etc/init.d/zfs.DEFAULT_INIT_SCRIPT to the
usual /etc/init.d/zfs location.

Currently, there is zfs.fedora and a more generic zfs.lsb init
script.  Hopefully, the distribution maintainers who know best
how they want their init scripts to function will feedback their
approved versions to be included in the project.

This change does not consider upstart jobs but I'm not at all
opposed to add that sort of thing.

13 years agoRegister .remount_fs handler
Brian Behlendorf [Tue, 15 Mar 2011 19:41:19 +0000 (12:41 -0700)]
Register .remount_fs handler

Register the missing .remount_fs handler.  This handler isn't strictly
required because the VFS does a pretty good job updating most of the
MS_* flags.  However, there's no harm in using the hook to call the
registered zpl callback for various MS_* flags.  Additionaly, this
allows us to lay the ground work for more complicated argument parsing
in the future.

13 years agoRegister .sync_fs handler
Brian Behlendorf [Tue, 15 Mar 2011 19:03:42 +0000 (12:03 -0700)]
Register .sync_fs handler

Register the missing .sync_fs handler.  This is a noop in most cases
because the usual requirement is that sync just be initiated.  As part
of the DMU's normal transaction processing txgs will be frequently
synced.  However, when the 'wait' flag is set the requirement is that
.sync_fs must not return until the data is safe on disk.  With the
addition of the .sync_fs handler this is now properly implemented.

13 years agoStrip 'zfsutil,remount' from /etc/mtab
Brian Behlendorf [Tue, 15 Mar 2011 18:17:33 +0000 (11:17 -0700)]
Strip 'zfsutil,remount' from /etc/mtab

When updating /etc/mtab we should be careful and strip certain
options.  In particular, we need to strip 'zfsutil' because if
we don't the mount utility will helpfull provide it to the
mount helper when we issue mount(8) again.  This subverts the
check that the caller is zfs(8) and not mount(8).

13 years agoAlways allow '-o remount,ro'
Brian Behlendorf [Tue, 15 Mar 2011 16:34:56 +0000 (09:34 -0700)]
Always allow '-o remount,ro'

Allow the mount(8) utility to always operate on all datasets when
remounting them read-only.  This critical for rc.sysinit/umountroot
which remounts the root filesystem read-only during shutdown to
ensure everything is correctly flushed to disk.

Fix minor typo, the check to set zfsutil should use the bitwise
'&'.  I must have accidentally hit the adjacent '*' and obviously
neither the compiler or my code review caught this.  Fix it now.

13 years agoDon't set I/O Scheduler for Partitions
Brian Behlendorf [Thu, 10 Mar 2011 21:34:17 +0000 (13:34 -0800)]
Don't set I/O Scheduler for Partitions

ZFS should only change the i/o scheduler for a disk when it has
ownership of the whole disk.  This is basically the same logic as
adjusting the write cache behavior on a disk.  This change updates
the vdev disk code to skip partitions when setting the i/o scheduler.

Closes #152

13 years agoCheck for trailing '/' in mount.zfs
Brian Behlendorf [Thu, 10 Mar 2011 20:58:44 +0000 (12:58 -0800)]
Check for trailing '/' in mount.zfs

When run with a root '/' cwd the mount.zfs helper would strip not
only the '/' but also the next character from the dataset name.
For example, '/tank' was changed to 'ank' instead of just 'tank'.
Originally, this was done for the '/tmp' cwd case where we needed
to strip the '/' following the cwd.  For example '/tmp/tank' needed
to remove the '/tmp' cwd plus 1 character for the '/'.

This change fixes the problem by checking the cwd and if it ends in
a '/' it does not strip and extra character.  Otherwise it will strip
the next character.  I believe this should only ever be true for the
root directory.

Closes #148

13 years agoPrep zfs-0.6.0-rc2 tag
Brian Behlendorf [Wed, 9 Mar 2011 23:17:28 +0000 (15:17 -0800)]
Prep zfs-0.6.0-rc2 tag

Create the second 0.6.0 release candidate tag (rc2).

13 years agoPrint mount/umount errors
Brian Behlendorf [Mon, 7 Mar 2011 18:10:20 +0000 (10:10 -0800)]
Print mount/umount errors

Because we are dependent of the system mount/umount utilities to
ensure correct mtab locking, we should not suppress their error
output.  During a successful mount/umount they will be silent,
but during a failure the error message they print is the only sure
way to know why a mount failed.  This is because the (u)mount(8)
return code does not contain the result of the system call issued.
The only way to clearly idenify why thing failed is to rely on
the error message printed by the tool.

Longer term once libmount is available we can issue the mount/umount
system calls within the tool and still be ensured correct mtab locking.

Closed #107

13 years agoFix mount helper
Brian Behlendorf [Fri, 4 Mar 2011 23:14:46 +0000 (15:14 -0800)]
Fix mount helper

Several issues related to strange mount/umount behavior were reported
and this commit should address most of them.  The original idea was
to put in place a zfs mount helper (mount.zfs).  This helper is used
to enforce 'legacy' mount behavior, and perform any extra mount argument
processing (selinux, zfsutil, etc).  This helper wasn't ready for the
0.6.0-rc1 release but with this change it's functional but needs to
extensively tested.

This change addresses the following open issues.
Closes #101
Closes #107
Closes #113
Closes #115
Closes #119

13 years agoFix O_APPEND Corruption
Brian Behlendorf [Wed, 9 Mar 2011 21:20:28 +0000 (13:20 -0800)]
Fix O_APPEND Corruption

Due to an uninitialized variable files opened with O_APPEND may
overwrite the start of the file rather than append to it.  This
was introduced accidentally when I removed the Solaris vnodes.

The zfs_range_lock_writer() function used to key off zf->z_vnode
to determine if a znode_t was for a zvol of zpl object.  With
the removal of vnodes this was replaced by the flag zp->z_is_zvol.
This flag was used to control the append behavior for range locks.

Unfortunately, this value was never properly initialized after
the vnode removal.  However, because most of memory is usually
zeros it happened to be set correctly most of the time making
the bug appear racy.  Properly initializing zp->z_is_zvol to
zero completely resolves the problem with O_APPEND.

Closes #126

13 years agoConserve stack in zfs_setattr()
Brian Behlendorf [Wed, 9 Mar 2011 18:48:49 +0000 (10:48 -0800)]
Conserve stack in zfs_setattr()

Move 'bulk' and 'xattr_bulk' from the stack to the heap to minimize
stack space usage.  These two arrays consumed 448 bytes on the stack
and have been replaced by two 8 byte points for a total stack space
saving of 432 bytes.  The zfs_setattr() path had been previously
observed to overrun the stack in certain circumstances.

13 years agoRange lock performance improvements
Brian Behlendorf [Tue, 8 Mar 2011 20:17:35 +0000 (12:17 -0800)]
Range lock performance improvements

The original range lock implementation had to be modified by commit
8926ab7 because it was unsafe on Linux.  In particular, calling
cv_destroy() immediately after cv_broadcast() is dangerous because
the waiters may still be asleep.  Thus the following cv_destroy()
will free memory which may still be in use.

This was fixed by updating cv_destroy() to block on waiters but
this in turn introduced a deadlock.  The deadlock was resolved
with the use of a taskq to move the offending free outside the
range lock.  This worked well but using the taskq for the free
resulted in a serious performace hit.  This is somewhat ironic
because at the time I felt using the taskq might improve things
by making the free asynchronous.

This patch refines the original fix and moves the free from the
taskq to a private free list.  Then items which must be free'd
are simply inserted in to the list.  When the range lock is dropped
it's safe to free the items.  The list is walked and all rl_t
entries are freed.

This change improves small cached read performance by 26x.  This
was expected because for small reads the number of locking calls
goes up significantly.  More surprisingly this change significantly
improves large cache read performance.  This probably attributable
to better cpu/memory locality.  Very likely the same processor
which allocated the memory is now freeing it.

bs ext3 zfs zfs+fix faster
----------------------------------------------
512     435     3       79       26x
1k      820     7       160      22x
2k      1536    14      305      21x
4k      2764    28      572      20x
8k      3788    50      1024     20x
16k     4300    86      1843     21x
32k     4505    138     2560     18x
64k     5324    252     3891     15x
128k    5427    276     4710     17x
256k    5427    413     5017     12x
512k    5427    497     5324     10x
1m      5427    521     5632     10x

Closes #142

13 years agoAdd zfs_open()/zfs_close()
Brian Behlendorf [Tue, 8 Mar 2011 19:04:51 +0000 (11:04 -0800)]
Add zfs_open()/zfs_close()

In the original implementation the zfs_open()/zfs_close() hooks
were dropped for simplicity.  This was functional but not 100%
correct with the expected ZFS sematics.  Updating and re-adding the
zfs_open()/zfs_close() hooks resolves the following issues.

1) The ZFS_APPENDONLY file attribute is once again honored.  While
there are still no Linux tools to set/clear these attributes once
there are it should behave correctly.

2) Minimal virus scan file attribute hooks were added.  Once again
this support in disabled but the infrastructure is back in place.

3) Most importantly correctly handle assigning files which were
opened syncronously to the intent log.  Without this change O_SYNC
modifications could be lost during a system crash even though they
were marked synchronous.

13 years agoSet stat->st_dev and statfs->f_fsid
Brian Behlendorf [Tue, 8 Mar 2011 00:06:22 +0000 (16:06 -0800)]
Set stat->st_dev and statfs->f_fsid

Filesystems like ZFS must use what the kernel calls an anonymous super
block.  Basically, this is just a filesystem which is not backed by a
single block device.  Normally this block device's dev_t is stored in
the super block.  For anonymous super blocks a unique reserved dev_t
is assigned as part of get_sb().

This sb->s_dev must then be set in the returned stat structures as
stat->st_dev.  This allows userspace utilities to easily detect the
boundries of a specific filesystem.  Tools such as 'du' depend on this
for proper accounting.

Additionally, under OpenSolaris the statfs->f_fsid is set to the device
id.  To preserve consistency with OpenSolaris we also set the fsid to
the device id.  Other Linux filesystem (ext) set the fsid to a unique
value determined by the filesystems uuid.  This value is unique but
maintains no relationship to the device id.  This may be desirable
when exporting NFS filesystem because it minimizes to chance of a
client observing the same fsid from two different servers.

Closes #140

13 years agoMake Missing Modules.symvers Fatal
Brian Behlendorf [Mon, 7 Mar 2011 21:03:48 +0000 (13:03 -0800)]
Make Missing Modules.symvers Fatal

Detect early on in configure if the Modules.symvers file is missing.
Without this file there will be build failures later and it's best
to catch this early and provide a useful error.  In this case the
most likely problem is the kernel-devel packages are not installed.
It may also be possible that they are using an unbuilt custom kernel
in which case they must build the kernel first.

Closes #127

13 years agoMake CONFIG_PREEMPT Fatal
Brian Behlendorf [Mon, 7 Mar 2011 18:59:26 +0000 (10:59 -0800)]
Make CONFIG_PREEMPT Fatal

Until support is added for preemptible kernels detect this at
configure time and make it fatal.  Otherwise, it is possible to
have a successful build and kernel modules with flakey behavior.

13 years agoAdd missing libspl+libzpool libs to libzfs
Brian Behlendorf [Thu, 3 Mar 2011 23:45:28 +0000 (15:45 -0800)]
Add missing libspl+libzpool libs to libzfs

The libspl and libzpool libraries were missing from the libzfs
Makefile.am.  They should be explicitly listed to avoid build
issues when compiling static libraries and binaries.

Additionally, ensure libzpool is built before libzfs because
libzfs is dependent on libzpool.  This was also exposed as an
issue when forcing static linking.

13 years agoUse Linux ATTR_ versions
Brian Behlendorf [Thu, 3 Mar 2011 19:29:15 +0000 (11:29 -0800)]
Use Linux ATTR_ versions

The AT_ versions of these macros are used on Solaris and while they
map to their Linux equivilants the code has been updated to use the
ATTR_ versions.

13 years agoConserve stack in zfs_setattr()
Brian Behlendorf [Wed, 2 Mar 2011 22:18:40 +0000 (14:18 -0800)]
Conserve stack in zfs_setattr()

Move 'tmpxvattr' from the stack to the heap to minimize stack
space usage.  This is enough to get us below the 1024 byte stack
frame warning.  That however is still a large stack frame and it
should be further reduced by moving the 'bulk' and 'xattr_bulk'
sa_bulk_attr_t variables to the heap in a future patch.

13 years agoDrop HAVE_XVATTR macros
Brian Behlendorf [Tue, 1 Mar 2011 20:24:09 +0000 (12:24 -0800)]
Drop HAVE_XVATTR macros

When I began work on the Posix layer it immediately became clear to
me that to integrate cleanly with the Linux VFS certain Solaris
specific things would have to go.  One of these things was to elimate
as many Solaris specific types from the ZPL layer as possible.  They
would be replaced with their Linux equivalents.  This would not only
be good for performance, but for the general readability and health of
the code.  The Solaris and Linux VFS are different beasts and should
be treated as such.  Most of the code remains common for constructing
transactions and such, but there are subtle and important differenced
which need to be repsected.

This policy went quite for for certain types such as the vnode_t,
and it initially seemed to be working out well for the vattr_t.  There
was a relatively small amount of related xvattr_t code I was forced to
comment out with HAVE_XVATTR.  But it didn't look that hard to come
back soon and replace it all with a native Linux type.

However, after going doing this path with xvattr some distance it
clear that this code was woven in the ZPL more deeply than I thought.
In particular its hooks went very deep in to the ZPL replay code
and replacing it would not be as easy as I originally thought.

Rather than continue persuing replacing and removing this code I've
taken a step back and reevaluted things.  This commit reverts many of
my previous commits which removed xvattr related code.  It restores
much of the code to its original upstream state and now relies on
improved xvattr_t support in the zfs package itself.

The result of this is that much of the code which I had commented
out, which accidentally broke things like replay, is now back in
place and working.  However, there may be a small performance
impact for getattr/setattr operations because they now require
a translation from native Linux to Solaris types.  For now that's
a price I'm willing to pay.  Once everything is completely functional
we can revisting the issue of removing the vattr_t/xvattr_t types.

Closes #111

13 years agoAdd xvattr support
Brian Behlendorf [Wed, 2 Mar 2011 00:24:39 +0000 (16:24 -0800)]
Add xvattr support

With the removal of the minimal xvattr support from the spl this
support needs to be replaced in the zfs package.  This is fairly
easily accomplished by directly adding portions of the sys/vnode.h
header from OpenSolaris.  These xvattr additions have been placed
in the sys/xvattr.h header file and included as needed where simply
a sys/vnode.h was included before.

In additon to the xvattr types and helper macros two functions
were also included.  The xva_init() and xva_getxoptattr() functions
were included as static inline functions in xvattr.h.  They are
simple enough and it was simpler to place them here rather than
in their own .c file.

13 years agoRemove caller_context_t
Brian Behlendorf [Wed, 2 Mar 2011 00:24:21 +0000 (16:24 -0800)]
Remove caller_context_t

Remove the remaining callers of caller_context_t.  This type has
been removed because it is not needed for the Linux port.

13 years agoAdd the zpool and filesystem versions
Darik Horn [Mon, 28 Feb 2011 16:15:05 +0000 (10:15 -0600)]
Add the zpool and filesystem versions

Print the supported zpool and filesystem versions at module load
time.  This change removes an ambiguity and adds information that
system administrators care about.  The phrase "ZFS pool version %s"
is the same as zpool upgrade -v so that the operator is familiar
with the message.

  ZFS: Loaded module v0.6.0, ZFS pool version 28, ZFS filesystem version 5
  ZFS: Unloaded module v0.6.0

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoFix set block scheduler warnings
Brian Behlendorf [Fri, 25 Feb 2011 19:26:41 +0000 (11:26 -0800)]
Fix set block scheduler warnings

There were two cases when attempting to set the vdev block device
scheduler which would causes console warnings.

The first case was when the vdev used a loop, ram, dm, or other
such device which doesn't support a configurable scheduler.  In
these cases attempting to set a scheduler is pointless and can
be safely skipped.

The secord case is slightly more troubling.  We were seeing
transient cases where setting the elevator would return -EFAULT.
On retry everything is fine so there appears to be a small window
where this is possible.  To handle that case we silently retry
up to three times before reporting the warning.

In all of the above cases the warning is harmless and at worse you
may see slightly different performance characteristics from one
or more of your vdevs.

13 years agoUse udev to create /dev/zvol/[dataset_name] links
Fajar A. Nugraha [Tue, 22 Feb 2011 10:58:44 +0000 (17:58 +0700)]
Use udev to create /dev/zvol/[dataset_name] links

This commit allows zvols with names longer than 32 characters, which
fixes issue on https://github.com/behlendorf/zfs/issues/#issue/102.

Changes include:
- use /dev/zd* device names for zvol, where * is the device minor
  (include/sys/fs/zfs.h, module/zfs/zvol.c).
- add BLKZNAME ioctl to get dataset name from userland
  (include/sys/fs/zfs.h, module/zfs/zvol.c, cmd/zvol_id).
- add udev rule to create /dev/zvol/[dataset_name] and the legacy
  /dev/[dataset_name] symlink. For partitions on zvol, it will create
  /dev/zvol/[dataset_name]-part* (etc/udev/rules.d/60-zvol.rules,
  cmd/zvol_id).

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoAdd the new blkdev_compat.h header to the DIST target.
Darik Horn [Thu, 24 Feb 2011 17:08:35 +0000 (11:08 -0600)]
Add the new blkdev_compat.h header to the DIST target.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoRemove rdev packing
Brian Behlendorf [Wed, 23 Feb 2011 23:13:03 +0000 (15:13 -0800)]
Remove rdev packing

Remove custom code to pack/unpack dev_t's.  Under Linux all dev_t's
are an unsigned 32-bit value even on 64-bit platforms.  The lower
20 bits are used for the minor number and the upper 12 for the major
number.

This means if your importing a pool from Solaris you may get strange
major/minor numbers.  But it doesn't really matter because even if
we add compatibility code to translate the encoded Solaris major/minor
they won't do you any good under Linux.  You will still need to
recreate the dev_t with a major/minor which maps to reserved major
numbers used under Linux.

Dropping this code also resolves 32-bit builds by removing the
offending 32-bit compatibility code.

13 years agoUse correct ASSERT3* variant
Brian Behlendorf [Wed, 23 Feb 2011 23:03:30 +0000 (15:03 -0800)]
Use correct ASSERT3* variant

ASSERT3P should be used instead of ASSERT3U when comparing
pointers.  Using ASSERT3U with the cast causes a compiler
warning for 32-bit builds which is fatal with --enable-debug.

13 years agoIncrease fragment size to block size
Brian Behlendorf [Wed, 23 Feb 2011 21:57:50 +0000 (13:57 -0800)]
Increase fragment size to block size

The underlying storage pool actually uses multiple block
size.  Under Solaris frsize (fragment size) is reported as
the smallest block size we support, and bsize (block size)
as the filesystem's maximum block size.  Unfortunately,
under Linux the fragment size and block size are often used
interchangeably.  Thus we are forced to report both of them
as the filesystem's maximum block size.

Closes #112

13 years agoFix 'statement with no effect' warning
Brian Behlendorf [Wed, 23 Feb 2011 21:03:19 +0000 (13:03 -0800)]
Fix 'statement with no effect' warning

Because the secpolicy_* macros are all currently defined to (0).
And because the caller of this function does not check the return
code.  The compiler complains that this statement has no effect
which is correct and OK.  To suppress the warning explictly cast
the result to (void).

13 years agoFix uninitialized variable
Brian Behlendorf [Wed, 23 Feb 2011 20:57:25 +0000 (12:57 -0800)]
Fix uninitialized variable

It was possible for rc to be unitialized in the parse_options()
function which triggered a compiler warning.  Ensure rc is always
initialized.

13 years agoFix enum compiler warning
Brian Behlendorf [Wed, 23 Feb 2011 20:50:05 +0000 (12:50 -0800)]
Fix enum compiler warning

Generally it's a good idea to use enums for switch statements,
but in this case it causes warning because the enum is really a
set of flags.  These flags are OR'ed together in some cases
resulting in values which are not part of the original enum.
This causes compiler warning such as this about invalid cases.

  error: case value ‘33’ not in enumerated type ‘zprop_source_t’

To handle this we simply case the enum to an int for the switch
statement.  This leaves all other enum type checking in place
and effectively disabled these warnings.

13 years agoLinux 2.6.38 compat, blkdev_get_by_path()
Brian Behlendorf [Tue, 22 Feb 2011 22:55:35 +0000 (14:55 -0800)]
Linux 2.6.38 compat, blkdev_get_by_path()

The open_bdev_exclusive() function has been replaced (again) by the
more generic blkdev_get_by_path() function.  Additionally, the
counterpart function close_bdev_exclusive() has been replaced by
blkdev_put().  Because these functions are more generic versions
of the functions they replaced the compatibility macro must add
the FMODE_EXCL mask to ensure they are exclusive.

Closes #114

13 years agoLinux 2.6.x compat, blkdev_compat.h
Brian Behlendorf [Tue, 22 Feb 2011 20:15:13 +0000 (12:15 -0800)]
Linux 2.6.x compat, blkdev_compat.h

For legacy reasons the zvol.c and vdev_disk.c Linux compatibility
code ended up in sys/blkdev.h and sys/vdev_disk.h headers.  While
there are worse places for this code to live it should be in a
linux/blkdev_compat.h header.  This change moves this block device
Linux compatibility code in to the linux/blkdev_compat.h header
and updates all the correct #include locations.  This is not a
functional change or bug fix, it is just code cleanup.

13 years agoPrep zfs-0.6.0-rc1 tag
Brian Behlendorf [Fri, 18 Feb 2011 17:33:12 +0000 (09:33 -0800)]
Prep zfs-0.6.0-rc1 tag

Create the first 0.6.0 release candidate tag (rc1).  The Posix
layer is now functional and passes fstest and several other
test suites cleanly.  We now need this release candidate tag
to broaden the test coverage before we can release the official
zfs-0.6.0.

13 years agoMerge branch 'zpl'
Brian Behlendorf [Fri, 18 Feb 2011 17:31:25 +0000 (09:31 -0800)]
Merge branch 'zpl'

13 years agoUse provided uid/gid for setattr
Brian Behlendorf [Thu, 17 Feb 2011 22:17:44 +0000 (14:17 -0800)]
Use provided uid/gid for setattr

When changing the uid/gid of a file via zfs_setattr() use the
Posix id passed in iattr->ia_uid/gid.  While the zfs_fuid_create()
code already had the fuid support disabled for Linux it was
returning the uid/gid from the credential.  With this change
the 'chown' command which relies on setxattr is now working
properly.

Also remove a little stray white space which was in front of
zfs_update_inode() call and the end of zfs_setattr().

13 years agoFix symlink(2) inode reference count
Brian Behlendorf [Thu, 17 Feb 2011 19:26:51 +0000 (11:26 -0800)]
Fix symlink(2) inode reference count

Under Linux sys_symlink(2) should result in a inode being created
with one reference for the inode itself, and a second reference on
the inode which is held by the new dentry.  Under Solaris this
appears not to be the case.  Their zfs_symlink() handler drops
the inode reference before returning.

The result of this under Linux is that the reference count for
symlinks is always one smaller than it should have been. This
results in a BUG() when the symlink is unlinked.  To handle this
the Linux port now keeps the inode reference which differs from
the Solaris behavior.  This results in correct reference counts.

Closes #96

13 years agoUse -zfs_readlink() error
Brian Behlendorf [Thu, 17 Feb 2011 17:48:06 +0000 (09:48 -0800)]
Use -zfs_readlink() error

The zfs_readlink() function returns a Solaris positive error value
and that needs to be converted to a Linux negative error value.
While in this case nothing would actually go wrong, it's still
incorrect and should be fixed if for no other reason than clarity.

13 years agoImprove 'zpool import' safety
Brian Behlendorf [Thu, 17 Feb 2011 17:21:39 +0000 (09:21 -0800)]
Improve 'zpool import' safety

There are three improvements here to 'zpool import' proposed by Fajar
in Github issue #98.  They are all good so I'm commiting all three.

1) Add descriptions for "hpet" and "core" blacklist entries.

2) Add "core" to the blacklist, as described in the issue accessing
this device will crash Xen dom0.

3) Refine probing behavior to use fstatat64().  This allows us to
determine if a device is a block device or a regular file without
having to open it.  This is the safest appraoch when probing /dev/
because the simple act of opening a device may have unexpected
consequences.

Closes #98

13 years agoFix readlink(2)
Brian Behlendorf [Wed, 16 Feb 2011 23:54:55 +0000 (15:54 -0800)]
Fix readlink(2)

This patch addresses three issues related to symlinks.

1) Revert the zfs_follow_link() function to a modified version
of the original zfs_readlink().  The only changes from the
original OpenSolaris version relate to using Linux types.
For the moment this means no vnode's and no zfsvfs_t.  The
caller zpl_follow_link() was also updated accordingly.  This
change was reverted because it was slightly gratuitious.

2) Update zpl_follow_link() to use local variables for the
link buffer.  I'd forgotten that iov.iov_base is updated by
uiomove() so after the call to zfs_readlink() it can not longer
be used.  We need our own private copy of the link pointer.

3) Allocate MAXPATHLEN instead of MAXPATHLEN+1.  By default
MAXPATHLEN is 4096 bytes which is a full page, adding one to
it pushes it slightly over a page.  That means you'll likely
end up allocating 2 pages which is wasteful of memory and
possibly slightly slower.

13 years agoAdd API to wait for pending commit callbacks
Ricardo M. Correia [Fri, 21 Jan 2011 22:35:41 +0000 (14:35 -0800)]
Add API to wait for pending commit callbacks

This adds an API to wait for pending commit callbacks of already-synced
transactions to finish processing.  This is needed by the DMU-OSD in
Lustre during device finalization when some callbacks may still not be
called, this leads to non-zero reference count errors.  See lustre.org
bug 23931.

13 years agoUpdate 'zfs.sh -u' to umount all zfs filesystems
Brian Behlendorf [Wed, 16 Feb 2011 19:10:31 +0000 (11:10 -0800)]
Update 'zfs.sh -u' to umount all zfs filesystems

Before it is safe to unload the zfs module stack all mounted
zfs filesystems must be unmounted.  If they are not unmounted,
there will be references held on the modules and the stack cannot
be removed.  To handle this have 'zfs.sh -u' which is used by all
of the test scripts umount all zfs filesystem before attempting
to unload the module stack.

13 years agoSuppress share error on mount
Brian Behlendorf [Wed, 16 Feb 2011 19:05:55 +0000 (11:05 -0800)]
Suppress share error on mount

Until code is added to support automatically sharing datasets
we should return success instead of failure.  This prevents the
command line tools from returning a non-zero error code.  While
a user likely won't notice this, test scripts like zconfig.sh
do and correctly fail because of it.

13 years agoAdd get/setattr, get/setxattr hooks
Brian Behlendorf [Wed, 16 Feb 2011 17:55:53 +0000 (09:55 -0800)]
Add get/setattr, get/setxattr hooks

While the attr/xattr hooks were already in place for regular
files this hooks can also apply to directories and special files.
While they aren't typically used in this way, it should be
supported.  This patch registers these additional callbacks
for both directory and special inode types.

13 years agoFix FIFO and socket handling
Brian Behlendorf [Wed, 16 Feb 2011 17:51:44 +0000 (09:51 -0800)]
Fix FIFO and socket handling

Under Linux when creating a fifo or socket type device in the ZFS
filesystem it's critical that the rdev is stored in a SA.  This
was already being correctly done for character and block devices,
but that logic needed to be extended to include FIFOs and sockets.

This patch takes care of device creation but a follow on patch
may still be required to verify that the dev_t is being correctly
packed/unpacked from the SA.

13 years agoCreate minors for all zvols
Brian Behlendorf [Wed, 16 Feb 2011 17:40:29 +0000 (09:40 -0800)]
Create minors for all zvols

It was noticed that when you have zvols in multiple datasets
not all of the zvol devices are created at module load time.
Fajarnugraha did the leg work to identify that the root cause of
this bug is a non-zero return value from zvol_create_minors_cb().

Returning a non-zero value from the dmu_objset_find_spa() callback
function results in aborting processing the remaining children in
a dataset.  Since we want to ensure that the callback in run on
all children regardless of error simply unconditionally return
zero from the zvol_create_minors_cb().  This callback function
is solely used for this purpose so surpressing the error is safe.

Closes #96

13 years agoLinux 2.6.36 compat, sops->evict_inode()
Brian Behlendorf [Fri, 11 Feb 2011 21:46:10 +0000 (13:46 -0800)]
Linux 2.6.36 compat, sops->evict_inode()

The new prefered inteface for evicting an inode from the inode cache
is the ->evict_inode() callback.  It replaces both the ->delete_inode()
and ->clear_inode() callbacks which were previously used for this.

13 years agoLinux 2.6.33 compat, get/set xattr callbacks
Brian Behlendorf [Fri, 11 Feb 2011 18:33:01 +0000 (10:33 -0800)]
Linux 2.6.33 compat, get/set xattr callbacks

The xattr handler prototypes were sanitized with the idea being that
the same handlers could be used for multiple methods.  The result of
this was the inode type was changes to a dentry, and both the get()
and set() hooks had a handler_flags argument added.  The list()
callback was similiarly effected but no autoconf check was added
because we do not use the list() callback.

13 years agoLinux 2.6.35 compat, fops->fsync()
Brian Behlendorf [Fri, 11 Feb 2011 16:58:55 +0000 (08:58 -0800)]
Linux 2.6.35 compat, fops->fsync()

The fsync() callback in the file_operations structure used to take
3 arguments.  The callback now only takes 2 arguments because the
dentry argument was determined to be unused by all consumers.  To
handle this a compatibility prototype was added to ensure the right
prototype is used.  Our implementation never used the dentry argument
either so it's just a matter of using the right prototype.

13 years agoLinux 2.6.35 compat, const struct xattr_handler
Brian Behlendorf [Fri, 11 Feb 2011 00:16:52 +0000 (16:16 -0800)]
Linux 2.6.35 compat, const struct xattr_handler

The const keyword was added to the 'struct xattr_handler' in the
generic Linux super_block structure.  To handle this we define an
appropriate xattr_handler_t typedef which can be used.  This was
the preferred solution because it keeps the code clean and readable.

13 years agoPrefer /lib/modules/$(uname -r)/ links
Brian Behlendorf [Thu, 10 Feb 2011 22:54:33 +0000 (14:54 -0800)]
Prefer /lib/modules/$(uname -r)/ links

Preferentially use the /lib/modules/$(uname -r)/source and
/lib/modules/$(uname -r)/build links.  Only if neither of these
links exist fallback to alternate methods for deducing which
kernel to build with.  This resolves the need to manually
specify --with-linux= and --with-linux-obj= on Debian systems.

13 years agoMS_DIRSYNC and MS_REC compat
Brian Behlendorf [Thu, 10 Feb 2011 20:11:05 +0000 (12:11 -0800)]
MS_DIRSYNC and MS_REC compat

It turns out that older versions of the glibc headers do not
properly define MS_DIRSYNC despite it being explicitly mentioned
in the man pages.  They instead call it S_WRITE, so for system
where this is not correct defined map MS_DIRSYNC to S_WRITE.
At the time of this commit both Ubuntu Lucid, and Debian Squeeze
both use the out of date glibc headers.

As for MS_REC this field is also not available in the older headers.
Since there is no obvious mapping in this case we simply disable
the recursive mount option which used it.

13 years agoAdd missing -ldl linker option
Brian Behlendorf [Thu, 10 Feb 2011 18:57:29 +0000 (10:57 -0800)]
Add missing -ldl linker option

The inclusion on dlsym(), dlopen(), and dlclose() symbols require
us to link against the dl library.  Be careful to add the flag to
both the libzfs library and the commands which depend on the library.

13 years agoUpdate AUTHORS file
Brian Behlendorf [Tue, 8 Feb 2011 23:40:52 +0000 (15:40 -0800)]
Update AUTHORS file

This file has gotten stale and needed to be updated.  There are
individuals who deserve to be recognized for their contributions
to the project.  I've done my best to assemble names from the
commit logs of those who have submitted patches.  This list may
not be comprehensive, if you feel I've overlooked your contribution
please let me know and we can get your name added.

13 years agoUse 'noop' IO Scheduler
Brian Behlendorf [Mon, 7 Feb 2011 21:54:59 +0000 (13:54 -0800)]
Use 'noop' IO Scheduler

Initial testing has shown the the right IO scheduler to use under Linux
is noop.  This strikes the ideal balance by allowing the zfs elevator
to do all request ordering and prioritization.  While allowing the
Linux elevator to do the maximum front/back merging allowed by the
physical device.  This yields the largest possible requests for the
device with the lowest total overhead.

While 'noop' should be right for your system you can choose a different
IO scheduler with the 'zfs_vdev_scheduler' option.  You may set this
value to any of the standard Linux schedulers: noop, cfq, deadline,
anticipatory.  In addition, if you choose 'none' zfs will not attempt
to change the IO scheduler for the block device.

13 years agoSuppress large kmem_alloc() warning
Brian Behlendorf [Mon, 7 Feb 2011 20:21:29 +0000 (12:21 -0800)]
Suppress large kmem_alloc() warning

The following warning was observed under normal operation.  It's
not fatal but it's something to be addressed long term.  Flag the
offending allocation with KM_NODEBUG to suppress the warning and
flag the call site.

SPL: Showing stack for process 21761
Pid: 21761, comm: iozone Tainted: P           ----------------
2.6.32-71.14.1.el6.x86_64 #1
Call Trace:
 [<ffffffffa05465a7>] spl_debug_dumpstack+0x27/0x40 [spl]
 [<ffffffffa054a84d>] kmem_alloc_debug+0x11d/0x130 [spl]
 [<ffffffffa05de166>] dmu_buf_hold_array_by_dnode+0xa6/0x4e0 [zfs]
 [<ffffffffa05de825>] dmu_buf_hold_array+0x65/0x90 [zfs]
 [<ffffffffa05de891>] dmu_read_uio+0x41/0xd0 [zfs]
 [<ffffffffa0654827>] zfs_read+0x147/0x470 [zfs]
 [<ffffffffa06644a2>] zpl_read_common+0x52/0x70 [zfs]
 [<ffffffffa0664503>] zpl_read+0x43/0x70 [zfs]
 [<ffffffff8116d905>] vfs_read+0xb5/0x1a0
 [<ffffffff8116da41>] sys_read+0x51/0x90
 [<ffffffff81013172>] system_call_fastpath+0x16/0x1b

13 years agoUpdate META to 0.6.0
Brian Behlendorf [Mon, 7 Feb 2011 20:09:23 +0000 (12:09 -0800)]
Update META to 0.6.0

Roll the version forward to 0.6.0, the addition of the Posix
layer warrents updating the major version number.

13 years agoInvalidate dcache and inode cache
Brian Behlendorf [Sat, 5 Feb 2011 00:54:34 +0000 (16:54 -0800)]
Invalidate dcache and inode cache

When performing a 'zfs rollback' it's critical to invalidate
the previous dcache and inode cache.  If we don't there will
stale cache entries which when accessed will result in EIOs.

13 years agoRemove useless libefi warnings
Brian Behlendorf [Sat, 5 Feb 2011 00:17:54 +0000 (16:17 -0800)]
Remove useless libefi warnings

These two warnings in libefi serve no real purpose.  When running
without DEBUG they are already supressed, and even when DEBUG is
enabled all they indicate is the device doesn't already have an
EFI label.  For a Linux machine this is probably the common case.

13 years agoMove cv_destroy() outside zp->z_range_lock()
Brian Behlendorf [Fri, 4 Feb 2011 22:38:11 +0000 (14:38 -0800)]
Move cv_destroy() outside zp->z_range_lock()

With the recent SPL change (d599e4fa) that forces cv_destroy()
to block until all waiters have been woken.  It is now unsafe
to call cv_destroy() under the zp->z_range_lock() because it
is used as the condition variable mutex.  If there are waiters
cv_destroy() will block until they wake up and aquire the mutex.
However, they will never aquire the mutex because cv_destroy()
will not return allowing it's caller to drop the lock.  Deadlock.

To avoid this cv_destroy() is now run asynchronously in a taskq.
This solves two problems:

1) It is no longer run under the zp->z_range_lock so no deadlock.
2) Since cv_destroy() may now block we don't want this slowing
   down zfs_range_unlock() and throttling the system.

This was not as much of an issue under OpenSolaris because their
cv_destroy() implementation does not do anything.  They do however
risk a bad paging request if cv_destroy() returns, the memory holding
the condition variable is free'd, and then the waiters wake up and
try to reference it.  It's a very small unlikely race, but it is
possible.

13 years agoAdd mmap(2) support
Brian Behlendorf [Thu, 3 Feb 2011 18:34:05 +0000 (10:34 -0800)]
Add mmap(2) support

It's worth taking a moment to describe how mmap is implemented
for zfs because it differs considerably from other Linux filesystems.
However, this issue is handled the same way under OpenSolaris.

The issue is that by design zfs bypasses the Linux page cache and
leaves all caching up to the ARC.  This has been shown to work
well for the common read(2)/write(2) case.  However, mmap(2)
is problem because it relies on being tightly integrated with the
page cache.  To handle this we cache mmap'ed files twice, once in
the ARC and a second time in the page cache.  The code is careful
to keep both copies synchronized.

When a file with an mmap'ed region is written to using write(2)
both the data in the ARC and existing pages in the page cache
are updated.  For a read(2) data will be read first from the page
cache then the ARC if needed.  Neither a write(2) or read(2) will
will ever result in new pages being added to the page cache.

New pages are added to the page cache only via .readpage() which
is called when the vfs needs to read a page off disk to back the
virtual memory region.  These pages may be modified without
notifying the ARC and will be written out periodically via
.writepage().  This will occur due to either a sync or the usual
page aging behavior.  Note because a read(2) of a mmap'ed file
will always check the page cache first even when the ARC is out
of date correct data will still be returned.

While this implementation ensures correct behavior it does have
have some drawbacks.  The most obvious of which is that it
increases the required memory footprint when access mmap'ed
files.  It also adds additional complexity to the code keeping
both caches synchronized.

Longer term it may be possible to cleanly resolve this wart by
mapping page cache pages directly on to the ARC buffers.  The
Linux address space operations are flexible enough to allow
selection of which pages back a particular index.  The trick
would be working out the details of which subsystem is in
charge, the ARC, the page cache, or both.  It may also prove
helpful to move the ARC buffers to a scatter-gather lists
rather than a vmalloc'ed region.

Additionally, zfs_write/read_common() were used in the readpage
and writepage hooks because it was fairly easy.  However, it
would be better to update zfs_fillpage and zfs_putapage to be
Linux friendly and use them instead.

13 years agoAdd Hooks for Linux Xattr Operations
Brian Behlendorf [Wed, 26 Jan 2011 20:10:01 +0000 (12:10 -0800)]
Add Hooks for Linux Xattr Operations

The Linux specific xattr operations have all been located in the
file zpl_xattr.c.  These functions primarily rely on the reworked
zfs_* functions to do their job.  They are also responsible for
converting the possible Solaris style error codes to negative
Linux errors.

13 years agoAdd Hooks for Linux Super Block Operations
Brian Behlendorf [Wed, 26 Jan 2011 20:09:10 +0000 (12:09 -0800)]
Add Hooks for Linux Super Block Operations

The Linux specific super block operations have all been located in the
file zpl_super.c.  These functions primarily rely on the reworked
zfs_* functions to do their job.  They are also responsible for
converting the possible Solaris style error codes to negative
Linux errors.

13 years agoAdd Hooks for Linux Inode Operations
Brian Behlendorf [Wed, 26 Jan 2011 20:08:24 +0000 (12:08 -0800)]
Add Hooks for Linux Inode Operations

The Linux specific inode operations have all been located in the
file zpl_inode.c.  These functions primarily rely on the reworked
zfs_* functions to do their job.  They are also responsible for
converting the possible Solaris style error codes to negative
Linux errors.

13 years agoAdd Hooks for Linux File Operations
Brian Behlendorf [Wed, 26 Jan 2011 20:03:58 +0000 (12:03 -0800)]
Add Hooks for Linux File Operations

The Linux specific file operations have all been located in the
file zpl_file.c.  These functions primarily rely on the reworked
zfs_* functions to do their job.  They are also responsible for
converting the possible Solaris style error codes to negative
Linux errors.

This first zpl_* commit also includes a common zpl.h header with
minimal entries to register the Linux specific hooks.  In also
adds all the new zpl_* file to the Makefile.in.  This is not a
standalone commit, you required the following zpl_* commits.

13 years agoWrap with HAVE_XVATTR
Brian Behlendorf [Tue, 8 Feb 2011 19:33:08 +0000 (11:33 -0800)]
Wrap with HAVE_XVATTR

For the moment exactly how to handle xvattr is not clear.  This
change largely consists of the code to comment out the offending
bits until something reasonable can be done.

13 years agoAdd zp->z_is_zvol flag
Brian Behlendorf [Tue, 8 Feb 2011 19:29:50 +0000 (11:29 -0800)]
Add zp->z_is_zvol flag

A new flag is required for the zfs_rlock code to determine if
it is operation of the zvol of zpl dataset.  This used to be
keyed off the zp->z_vnode, which was a hack to begin with, but
with the removal of vnodes we needed a dedicated flag.

13 years agoPrototype/structure update for Linux
Brian Behlendorf [Tue, 8 Feb 2011 19:16:06 +0000 (11:16 -0800)]
Prototype/structure update for Linux

I appologize in advance why to many things ended up in this commit.
When it could be seperated in to a whole series of commits teasing
that all apart now would take considerable time and I'm not sure
there's much merrit in it.  As such I'll just summerize the intent
of the changes which are all (or partly) in this commit.  Broadly
the intent is to remove as much Solaris specific code as possible
and replace it with native Linux equivilants.  More specifically:

1) Replace all instances of zfsvfs_t with zfs_sb_t.  While the
type is largely the same calling it private super block data
rather than a zfsvfs is more consistent with how Linux names
this.  While non critical it makes the code easier to read when
your thinking in Linux friendly VFS terms.

2) Replace vnode_t with struct inode.  The Linux VFS doesn't have
the notion of a vnode and there's absolutely no good reason to
create one.  There are in fact several good reasons to remove it.
It just adds overhead on Linux if we were to manage one, it
conplicates the code, and it likely will lead to bugs so there's
a good change it will be out of date.  The code has been updated
to remove all need for this type.

3) Replace all vtype_t's with umode types.  Along with this shift
all uses of types to mode bits.  The Solaris code would pass a
vtype which is redundant with the Linux mode.  Just update all the
code to use the Linux mode macros and remove this redundancy.

4) Remove using of vn_* helpers and replace where needed with
inode helpers.  The big example here is creating iput_aync to
replace vn_rele_async.  Other vn helpers will be addressed as
needed but they should be be emulated.  They are a Solaris VFS'ism
and should simply be replaced with Linux equivilants.

5) Update znode alloc/free code.  Under Linux it's common to
embed the inode specific data with the inode itself.  This removes
the need for an extra memory allocation.  In zfs this information
is called a znode and it now embeds the inode with it.  Allocators
have been updated accordingly.

6) Minimal integration with the vfs flags for setting up the
super block and handling mount options has been added this
code will need to be refined but functionally it's all there.

This will be the first and last of these to large to review commits.

13 years agoRemove dmu_write_pages() support
Brian Behlendorf [Tue, 8 Feb 2011 18:39:06 +0000 (10:39 -0800)]
Remove dmu_write_pages() support

For the moment we do not use dmu_write_pages() to write pages
directly in to a dmu object.  It may be required at some point
in the future, but for now is simplest and cleanest to drop it.
It can be easily readded if/when needed.

13 years agoCreate a root znode without VFS dependencies
Brian Behlendorf [Wed, 26 Jan 2011 20:49:58 +0000 (12:49 -0800)]
Create a root znode without VFS dependencies

For portability reasons it's handy to be able to create a root
znode and basic filesystem components without requiring the full
cooperation of the VFS.  We are committing to this to simply the
filesystem creations code.

13 years agoRemove zfs_ctldir.[ch]
Brian Behlendorf [Wed, 26 Jan 2011 20:45:24 +0000 (12:45 -0800)]
Remove zfs_ctldir.[ch]

This code is used for snapshot and heavily leverages Solaris
functionality we do not want to reimplement.  These files have
been removed, including references to them, and will be replaced
by a zfs_snap.c/zpl_snap.c implementation which handles snapshots.

13 years agoDisable fuid features
Brian Behlendorf [Thu, 6 Jan 2011 22:53:21 +0000 (14:53 -0800)]
Disable fuid features

These features should probably be enabled in the Linux zpl code.
For now I'm disabling them until it's clear what needs to be done.

13 years agoDisable zfs_sync during oops/panic
Brian Behlendorf [Thu, 6 Jan 2011 22:07:41 +0000 (14:07 -0800)]
Disable zfs_sync during oops/panic

Minor update to ensure zfs_sync() is disabled if a kernel oops/panic
is triggered.  As the comment says 'data integrity is job one'.  This
change could have been done by defining panicstr to oops_in_progress
in the SPL.  But I felt it was better to use the native Linux API
here since to be clear.

13 years agoDisable Shutdown/Reboot
Brian Behlendorf [Thu, 6 Jan 2011 00:38:30 +0000 (16:38 -0800)]
Disable Shutdown/Reboot

This support has been disable with HAVE_SHUTDOWN.  We can support
this at some point by adding the needed reboot notifiers.

13 years agoRemove SYNC_ATTR check
Brian Behlendorf [Thu, 6 Jan 2011 22:15:48 +0000 (14:15 -0800)]
Remove SYNC_ATTR check

This flag does not need to be support under Linux.  As the comment
says it was only there to support fsflush() for old filesystem like
UFS.  This is not needed under Linux.

13 years agoRemove mount options
Brian Behlendorf [Thu, 6 Jan 2011 20:56:48 +0000 (12:56 -0800)]
Remove mount options

Mount option parsing is still very Linux specific and will be
handled above this zfs filesystem layer.  Honoring those mount
options once set if of course the responsibility of the lower
layers.

13 years agoRemove zfs_active_fs_count
Brian Behlendorf [Thu, 6 Jan 2011 01:00:34 +0000 (17:00 -0800)]
Remove zfs_active_fs_count

This variable was used to ensure that the ZFS module is never
removed while the filesystem is mounted.  Once again the generic
Linux VFS handles this case for us so it can be removed.

13 years agoRemove unused mount functions
Brian Behlendorf [Thu, 6 Jan 2011 00:56:49 +0000 (16:56 -0800)]
Remove unused mount functions

The functions zfs_mount_label_policy(), zfs_mountroot(), zfs_mount()
will not be needed because most of what they do is already handled
by the generic Linux VFS layer.  They all call zfs_domount() which
creates the actual dataset, the caller of this library call which
will be in the zpl layer is responsible for what's left.

13 years agoRemove zfs_major/zfs_minor/zfsfstype
Brian Behlendorf [Thu, 6 Jan 2011 00:24:57 +0000 (16:24 -0800)]
Remove zfs_major/zfs_minor/zfsfstype

Under Linux we don't need to reserve a major or minor number for
the filesystem.  We can rely on the VFS to handle colisions without
this being handled by the lower ZFS layers.

Additionally, there is no need to keep a zfsfstype around.  We are
not limited on Linux by the OpenSolaris infrastructure which needed
this.  The upper zpl layer can specify the filesystem type.

13 years agoRemove Solaris VFS Hooks
Brian Behlendorf [Wed, 5 Jan 2011 22:46:59 +0000 (14:46 -0800)]
Remove Solaris VFS Hooks

The ZFS code is being restructured to act as a library and a stand
alone module.  This allows us to leverage most of the existing code
with minimal modification.  It also means we need to drop the Solaris
vfs/vnode functions they will be replaced by Linux equivilants and
updated to be Linux friendly.

13 years agoVFS: Add zfs_inode_update() helper
Brian Behlendorf [Wed, 5 Jan 2011 22:27:30 +0000 (14:27 -0800)]
VFS: Add zfs_inode_update() helper

For the moment we have left ZFS unchanged and it updates many values
as part of the znode.  However, some of these values should be set
in the inode.  For the moment this is handled by adding a function
called zfs_inode_update() which updates the inode based on the znode.

This is considered a workaround until we can systematically go
through the ZFS code and have it directly update the inode.  At
which point zfs_update_inode() can be dropped entirely.  Keeping
two copies of the same data isn't only inefficient it's a breeding
ground for bugs.

13 years agoVFS: Integrate zfs_znode_alloc()
Brian Behlendorf [Wed, 5 Jan 2011 21:16:12 +0000 (13:16 -0800)]
VFS: Integrate zfs_znode_alloc()

Under Linux the convention for filesystem specific data structure is
to embed it along with the generic vfs data structure.  This differs
significantly from Solaris.

Since we want to integrates as cleanly with the Linux VFS as possible.
This changes modifies zfs_znode_alloc() to allocate a znode with an
embedded inode for use with the generic VFS.  This is done by calling
iget_locked() which will allocate a new inode if needed by calling
sb->alloc_inode().  This function allocates enough memory for a
znode_t by returns a pointer to the inode structure for Linux's VFS.
This function is also responsible for setting the callback
znode->z_set_ops_inodes() which is used to register the correct
handlers for the inode.

13 years agoEnable zfs_znode compilation
Brian Behlendorf [Wed, 22 Dec 2010 00:28:11 +0000 (16:28 -0800)]
Enable zfs_znode compilation

Basic compilation of the bulk of zfs_znode.c has been enabled.  After
much consideration it was decided to convert the existing vnode based
interfaces to more friendly Linux interfaces.  The following commits
will systematically replace update the requiter interfaces.  There
are of course pros and cons to this decision.

Pros:
* This simplifies intergration with Linux in the long term.  There is
  no longer any need to manage vnodes which are a foreign concept to
  the Linux VFS.
* Improved long term maintainability.
* Minor performance improvements by removing vnode overhead.

Cons:
* Added work in the short term to modify multiple ZFS interfaces.
* Harder to pull in changes if we ever see any new code from Solaris.
* Mixed Solaris and Linux interfaces in some ZFS code.

13 years agoACL related changes
Brian Behlendorf [Fri, 17 Dec 2010 23:21:18 +0000 (15:21 -0800)]
ACL related changes

A small collection of ACL related changes related to not
supporting fuid mapping.  This whole are will need to be
closely investigated.

13 years agoInit/destroy tsd
Brian Behlendorf [Fri, 17 Dec 2010 23:26:17 +0000 (15:26 -0800)]
Init/destroy tsd

Add missing tsd_destroy() call for rrw_tsd_key to avoid a leak.

13 years agoAdd Linux Compat Infrastructure
Brian Behlendorf [Tue, 18 Jan 2011 19:42:25 +0000 (11:42 -0800)]
Add Linux Compat Infrastructure

Lay the initial ground work for a include/linux/ compatibility
directory.  This was less critical in the past because the bulk
of the ZFS code consumes the Solaris API via the SPL.  This API
was stable and the bulk Linux API differences were handled in
the SPL.

However, with the addition of a full Posix layer written directly
against the Linux APIs we are going to need more compatibility
code.  It makes sense that all this code should be cleanly located
in one place.  Subsequent patches should move the existing zvol
and vdev_disk compatibility code in to this directory.

13 years agoReplace VOP_* calls with direct zfs_* calls
Brian Behlendorf [Wed, 22 Dec 2010 18:07:03 +0000 (10:07 -0800)]
Replace VOP_* calls with direct zfs_* calls

These generic Solaris wrappers are no longer required.  Simply
directly call the correct zfs functions for clarity.

13 years agoAdd basic uio support
Brian Behlendorf [Wed, 22 Dec 2010 20:13:57 +0000 (12:13 -0800)]
Add basic uio support

This code originates in OpenSolaris and was modified by KQ Infotech
to be compatible with Linux.  While supporting uios in the short
term is useful to get something working this is not an abstraction
we want to keep.  This code is expected to be short lived and
removed as soon as all the remaining uio based APIs and updated.

13 years agoAdd trivial acl helpers
Brian Behlendorf [Wed, 12 Jan 2011 20:51:48 +0000 (12:51 -0800)]
Add trivial acl helpers

The zfs acl code makes use of the two OpenSolaris helper functions
acl_trivial_access_masks() and ace_trivial_common().  Since they are
only called from zfs_acl.c I've brought them over from OpenSolaris
and added them as static function to this file.  This way I don't
need to reimplement this functionality from scratch in the SPL.

Long term once I take a more careful look at the acl implementation
it may be the case that these functions really aren't needed.  If
that turns out to be the case they can then be removed.