Commit Graph

2334 Commits

Author SHA1 Message Date
Konstantin Belousov
c4702e66f4 Remove unused VOP_IOCTL and VOP_KQFILTER implementations for fifofs.
MFC after:	2 weeks
2009-06-10 14:02:22 +00:00
Konstantin Belousov
c4df27d5c8 VOP_IOCTL takes unlocked vnode as an argument. Due to this, v_data may
be NULL or derefenced memory may become free at arbitrary moment.

Lock the vnode in cd9660, devfs and pseudofs implementation of VOP_IOCTL
to prevent reclaim; check whether the vnode was already reclaimed after
the lock is granted.

Reported by:	georg at dts su
Reviewed by:	des (pseudofs)
MFC after:	2 weeks
2009-06-10 13:57:36 +00:00
Rick Macklem
410654ec1b Since vn_lock() with the LK_RETRY flag never returns an error
for FreeBSD-CURRENT, the code that checked for and returned the
error was broken. Change it to check for VI_DOOMED set after
vn_lock() and return an error for that case. I believe this
should only happen for forced dismounts.

Approved by:	kib (mentor)
2009-06-09 15:18:01 +00:00
Rick Macklem
2fa32154e4 Fix nfscl_getcl() so that it doesn't crash when it is called to
do an NFSv4 Close operation with the cred argument NULL. Also,
clarify what NULL arguments mean in the function's comment.

Approved by:	kib (mentor)
2009-06-08 18:41:23 +00:00
Robert Watson
dde155e95a Use #ifdef APPLE_MAC instead of #ifdef MAC to conditionalize Apple-specific
behavior for unicode support in UDF so as not to conflict with the MAC
Framework.

Note that Apple's XNU kernel also uses #ifdef MAC for the MAC Framework.

Suggested by:	pjd
MFC after:	3 days
2009-06-06 07:13:57 +00:00
Dag-Erling Smørgrav
c097b30885 Drop Giant.
MFC after:	1 week
2009-06-06 00:44:13 +00:00
Robert Watson
bcf11e8d00 Move "options MAC" from opt_mac.h to opt_global.h, as it's now in GENERIC
and used in a large number of files, but also because an increasing number
of incorrect uses of MAC calls were sneaking in due to copy-and-paste of
MAC-aware code without the associated opt_mac.h include.

Discussed with:	pjd
2009-06-05 14:55:22 +00:00
Robert Watson
37ba986a5f Don't check MAC in the NFS server ACL set path, right now we aren't
enforcing MAC for NFS clients.
2009-06-05 14:15:00 +00:00
Robert Watson
927e0a56ce Re-add opt_mac.h include, which is required in order for MNT_MULTILABEL
to be set properly on devfs.  Otherwise, it isn't possible to set labels
on /dev nodes.

Reported by:	Sergio Rodriguez <sergiorr at yahoo.com>
MFC after:	3 days
2009-06-04 10:30:18 +00:00
Alan Cox
1f17689408 nfs_write() can use the recently introduced vfs_bio_set_valid() instead of
vfs_bio_set_validclean(), thereby avoiding the page queues lock.

Garbage collect vfs_bio_set_validclean().  Nothing uses it any longer.
2009-05-31 20:18:02 +00:00
Konstantin Belousov
b00098d164 Unlock the pseudofs vnode before calling fill method for pfs_readlink().
The fill code may need to lock another vnode, e.g. procfs file
implementation.

Reviewed by:	des
Tested by:	pho
MFC after:	2 weeks
2009-05-31 15:01:50 +00:00
Konstantin Belousov
b0f34bb643 Implement the bypass routine for VOP_VPTOCNP in nullfs.
Among other things, this makes procfs <pid>/file working for executables
started from nullfs mount.

Tested by:	pho
PR:	94269, 104938
2009-05-31 14:58:43 +00:00
Konstantin Belousov
b9131889d2 Do not drop vnode interlock in null_checkvp(). null_lock() verifies that
v_data is not-null before calling NULLVPTOLOWERVP(), and dropping the
interlock allows for reclaim to clean v_data and free the memory.

While there, remove unneeded semicolons and convert the infinite loops
to panics. I have a will to remove null_checkvp() altogether, or leave
it as a trivial stub, but not now.

