Commit Graph

1086 Commits

Author SHA1 Message Date
mjf a2be0ed655 Revert the changes I introduced trying to solve tmpfs' NFS export problem.
Requested by yamt@
2006-10-31 08:12:46 +00:00
jmmv bccb33bf70 Fix a typo in a comment. 2006-10-30 16:06:05 +00:00
reinoud dc5b5420b9 Revisit mnt_vnodelist TAILQ patch. Remove all suspicious TAILQ_FOREACH()
loops where vnodes can get removed or added during the loops. This could
lead to panic's on unmount since nodes are skipped or otherwise
TAILQ_NEXT(0xdeadbeef, ...) was dereferenced.
2006-10-25 22:01:54 +00:00
mjf 84bd46b9f9 Add support to allow a file system to not permit being exported over NFS.
Approved by elad@ and wrstuden@
2006-10-24 21:53:10 +00:00
pooka 96d8335980 kauth_cred_uucvt() -> kauth_uucred_to_cred(), introduce kauth_cred_to_uucred()
per tech-kern proposal
2006-10-22 13:07:15 +00:00
reinoud 0ce809091d Replace the LIST structure mp->mnt_vnodelist to a TAILQ structure since all
vnodes were synced and processed backwards. This meant that the last
accessed node was processed first and the earlierst last.

An extra benefit is the removal of the ugly hack from the Berkly days on
LFS.

In the proces, i've also replaced the various variations hand written loops
by the TAILQ_FOREACH() macro's.
2006-10-20 18:58:12 +00:00
dogcow 372e6ef309 now that we have -Wno-unused-parameter, back out all the tremendously ugly
code to gratuitously access said parameters.
2006-10-17 18:21:29 +00:00
christos 3b347a3429 another variable should have been _KERNEL only. 2006-10-17 14:55:13 +00:00
christos 0a3d351aae don't expose kernel variables to userland. 2006-10-17 14:53:54 +00:00
yamt 583781abd3 grab glock when calling uvm_unp_setsize, so that it doesn't interfere
mmap'ed accesses.  this fixes an assertion failure in in nfs_doio_read.
("vp->v_size >= uiop->uio_offset + uiop->uio_resid")
2006-10-14 09:18:57 +00:00
christos 6c265266c5 more __unused 2006-10-13 20:53:59 +00:00
dogcow 44603cac1f more unused variable fallout. 2006-10-13 18:28:06 +00:00
christos 4d595fd7b1 - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
2006-10-12 01:30:41 +00:00
dogcow 55ddfc9aae change the MOWNER_INIT define to take two args; fix extant struct mowner
decls to use it. Makes options MBUFTRACE compile again and not whinge about
missing structure declarations. (Also makes initialization consistent.)
2006-10-10 21:49:14 +00:00
drochner 429dff1c3d Flush regular files before setattr also if the mode bits are going to
be set. Linux NFS servers (at least) reset suid/sgid bits if a write
happens afterwards. Add a comment why this is done.
This fixes system builds on diskless systems for me where suid bits
were missing after install(1).
Approved by yamt.
2006-09-29 16:19:50 +00:00
yamt ff1a471a3b nfs_ispublicfh: fix another instance of cast-qual. 2006-09-04 08:38:16 +00:00
yamt 80fe9dcf8f remove (void *) cast from NFSRVFH_DATA as it sometimes
discards const qualifier.  pointed out by Havard Eidnes.
(it wasn't detected by in-tree gcc4.  seems like a compiler bug.)
2006-09-04 08:27:49 +00:00
yamt 8b789e8490 nfs_fhtovp: try to detect stale or invalid handles by issuing VOP_GETATTR. 2006-09-02 13:37:52 +00:00
yamt b45e7d3197 nfsdreq_free: remove an assertion which is not true. 2006-09-02 13:30:08 +00:00
yamt 3311de9ddc implement vptofh and fhtovp for nfs. 2006-09-02 12:40:58 +00:00
yamt d7d8adb6ea nfsd: deal with variable-sized filehandles. 2006-09-02 12:40:36 +00:00
yamt d70ea60617 #ifdef out nqsrv_getlease and friends unless defined(NFSSERVER). 2006-09-02 12:39:59 +00:00
christos 57eb3ffe77 fix default type decls
fix incomplete initializer
2006-09-02 07:26:47 +00:00
christos da9052a357 Don't free what we did not allocate. 2006-08-24 12:40:39 +00:00
christos f73c6e5980 Change iostat_alloc() to take the parent pointer and the name directly, so
that callers are not responsible for initializing the fields. Store the name
inside the struct instead of maintaining a pointer to external storage, or
leaked memory (nfs case).
2006-08-23 17:19:32 +00:00
yamt 2253872d55 nfsm_srvfhtom: ensure that padding bytes in nfsv2 file handles are zero. 2006-08-08 13:07:32 +00:00
martin b4cb63a646 Make filehandles opaque to userland 2006-07-31 16:34:42 +00:00
ad f474dceb13 Use the LWP cached credentials where sane. 2006-07-23 22:06:03 +00:00
christos 1c50629119 When there are too many empty entries in a row, and we need to try to
read the next block, free the cookie buffer before doing so to avoid
a memory leak. Reported by  Mark Davies.
2006-07-20 15:12:23 +00:00
yamt b0c4bb36d9 nfs_getreq: fix a kauth fallout.
pointed by nanashi-san.  http://pc8.2ch.net/test/read.cgi/unix/1145181361/786
2006-07-15 05:54:10 +00:00
martin a3b5baed42 Fix alignement problems for fhandle_t, exposed by gcc4.1.
While touching all vptofh/fhtovp functions, get rid of VFS_MAXFIDSIZ,
version the getfh(2) syscall and explicitly pass the size available in
the filehandle from userland.

Discussed on tech-kern, with lots of help from yamt (thanks!).
2006-07-13 12:00:24 +00:00
yamt ce1a2b18c3 some comments taken from Jed Davis's patch. 2006-07-01 11:30:44 +00:00
yamt e38f237e53 if a file is sillyrename'ed because it's a destination of rename,
make sillyrename (try to) use LINK operation rather than RENAME.
PR/33861 from Jed Davis.  he provided the almost same patch.
according to him, it also happen to be what opensolaris does in this case.

from the PR:
> In nfs_rename(), if the destination appears to exist and is "in use"
> (this check is apparently satisfied even if the file isn't in use by
> anything except the rename itself), it will sillyrename it, then delete
> the sillyrenamed file even if the rename fails -- for instance, because
> the "from" file no longer exists on the server.

> mkdir a b; touch a/x; perl -e 'fork(); rename("a/x","b/x") or die "$!\n"'
>
> Afterwards, neither a/x nor b/x will exist.

> 1) Lookup of b/x; fails with NOENT.
> 2) Rename from a/x to b/x; succeeds.
> 3) Lookup of b/x; fails with NOENT.
> 4) Rename from b/x to b/.nfsA23a3; succeeds.
> 5) Rename from a/x to b/x; fails with NOENT.
> 6) Remove of b/.nfsA23a3; succeeds.
2006-07-01 11:29:42 +00:00
yamt 2246835eec wrap long lines and fix indents after kauth merge. 2006-06-30 09:56:03 +00:00
yamt 3333e8aa5c fix handling of NFSERR_NOTSUPP and NFSERR_BAD_COOKIE,
which have been broken since nfs_socket.c rev.1.115.
2006-06-30 09:55:34 +00:00
yamt 2a9a8246f0 nfs_request: don't bother to handle NFSERR_STALEWRITEVERF
because it isn't a real nfs error value.
2006-06-30 09:55:06 +00:00
yamt 7d3142aa6a - introduce vfs_composefh() and use it where appropriate.
- fix lock/unlock mismatch in sys_getfh.
2006-06-17 07:06:50 +00:00
christos d13a9159e3 stack police: don't allocate statvfs on the stack. 2006-06-09 21:41:14 +00:00
kardel de4337ab21 merge FreeBSD timecounters from branch simonb-timecounters
- struct timeval time is gone
  time.tv_sec -> time_second
