aboutsummaryrefslogtreecommitdiff
path: root/sys/nfsclient/nfs_bio.c
Commit message (Collapse)AuthorAgeFilesLines
* Do not leave invalid pages in the object after the short read for aKonstantin Belousov2012-08-141-4/+8
| | | | | | | | | | | | | | | | | network file systems (not only NFS proper). Short reads cause pages other then the requested one, which were not filled by read response, to stay invalid. Change the vm_page_readahead_finish() interface to not take the error code, but instead to make a decision to free or to (de)activate the page only by its validity. As result, not requested invalid pages are freed even if the read RPC indicated success. Noted and reviewed by: alc MFC after: 1 week Notes: svn path=/head/; revision=239246
* After the PHYS_TO_VM_PAGE() function was de-inlined, the main reasonKonstantin Belousov2012-08-051-0/+1
| | | | | | | | | | | | | | | | to pull vm_param.h was removed. Other big dependency of vm_page.h on vm_param.h are PA_LOCK* definitions, which are only needed for in-kernel code, because modules use KBI-safe functions to lock the pages. Stop including vm_param.h into vm_page.h. Include vm_param.h explicitely for the kernel code which needs it. Suggested and reviewed by: alc MFC after: 2 weeks Notes: svn path=/head/; revision=239065
* Reduce code duplication and exposure of direct access to structKonstantin Belousov2012-08-041-30/+2
| | | | | | | | | | | | vm_page oflags by providing helper function vm_page_readahead_finish(), which handles completed reads for pages with indexes other then the requested one, for VOP_GETPAGES(). Reviewed by: alc MFC after: 1 week Notes: svn path=/head/; revision=239040
* PR# 165923 reported intermittent write failures for dirtyRick Macklem2012-05-121-1/+6
| | | | | | | | | | | | | | | | | | | | | | memory mapped pages being written back on an NFS mount. Since any thread can call VOP_PUTPAGES() to write back a dirty page, the credentials of that thread may not have write access to the file on an NFS server. (Often the uid is 0, which may be mapped to "nobody" in the NFS server.) Although there is no completely correct fix for this (NFS servers check access on every write RPC instead of at open/mmap time), this patch avoids the common cases by holding onto a credential that recently opened the file for writing and uses that credential for the write RPCs being done by VOP_PUTPAGES() for both NFS clients. Tested by: Joel Ray Holveck (joelh at juniper.net) PR: kern/165923 Reviewed by: kib MFC after: 2 weeks Notes: svn path=/head/; revision=235332
* Remove unused thread argument from vtruncbuf().Edward Tomasz Napierala2012-04-231-1/+1
| | | | | | | Reviewed by: kib Notes: svn path=/head/; revision=234605
* Fix the NFS clients so that they use copyin() instead of bcopy(),Rick Macklem2012-03-011-1/+16
| | | | | | | | | | | when doing direct I/O. This direct I/O code is not enabled by default. Submitted by: kib (earlier version) Reviewed by: kib MFC after: 1 week Notes: svn path=/head/; revision=232327
* Fix found places where uio_resid is truncated to int.Konstantin Belousov2012-02-211-7/+7
| | | | | | | | | | | | Add the sysctl debug.iosize_max_clamp, enabled by default. Setting the sysctl to zero allows to perform the SSIZE_MAX-sized i/o requests from the usermode. Discussed with: bde, das (previous versions) MFC after: 1 month Notes: svn path=/head/; revision=231949
* A problem with respect to data read through the buffer cache for bothRick Macklem2012-01-271-9/+5
| | | | | | | | | | | | | | | | | | NFS clients was reported to freebsd-fs@ under the subject "NFS corruption in recent HEAD" on Nov. 26, 2011. This problem occurred when a TCP mounted root fs was changed to using UDP. I believe that this problem was caused by the change in mnt_stat.f_iosize that occurred because rsize was decreased to the maximum supported by UDP. This patch fixes the problem by using v_bufobj.bo_bsize instead of f_iosize, since the latter is set to f_iosize when the vnode is allocated, but does not change for a given vnode when f_iosize changes. Reported by: pjd Reviewed by: kib MFC after: 2 weeks Notes: svn path=/head/; revision=230605
* Rename vm_page_set_valid() to vm_page_set_valid_range().Konstantin Belousov2011-11-301-1/+1
| | | | | | | | | | The vm_page_set_valid() is the most reasonable name for the m->valid accessor. Reviewed by: attilio, alc Notes: svn path=/head/; revision=228156
* Merge 220876, 220877, and 221537 from the new NFS client to the old:John Baldwin2011-08-091-2/+6
| | | | | | | | | | | | | Allow the NFS client to use a max file size larger than 1TB for v3 mounts. It now allows files up to OFF_MAX subject to whatever limit the server advertises. Reviewed by: rmacklem Approved by: re (kib) MFC after: 1 week Notes: svn path=/head/; revision=224733
* In the VOP_PUTPAGES() implementations, change the default error fromKonstantin Belousov2011-06-011-6/+2
| | | | | | | | | | | | | | | | | | | VM_PAGER_AGAIN to VM_PAGER_ERROR for the uwritten pages. Return VM_PAGER_AGAIN for the partially written page. Always forward at least one page in the loop of vm_object_page_clean(). VM_PAGER_ERROR causes the page reactivation and does not clear the page dirty state, so the write is not lost. The change fixes an infinite loop in vm_object_page_clean() when the filesystem returns permanent errors for some page writes. Reported and tested by: gavin Reviewed by: alc, rmacklem MFC after: 1 week Notes: svn path=/head/; revision=222586
* Move sys/nfsclient/nfs_kdtrace.h to sys/nfs/nfs_kdtrace.h soRick Macklem2011-05-061-1/+1
| | | | | | | it can be used by the new NFS client as well as the old one. Notes: svn path=/head/; revision=221543
* Do not synchronously start the nfsiod threads at all. The r212506Konstantin Belousov2010-10-181-17/+9
| | | | | | | | | | | | | | | | | | | | | | fixed the issues with file descriptor locks, but the same problems are present for vnode lock/user map lock. If the nfs_asyncio() cannot find the free nfsiod, schedule task to create new nfsiod and return error. This causes fall back to the synchronous i/o for nfs_strategy(), or does not start read at all in the case of readahead. The caller that holds vnode and potentially user map lock does not wait for kproc_create() to finish, preventing the LORs. The change effectively reverts r203072, because we never hand off the request to newly created nfsiod thread anymore. Reviewed by: jhb Tested by: jhb, pluknet MFC after: 3 weeks Notes: svn path=/head/; revision=214026
* In NFS clients, instead of inconsistently using #ifdefKonstantin Belousov2010-06-131-10/+4
| | | | | | | | | | | DIAGNOSTIC and #ifndef DIAGNOSTIC for debug assertions, prefer KASSERT(). Also change one #ifdef DIAGNOSTIC in the new nfs server. Submitted by: Mikolaj Golub <to.my.trociny gmail com> MFC after: 2 weeks Notes: svn path=/head/; revision=209120
* Push down the page queues lock into vm_page_activate().Alan Cox2010-05-071-8/+9
| | | | Notes: svn path=/head/; revision=207746
* Eliminate page queues locking around most calls to vm_page_free().Alan Cox2010-05-061-4/+0
| | | | Notes: svn path=/head/; revision=207728
* Acquire the page lock around all remaining calls to vm_page_free() onAlan Cox2010-05-051-6/+12
| | | | | | | | | | | | | | | | managed pages that didn't already have that lock held. (Freeing an unmanaged page, such as the various pmaps use, doesn't require the page lock.) This allows a change in vm_page_remove()'s locking requirements. It now expects the page lock to be held instead of the page queues lock. Consequently, the page queues lock is no longer required at all by callers to vm_page_rename(). Discussed with: kib Notes: svn path=/head/; revision=207669
* Move checking against RLIMIT_FSIZE into one place, vn_rlimit_fsize().Edward Tomasz Napierala2010-05-051-13/+2
| | | | | | | Reviewed by: kib Notes: svn path=/head/; revision=207662
* Lock the page around vm_page_activate() and vm_page_deactivate() callsKonstantin Belousov2010-05-031-2/+6
| | | | | | | | | | where it was missed. The wrapped fragments now protect wire_count with page lock. Reviewed by: alc Notes: svn path=/head/; revision=207584
* Fix a race that can occur when nfs nfsiod threads are being created.Rick Macklem2010-01-271-3/+3
| | | | | | | | | | | | | | | | | | Without this patch it was possible for a different thread that calls nfs_asyncio() to snitch a newly created nfsiod thread that was intended for another caller of nfs_asyncio(), because the nfs_iod_mtx mutex was unlocked while the new nfsiod thread was created. This patch labels the newly created nfsiod, so that it is not taken by another caller of nfs_asyncio(). This is believed to fix the problem reported on the freebsd-stable email list under the subject: FreeBSD NFS client/Linux NFS server issue. Tested by: to DOT my DOT trociny AT gmail DOT com Reviewed by: jhb MFC after: 2 weeks Notes: svn path=/head/; revision=203072
* Use PBDRY flag for msleep(9) in NFS and NLM when sleeping thread ownsKonstantin Belousov2009-07-141-4/+4
| | | | | | | | | | | | | kernel resources that block other threads, like vnode locks. The SIGSTOP sent to such thread (process, rather) shall not stop it until thread releases the resources. Tested by: pho Reviewed by: jhb Approved by: re (kensmith) Notes: svn path=/head/; revision=195703
* Adjust the internal NFS KPI to avoid the last traces of NFS_LEGACYRPC.Doug Rabson2009-06-301-10/+10
| | | | | | | Approved by: re Notes: svn path=/head/; revision=195203
* Remove the old kernel RPC implementation and the NFS_LEGACYRPC option.Doug Rabson2009-06-301-1/+0
| | | | | | | Approved by: re Notes: svn path=/head/; revision=195202
* Fix some of the style errors in *getpages().Alan Cox2009-06-181-18/+13
| | | | Notes: svn path=/head/; revision=194425
* Add a test for VI_DOOMED just after nfs_upgrade_vnlock() inRick Macklem2009-06-101-8/+15
| | | | | | | | | | | | | | | | nfs_bioread_check_cons(). This is required since it is possible for the vnode to be vgonel()'d while in nfs_upgrade_vnlock() when a forced dismount is in progress. Also, move the check for VI_DOOMED in nfs_vinvalbuf() down to after nfs_upgrade_vnlock() and replace the out of date comment for it. Submitted by: jhb Tested by: pho Approved by: kib (mentor) MFC after: 1 month Notes: svn path=/head/; revision=193952
* nfs_write() can use the recently introduced vfs_bio_set_valid() instead ofAlan Cox2009-05-311-1/+1
| | | | | | | | | vfs_bio_set_validclean(), thereby avoiding the page queues lock. Garbage collect vfs_bio_set_validclean(). Nothing uses it any longer. Notes: svn path=/head/; revision=193187
* Make *getpages()s' assertion on the state of each page's dirty bitsAlan Cox2009-05-281-1/+1
| | | | | | | stricter. Notes: svn path=/head/; revision=192986
* Remove the unmaintained University of Michigan NFSv4 client from 8.xRobert Watson2009-05-221-14/+7
| | | | | | | | | | prior to 8.0-RELEASE. Rick Macklem's new and more feature-rich NFSv234 client and server are replacing it. Discussed with: rmacklem Notes: svn path=/head/; revision=192578
* Eliminate unnecessary clearing of the page's dirty mask from variousAlan Cox2009-05-151-1/+3
| | | | | | | | | getpages functions. Eliminate a stale comment. Notes: svn path=/head/; revision=192134
* Eliminate gratuitous clearing of the page's dirty mask.Alan Cox2009-05-121-1/+2
| | | | Notes: svn path=/head/; revision=192010
* Eliminate stale comments.Alan Cox2009-05-101-6/+1
| | | | | | | Eliminate a case of unnecessary page queues locking. Notes: svn path=/head/; revision=191964
* Add DTrace probes to the NFS access and attribute caches. Access cacheRobert Watson2009-03-241-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | events are: nfsclient:accesscache:flush:done nfsclient:accesscache:get:hit nfsclient:accesscache:get:miss nfsclient:accesscache:load:done They pass the vnode, uid, and requested or loaded access mode (if any); the load event may also report a load error if the RPC fails. The attribute cache events are: nfsclient:attrcache:flush:done nfsclient:attrcache:get:hit nfsclient:attrcache:get:miss nfsclient:attrcache:load:done They pass the vnode, optionally the vattr if one is present (hit or load), and in the case of a load event, also a possible RPC error. MFC after: 1 month Sponsored by: Google, Inc. Notes: svn path=/head/; revision=190380
* Remove the struct thread unuseful argument from bufobj interface.Attilio Rao2008-10-101-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | In particular following functions KPI results modified: - bufobj_invalbuf() - bufsync() and BO_SYNC() "virtual method" of the buffer objects set. Main consumers of bufobj functions are affected by this change too and, in particular, functions which changed their KPI are: - vinvalbuf() - g_vfs_close() Due to the KPI breakage, __FreeBSD_version will be bumped in a later commit. As a side note, please consider just temporary the 'curthread' argument passing to VOP_SYNC() (in bufsync()) as it will be axed out ASAP Reviewed by: kib Tested by: Giovanni Trematerra <giovanni dot trematerra at gmail dot com> Notes: svn path=/head/; revision=183754
* Decontextualize the couplet VOP_GETATTR / VOP_SETATTR as the passed threadAttilio Rao2008-08-281-3/+3
| | | | | | | | | was always curthread and totally unuseful. Tested by: Giovanni Trematerra <giovanni dot trematerra at gmail dot com> Notes: svn path=/head/; revision=182371
* namei() can call underlying nfs_readlink() passing a struct uio pointerAttilio Rao2008-02-091-4/+4
| | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=176134
* Fix for a very rare race, caused by the nfsiod wakeup and nfsiod idleMohan Srinivasan2007-09-251-0/+7
| | | | | | | | | | | 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 Notes: svn path=/head/; revision=172324
* Fix up NFS client write error handling. Errors are split intoJohn Baldwin2007-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) Notes: svn path=/head/; revision=171189
* Do proper "locking" for missing vmmeters part.Attilio Rao2007-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) Notes: svn path=/head/; revision=170292
* Revert VMCNT_* operations introduction.Attilio Rao2007-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) Notes: svn path=/head/; revision=170170
* - define and use VMCNT_{GET,SET,ADD,SUB,PTR} macros for manipulatingJeff Roberson2007-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> Notes: svn path=/head/; revision=169667
* Various fixes to the NFS Directio support.John Baldwin2007-04-251-6/+7
| | | | | | | | | | | | | | | - 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 Notes: svn path=/head/; revision=169043
* Introduce a field to struct vm_page for storing flags that areAlan Cox2006-08-091-1/+1
| | | | | | | | | | | | | | | | | | | synchronized by the lock on the object containing the page. Transition PG_WANTED and PG_SWAPINPROG to use the new field, eliminating the need for holding the page queues lock when setting or clearing these flags. Rename PG_WANTED and PG_SWAPINPROG to VPO_WANTED and VPO_SWAPINPROG, respectively. Eliminate the assertion that the page queues lock is held in vm_page_io_finish(). Eliminate the acquisition and release of the page queues lock around calls to vm_page_io_finish() in kern_sendfile() and vfs_unbusy_pages(). Notes: svn path=/head/; revision=161125
* Call vm_object_page_clean() with the object lock held.Stephan Uphoff2006-05-251-0/+2
| | | | | | | | | Submitted by: kensmith@ Reviewed by: mohans@ MFC after: 6 days Notes: svn path=/head/; revision=158915
* Do not set B_NOCACHE on buffers when releasing them in flushbuflist().Stephan Uphoff2006-05-251-0/+11
| | | | | | | | | | | | | | | | | | If B_NOCACHE is set the pages of vm backed buffers will be invalidated. However clean buffers can be backed by dirty VM pages so invalidating them can lead to data loss. Add support for flush dirty page in the data invalidation function of some network file systems. This fixes data losses during vnode recycling (and other code paths using invalbuf(*,V_SAVE,*,*)) for data written using an mmaped file. Collaborative effort by: jhb@,mohans@,peter@,ps@,ups@ Reviewed by: tegge@ MFC after: 7 days Notes: svn path=/head/; revision=158906
* Changes to make the NFS client MP safe.Mohan Srinivasan2006-05-191-121/+209
| | | | | | | Thanks to Kris Kennaway for testing and sending lots of bugs my way. Notes: svn path=/head/; revision=158739
* Keep track of the number of in-progress async direct IO writes in the nfsnode.Mohan Srinivasan2006-04-061-4/+17
| | | | | | | | Make fsync/close wait until all of these drain. Add a check to nfs_getpage() and nfs_putpage(). Notes: svn path=/head/; revision=157557
* - Always return success from NFS strategy. nfs_doio(), in thePaul Saab2005-11-211-1/+1
| | | | | | | | | | | | | | | event of an error, does the right thing, in terms of setting the error flags in the buf header. That fixes a crash from bstrategy(). - Treat ETIMEDOUT as a "recoverable" error, causing the buffer to be re-dirtied. ETIMEDOUT can occur on soft mounts, when the number of retries are exceeded, and we don't want data loss in that case. Submitted by: Mohan Srinivasan Notes: svn path=/head/; revision=152656
* Remove the NFS client rslock. The rslock was used to serializePaul Saab2005-07-211-76/+2
| | | | | | | | | | | | | | writers that want to extend the file. It was also used to serialize readers that might want to read the last block of the file (with a writer extending the file). Now that we support vnode locking for NFS, the rslock is unnecessary. Writers grab the exclusive vnode lock before writing and readers grab the shared (or in some cases the exclusive) lock. Submitted by: Mohan Srinivasan Notes: svn path=/head/; revision=148268
* Ifdef out the incomplete non-blocking IO implementation for NFSBrian Feldman2005-06-161-0/+2
| | | | | | | | | | | pending discussion of how implementation would proceed. Applications like -lc_r expect select(3) to match the EAGAIN-status of IO functions. Approved by: re Notes: svn path=/head/; revision=147420
* Fix a serious deadlock with the NFS client. Given a large enoughBrian Feldman2005-06-101-0/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | atomic write request, it can fill the buffer cache with the entirety of that write in order to handle retries. However, it never drops the vnode lock, or else it wouldn't be atomic, so it ends up waiting indefinitely for more buf memory that cannot be gotten as it has it all, and it waits in an uncancellable state. To fix this, hibufspace is exported and scaled to a reasonable fraction. This is used as the limit of how much of an atomic write request by the NFS client will be handled asynchronously. If the request is larger than this, it will be turned into a synchronous request which won't deadlock the system. It's possible this value is far off from what is required by some, so it shall be tunable as soon as mount_nfs(8) learns of the new field. The slowdown between an asynchronous and a synchronous write on NFS appears to be on the order of 2x-4x. General nod by: gad MFC after: 2 weeks More testing: wes PR: kern/79208 Notes: svn path=/head/; revision=147280