Reported and tested by:	pho
2009-05-31 14:54:20 +00:00
Konstantin Belousov
cec9ed6d7f Lock the real null vnode lock before substitution of vp->v_vnlock.
This should not really matter for correctness, since vp->v_lock is
not locked before the call, and null_lock() holds the interlock,
but makes the control flow for reclaim more clear.

Tested by:	pho
2009-05-31 14:52:45 +00:00
Marko Zec
705fe7ce35 Unbreak options VIMAGE kernel builds.
Approved by:	julian (mentor)
2009-05-31 11:57:51 +00:00
Rick Macklem
d00a615a98 Add a check to v_type == VREG for the recently modified code that
does NFSv4 Closes in the experimental client's VOP_INACTIVE().
I also replaced a bunch of ap->a_vp with a local copy of vp,
because I thought that made it more readable.

Approved by:	kib (mentor)
2009-05-30 22:11:12 +00:00
Edward Tomasz Napierala
c97fcdba57 Add VOP_ACCESSX, which can be used to query for newly added V*
permissions, such as VWRITE_ACL.  For a filsystems that don't
implement it, there is a default implementation, which works
as a wrapper around VOP_ACCESS.

Reviewed by:	rwatson@
2009-05-30 13:59:05 +00:00
Jamie Gritton
76ca6f88da Place hostnames and similar information fully under the prison system.
The system hostname is now stored in prison0, and the global variable
"hostname" has been removed, as has the hostname_mtx mutex.  Jails may
have their own host information, or they may inherit it from the
parent/system.  The proper way to read the hostname is via
getcredhostname(), which will copy either the hostname associated with
the passed cred, or the system hostname if you pass NULL.  The system
hostname can still be accessed directly (and without locking) at
prison0.pr_host, but that should be avoided where possible.

The "similar information" referred to is domainname, hostid, and
hostuuid, which have also become prison parameters and had their
associated global variables removed.

Approved by:	bz (mentor)
2009-05-29 21:27:12 +00:00
Alan Cox
3933ec4d15 Make *getpages()s' assertion on the state of each page's dirty bits
stricter.
2009-05-28 18:11:09 +00:00
Dag-Erling Smørgrav
26088b9d4d Use a temporary variable to avoid a duplicate strlen().
Submitted by:	kib
MFC after:	1 week
2009-05-28 10:24:26 +00:00
Rick Macklem
fdd88deeba Fix handling of NFSv4 Close operations in ncl_inactive(). Only
do them for NFSv4 and flush writes to the server before doing
the Close(s), as required. Also, use the a_td argument instead of
curthread.

Approved by:	kib (mentor)
2009-05-27 19:41:29 +00:00
Alan Cox
e2d0be0172 Eliminate redundant setting of a page's valid bits and pointless clearing
of the same page's dirty bits.
2009-05-27 18:12:10 +00:00
Rick Macklem
ee1c1433e3 Add a function to the experimental nfs subsystem that tests to see
if a local file system supports NFSv4 ACLs. This allows the
NFSHASNFS4ACL() macro to be correctly implemented. The NFSv4 ACL
support should now work when the server exports a ZFS volume.

Approved by:	kib (mentor)
2009-05-27 15:16:56 +00:00
Jamie Gritton
0304c73163 Add hierarchical jails. A jail may further virtualize its environment
by creating a child jail, which is visible to that jail and to any
parent jails.  Child jails may be restricted more than their parents,
but never less.  Jail names reflect this hierarchy, being MIB-style
dot-separated strings.

Every thread now points to a jail, the default being prison0, which
contains information about the physical system.  Prison0's root
directory is the same as rootvnode; its hostname is the same as the
global hostname, and its securelevel replaces the global securelevel.
Note that the variable "securelevel" has actually gone away, which
should not cause any problems for code that properly uses
securelevel_gt() and securelevel_ge().

Some jail-related permissions that were kept in global variables and
set via sysctls are now per-jail settings.  The sysctls still exist for
backward compatibility, used only by the now-deprecated jail(2) system
call.