- struct timeval mono_time is gone
  mono_time.tv_sec -> time_uptime
- access to time via
	{get,}{micro,nano,bin}time()
	get* versions are fast but less precise
- support NTP nanokernel implementation (NTP API 4)
- further reading:
  Timecounter Paper: http://phk.freebsd.dk/pubs/timecounter.pdf
  NTP Nanokernel: http://www.eecis.udel.edu/~mills/ntp/html/kern.html
2006-06-07 22:33:33 +00:00
blymn 4a065f3379 Clean up bogus whitespace 2006-05-28 13:23:08 +00:00
yamt 3ef3d785cc nfs_request: use kauth_cred_free rather than kauth_cred_destroy. 2006-05-28 06:47:58 +00:00
yamt 16dbcd1c54 mountnfs: reject wrongly-sized filehandle for nfsv2. 2006-05-20 07:42:02 +00:00
yamt eb04c18e83 nqsrv_getlease: call nfs_init() to fix NFSSERVER && !NFS case. 2006-05-20 07:40:56 +00:00
yamt b245701ca1 - fix compilation problem for !NFSSERVER && NFS.
pointed by Tom Spindler on source-changes@.
- make nfs_srvdesc_pool static.
2006-05-19 13:53:11 +00:00
yamt b861e24c71 - fix some leaks in nfsd, introduced by kauth changes.
- simplify code.
- add some assertions.
- wrap some long lines.
- remove an unnecessary ";".
2006-05-18 12:44:45 +00:00
yamt 635dba4477 - nfs_export_unmount: don't forget to free exports.
- rename clear_exports for consistency.
2006-05-18 10:07:34 +00:00
elad fc9422c9d9 integrate kauth. 2006-05-14 21:31:52 +00:00
christos c0fdc5190f XXX: GCC uninitialized 2006-05-14 05:42:43 +00:00
mrg 084c052803 quell GCC 4.1 uninitialised variable warnings.
XXX: we should audit the tree for which old ones are no longer needed
after getting the older compilers out of the tree..
2006-05-10 21:53:14 +00:00
blymn 10df330c85 Prefix iostat structure elements with io_ 2006-04-20 12:13:51 +00:00
christos de6470e701 m_freem takes one arg. 2006-04-15 02:49:25 +00:00
christos 2fd9c5d744 s/mfree/m_freem/ 2006-04-15 02:48:32 +00:00
dogcow bbfbd3e91f #if -> #ifdef 2006-04-15 02:46:39 +00:00
christos f540054634 Coverity CID 735: Remove duplicate code. 2006-04-15 01:58:44 +00:00
christos 0b55b29a78 Coverity CID 734: Define NFS_TEST_HEAVY for testing nfsds, and use this to
ifdef out dead code. XXX: Why is this turned on by default?
2006-04-15 01:57:36 +00:00
christos 4ea21306a7 Coverity CID 736: Comment out dead code. 2006-04-15 01:54:46 +00:00
christos 0016be6042 Coverity CID 1175: Remove dead code. 2006-04-15 01:52:44 +00:00
christos 1ee078d67e Coverity CID 744: Conditionally define out dead code (only if it is dead) 2006-04-15 01:51:47 +00:00
christos 35829d71d3 Coverity CID 1141: Add a KASSERT before deref. 2006-04-15 01:45:15 +00:00
christos c3a65fd394 Coverity CID 1142: Add a KASSERT before deref. 2006-04-15 01:41:46 +00:00
christos d008757117 Coverity CID 1143: Prevent NULL deref. 2006-04-15 01:39:15 +00:00
christos 09436af99e Coverity CID 1144: Protect against NULL deref. 2006-04-15 01:37:46 +00:00
christos 6668c9c154 Coverity CID 1162: Prevent NULL deref. 2006-04-15 01:35:12 +00:00
christos b31d7b8b49 Coverity CID 1165: Cannot have nfsiod without an lwp, so remove the superfluous
test.
2006-04-15 01:31:11 +00:00
christos b2bd561652 Coverity CID 2445: Only set from_p if we succeed so that we free it on error. 2006-04-15 01:25:54 +00:00
christos bd57687667 Don't leak mbufs on error. 2006-04-15 01:25:01 +00:00
christos 6555ff0ad3 From my posting of April 3 to tech-kern:
My understanding is that the CLRSIG() is supposed to clear the signal
that was sent to the syncer process to prevent it from being delivered
to the syncer process in case unmounting fails, so that the syncer process
does not die while the filesystem is still mounted. The typical scenario
is, the syncher process is tsleep()ing in the kernel, and waking up when
it needs to do work. If someone sends a signal to it, eg. kill -TERM
the mfs process, then the kernel will try to unmount the mfs filesystem
before delivering the signal to the process. If that unmount fails, then
we should not really kill the process because that will hang the mount.
So we call CLRSIG() to stop the signal from being delivered.

