summaryrefslogtreecommitdiffstats
path: root/sys/nfsclient
Commit message (Collapse)AuthorAgeFilesLines
* - Complete part of the unfinished bufobj work by consistently usingjeff2008-03-223-38/+36
| | | | | | | | | | | | | | | | | BO_LOCK/UNLOCK/MTX when manipulating the bufobj. - Create a new lock in the bufobj to lock bufobj fields independently. This leaves the vnode interlock as an 'identity' lock while the bufobj is an io lock. The bufobj lock is ordered before the vnode interlock and also before the mnt ilock. - Exploit this new lock order to simplify softdep_check_suspend(). - A few sync related functions are marked with a new XXX to note that we may not properly interlock against a non-zero bv_cnt when attempting to sync all vnodes on a mountlist. I do not believe this race is important. If I'm wrong this will make these locations easier to find. Reviewed by: kib (earlier diff) Tested by: kris, pho (earlier diff)
* In keeping with style(9)'s recommendations on macros, use a ';'rwatson2008-03-161-1/+1
| | | | | | | | | after each SYSINIT() macro invocation. This makes a number of lightweight C parsers much happier with the FreeBSD kernel source, including cflow's prcc and lxr. MFC after: 1 month Discussed with: imp, rink
* Expand the nfs_opts array to include all possible stringrodrigc2008-03-051-1/+4
| | | | | | | | | | | mount options that mount_nfs could pass down, if it passed down string mount options. Right now, mount_nfs jut passes down a single mount option named "nfs_args" with a fully initialized 'struct nfs_args'. In future commits, we will add code to the kernel for parsing stringified NFS mount options, so that we can convert mount_nfs to pass string options from userspace to kernel, instead of an initialized struct nfs_args.
* In nfs_mount(), default initialize struct nfs_argsrodrigc2008-03-051-1/+25
| | | | | | | | | | | | | | the same way that it is default initialized in revision 1.77 of mount_nfs.c. Right now, this is a no-op, because currently we initialize struct nfs_args in mount_nfs in userspace, and pass it down into the kernel via nmount(), so we overwrite whatever we initialize here with the value passed in from userspace. However, this lays the groundwork for moving away from passing struct nfs_args from userspace to kernel via nmount(), so that we can instead pass string mount options via nmount() which can be parsed in the kernel. This will make it easier to add new NFS mount options.
* Axe the 'thread' argument from VOP_ISLOCKED() and lockstatus() as it isattilio2008-02-252-3/+2
| | | | | | | | | always curthread. As KPI gets broken by this patch, manpages and __FreeBSD_version will be updated by further commits. Tested by: Andrea Barberio <insomniac at slackware dot it>
* Introduce some functions in the vnode locks namespace and in the ffsattilio2008-02-241-2/+2
| | | | | | | | | | | | | | | namespace in order to handle lockmgr fields in a controlled way instead than spreading all around bogus stubs: - VN_LOCK_AREC() allows lock recursion for a specified vnode - VN_LOCK_ASHARE() allows lock sharing for a specified vnode In FFS land: - BUF_AREC() allows lock recursion for a specified buffer lock - BUF_NOREC() disallows recursion for a specified buffer lock Side note: union_subr.c::unionfs_node_update() is the only other function directly handling lockmgr fields. As this is not simple to fix, it has been left behind as "sole" exception.
* Prevent the NFS client from losing MNT_ROOTFS on the rootyar2008-02-171-9/+6
| | | | | | | | | | | | | | | file system. In particular, stop overwriting mount point flags in nfs_mountdiskless() because now they are set elsewhere. (They were _initialized_ by that function in the 4.4BSD days, when mount structures were not allocated in a centralized manner -- see rev. 1.1 of this file.) Fix nfs_mount(), which happened to depend on the loss of MNT_ROOTFS when it came to update handling. Also note that mountnfs() no longer handles updates. Now they shouldn't reach this function, so printf a diagnostic message if that happens due to a coding error.
* - Add real assertions to lockmgr locking primitives.attilio2008-02-131-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A couple of notes for this: * WITNESS support, when enabled, is only used for shared locks in order to avoid problems with the "disowned" locks * KA_HELD and KA_UNHELD only exists in the lockmgr namespace in order to assert for a generic thread (not curthread) owning or not the lock. Really, this kind of check is bogus but it seems very widespread in the consumers code. So, for the moment, we cater this untrusted behaviour, until the consumers are not fixed and the options could be removed (hopefully during 8.0-CURRENT lifecycle) * Implementing KA_HELD and KA_UNHELD (not surported natively by WITNESS) made necessary the introduction of LA_MASKASSERT which specifies the range for default lock assertion flags * About other aspects, lockmgr_assert() follows exactly what other locking primitives offer about this operation. - Build real assertions for buffer cache locks on the top of lockmgr_assert(). They can be used with the BUF_ASSERT_*(bp) paradigm. - Add checks at lock destruction time and use a cookie for verifying lock integrity at any operation. - Redefine BUF_LOCKFREE() in order to not use a direct assert but let it rely on the aforementioned destruction time check. KPI results evidently broken, so __FreeBSD_version bumping and manpage update result necessary and will be committed soon. Side note: lockmgr_assert() will be used soon in order to implement real assertions in the vnode namespace replacing the legacy and still bogus "VOP_ISLOCKED()" way. Tested by: kris (earlier version) Reviewed by: jhb
* Consolidate the code to generate a new XID for a NFS request into ajhb2008-02-133-22/+25
| | | | | | | | nfs_xid_gen() function instead of duplicating the logic in both nfsm_rpchead() and the NFS3ERR_JUKEBOX handling in nfs_request(). MFC after: 1 week Submitted by: mohans (a long while ago)
* Switch the default NFS mount mode from UDP to TCP. UDP mounts are akris2008-02-111-2/+2
| | | | | | | | | | historical relic, and are no longer appropriate for either LAN or WAN mounting. At modern (gigabit and 10 gigabit) LAN speeds packet loss from socket buffer fill events is common, and sequence numbers wrap quickly enough that data corruption is possible. TCP solves both of these problems without imposing significant overhead. MFC after: 1 month
* namei() can call underlying nfs_readlink() passing a struct uio pointerattilio2008-02-093-9/+9
| | | | | | | | | | | | | | owned by a NULL owner. This will lead consequent VOP_ISLOCKED() present into nfs_upgrade_vnlock() to panic as it only acquire curthread now. Fix nfs_upgrade_vnlock() and nfs_downgrade_vnlock() in order to not use more the struct thread pointer passed as argument (as it is really nomore required there as vn_lock() and VOP_UNLOCK doesn't get the lock more). Using curthread, in place, doesn't get ambiguity as LK_EXCLOTHER should be handled as a "not locked" request by both functions. Reported by: kris Tested by: kris Reviewed by: ups
* Conver all explicit instances to VOP_ISLOCKED(arg, NULL) intoattilio2008-02-081-1/+1
| | | | | | | | VOP_ISLOCKED(arg, curthread). Now, VOP_ISLOCKED() and lockstatus() should only acquire curthread as argument; this will lead in axing the additional argument from both functions, making the code cleaner. Reviewed by: jeff, kib
* Cleanup lockmgr interface and exported KPI:attilio2008-01-241-1/+1
| | | | | | | | | | | | | | | | | | | | - Remove the "thread" argument from the lockmgr() function as it is always curthread now - Axe lockcount() function as it is no longer used - Axe LOCKMGR_ASSERT() as it is bogus really and no currently used. Hopefully this will be soonly replaced by something suitable for it. - Remove the prototype for dumplockinfo() as the function is no longer present Addictionally: - Introduce a KASSERT() in lockstatus() in order to let it accept only curthread or NULL as they should only be passed - Do a little bit of style(9) cleanup on lockmgr.h KPI results heavilly broken by this change, so manpages and FreeBSD_version will be modified accordingly by further commits. Tested by: matteo
* - Introduce the function lockmgr_recursed() which returns true if theattilio2008-01-192-5/+6
| | | | | | | | | | | | | | | | | | | lockmgr lkp, when held in exclusive mode, is recursed - Introduce the function BUF_RECURSED() which does the same for bufobj locks based on the top of lockmgr_recursed() - Introduce the function BUF_ISLOCKED() which works like the counterpart VOP_ISLOCKED(9), showing the state of lockmgr linked with the bufobj BUF_RECURSED() and BUF_ISLOCKED() entirely replace the usage of bogus BUF_REFCNT() in a more explicative and SMP-compliant way. This allows us to axe out BUF_REFCNT() and leaving the function lockcount() totally unused in our stock kernel. Further commits will axe lockcount() as well as part of lockmgr() cleanup. KPI results, obviously, broken so further commits will update manpages and freebsd version. Tested by: kris (on UFS and NFS)
* VOP_LOCK1() (and so VOP_LOCK()) and VOP_UNLOCK() are only used inattilio2008-01-133-5/+5
| | | | | | | | | | | conjuction with 'thread' argument passing which is always curthread. Remove the unuseful extra-argument and pass explicitly curthread to lower layer functions, when necessary. KPI results broken by this change, which should affect several ports, so version bumping and manpage update will be further committed. Tested by: kris, pho, Diego Sardina <siarodx at gmail dot com>
* The previous revision broke the case of reconnecting to a TCP NFS serverjhb2008-01-111-1/+22
| | | | | | | | | | | | | | | via a new socket during an NFS operation as that reconnect takes place in the context of an arbitrary thread with an arbitrary credential. Ideally we would like to use the mount point's credential for the entire process of setting up the socket to connect to the NFS server. Since some of the APIs (sobind(), etc.) only take a thread pointer and infer the credential from that instead of a direct credential, work around the problem by temporarily changing the current thread's credential to that of the mount point while connecting the socket and then reverting back to the original credential when we are done. Reviewed by: rwatson Tested on: UDP, TCP, TCP with forced reconnect
* Pass curthread to various socket routines (socreate(), sobind(), andjhb2008-01-101-1/+1
| | | | | | | | | soconnect()) instead of &thread0 when establishing a connection to the NFS server. Otherwise inconsistent credentials may be used when setting up the NFS socket. MFC after: 1 week Reviewed by: rwatson
* vn_lock() is currently only used with the 'curthread' passed as argument.attilio2008-01-102-5/+5
| | | | | | | | | | | | | | | | Remove this argument and pass curthread directly to underlying VOP_LOCK1() VFS method. This modify makes the code cleaner and in particular remove an annoying dependence helping next lockmgr() cleanup. KPI results, obviously, changed. Manpage and FreeBSD_version will be updated through further commits. As a side note, would be valuable to say that next commits will address a similar cleanup about VFS methods, in particular vop_lock1 and vop_unlock. Tested by: Diego Sardina <siarodx at gmail dot com>, Andrea Di Pasquale <whyx dot it at gmail dot com>
* Remove hacks from the NFSv2/3 client intended to handle a lack of arwatson2007-11-191-25/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | server-side RPC retranmission cache for non-idempotent operations: these hacks substituted 0 (success) for the expected EEXIST in the event that a target name already existed for LINK, SYMLINK, and MKDIR operations, under the assumption that EEXIST represented a second application of the original RPC rather than a true failure. Background: certain NFS operations (in this case, LINK, SYMLINK, and MKDIR) are not idempotent, as they leave behind persisting state on the server that prevents them from being replayed without an error;if an UDP RPC reply is lost leading to a retransmission by theclient, the second reply will return EEXIST rather than success, asthe new object has already been created. The NFS client previouslysilently mapped the EEXIST return into success to paper over thisproblem. However, in all modern NFS server implementations, a reply cache is kept in order to retransmit the original reply to a retransmitted request, rather than performing the operation a second time, allowing this hack to be avoided. This allows link()-based filelocking over NFS to operate correctly, as an application requestingthe creation of a new link for a file to tell if it succeededatomically or not. Other NFS clients, including Solaris and Linux, generally follow this behavior for the same reasons. Most clients also now default to TCP, which also helps avoid the issue of retransmitted but non-idempotent requests in most cases. Reported by: Adam McDougall <mcdouga9 at egr dot msu dot edu>, Timo Sirainen <tss at iki dot fi> Reviewed by: mohans MFC after: 1 week
* Add the following mount options to the nfs_opts array:rodrigc2007-10-271-1/+4
| | | | | | | | | | | | | noatime, noexec, suiddir, nosuid, nosymfollow, union, noclusterr, noclusterw, multilabel, acls, force, update, async. These options correspond to MOPT_STDOPTS, MOPT_FORCE, MOPT_UPDATE, and MOPT_ASYNC. Currently, mount_nfs converts these "-o" options from strings to MNT_ flags via getmntopts(), and passes the flags from userspace to the kernel. This change will allow us in future to pass these mount options as strings directly to the kernel via nmount() when doing NFS mounts.
* Rename the kthread_xxx (e.g. kthread_create()) callsjulian2007-10-201-3/+3
| | | | | | | | | | | to kproc_xxx as they actually make whole processes. Thos makes way for us to add REAL kthread_create() and friends that actually make theads. it turns out that most of these calls actually end up being moved back to the thread version when it's added. but we need to make this cosmetic change first. I'd LOVE to do this rename in 7.0 so that we can eventually MFC the new kthread_xxx() calls.
* Add a -z flag to nfsstat which zeros the NFS statistics after displayingjhb2007-10-181-1/+1
| | | | | | | | them. MFC after: 1 week Requested by: ps Submitted by: ps (6 years ago)
* Get rid of qaddr_t.alfred2007-10-161-1/+1
| | | | Requested by: bde
* NFS MP scaling changes.mohans2007-10-124-75/+131
| | | | | | | | | | | | | | - Eliminate the hideous nfs_sndlock that serialized NFS/TCP request senders thru the sndlock. - Institute a new nfs_connectlock that serializes NFS/TCP reconnects. Add logic to wait for pending request senders to finish sending before reconnecting. Dial down the sb_timeo for NFS/TCP sockets to 1 sec. - Break out the nfs xid manipulation under a new nfs xid lock, rather than over loading the nfs request lock for this purpose. - Fix some of the locking in nfs_request. Many thanks to Kris Kennaway for his help with this and for initiating the MP scaling analysis and work. Kris also tested this patch thorougly. Approved by: re@ (Ken Smith)
* Fix for a very rare race, caused by the nfsiod wakeup and nfsiod idlemohans2007-09-252-3/+20
| | | | | | | | timeout occurring at exactly the same time. If this happens, the nfsiod exits although there may be a queued async IO request for it. Found by : Kris Kennaway Approved by: re
* Remove the now-unused NET_{LOCK,UNLOCK,ASSERT}_GIANT() macros, whichrwatson2007-08-064-50/+14
| | | | | | | | | | | | | | | previously conditionally acquired Giant based on debug.mpsafenet. As that has now been removed, they are no longer required. Removing them significantly simplifies error-handling in the socket layer, eliminated quite a bit of unwinding of locking in error cases. While here clean up the now unneeded opt_net.h, which previously was used for the NET_WITH_GIANT kernel option. Clean up some related gotos for consistency. Reviewed by: bz, csjp Tested by: kris Approved by: re (kensmith)
* Fix for a race where out of order loading of NFS attrs into thejhb2007-07-031-1/+17
| | | | | | | | | | | | nfsnode could lead to attrs being stale. One example (that we ran into) was a READDIR+, WRITE. The responses came back in order, but the attrs from the WRITE were loaded before the attrs from the READDIR+, leading to the wrong size from being read on the next stat() call. MFC after: 1 week Submitted by: mohans Approved by: re (kensmith)
* Fix up NFS client write error handling. Errors are split intojhb2007-07-031-0/+15
| | | | | | | | | | | | | recoverable and unrecoverable. For the former, we redirty the buffer and hang onto it for future retries. For the latter (eg. ESTALE), we discard the buffer and return the error back to the user on the next syscall. This fixes a number of vfs panics and fixes having a large number of dirty buffers (that cannot be written out and reclaimed) from hanging around. Thanks to ups@ for discussions on this issue. Reported by: kris, Kai, others Approved by: re (kensmith)
* Do proper "locking" for missing vmmeters part.attilio2007-06-041-4/+4
| | | | | | | | Now, we assume no more sched_lock protection for some of them and use the distribuited loads method for vmmeter (distribuited through CPUs). Reviewed by: alc, bde Approved by: jeff (mentor)
* - Move rusage from being per-process in struct pstats to per-thread injeff2007-06-011-1/+1
| | | | | | | | | | | | | | | | | | | td_ru. This removes the requirement for per-process synchronization in statclock() and mi_switch(). This was previously supported by sched_lock which is going away. All modifications to rusage are now done in the context of the owning thread. reads proceed without locks. - Aggregate exiting threads rusage in thread_exit() such that the exiting thread's rusage is not lost. - Provide a new routine, rufetch() to fetch an aggregate of all rusage structures from all threads in a process. This routine must be used in any place requiring a rusage from a process prior to it's exit. The exited process's rusage is still available via p_ru. - Aggregate tick statistics only on demand via rufetch() or when a thread exits. Tick statistics are kept in the thread and protected by sched_lock until it exits. Initial patch by: attilio Reviewed by: attilio, bde (some objections), arch (mostly silent)
* Revert VMCNT_* operations introduction.attilio2007-05-311-4/+4
| | | | | | | | Probabilly, a general approach is not the better solution here, so we should solve the sched_lock protection problems separately. Requested by: alc Approved by: jeff (mentor)
* In nfs_down(), if rep can be NULL, which we test for, then we shouldrwatson2007-05-181-3/+4
| | | | | | | | | lock and unlock conditionally, not just set the flag on it conditionally. In practice, this bug couldn't manifest, as in the current revision of the code, no callers pass a NULL rep. CID: 1416 Found with: Coverity Prevent(tm)
* - define and use VMCNT_{GET,SET,ADD,SUB,PTR} macros for manipulatingjeff2007-05-181-4/+4
| | | | | | | | vmcnts. This can be used to abstract away pcpu details but also changes to use atomics for all counters now. This means sched lock is no longer responsible for protecting counts in the switch routines. Contributed by: Attilio Rao <attilio@FreeBSD.org>
* Various fixes to the NFS Directio support.jhb2007-04-252-6/+11
| | | | | | | | | | | | - Fix for a bug where a close would not wait for all (directio) dirty buffers to drain. The nfsnode was not marked NMODIFIED when there were directio dirtied buffers pending, causing this. - No reason to vhold/vrele the vp when enqueueing DirectIO requests for the nfsiods. The vnode can't really go way since the close has to wait for these requests to drain. MFC after: 1 week Submitted by: mohans
* Attempt to rationalize NFS privileges:rwatson2007-04-211-11/+5
| | | | | | | | | | | - Replace PRIV_NFSD with PRIV_NFS_DAEMON, add PRIV_NFS_LOCKD. - Use PRIV_NFS_DAEMON in the NFS server. - In the NFS client, move the privilege check from nfslockdans(), which occurs every time a write is performed on /dev/nfslock, and instead do it in nfslock_open() just once. This allows us to avoid checking the saved uid for root, and just use the effective on open. Use PRIV_NFS_LOCKD.
* Don't destroy a mutex just before we use it, instead,delphij2007-03-231-1/+1
| | | | destroy it after we have used it.
* Make insmntque() externally visibile and allow it to fail (e.g. duringtegge2007-03-131-0/+11
| | | | | | | | | | | | | | | | | | | | | | | late stages of unmount). On failure, the vnode is recycled. Add insmntque1(), to allow for file system specific cleanup when recycling vnode on failure. Change getnewvnode() to no longer call insmntque(). Previously, embryonic vnodes were put onto the list of vnode belonging to a file system, which is unsafe for a file system marked MPSAFE. Change vfs_hash_insert() to no longer lock the vnode. The caller now has that responsibility. Change most file systems to lock the vnode and call insmntque() or insmntque1() after a new vnode has been sufficiently setup. Handle failed insmntque*() calls by propagating errors to callers, possibly after some file system specific cleanup. Approved by: re (kensmith) Reviewed by: kib In collaboration with: kib
* Back out a chance to nfs_timer() that inadvertantly crept in the last checkin :(mohans2007-03-091-1/+1
|
* Over NFS, an open() call could result in multiple over-the-wiremohans2007-03-094-2/+31
| | | | | | | | | | | | GETATTRs being generated - one from lookup()/namei() and the other from nfs_open() (for cto consistency). This change eliminates the GETATTR in nfs_open() if an otw GETATTR was done from the namei() path. Instead of extending the vop interface, we timestamp each attr load, and use this to detect whether a GETATTR was done from namei() for this syscall. Introduces a thread-local variable that counts the syscalls made by the thread and uses <pid, tid, thread syscalls> as the attrload timestamp. Thanks to jhb@ and peter@ for a discussion on thread state that could be used as the timestamp with minimal overhead.
* Use pause() rather than tsleep() on stack variables and function pointers.jhb2007-02-271-1/+1
|
* Backing out an earlier change. It seems harmless for NFS to miss the "forcemohans2007-02-161-6/+0
| | | | | unmount" flag, making the acquisition of the MNT_ILOCK in nfs_request() and nfs_sigintr() unnecessary. Pointed out by tegge@.
* Add missing MNT_ILOCK around some mnt_kern_flag accesses.mohans2007-02-111-0/+6
|
* Fix for a vnode lock leak in nfs_create() in the event of an error.mohans2007-01-311-0/+2
| | | | Spotted by ups@.
* Instead of always hard-coding the socket type for the nfs root mount askris2007-01-301-1/+1
| | | | | | | | | | | | | SOCK_DGRAM (i.e. UDP), respect the value configured earlier. This allows TCP NFS root mounts using e.g. the boot.nfsroot.options="tcp" tunable. In this case some of the connection parameters like the retry timer were previously set appropriately for TCP but inappropriately for the UDP socket that was actually used, leading to e.g. extremely long recovery times (O(hours)) after a nfs server reboot. Reviewed by: mohans MFC After: 2 weeks
* Unstaticize nfs_iosize() in nfsclient and use it in nfs4client insteadbde2007-01-252-7/+7
| | | | | | | | | | | of duplicating it except for larger style bugs in the copy. Fix some nearby style bugs (including a harmless type mismatch) in and near the remaining copy. This is part of fixing collisions of the 2 nfs*client's names. Even static names should have a unique prefixes so that they can be debugged easily.
* Cylinder group bitmaps and blocks containing inode for a snapshotkib2007-01-231-0/+1
| | | | | | | | | | | | | | | | | | | | | file are after snaplock, while other ffs device buffers are before snaplock in global lock order. By itself, this could cause deadlock when bdwrite() tries to flush dirty buffers on snapshotted ffs. If, during the flush, COW activity for snapshot needs to allocate block and ffs_alloccg() selects the cylinder group that is being written by bdwrite(), then kernel would panic due to recursive buffer lock acquision. Avoid dealing with buffers in bdwrite() that are from other side of snaplock divisor in the lock order then the buffer being written. Add new BOP, bop_bdwrite(), to do dirty buffer flushing for same vnode in the bdwrite(). Default implementation, bufbdflush(), refactors the code from bdwrite(). For ffs device buffers, specialized implementation is used. Reviewed by: tegge, jeff, Russell Cattelan (cattelan xfs org, xfs changes) Tested by: Peter Holm X-MFC after: 3 weeks (if ever: it changes ABI)
* NetApp filers return corrupt post op attrs in the wcc on NFS error responses.mohans2006-12-111-1/+8
| | | | | | | This is easy to reproduce for EROFS. I am not sure if the attrs can be corrupt for other NFS error responses. For now, disabling wcc pre-op attr checks and post-op attr loads on NFS errors (sysctl'ed). Reported by: Kris Kennaway
* consolidate parsing of nfs root mount options in one placesam2006-12-064-51/+77
| | | | | | | and handle all options (some may require fixes elsewhere) Reviewed by: jhb, mohans MFC after: 1 month
* In nfs_nget(), we must initialize the fh in the nfsnode before inserting themohans2006-11-291-6/+6
| | | | | | vnode into the vfs hash. Otherwise, another thread walking the hash can trip on an nfsnode with an uninitialized or partially initialized fh. Thanks to ups@ for spotting this race.
* bde@ pointed out that tprintf() acquires Giant so callers of tprintf() don'tmohans2006-11-271-6/+4
| | | | | | have to explicitly acquire Giant (although they need to be aware of this and not hold any locks at that point). Remove the acquisitions of Giant in the NFS client wrapping tprintf().
OpenPOWER on IntegriCloud