Approved by:	bz (mentor)
2009-05-27 14:11:23 +00:00
Rick Macklem
c3e22f831f Fix the experimental nfs subsystem so that it builds with the
current NFSv4 ACLs, as defined in sys/acl.h. It still needs a
way to test a mount point for NFSv4 ACL support before it will
work. Until then, the NFSHASNFS4ACL() macro just always returns 0.

Approved by:	kib (mentor)
2009-05-26 22:21:53 +00:00
Edward Tomasz Napierala
ff392a1d87 Adapt to the new ACL #define names.
Reviewed by:	rmacklem@
2009-05-26 17:01:00 +00:00
Rick Macklem
10a5a16efa Add two sysctl variables to the experimental nfs server, so
that the range of versions of NFS handled by the server can
be limited. The nfsd daemon must be restarted after these
sysctl variables are changed, in order for the change to take
effect.

Approved by:	kib (mentor)
2009-05-26 01:47:37 +00:00
Rick Macklem
9183a2a33e Fix the handling of NFSv4 Illegal Operation number to conform
to RFC3530 (the operation number in the reply must be set to
the value for OP_ILLEGAL). Also cleaned up some indentation.

Approved by:	kib (mentor)
2009-05-26 01:16:09 +00:00
Rick Macklem
415670e4c2 Fix the experimental nfs server's interface to the new krpc so
that it handles the case of a non-exported NFSv4 root correctly.
Also, delete handling for the case where nd_repstat is already
set in nfs_proc(), since that no longer happens.

Approved by:	kib (mentor)
2009-05-26 01:09:33 +00:00
Rick Macklem
b1cfc0d961 Add NFSv4 root export checks to the DelegPurge, Renew and
ReleaseLockOwner operations analagous to what is already
in place for SetClientID and SetClientIDConfirm. These are
the five NFSv4 operations that do not use file handle(s),
so the checks are done using the NFSv4 root export entries
in /etc/exports.

Approved by:	kib (mentor)
2009-05-25 01:00:09 +00:00
Rick Macklem
6098ac23c1 Temporarily #undef NFS4_ACL_EXTATTR_NAME, so that the
experimental nfs subsystem will build while the NFSv4 ACL
support is going into the kernel.

Approved by:	kib (mentor)
2009-05-24 23:47:22 +00:00
Rick Macklem
05c965a221 Crib the realign function out of nfs_krpc.c and add a call
to it for the client side reply. Hopefully this fixes the
problem with using the new krpc for arm for the experimental
nfs client.

Approved by:	kib (mentor)
2009-05-24 19:46:12 +00:00
Rick Macklem
c1edc4480e Fix the experimental NFSv4 server so that it handles the case
where a client is not allowed NFSv4 access correctly. This
restriction is specified in the "V4: ..." line(s) in
/etc/exports.

Approved by:	kib (mentor)
2009-05-24 18:49:53 +00:00
Rick Macklem
63bde62e9a Fix the experimental nfsv4 client so that it works for the
case of a kerberized mount without a host based principal
name. This will only work for mounts being done by a user
other than root. Support for a host based principal name
will not work until proposed changes to the rpcsec_gss part
of the krpc are committed. It now builds for "options KGSSAPI".

Approved by:	kib (mentor)
2009-05-24 03:22:49 +00:00
Alan Cox
5662349ed5 Eliminate the unnecessary clearing of a page's dirty bits from
nwfs_getpages().
2009-05-23 18:25:11 +00:00
Rick Macklem
e2b84e0308 Fix the rpc_gss_secfind() call in nfs_commonkrpc.c so that
the code will build when "options KGSSAPI" is specified
without requiring the proposed changes that add host based
initiator principal support. It will not handle the case where
the client uses a host based initiator principal until those
changes are committed. The code that uses those changes is
#ifdef'd notyet until the krpc rpcsec_changes are committed.

Approved by:	kib (mentor)
2009-05-23 00:40:17 +00:00
Rick Macklem
b66124f314 Change the sysctl_base argument to svcpool_create() to NULL for
client side callbacks so that leaf names are not re-used,
since they are already being used by the server.

Approved by:	kib (mentor)
2009-05-22 23:22:56 +00:00
Rick Macklem
9dd7554f09 Fix the name of the module common to the client and server
in the experimental nfs subsystem to the correct one for
the MODULE_DEPEND() macro.