So the first call to issignal() will return the signal number that was
sent to the syncer process (unless someone malicious was able to send
a lower numbered signal between the time tsleep() returned and we called
issignal()... something that is not really easy to do). But you are
right, we should not be calling it many times as a side effect of this
macro.

Rewrite CLRSIG() clear all the signals and call issignal() the correct
number of times.
2006-04-15 01:16:40 +00:00
christos 881fbaa328 Coverity CID 2509: Initialize cache 2006-04-15 00:45:49 +00:00
christos ff33272e7b Coverity CID 2510-2514: Always initialize cache. 2006-04-15 00:44:18 +00:00
christos 4c9d749d77 Coverity CID 2515-2519: Initialize rexmit on error path. 2006-04-15 00:40:20 +00:00
christos 1099609bd0 Coverity CID 2520: rexmit can be uninitialized on error path. 2006-04-15 00:36:23 +00:00
blymn 3c0adb7d99 Make i/o statistics collection more generic, include tape drives and
nfs mounts in the set of devices that statistics will be reported on.
2006-04-14 13:09:05 +00:00
yamt c5fcdd1719 some cleanups after the introduction of GOP_SIZE_MEM flag.
- remove GOP_SIZE_READ/GOP_SIZE_WRITE flags.
  they have not been used since the change.
- ufs_balloc_range: remove code which has been no-op since the change.
  thanks Konrad Schroder for explaining the original intention of the code.
- ffs_gop_size: don't extend past eof, in the case of GOP_SIZE_MEM.
  otherwise genfs_getpages end up to allocate pages past eof unnecessarily.
2006-03-30 12:40:06 +00:00
martin d6d75eaf5d KASSERT that the returned file id length from VPTOFH is <= the
maximum allowed value (_VFS_MAXFIDSZ).
2006-03-27 20:20:45 +00:00
christos c92b23ffa8 Don't use DEBUG, add a new DEBUG_NFS_BOOT_DHCP variable to provide more
information. Print more information about what fails.
2006-03-16 15:55:20 +00:00
yamt 6bf35dc8ec bump NFS_MAXDGRAMDATA from 32k to 60k. (ie. near the protocol limit of udp.)
- it can help performance for some environments.
- administrators should be free to do silly things. :-)
2006-03-14 03:23:23 +00:00
rpaulo 5bb59eeab9 Back out revision 1.125 and 1.124. The code for checking if
slp->ns_reclen == 0, was already there since "Linux sometimes
generates 0-lenght records.".

Bad Rui...
2006-03-01 21:31:00 +00:00
rpaulo 52dc289cfd In nfsrv_getstream(), ns_reclen will never be negative due to the
previous assignment (recmark & ~0x80000000).
Pointed out by Christos.
2006-03-01 19:38:29 +00:00
rpaulo b948e12637 From FreeBSD SA-06:10
Correct a remote kernel panic when processing zero-length RPC records
	via TCP.
2006-03-01 15:30:12 +00:00
yamt ec5a93183a merge yamt-uio_vmspace branch.
- use vmspace rather than proc or lwp where appropriate.
  the latter is more natural to specify an address space.
  (and less likely to be abused for random purposes.)
