summaryrefslogtreecommitdiffstats
path: root/sys/fs/tmpfs/tmpfs_vnops.c
Commit message (Collapse)AuthorAgeFilesLines
* MFC r295574:markj2016-02-221-1/+4
| | | | | | Clear the cookie pointer on error in tmpfs_readdir(). Approved by: re (glebius)
* MFC r277828:kib2015-02-111-9/+8
| | | | | | | | | | | | | Update mtime for tmpfs files modified through memory mapping. MFC r277969: Update both ctime and mtime for writes to tmpfs files. MFC r277972: Remove single-use boolean. MFC r278151: Remove duplicated assignment.
* MFC r276007:kib2015-01-041-1/+5
| | | | Handle MAKEENTRY cnp flag in the VOP_CREATE().
* MFC r275897:kib2015-01-011-1/+1
| | | | | Set NOCACHE flag for CREATE namei() calls, do not specially handle MAKEENTRY in VOP_LOOKUP().
* MFC r268765:kib2014-07-301-1/+0
| | | | Remove unused header.
* MFC r268764:kib2014-07-301-15/+0
| | | | | Check for the cross-device cross-link attempt in the VFS, instead of VOP_LINK() implemenations.
* MFC r268766:kib2014-07-281-1/+3
| | | | Do not ignore error from tmpfs_alloc_vp().
* MFC r268614:kib2014-07-281-13/+13
| | | | | Use tmpfs_vn_get_ino_gen() to handle the races with reclaim in tmpfs dotdot lookup.
* MFC r268613:kib2014-07-281-1/+1
| | | | Style. Add comment about lock mode.
* MFC r268609:kib2014-07-281-0/+2
| | | | Add some assertions for the code handling vm_object for tmpfs vnode.
* MFC r268608:kib2014-07-281-2/+2
| | | | | The tmpfs_link() must not dereference the filesystem-specific data for a vnode until it is verified that the vnode indeed belongs to tmpfs mount.
* MFC r268605:kib2014-07-281-41/+0
| | | | Remove code separator lines which do not conform to style(9).
* MFC r267564:kib2014-06-241-6/+1
| | | | | In msdosfs_setattr(), add a check for result of the utimes(2) permissions test. Refactor the permission checks for utimes(2).
* MFC r263131,r263174,r263175:bdrewery2014-03-301-6/+12
| | | | | | | | | | | | | | | | Tmpfs readdir() redundant logic and code readability cleanup. r263131: Cleanup redundant logic and add some comments to help explain how it works in lieu of potentially less clear code. r263174: Rename cnt to maxcookies and change its use as the condition for when to lookup cookies to be less obscure. r263175: Add missing FALLTHROUGH comment in tmpfs_dir_getdents for looking up '.' and '..'.
* Extract the general-purpose code from tmpfs to perform uiomove fromkib2013-08-211-211/+24
| | | | | | | | the page queue of some vm object. Discussed with: alc Tested by: pho Sponsored by: The FreeBSD Foundation
* The soft and hard busy mechanism rely on the vm object lock to work.attilio2013-08-091-9/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Unify the 2 concept into a real, minimal, sxlock where the shared acquisition represent the soft busy and the exclusive acquisition represent the hard busy. The old VPO_WANTED mechanism becames the hard-path for this new lock and it becomes per-page rather than per-object. The vm_object lock becames an interlock for this functionality: it can be held in both read or write mode. However, if the vm_object lock is held in read mode while acquiring or releasing the busy state, the thread owner cannot make any assumption on the busy state unless it is also busying it. Also: - Add a new flag to directly shared busy pages while vm_page_alloc and vm_page_grab are being executed. This will be very helpful once these functions happen under a read object lock. - Move the swapping sleep into its own per-object flag The KPI is heavilly changed this is why the version is bumped. It is very likely that some VM ports users will need to change their own code. Sponsored by: EMC / Isilon storage division Discussed with: alc Reviewed by: jeff, kib Tested by: gavin, bapt (older version) Tested by: pho, scottl
* Revert r253939:attilio2013-08-051-6/+8
| | | | | | | | | | | | | We cannot busy a page before doing pagefaults. Infact, it can deadlock against vnode lock, as it tries to vget(). Other functions, right now, have an opposite lock ordering, like vm_object_sync(), which acquires the vnode lock first and then sleeps on the busy mechanism. Before this patch is reinserted we need to break this ordering. Sponsored by: EMC / Isilon storage division Reported by: kib
* The page hold mechanism is fast but it has couple of fallouts:attilio2013-08-041-8/+6
| | | | | | | | | | | | | | | | | | | | | | | | - It does not let pages respect the LRU policy - It bloats the active/inactive queues of few pages Try to avoid it as much as possible with the long-term target to completely remove it. Use the soft-busy mechanism to protect page content accesses during short-term operations (like uiomove_fromphys()). After this change only vm_fault_quick_hold_pages() is still using the hold mechanism for page content access. There is an additional complexity there as the quick path cannot immediately access the page object to busy the page and the slow path cannot however busy more than one page a time (to avoid deadlocks). Fixing such primitive can bring to complete removal of the page hold mechanism. Sponsored by: EMC / Isilon storage division Discussed with: alc Reviewed by: jeff Tested by: pho
* Remove unnecessary soft busy of the page before to do vn_rdwr() inattilio2013-08-041-5/+3
| | | | | | | | | | | | kern_sendfile() which is unnecessary. The page is already wired so it will not be subjected to pagefault. The content cannot be effectively protected as it is full of races already. Multiple accesses to the same indexes are serialized through vn_rdwr(). Sponsored by: EMC / Isilon storage division Reviewed by: alc, jeff Tested by: pho
* Add missing VM object unlocks in an error case.alc2013-06-071-0/+2
| | | | Reviewed by: kib
* Don't busy the page unless we are likely to release the object lock.alc2013-06-061-4/+7
| | | | | Reviewed by: kib Sponsored by: EMC / Isilon Storage Division
* Eliminate unnecessary vm object locking from tmpfs_nocacheread().alc2013-06-041-2/+0
|
* Avoid deactivating the page if it is already on a queue, only requeuekib2013-05-061-6/+10
| | | | | | | | | | the page. This both reduces the number of queues locking and avoids moving the active page to inactive list just because the page was read or written. Based on the suggestion by: alc Reviewed by: alc Tested by: pho
* Fix the v_object leak for non-regular tmpfs vnodes.kib2013-05-021-0/+3
| | | | | Reported and tested by: pho Sponsored by: The FreeBSD Foundation
* For the new regular tmpfs vnode, v_object is initialized beforekib2013-05-021-13/+2
| | | | | | | | | | | | | | insmntque() is called. The standard insmntque destructor resets the vop vector to deadfs one, and calls vgone() on the vnode. As result, v_object is kept unchanged, which triggers an assertion in the reclaim code, on instmntque() failure. Also, in this case, OBJ_TMPFS flag on the backed vm object is not cleared. Provide the tmpfs insmntque() destructor which properly clears OBJ_TMPFS flag and resets v_object. Reported and tested by: pho Sponsored by: The FreeBSD Foundation
* The page read or written could be wired. Do not requeue if the pagekib2013-05-021-2/+4
| | | | | | | is not on a queue. Reported and tested by: pho Sponsored by: The FreeBSD Foundation
* Rework the handling of the tmpfs node backing swap object and tmpfskib2013-04-281-158/+82
| | | | | | | | | | | | | | | | | | vnode v_object to avoid double-buffering. Use the same object both as the backing store for tmpfs node and as the v_object. Besides reducing memory use up to 2x times for situation of mapping files from tmpfs, it also makes tmpfs read and write operations copy twice bytes less. VM subsystem was already slightly adapted to tolerate OBJT_SWAP object as v_object. Now the vm_object_deallocate() is modified to not reinstantiate OBJ_ONEMAPPING flag and help the VFS to correctly handle VV_TEXT flag on the last dereference of the tmpfs backing object. Reviewed by: alc Tested by: pho, bf MFC after: 1 month
* - Constify local path variable for chflagsat().pjd2013-03-221-1/+1
| | | | | | - Use correct format characters (%lx) for u_long. This fixes the build broken in r248599.
* Remove negative name cache entry pointing to the target name, whichkib2013-03-171-0/+1
| | | | | | | | could be instantiated while tdvp was unlocked. Reported by: Rick Miller <vmiller at hostileadmin com> Tested by: pho MFC after: 1 week
* Rename VM_OBJECT_LOCK(), VM_OBJECT_UNLOCK() and VM_OBJECT_TRYLOCK() toattilio2013-02-201-22/+22
| | | | | | their "write" versions. Sponsored by: EMC / Isilon storage division
* Switch vm_object lock to be a rwlock.attilio2013-02-201-0/+2
| | | | | | | | * VM_OBJECT_LOCK and VM_OBJECT_UNLOCK are mapped to write operations * VM_OBJECT_SLEEP() is introduced as a general purpose primitve to get a sleep operation using a VM_OBJECT_LOCK() as protection * The approach must bear with vm_pager.h namespace pollution so many files require including directly rwlock.h
* Remove a racy checks on resident and cached pages forattilio2013-02-101-12/+0
| | | | | | | | | | | | | | | | tmpfs_mapped{read, write}() functions: - tmpfs_mapped{read, write}() are only called within VOP_{READ, WRITE}(), which check before-hand to work only on valid VREG vnodes. Also the vnode is locked for the duration of the work, making vnode reclaiming impossible, during the operation. Hence, vobj can never be NULL. - Currently check on resident pages and cached pages without vm object lock held is racy and can do even more harm than good, as a page could be transitioning between these 2 pools and then be skipped entirely. Skip the checks as lookups on empty splay trees are very cheap. Discussed with: alc Tested by: flo MFC after: 2 weeks
* tmpfs: Replace directory entry linked list with RB-Tree.gleb2013-01-061-73/+37
| | | | | | | | | | | | | | | | | | | | | Use file name hash as a tree key, handle duplicate keys. Both VOP_LOOKUP and VOP_READDIR operations utilize same tree for search. Directory entry offset (cookie) is either file name hash or incremental id in case of hash collisions (duplicate-cookies). Keep sorted per directory list of duplicate-cookie entries to facilitate cookie number allocation. Don't fail if previous VOP_READDIR() offset is no longer valid, start with next dirent instead. Other file system handle it similarly. Workaround race prone tn_readdir_last[pn] fields update. Add tmpfs_dir_destroy() to free all dirents. Set NFS cookies in tmpfs_dir_getdents(). Return EJUSTRETURN from tmpfs_dir_getdents() instead of hard coded -1. Mark directory traversal routines static as they are no longer used outside of tmpfs_subr.c
* After the PHYS_TO_VM_PAGE() function was de-inlined, the main reasonkib2012-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
* Remove unused thread argument to vrecycle().trasz2012-04-231-2/+1
| | | | Reviewed by: kib
* - Introduce a cache-miss optimization for consistency with otherattilio2012-04-091-1/+1
| | | | | | | | | accesses of the cache member of vm_object objects. - Use novel vm_page_is_cached() for checks outside of the vm subsystem. Reviewed by: alc MFC after: 2 weeks X-MFC: r234039
* Prevent tmpfs_rename() deadlock in a way similar to UFSgleb2012-03-141-7/+176
| | | | | | Unlock vnodes and try to lock them one by one. Relookup fvp and tvp. Approved by: mdf (mentor)
* Remove fifo.h. The only used function declaration from the header iskib2012-03-111-1/+0
| | | | | | migrated to sys/vnode.h. Submitted by: gianni
* Similar to the fixes in 226967 and 226987, purge any name cache entriesjhb2012-03-021-0/+2
| | | | | | | | | associated with the previous vnode (if any) associated with the target of a rename(). Otherwise, a lookup of the target pathname concurrent with a rename() could re-add a name cache entry after the namei(RENAME) lookup in kern_renameat() had purged the target pathname. MFC after: 2 weeks
* Replace PRIdMAX with "jd" in a printf call. Cast the corresponding value totijl2012-02-141-5/+2
| | | | intmax_t instead of uintmax_t, because the original type is off_t.
* When tmpfs_write() resets an extended file to its original size after analc2012-01-161-2/+3
| | | | | | | | error, we want tmpfs_reg_resize() to ignore I/O errors and unconditionally update the file's size. Reviewed by: kib MFC after: 3 weeks
* Neither tmpfs_nocacheread() nor tmpfs_mappedwrite() needs to callalc2012-01-141-20/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | vm_object_pip_{add,subtract}() on the swap object because the swap object can't be destroyed while the vnode is exclusively locked. Moreover, even if the swap object could have been destroyed during tmpfs_nocacheread() and tmpfs_mappedwrite() this code is broken because vm_object_pip_subtract() does not wake up the sleeping thread that is trying to destroy the swap object. Free invalid pages after an I/O error. There is no virtue in keeping them around in the swap object creating more work for the page daemon. (I believe that any non-busy page in the swap object will now always be valid.) vm_pager_get_pages() does not return a standard errno, so its return value should not be returned by tmpfs without translation to an errno value. There is no reason for the wakeup on vpg in tmpfs_mappedwrite() to occur with the swap object locked. Eliminate printf()s from tmpfs_nocacheread() and tmpfs_mappedwrite(). (The swap pager already spam your console if data corruption is imminent.) Reviewed by: kib MFC after: 3 weeks
* Don't pass VM_ALLOC_ZERO to vm_page_grab() in tmpfs_mappedwrite() andalc2012-01-031-2/+2
| | | | | | | | tmpfs_nocacheread(). It is both unnecessary and a pessimization. It results in either the page being zeroed twice or zeroed first and then overwritten by an I/O operation. MFC after: 3 weeks
* Avoid panics from recursive rename operations. Not a perfect patch butivoras2011-11-221-6/+3
| | | | | | | | | good enough for now. PR: kern/159418 Submitted by: Gleb Kurtsou Reviewed by: kib MFC after: 1 month
* Added missing cache purge of from argument for rename().pho2011-11-011-0/+1
| | | | | | Reported by: Anton Yuzhaninov <citrin citrin ru> In collaboration with: kib MFC after: 1 week
* Split the vm_page flags PG_WRITEABLE and PG_REFERENCED into atomickib2011-09-061-6/+3
| | | | | | | | | | | | | | | | | flags field. Updates to the atomic flags are performed using the atomic ops on the containing word, do not require any vm lock to be held, and are non-blocking. The vm_page_aflag_set(9) and vm_page_aflag_clear(9) functions are provided to modify afalgs. Document the changes to flags field to only require the page lock. Introduce vm_page_reference(9) function to provide a stable KPI and KBI for filesystems like tmpfs and zfs which need to mark a page as referenced. Reviewed by: alc, attilio Tested by: marius, flo (sparc64); andreast (powerpc, powerpc64) Approved by: re (bz)
* Eliminate two dubious attempts at optimizing the implementation of aalc2011-02-221-12/+4
| | | | | | | | | | | | | | | | | | file's last accessed, modified, and changed times: TMPFS_NODE_ACCESSED and TMPFS_NODE_CHANGED should be set unconditionally in tmpfs_remove() without regard to the number of hard links to the file. Otherwise, after the last directory entry for a file has been removed, a process that still has the file open could read stale values for the last accessed and changed times with fstat(2). Similarly, tmpfs_close() should update the time-related fields even if all directory entries for a file have been removed. In this case, the effect is that the time-related fields will have values that are later than expected. They will correspond to the time at which fstat(2) is called. In collaboration with: kib MFC after: 1 week
* tmpfs_remove() isn't modifying the file's data, so it shouldn't setalc2011-02-191-2/+1
| | | | | | | | | TMPFS_NODE_MODIFIED on the node. PR: 152488 Submitted by: Anton Yuzhaninov Reviewed by: kib MFC after: 1 week
* In tmpfs_readdir(), normalize handling of the directory entries thatkib2011-01-201-1/+1
| | | | | | | | | | either overflow the supplied buffer, or cause uiomove fail. Do not advance cached de when directory entry was not copied out. Do not return EOF when no entries could be copied due to first entry too large for supplied buffer, signal EINVAL instead. Reported by: Beat G?tzi <beat chruetertee ch> MFC after: 1 week
* tmpfs + sendfile: do not produce partially valid pages for vnode's tailavg2010-10-121-3/+6
| | | | | | See r213730 for details of analogous change in ZFS. MFC after: 3 days
OpenPOWER on IntegriCloud