Approved by:	kib (mentor)
2009-05-22 20:55:29 +00:00
Rick Macklem
ed41a7ccee Change the printf of r192595 to identify the function,
as requested by Sam.

Approved by:	kib (mentor)
2009-05-22 19:05:48 +00:00
Rick Macklem
476174008c Modified the printf message of r192590 to remove the
possible DOS attack, as suggested by Sam.

Approved by:	kib (mentor)
2009-05-22 18:10:39 +00:00
Rick Macklem
8757104e6b Change the comment at the beginning of the function to reflect the
change from panic() to printf() done by r192588.
2009-05-22 16:46:01 +00:00
Rick Macklem
199685bca9 Change the reboot panic that would have occurred if clientid
numbers wrapped around to a printf() warning of a possible
DOS attack, in the experimental nfsv4 server.

Approved by:	kib (mentor)
2009-05-22 16:41:33 +00:00
Rick Macklem
682eec57c4 Modify the mount handling code in the experimental nfs client to
use the newer nmount() style arguments, as is used by mount_nfs.c.
This prepares the kernel code for the use of a mount_nfs.c with
changes for the experimental client integrated into it.

Approved by:	kib (mentor)
2009-05-22 15:08:12 +00:00
Rick Macklem
6ffb637d4a Change the code in the experimental nfs client to avoid flushing
writes upon close when a write delegation is held by the client.
This should be safe to do, now that nfsv4 Close operations are
delayed until ncl_inactive() is called for the vnode.

Approved by:	kib (mentor)
2009-05-22 15:01:47 +00:00
Rick Macklem
7951235502 Fix the comment in sys/fs/nfs/nfs.h to correctly reflect the
current use of the R_xxx flags. This changed when the
NFS_LEGACYRPC code was removed from the subsystem.

Approved by:	kib (mentor)
2009-05-22 14:53:26 +00:00
Robert Watson
86ce6a83d1 Remove the unmaintained University of Michigan NFSv4 client from 8.x
prior to 8.0-RELEASE.  Rick Macklem's new and more feature-rich NFSv234
client and server are replacing it.

Discussed with:	rmacklem
2009-05-22 12:35:12 +00:00
Rick Macklem
92f7f12bca Fix the experimental nfs server so that it depends on the nlm,
since it now calls nlm_acquire_next_sysid().

Approved by:	kib (mentor)
2009-05-22 01:15:07 +00:00
Rick Macklem
bac9ff3446 Fix the comment at line 3711 to be consistent with the change
applied for r192537.

Approved by:	kib (mentor)
2009-05-21 14:52:36 +00:00
Rick Macklem
b839e625b0 Modify sys/fs/nfsserver/nfs_nfsdport.c to use nlm_acquire_next_sysid()
to set the l_sysid for locks correctly.

Approved by:	kib (mentor)
2009-05-21 01:50:27 +00:00
Rick Macklem
29e890f126 Although it should never happen, all the nfsv4 server can do
when it runs out of clientids is reboot. I had replaced cpu_reboot()
with printf(), since cpu_reboot() doesn't exist for sparc64.
This change replaces the printf() with panic(), so the reboot
would occur for this highly unlikely occurrence.

Approved by:	kib (mentor)
2009-05-20 18:58:07 +00:00
Rick Macklem
47a598563d Change the experimental NFSv4 client so that it does not do
the NFSv4 Close operations until ncl_inactive(). This is
necessary so that the Open StateIDs are available for doing
I/O on mmap'd files after VOP_CLOSE(). I also changed some
indentation for the nfscl_getclose() function.

Approved by:	kib (mentor)
2009-05-18 21:22:03 +00:00
Rick Macklem
2c1b26b976 Fix the acquisition of local locks via VOP_ADVLOCK() by the
experimental nfsv4 server. It was setting the a_id argument
to a fixed value, but that wasn't sufficient for FreeBSD8.
Instead, set l_pid and l_sysid to 0 plus set the F_REMOTE
flag to indicate that these fields are used to check for
same lock owner. Since, for NFSv4, a lockowner is a ClientID plus
an up to 1024byte name, it can't be put in l_sysid easily.
I also renamed the p variable to td, since it's a thread ptr.