- fix a swdmover race.
2006-03-01 12:38:10 +00:00
thorpej 58853410ae Use device_class() instead of accessing dv_class directly. 2006-02-21 04:32:38 +00:00
yamt dae53410a7 - tweak RUN_ONCE api to allow init_func returns an error.
- physio: handle failure of workqueue_create.
2006-01-16 21:45:38 +00:00
yamt cabee93abb nfs_doio_read: clear uio_resid when filling a hole. 2006-01-14 08:57:40 +00:00
yamt 24c6af7659 mountd_set_exports_list: check if VFS_VPTOFH actually works. 2006-01-05 12:21:00 +00:00
yamt 28b96a0b9d ensure the export list is not changed during nfsd operations. 2006-01-05 11:22:56 +00:00
yamt 789fa21531 fix a deadlock due to a spl problem. 2006-01-03 22:25:48 +00:00
yamt 463bed6af1 de-__P. 2006-01-03 12:59:49 +00:00
yamt dbf3dbe4b0 don't install nfs_var.h. 2006-01-03 12:47:51 +00:00
yamt 27dc8f3f48 move function prototypes from nfs.h to nfs_var.h. 2006-01-03 12:30:46 +00:00
yamt 7416ebb551 nfssvc_nfsd: reduce a chance for a slow peer to capture all our threads.
instead of sleeping to wait for the socket to send our reply,
just hand-off our reply to the thread which is holding the socket.
2006-01-03 12:30:01 +00:00
yamt a5da6cae5b remove a few unnecessary caddr_t casts. 2006-01-03 11:41:50 +00:00
yamt acff143090 improve nfsd locking.
- don't bother to take nfs_sndlock when doing nfsrv_rcv.
  unlike client, we never reconnect.
- nfsrv_getstream: fix the case that m_split sleeps.
- free socket in nfsrv_slpderef rather than nfsrv_zapsock.
  fix race with nfssvc_nfsd.
- while i'm here, remove NFSD_WAITING and NFSD_REQINPROG
  as they are redundant.
- some comments and assertions.
2006-01-03 11:41:03 +00:00
yamt 07684acc5e nfs_inactive:
- use LK_CANRECURSE instead of LK_RECURSEFAIL.
  PR/32435 from Valeriy E. Ushakov.
- panic explicitly if the parent directory has been revoked.
  add an XXX comment.
2006-01-02 21:43:24 +00:00
jmmv e7b8314535 Avoid dereferencing the lwp parameter in nfs_receive, as it is always NULL.
Solves a crash when mounting NFS shares.  (The proc parameter used before
the conversion to lwp's was NULL too, so the addition of 'l->l_proc' in the
code was extra.)
2005-12-30 10:35:44 +00:00
yamt d085790ab8 netcred_lookup: remove a wrong assertion and handle the case properly. 2005-12-15 21:46:31 +00:00
reinoud 255662c92a Fix of panic that was introduced since ktrace-lwp branch was merged. The
shortcut to the process of the passed lwp paniced the kernel since lwp
could/can be passwd as NULL in VOP_WRITE().

This was happening when ktracing to NFS. The function ktrwrite() set the
uio_lwp to NULL and then calls VOP_WRITE() with this argument. nfs_write()
then accessed lwp *l->l_proc wich paniced.

Thanks to David Laight for his help on tracking it down.
2005-12-13 13:12:18 +00:00
christos 95e1ffb156 merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
yamt 221616873d merge yamt-readahead branch. 2005-11-29 22:52:02 +00:00
thorpej 49fc1cb09c Use a once control to initialize the NFS server / client shared data
from nfs_vfs_init() or sys_nfssvc().  Remove the nfs_init() call from
main().
2005-11-25 20:01:38 +00:00
yamt b0cf681a01 - reduce number of linear search per rpc.
- coalesce mount_netexport_pair into netexport.
2005-11-22 04:44:29 +00:00
yamt f1bf6425bc use c99 initializers for proct. 2005-11-21 09:39:02 +00:00
yamt 6e0ca2f323 fix bugs introduced by the recent exports list rototill.
- mountd_set_exports_list: don't discard error.
- nfs_update_exports_30: check the correct flag.
2005-11-20 06:23:44 +00:00
yamt df6c7b914b nfs_read: return EISDIR rather than EPERM for !VREG files. 2005-11-05 19:21:14 +00:00
yamt a0a8d930a4 nfs_bioread: push delayed truncation and tweak loop accordingly.
PR/31926 from Jed Davis.
2005-11-04 19:39:30 +00:00
yamt a748ea88dd merge yamt-vop branch. remove following VOPs.
VOP_BLKATOFF
	VOP_VALLOC
	VOP_BALLOC
	VOP_REALLOCBLKS
	VOP_VFREE
	VOP_TRUNCATE
	VOP_UPDATE
2005-11-02 12:38:58 +00:00
thorpej f243f4debb Fix paste-o in the NFSV3SATTRTIME_TOSERVER case of mtime handing (need
to set va_mtime, not va_atime).
2005-10-31 14:21:35 +00:00
yamt 793a63d824 - remove a ufs dependency.
- bump readdir block size to 1024.  (the same value as userland DIRBLKSIZ)
2005-10-06 10:23:01 +00:00
yamt e10443f324 nfs_bioread: handle file truncation on the server a little more gracefully. 2005-10-06 10:20:58 +00:00
jdolecek 5fbad4b597 use killproc() for killing the process due to text file modification, so
that it's logged too

PR: 17392 by Greg A. Woods
2005-10-01 21:09:03 +00:00
yamt 17269a9baf nfsm_srvsattr: use nanotime(9) rather than time(9) for NFSV3SATTRTIME_TOSERVER. 2005-10-01 06:13:55 +00:00
jmmv 3955cf65f9 Add some COMPAT_30 code to let old mountd binaries work after the NFS
exports rototill.
2005-09-25 21:57:40 +00:00
tron d8706f77dd Correct typo in last commit to fix compilation error. 2005-09-25 12:49:09 +00:00
christos c5dae239cc Add missing TIMEDOUT and IO errors. 2005-09-25 02:48:40 +00:00
christos a6ce8d7c4d Convert from nfs error values to regular errno's. Although most values of
nfs errors are chosen to be the same as errno, some of them are not and
it is better for portability to do the conversion anyway. Also a server
can return a bad error number that can cause the server to crash, because
it can have the high bits that are used internally set. This was the case
with amd. Finally nfs_request() should return a valid errno, because we
can return a bogus value to userland. Thanks to rpaulo for debugging this.
2005-09-25 00:20:38 +00:00
jmmv 50cbbb8bf4 Remove the mount<->netexport entry from the map during umount... otherwise
we leave a dangling pointer in the list *ouch*.
2005-09-23 19:39:15 +00:00
jmmv 2a3e5eeb7c Apply the NFS exports list rototill patch:
- Remove all NFS related stuff from file system specific code.
- Drop the vfs_checkexp hook and generalize it in the new nfs_check_export
  function, thus removing redundancy from all file systems.
- Move all NFS export-related stuff from kern/vfs_subr.c to the new
  file sys/nfs/nfs_export.c.  The former was becoming large and its code
  is always compiled, regardless of the build options.  Using the latter,
  the code is only compiled in when NFSSERVER is enabled.  While doing this,
  also make some functions in nfs_subs.c conditional to NFSSERVER.
- Add a new command in nfssvc(2), called NFSSVC_SETEXPORTSLIST, that takes a
  path and a set of export entries.  At the moment it can only clear the
  exports list or append entries, one by one, but it is done in a way that
  allows setting the whole set of entries atomically in the future (see the
  comment in mountd_set_exports_list or in doc/TODO).
- Change mountd(8) to use the nfssvc(2) system call instead of mount(2) so
  that it becomes file system agnostic.  In fact, all this whole thing was
  done to remove a 'XXX' block from this utility!
- Change the mount*, newfs and fsck* userland utilities to not deal with NFS
  exports initialization; done internally by the kernel when initializing
  the NFS support for each file system.
- Implement an interface for VFS (called VFS hooks) so that several kernel
  subsystems can run arbitrary code upon receipt of specific VFS events.
  At the moment, this only provides support for unmount and is used to
  destroy NFS exports lists from the file systems being unmounted, though it
  has room for extension.

Thanks go to yamt@, chs@, thorpej@, wrstuden@ and others for their comments
and advice in the development of this patch.
2005-09-23 12:10:31 +00:00
christos 7c86163536 ATTRTIMEO takes 2 args. 2005-09-19 00:49:52 +00:00
christos 8f69843f6a Allow turning off the attribute cache. 2005-09-18 23:44:54 +00:00
rpaulo 9c8a38bb3b Wrap a multiple line comment so that it doesn't go beyond 80 columns. 2005-09-11 20:19:31 +00:00
jmmv 86e1067af8 Set va_type to VLNK before calling VOP_SYMLINK to match the change in the
vfs_syscalls.c file.  Pointed out by yamt@.
2005-09-06 09:36:28 +00:00
yamt b247716cf3 as we now have 64bit ino_t, no need to truncate nfsv3 fileids. 2005-08-19 12:47:23 +00:00
yamt 437ecc32b5 fix some simple bugs in the 64bit ino_t changes.
- edp -> dp
- * -> +
2005-08-19 10:08:48 +00:00
christos 50f8955b6e 64 bit inode changes. 2005-08-19 02:04:03 +00:00
onoe 5c08c84474 Fix mbuf leak in nfssvc_nfsd(). 2005-08-03 06:25:11 +00:00
yamt d5c148af81 use a correct credential for readlink. discussed on source-changes@. 2005-07-21 10:39:46 +00:00
yamt 445a39080e nfs_doio_read: revert readlink part of 1.129 and 1.130 because they were wrong. 2005-07-21 10:37:36 +00:00
christos d9a0117f1e Back to using curproc in the VLNK case when uiop->uio_procp == NULL,
and explain why we need to.
2005-07-07 14:26:37 +00:00
christos c7f5a1fb60 1. use p = uio->uio_procp consistently and eliminate suspicious uses
of curproc (where uio->uio_procp should be used?). Don't do this
   for nfs_commit(), because yamt says it is possibly wrong.
2. nfs_doio() does not use struct proc; remove it and the code to compute it.
3. use copyin_proc() and copyout_proc() instead of copyin() and copyout().
4. check return of copyout_proc(). and mark return from copyin_proc() XXX
5. Eliminate check p == curproc assertion check from nfs_write;
   nfs_read does not have it and we might be called in a different
   process context anyway (PR 20138).