Approved by:	kib (mentor)
2009-05-17 19:33:48 +00:00
Rick Macklem
57d1e46484 Added a SYSCTL to sys/fs/nfsserver/nfs_nfsdport.c so that the value of
nfsrv_dolocallocks can be changed via sysctl. I also added some non-empty
descriptor strings and reformatted some overly long lines.

Approved by:	kib (mentor)
2009-05-17 17:54:01 +00:00
Alan Cox
f2eb372e02 Merge r191964: Eliminate a case of unnecessary page queues locking. 2009-05-17 06:45:30 +00:00
Rick Macklem
72d1bbba52 Changed sys/fs/nfs_clbio.c in the same way Alan Cox changed
sys/nfsclient/nfs_bio.c for r192134, so that the sources stay
in sync.

Approved by:	kib (mentor)
2009-05-16 22:31:38 +00:00
Rick Macklem
15e8331f0e Fixed the Null callback RPCs so that they work with the new krpc. This
required two changes: setting the program and version numbers before
connect and fixing the handling of the Null Rpc case in newnfs_request().

Approved by:	kib (mentor)
2009-05-16 03:12:55 +00:00
Rick Macklem
0c794c5db1 Move the nfsstat structure and proc/op number definitions on the
experimental nfs subsystem from sys/fs/nfs/nfs.h and sys/fs/nfs/nfsproto.h
to sys/fs/nfs/nfsport.h and rename nfsstat to ext_nfsstat. This was done
so that src/usr.bin/nfsstat.c could use it alongside the regular nfs
include files and struct nfsstat.

Approved by:	kib (mentor)
2009-05-15 19:33:59 +00:00
Konstantin Belousov
0e9bd89d7d Devfs replaces file ops vector with devfs-specific one in devfs_open(),
before the struct file is fully initialized in vn_open(), in particular,
fp->f_vnode is NULL. Other thread calling file operation before f_vnode
is set results in NULL pointer dereference in devvn_refthread().

Initialize f_vnode before calling d_fdopen() cdevsw method, that might
set file ops too.

Reported and tested by:	Chris Timmons <cwt networks cwu edu>
	(RELENG_7 version)
MFC after:	3 days
2009-05-15 19:23:05 +00:00
Rick Macklem
d34b41c9c2 Modify the diskless booting code in sys/fs/nfsclient to be compatible
with what is in sys/nfsclient, so that it will at least build now.

Approved by:	kib (mentor)
2009-05-15 16:03:11 +00:00
Alan Cox
42eb41087c Eliminate unnecessary clearing of the page's dirty mask from various
getpages functions.

Eliminate a stale comment.
2009-05-15 04:33:35 +00:00
Rick Macklem
98ad44534e Apply changes to the experimental nfs server so that it uses the security
flavors as exported in FreeBSD-CURRENT. This allows it to use a
slightly modified mountd.c instead of a different utility.

Approved by:	kib (mentor)
2009-05-14 21:39:08 +00:00
Rick Macklem
cec6336717 Change the file names in the comments in sys/fs/nfs/nfs_var.h so
that they are the names used in FreeBSD-CURRENT. Also shuffled a
few entries around, so that they under the correct comment.

Approved by:	kib (mentor)
2009-05-14 20:39:09 +00:00
Rick Macklem
a770e183dd Apply a one line change to nfs_clbio.c (which is largely a copy
of sys/nfsclient/nfs_bio.c) to track the change recently committed
by acl for nfs_bio.c.

Approved by:	kib (mentor)
2009-05-13 21:18:34 +00:00
Rick Macklem
7e74551956 Modify the experimental nfs server to use the new nfsd_nfsd_args
structure for nfsd. Includes a change that clarifies the use of
an empty principal name string to indicate AUTH_SYS only.

Approved by:	kib (mentor)
2009-05-12 16:04:51 +00:00
Konstantin Belousov
3fe65eb8fe Report all fdescfs vnodes as VCHR for stat(2). Fake the unique
major/minor numbers of the devices.

Pretending that the vnodes are character devices prevents file tree
walkers from descending into the directories opened by current process.
Also, not doing stat on the filedescriptors prevents the recursive entry
into the VFS.