2005-07-07 02:05:03 +00:00
yamt 44d128fa8e - constify genfs_ops.
- use member designators.
2005-06-28 09:30:37 +00:00
atatat 420d91208b Properly fix the constipated lossage wrt -Wcast-qual and the sysctl
code.  I know it's not the prettiest code, but it seems to work rather
well in spite of itself.
2005-06-09 02:19:59 +00:00
christos e7c15fae96 - sprinkle const
- avoid shadowed variables
- mark bad const use with XXXUNCONST
2005-05-29 20:58:13 +00:00
yamt 9cb572b112 nfsrv_mknod: reject device numbers which we can't handle. 2005-05-18 12:57:34 +00:00
christos 362a4a0bd5 Yes, it was a cool trick >20 years ago to use "0123456789abcdef"[a] to
implement, xtoa(), but I think defining the samestring 50 times is a bit
too much. Defined HEXDIGITS and hexdigits in subr_prf.c and use it...
2005-05-17 04:14:57 +00:00
yamt c5544c42b5 nfsrv_rcv: don't do so_receive from socket upcall context.
while there's little benefits, it complicates locking and confuses
flow control.
2005-03-29 09:22:35 +00:00
thorpej e633e8b61b - Define a VFS_ATTACH() macro that places a reference to a vfsops structure
into the "vfsops" link set.
- Use VFS_ATTACH() where vfsops are declared for individual file systems.
- In vfsinit(), traverse the "vfsops" link set, rather than vfs_list_initial[].
2005-03-29 02:41:05 +00:00
perry bcfcddbac1 nuke trailing whitespace 2005-02-26 22:31:44 +00:00
yamt 12ee5f9c3a nfs_namei: return EACCES for empty filenames as rfc1813 says. 2005-01-28 10:12:23 +00:00
yamt 2520660990 nfs_clearcommit: don't attempt to clear commit info (n_pushlo, etc)
unless the vnode is of VREG.  union members used to keep commit info
are used for other purposes in the case of !VREG.
2005-01-28 10:11:31 +00:00
yamt f1661c75d1 - simplify nfs_bio.c rev.1.126
- add an assertion.

no functional changes.
2005-01-27 12:46:42 +00:00
yamt cf56f2b873 keep directory eof cache when inactivating vnode
because there's no reason to throw it away.
(fix an unintended side effect of nfs_subs.c rev.1.144.)
2005-01-27 11:33:26 +00:00
yamt 407a63dc34 nfs_bioread:
- if a buffer is still empty after successful nfs_doio, it implies EOF.
- don't cache blocks beyond EOF.
2005-01-27 11:29:25 +00:00
yamt f6e331ee7c nfs_readdirrpc, nfs_readdirplusrpc:
avoid infinite loops when getting readdir response without
any entries or eof.  PR/28971.
2005-01-26 10:33:54 +00:00
yamt 72d6e88acf handle a really empty directory, which doesn't have even the dot entry. 2005-01-26 10:30:58 +00:00
yamt a7b5d8f567 nfs_check_wccdata: comment. 2005-01-25 12:20:32 +00:00
yamt de3e729ad9 s/time/mono_time/ for n_attrstamp and n_accstamp. (parts of) PR/25641. 2005-01-21 14:31:29 +00:00
yamt fc08656a20 implement inaccurate mtime/ctime detection.
namely, if mtime or ctime are same between pre_op_attr and post_op_attr
when we expected them to be changed, don't trust the server.
2005-01-19 16:22:19 +00:00
chs 8975a0856f adjust the UBC mapping code to support non-vnode uvm_objects.
this means we can no longer look at the vnode size to determine how many
pages to request in a fault, which is good since for NFS the size can change
out from under us on the server anyway.  there's also a new flag UBC_UNMAP
for ubc_release(), so that the file system code can make the decision about
whether to cache mappings for files being used as executables.
2005-01-09 16:42:43 +00:00
yamt e5bd47dc3c invalidate cache if filesize is changed besides our activity
because it means that we're out of sync with the server.
2005-01-09 01:32:32 +00:00
yamt 68c071389c nfs_lookup: check n_nctime for positive entries as well to improve
cache consistency.
2005-01-08 03:12:30 +00:00
yamt f80647ef1e nfs_loadattrcache: invalidate access cache when ctime is changed. 2005-01-06 11:52:44 +00:00
thorpej 1c95472d01 Add the system call and VFS infrastructure for file system extended
attributes.

From FreeBSD.
2005-01-02 16:08:28 +00:00
yamt f4221aaaf6 revive spec vop_bwrite as it's needed for block devices.
PR/28684 from Jukka Salmi.
2004-12-17 03:31:20 +00:00
yamt ee344f939f redirect some VOPs which shouldn't be used for nfs
to genfs_badop (ie. panic).
2004-12-14 09:15:23 +00:00
yamt e3ed5def47 - centerize code to invalidate stale cache.
- don't ignore errors when invalidating buffers in nfs_open.
2004-12-14 09:13:13 +00:00
bouyer 0f82537ed4 The macro used for static server address is NFS_BOOTSTATIC_SERVADDR, not
NFS_BOOTSTATIC_SADDR. From Xen source distribution.
XXX NFS_BOOTSTATIC* doesn't seem to be documented anywhere ...
2004-12-12 16:24:14 +00:00
yamt 8cd5f554ba nfsrv_commit: make cnt unsigned so that very large commit requests can be
handled properly.
2004-12-09 02:18:45 +00:00
yamt 2bc7120ab8 when calling create-type VOP, make sure that va_mode is set
even when a client doesn't specify it.
(most filesystems get confused if va_mode is VNOVAL.)
2004-12-09 01:48:22 +00:00
yamt f11ea18093 nfsrv_read: fall back to copying when fail to loan pages.
(i forgot to commit this with uvm_loan.c rev.1.51.)
2004-12-04 08:07:52 +00:00
yamt a9fa9f0745 since daddr_t is 64-bit these days, simply use nfs directory cookies
as buffer cache indexes.  regress/sys/fs/getdents is now supposed to work.
fix PR/27112.
2004-10-26 04:34:46 +00:00
yamt 20a0770136 remove #if 0'ed out definition of VA_EXCLUSIVE. 2004-10-26 00:58:54 +00:00
yamt 3d250e0476 remove an unused macro, NMOD. 2004-10-26 00:27:07 +00:00
yamt 94223b8ff0 nfs_enterdircache: initialize dc_flags of a newly allocated dircache entry.
provided by Greg Oster.
2004-10-03 10:51:28 +00:00
yamt 31c025d90c nfs_readdirrpc, nfs_readdirplusrpc:
don't expose kernel garbage data to userland.
2004-10-03 10:17:33 +00:00
yamt 6b8cd53946 nfs_writerpc: fix PHOLD leak on error. 2004-10-01 01:08:01 +00:00
yamt 77b63b73b8 g/c NFSMINOFF, which is unused and identical with MRESETDATA. 2004-09-29 11:24:28 +00:00
yamt ac65f2420a nfs_readdirplusrpc: fix spurious EBUSYs. 2004-09-23 10:46:44 +00:00
skrll f7155e40f6 There's no need to pass a proc value when using UIO_SYSSPACE with
vn_rdwr(9) and uiomove(9).

OK'd by Jason Thorpe
2004-09-17 14:11:20 +00:00
yamt e11d5e7c46 fix access-after-free bugs in dircache code by refcounting nfsdircache.
PR/26864.
2004-09-15 09:50:56 +00:00
yamt 4fd5a025bf nfs_request: a workaround for servers doing "maproot".
for i/o requests which are expected not to fail due to permission
to mimic unix file open semantics (READ, WRITE, COMMIT),
try two credentials.  namely, the file owner's one and open time one.
remember which credential worked in per-file basis and try it first
next time to minimize number of retries.
ideas from Chuck Silvers.  PR/23716 and PR/24987.
2004-08-24 20:09:44 +00:00
yamt bee0b74932 remove a "proc botch" debug printf. ok'ed by Jonathan Stone. 2004-08-18 23:44:47 +00:00
mycroft 45a21b76f0 Fixing age old cruft:
* Rather than using mnt_maxsymlinklen to indicate that a file systems returns
  d_type fields(!), add a new internal flag, IMNT_DTYPE.

Add 3 new elements to ufsmount:
* um_maxsymlinklen, replaces mnt_maxsymlinklen (which never should have existed
  in the first place).
* um_dirblksiz, which tracks the current directory block size, eliminating the
  FS-specific checks littered throughout the code.  This may be used later to
  make the block size variable.
* um_maxfilesize, which is the maximum file size, possibly adjusted lower due
  to implementation issues.

Sync some bug fixes from FFS into ext2fs, particularly:
* ffs_lookup.c 1.21, 1.28, 1.33, 1.48
* ffs_inode.c 1.43, 1.44, 1.45, 1.66, 1.67
* ffs_vnops.c 1.84, 1.85, 1.86

Clean up some crappy pointer frobnication.
2004-08-15 07:19:54 +00:00
yamt 7653f67dd6 nfs_readdirplusrpc: fix a very long-standing cache corruption bug.
in the case of !bigenough, don't fill d_type or dnlc with bogus data.
2004-07-20 22:02:21 +00:00
yamt 62190652f1 revert nfs_vnops.c rev.1.189.
it's no longer needed because cache_enter() has been changed to handle
duplicated entries by itsself.
2004-07-20 22:00:29 +00:00
yamt e9bca9a46e nfs_doio_read: on short read, zero out the rest of the buffer unconditionally.
we can't rely on n_size here because it can be changed under us.
2004-07-18 07:43:00 +00:00
yamt 1c77f27a7a nfs_commit: use NAC_NOTRUNC when loading an attribute
as we're called holding pages locked.
2004-07-18 07:41:42 +00:00
yamt 72afe94686 nfs_fsinfo: when changing rsize/wsize,
keep mnt_fs_bshift in-sync.  otherwise genfs_getpages behaves badly.
2004-07-12 12:40:30 +00:00
yamt 0f5d997ee9 - include opt_inet.h for INET.
- catchup to in_ifaddr -> in_ifaddrhead rename.