Requested by:	kientzle
Discussed with:	Jilles Tjoelker <jilles stack nl>
2009-05-12 09:28:45 +00:00
Konstantin Belousov
ada3b6a9ea Return controlled EINVAL when the fdescfs lookup routine is given string
representing too large integer, instead of overflowing and possibly
returning a random but valid vnode.

Noted by:	Jilles Tjoelker <jilles stack nl>
MFC after:	3 days
2009-05-12 09:22:33 +00:00
Alan Cox
12aa4fdca9 Eliminate gratuitous clearing of the page's dirty mask. 2009-05-12 05:49:02 +00:00
Rick Macklem
1c6c0ed937 Change the name of the nfs server addsock structure from nfsd_args
to nfsd_addsock_args, so that it is consistent with the one in
	sys/nfsserver/nfs.h.

Approved by:	kib (mentor)
2009-05-11 19:37:05 +00:00
Rick Macklem
70839889c6 Modify nfsvno_fhtovp() to ensure that it always sets the credp
argument. Returning without credp set could result in a caller
	doing crfree() on garbage.

Reviewed by:	kan
Approved by:	kib (mentor)
2009-05-11 18:45:04 +00:00
Attilio Rao
dfd233edd5 Remove the thread argument from the FSD (File-System Dependent) parts of
the VFS.  Now all the VFS_* functions and relating parts don't want the
context as long as it always refers to curthread.

In some points, in particular when dealing with VOPs and functions living
in the same namespace (eg. vflush) which still need to be converted,
pass curthread explicitly in order to retain the old behaviour.
Such loose ends will be fixed ASAP.

While here fix a bug: now, UFS_EXTATTR can be compiled alone without the
UFS_EXTATTR_AUTOSTART option.

VFS KPI is heavilly changed by this commit so thirdy parts modules needs
to be recompiled.  Bump __FreeBSD_version in order to signal such
situation.
2009-05-11 15:33:26 +00:00
Alan Cox
f45cc06eb1 Eliminate stale comments.
Eliminate a case of unnecessary page queues locking.
2009-05-10 17:05:43 +00:00
Alexander Kabaev
5679fe1957 Do not embed struct ucred into larger netcred parent structures.
Credential might need to hang around longer than its parent and be used
outside of mnt_explock scope controlling netcred lifetime. Use separate
reference-counted ucred allocated separately instead.

While there, extend mnt_explock coverage in vfs_stdexpcheck and clean-up
some unused declarations in new NFS code.

Reported by:	John Hickey
PR:		kern/133439
Reviewed by:	dfr, kib
2009-05-09 18:09:17 +00:00
Rick Macklem
9ec7b004d0 Add the experimental nfs subtree to the kernel, that includes
support for NFSv4 as well as NFSv2 and 3.
	It lives in 3 subdirs under sys/fs:
	nfs - functions that are common to the client and server
	nfsclient - a mutation of sys/nfsclient that call generic functions
	to do RPCs and handle state. As such, it retains the
	buffer cache handling characteristics and vnode semantics that
	are found in sys/nfsclient, for the most part.
	nfsserver - the server. It includes a DRC designed specifically for
	NFSv4, that is used instead of the generic DRC in sys/rpc.
	The build glue will be checked in later, so at this point, it
	consists of 3 new subdirs that should not affect kernel building.

Approved by:	kib (mentor)
2009-05-04 15:23:58 +00:00
Robert Watson
885868cd8f Remove VOP_LEASE and supporting functions. This hasn't been used since
the removal of NQNFS, but was left in in case it was required for NFSv4.
Since our new NFSv4 client and server can't use it for their
requirements, GC the old mechanism, as well as other unused lease-
related code and interfaces.

Due to its impact on kernel programming and binary interfaces, this
change should not be MFC'd.

Proposed by:    jeff
Reviewed by:    jeff
Discussed with: rmacklem, zach loafman @ isilon
2009-04-10 10:52:19 +00:00
Dag-Erling Smørgrav
4970b8ae0a Remove spurious locking in pfs_write().
Reported by:	Andrew Brampton <me@bramp.net>
MFC after:	1 week
2009-04-08 09:02:42 +00:00
Dag-Erling Smørgrav
59fc1b068f Fix an inverted KASSERT. Add similar assertions in other similar places.
Reported by:	Andrew Brampton <me@bramp.net>
MFC after:	1 week
2009-04-07 16:13:10 +00:00
Peter Holm
aa73f8c7a2 Do not use null_bypass for VOP_ISLOCKED, directly call default
implementation. null_bypass cannot work for the !nullfs-vnodes, in
particular, for VBAD vnodes.

In collaboration with:	kib
2009-03-18 13:54:35 +00:00
Attilio Rao
b13ec5e016 Remove the null_islocked() overloaded vop because the standard one does
the same.
2009-03-13 07:09:20 +00:00
John Baldwin
33fc362512 Add a new internal mount flag (MNTK_EXTENDED_SHARED) to indicate that a
filesystem supports additional operations using shared vnode locks.
Currently this is used to enable shared locks for open() and close() of
read-only file descriptors.
- When an ISOPEN namei() request is performed with LOCKSHARED, use a
  shared vnode lock for the leaf vnode only if the mount point has the
  extended shared flag set.
- Set LOCKSHARED in vn_open_cred() for requests that specify O_RDONLY but
  not O_CREAT.
- Use a shared vnode lock around VOP_CLOSE() if the file was opened with
  O_RDONLY and the mountpoint has the extended shared flag set.
- Adjust md(4) to upgrade the vnode lock on the vnode it gets back from
  vn_open() since it now may only have a shared vnode lock.
- Don't enable shared vnode locks on FIFO vnodes in ZFS and UFS since
  FIFO's require exclusive vnode locks for their open() and close()
  routines.  (My recent MPSAFE patches for UDF and cd9660 already included
  this change.)
- Enable extended shared operations on UFS, cd9660, and UDF.

Submitted by:	ups
Reviewed by:	pjd (ZFS bits)
MFC after:	1 month
2009-03-11 14:13:47 +00:00
Konstantin Belousov
52dc9305aa Enable advisory file locking for devfs vnodes.
Reported by:	Timothy Redaelli <timothy redaelli eu>
MFC after:	1 week
2009-03-11 12:53:16 +00:00
Konstantin Belousov
062ef8a5f8 Do not use bypass for vop_vptocnp() from nullfs, call standard
implementation instead. The bypass does not assume that returned vnode
is only held.

Reported by:	Paul B. Mahol <onemda gmail com>, pluknet <pluknet gmail com>
Reviewed by:	jhb
Tested by:	pho, pluknet <pluknet gmail com>
2009-03-10 14:35:21 +00:00
Konstantin Belousov
125dcf8c7d Extract the no_poll() and vop_nopoll() code into the common routine
poll_no_poll().
Return a poll_no_poll() result from devfs_poll_f() when
filedescriptor does not reference the live cdev, instead of ENXIO.

Noted and tested by:	hps
MFC after:	1 week
2009-03-06 15:35:37 +00:00
Andriy Gapon
159da68b48 udf: use truly unique directory cookie
'off' is an offset within current block, so there is a good chance
it can be non-unique, so use complete offset.

Submitted by:	bde
Approved by:	jhb
2009-03-04 13:54:10 +00:00
Andriy Gapon
9cd835bba9 udf_strategy: remove redundant comment
We fail mapping for any udf_bmap_internal error and there can be
different reasons for it, so no need to (over-)emphasize files with
data in fentry.

Submitted by:	bde
Approved by:	jhb
2009-03-04 13:53:57 +00:00
Andriy Gapon
ff9e355b51 udf_readdir: do not advance offset if entry can not be uio-ed
Previosly readdir missed some directory entries because there was
no space for them in current uio but directory stream offset
was advanced nevertheless.
jhb has discoved the issue and provided a test-case.

Reviewed by:	bde
Approved by:	jhb (mentor)
2009-03-03 13:10:25 +00:00
Konstantin Belousov
2883703e00 Use the p_sysent->sv_flags flag SV_ILP32 to detect 32bit process
executing on 64bit kernel. This eliminates the direct comparisions
of p_sysent with &ia32_freebsd_sysvec, that were left intact after
r185169.
2009-03-02 18:43:50 +00:00
John Baldwin
c72ae1423b - Hold a reference on the cdev a filesystem is mounted from in the mount.
- Remove the cdev pointers from the denode and instead use the mountpoint's
  reference to call dev2udev() in getattr().