XXX the address on the top of in_ifaddrhead is likely 127.0.0.1.
using it to construct the verifier doesn't make much sense.
maybe it's better to use some uuid or ip_randomid-like method.
2004-07-08 11:21:35 +00:00
yamt fad58613ba nfs_create: after an exclusive create rpc, make sure to update
timestamps, which were likely used to store the verifier.
reported by Mark Davies.  PR/26200
2004-07-08 11:12:14 +00:00
pk a7c40722d8 Call inittodr() from main(). Let file system code set the recorded `last
update' time (if any) through the new function setrootfstime().
2004-07-05 07:28:45 +00:00
yamt 21ae434eb2 nfs_lookup: use cache_lookup_raw() so that:
- "intrusive" dirops now have more chances to get benefits from dnlc.
- fixes a deadlock due to vnode locking order inversion.

nfs_create and others: purge stale dnlc entries
as nfs_lookup() no longer does it automatically.
2004-06-27 08:53:03 +00:00
jonathan 5249b5a2a5 Rename MBUFTRACE helper function m_claim() to m_claimm(),
for consistency with M_FREE() and m_freem().  Affected files:

sys/mbuf.h
kern/uipc_socket2.c
kern/uipc_mbuf.c
net/if_ethersubr.c
netatalk/ddp_input.c
nfs/nfs_socket.c
2004-06-24 04:15:50 +00:00
yamt 3e209dd94a nfs_lookup: maintain PDIRUNLOCK even in the case of success to make
layered filesystems happy.
2004-06-16 23:55:30 +00:00
yamt ad338b9eff nfs_searchdircache: fix a null dereference in the case that
offset!=0 and dircache hasn't been initialized yet.
2004-06-14 12:28:35 +00:00
yamt e3b58482fb nfs_doio_read: use np->n_rcred instead of curproc->p_ucred for VDIR.
XXX maybe it's better to use a cred passed by VOP_READDIR.
2004-06-11 12:26:31 +00:00
yamt 03db65e256 make sure that nfssvc sockets are zapped before being freed. 2004-06-10 12:59:57 +00:00
yamt b0ac3e4201 nfsrv_zapsock: fix an inverted condition in nfs_syscall.c rev.1.74. 2004-06-10 12:57:43 +00:00
yamt 7407c491c3 nfsrv_create: fix an LP64 problem for exclusive create. 2004-05-31 08:47:08 +00:00
yamt ee306471a7 remove an unused instance of VOP_UPDATE. 2004-05-27 12:55:07 +00:00
hannken 8c21bc6224 Add ffs internal snapshots. Written by Marshall Kirk McKusick for FreeBSD.
- Not enabled by default. Needs kernel option FFS_SNAPSHOT.
- Change parameters of ffs_blkfree.
- Let the copy-on-write functions return an error so spec_strategy
    may fail if the copy-on-write fails.
- Change genfs_*lock*() to use vp->v_vnlock instead of &vp->v_lock.
- Add flag B_METAONLY to VOP_BALLOC to return indirect block buffer.
- Add a function ffs_checkfreefile needed for snapshot creation.
- Add special handling of snapshot files:
    Snapshots may not be opened for writing and the attributes are read-only.
    Use the mtime as the time this snapshot was taken.
    Deny mtime updates for snapshot files.
- Add function transferlockers to transfer any waiting processes from
  one lock to another.
- Add vfsop VFS_SNAPSHOT to take a snapshot and make it accessible through
  a vnode.
- Add snapshot support to ls, fsck_ffs and dump.

Welcome to 2.0F.

Approved by: Jason R. Thorpe <thorpej@netbsd.org>
2004-05-25 14:54:55 +00:00
atatat 53c625655c Sysctl descriptions under vfs subtree 2004-05-25 04:44:43 +00:00
jonathan 20f923718e Change DIAGNOSTIC warning in nfs_send() about NULL rep->r_procp: the
warning is triggered pervasively, so print it only once per boot.
(The callers who pass NULL r_procps should soon be fixed to pass a
valid struct proc* ).
2004-05-24 19:08:07 +00:00
yamt 345a3c375d - for tcp, use SO_RCVTIMEO to recover from server crash.
otherwise we can be stuck in soreceive forever.
  the problem is pointed by Minoura Makoto.  PR/25662
- clear r_rexmit on reconnect and clear r_rtt and R_TIMING on retransmit
  so that the above (and soft mounts) happy.
2004-05-23 08:08:48 +00:00
christos 45fb41a2bd cut down another 7K by more NFS_V2_ONLY ifdefs. 2004-05-23 05:53:01 +00:00
jonathan 230fb9b8ab Eliminate several uses of `curproc' from the socket-layer code and from NFS.
Add a new explicit `struct proc *p' argument to socreate(), sosend().
Use that argument instead of curproc. Follow-on changes to pass that
argument to socreate(), sosend(), and (*so->so_send)() calls.
These changes reviewed and independently recoded  by Matt Thomas.

Changes to soreceive() and (*dom->dom_exernalize() from Matt Thomas:
pass soreceive()'s struct uio* uio->uio_procp to unp_externalize().
Eliminate curproc from unp_externalize.   Also, now soreceive() uses
its uio->uio_procp value, pass that same value downward to
((pr->pru_usrreq)() calls for consistency, instead of (struct proc * )0.

Similar changes in sys/nfs to eliminate (most) uses of curproc,
either via the req-> r_procp field of a struct nfsreq *req argument,
or by passing down new explicit struct proc * arguments.

Reviewed by: Matt Thomas, posted to tech-kern.
NB: The (*pr->pru_usrreq)() change should be tested on more (all!) protocols.
2004-05-22 22:52:13 +00:00
yamt 7a6774551d enable reply cache for connection oriented protocols as well.
linux retransmits rpcs even when using tcp.
2004-05-21 13:53:40 +00:00
yamt 92e4dbdd94 #if 0 out CREATE optimization for now because it has a problem in the case
of O_CREAT|O_TRUNC, which is hard to be fixed without changing upper layer.
2004-05-17 12:17:18 +00:00
yamt 8d2f96d0fc g/c unused NFS_*ALLOC defines. 2004-05-12 20:11:27 +00:00
yamt 75f99c3465 nfs_lookup: handle "." by ourselves as RFC1813 3.2 says. 2004-05-10 12:43:51 +00:00
yamt 2dd754b680 don't do kludge for a reply to a retransmitted request
unless we actually retransmitted the request.
2004-05-10 10:40:42 +00:00
yamt 1c1b12397d nfs_lookup: avoid CREATE optimization for DOTDOT.
creating a DOTDOT entry has no sense and will fail anyway.
2004-05-08 21:35:13 +00:00