Reviewed by:	kib, julian
2009-02-27 20:00:15 +00:00
Andriy Gapon
b2c91b67b6 udf_readatoffset: return correct size and data pointer for data in fentry
This should help correct reading of directories with data located
in fentry.

Submitted by:	bde
Approved by:	jhb (mentor)
2009-02-27 17:29:31 +00:00
Andriy Gapon
b0c0fb5940 udf_readatoffset: read through directory vnode, do not read > MAXBSIZE
Currently bread()-ing through device vnode with
(1) VMIO enabled,
(2) bo_bsize != DEV_BSIZE
(3) more than 1 block
results in data being incorrectly cached.
So instead a more common approach of using a vnode belonging to fs is now
employed.
Also, prevent attempt to bread more than MAXBSIZE bytes because of
adjustments made to account for offset that doesn't start on block
boundary.
Add expanded comments to explain the calculations.
Also drop unused inline function while here.

PR: kern/120967
PR: kern/129084

Reviewed by: scottl, kib
Approved by: jhb (mentor)
2009-02-26 18:58:41 +00:00
Andriy Gapon
fb2a76ccf8 udf: add read-ahead support modeled after cd9660
Reviewed by: scottl
Approved by: jhb (mentor)
2009-02-26 12:33:22 +00:00
Andriy Gapon
82467096ff udf_map: return proper error code instead of leaking an internal one
Incidentally this also allows for small files with data embedded into
fentry to be mmap-ed.

Approved by: jhb (mentor)
2009-02-26 12:33:17 +00:00
Andriy Gapon
be52a95d88 udf_read: correctly read data from files with data embedded into fentry,
... as opposed to files with data in extents.
Some UDF authoring tools produce this type of file for sufficiently small
data files.

Approved by: jhb (mentor)
2009-02-26 12:33:12 +00:00
Andriy Gapon
5792e04db9 udf_strategy: tiny optimization of logic, calculations; extra diagnostics
Use bit-shift instead of division/multiplication.
Act on error as soon as it is detected.
Report attempt to read data embedded in file entry via regular way.
While there, fix lblktosize macro and make use of it.

No functionality should change as a result.

Approved by: jhb (mentor)
2009-02-26 12:33:02 +00:00
Edward Tomasz Napierala
4f560d7595 Right now, when trying to unmount a device that's already gone,
msdosfs_unmount() and ffs_unmount() exit early after getting ENXIO.
However, dounmount() treats ENXIO as a success and proceeds with
unmounting.  In effect, the filesystem gets unmounted without closing
GEOM provider etc.

Reviewed by:	kib
Approved by:	rwatson (mentor)
Tested by:	dho
Sponsored by:	FreeBSD Foundation
2009-02-23 21:09:28 +00:00
Alan Cox
2984411d7b Use uiomove_fromphys() instead of the combination of sf_buf and uiomove().
This is not only shorter; it also eliminates unnecessary thread pinning on
architectures that implement a direct map.

MFC after:	3 weeks
2009-02-22 19:50:09 +00:00
Alan Cox
2ade0391c2 Simplify the unwiring and activation of pages.
MFC after:	1 week
2009-02-22 18:15:17 +00:00
Andriy Gapon
7b1eb68a49 style nit in r188815
Pointed out by:	jhb, rpaulo
Approved by:	jhb (mentor)
2009-02-19 15:37:43 +00:00
Andriy Gapon
84206c741f fs/udf: fix incorrect error return (-1) when reading a large dir
Not enough space in user-land buffer is not an error, userland
will read further until eof is reached. So instead of propagating
-1 to caller we convert it to zero/success.

cd9660 code works exactly the same way.

PR:		kern/78987
Reviewed by:	jhb (mentor)
Approved by:	jhb (mentor)
2009-02-19 15:05:30 +00:00
Dag-Erling Smørgrav
655fcdaa00 Fix a logic bug that caused the pfs_attr method to be called only for
PFS_PROCDEP nodes.

Submitted by:	Andrew Brampton <brampton@gmail.com>
MFC after:	2 weeks
2009-02-16 15:17:26 +00:00
John Baldwin
ea77ff0a15 Use shared vnode locks when invoking VOP_READDIR().
MFC after:	1 month
2009-02-13 18:18:14 +00:00