summaryrefslogtreecommitdiffstats
path: root/sys/fs/tmpfs
Commit message (Collapse)AuthorAgeFilesLines
* Provide vfs suspension support only for filesystems which need it.mjg2014-10-191-0/+9
| | | | | | | | Need is expressed by providing vfs_susp_clean function in vfsops. Differential Revision: D952 Reviewed by: kib (previous version) MFC after: 2 weeks
* Do not ignore error from tmpfs_alloc_vp(). It results in access tokib2014-07-161-1/+3
| | | | | | | | the random memory. Reported and tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 2 weeks
* Remove unused header.kib2014-07-161-1/+0
| | | | | | Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 2 weeks
* Check for the cross-device cross-link attempt in the VFS, instead ofkib2014-07-161-15/+0
| | | | | | | | | | | | | forcing filesystem VOP_LINK() methods to repeat the code. In tmpfs_link(), remove redundand check for the type of the source, already done by VFS. Note that NFS server already performs this check before calling VOP_LINK(). Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 2 weeks
* Rework the tmpfs unmount.kib2014-07-143-27/+74
| | | | | | | | | | | | | | | | | | | | | | | | | | | - Suspend filesystem for unmount. This prevents new tmpfs nodes from instantiating, and also ensures that only unmount thread can destroy nodes. - Do not start tmpfs node deletion until all vnodes are reclaimed, which guarantees that no thread can access tmpfs data. For this, call vflush() in the loop, until the mnt_nvnodelistsize is non-zero. Note that after mnt_nvnodelistsize becomes 0, insmntque() blocks insertion of a vnode germ into the mount list of vnodes. - Fail node allocation when the filesystem is being unmounted. This is race-free due to the vflush() call in loop. This is mostly cosmetic, avoiding some more work which might be done until suspension in unmount is started. Note that there is currently no way to prevent new vnode instantiation from readers during the unmount. Due to this, forced unmount might live-lock if vflush() loop cannot get to the zero vnode count due to races with readers. The unmount would proceed after the load is lifted. Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 2 weeks
* Change forgotten in r268615. Set the OBJ_TMPFS_NODE flag forkib2014-07-141-1/+1
| | | | | | | | vm_object of VREG tmpfs node. Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 2 weeks
* Use tmpfs_vn_get_ino_gen() to handle the races with reclaim in tmpfskib2014-07-141-13/+13
| | | | | | | | dotdot lookup. Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 2 weeks
* Style. Add comment about lock mode.kib2014-07-142-1/+2
| | | | | | Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 2 weeks
* In tmpfs_alloc_file(), code after the 'out' label does only 'returnkib2014-07-141-9/+5
| | | | | | | | error;'. Replace goto's with the return. Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 2 weeks
* Add convenience macro to assert tmpfs node lock.kib2014-07-142-1/+3
| | | | | | Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 2 weeks
* Add some assertions for the code handling vm_object for tmpfs vnode.kib2014-07-142-0/+3
| | | | | | | | | | | In particular, vnode must be exclusively locked when the tmpfs vnode and object are divorced. When the vnode is opened, the object must be still alive, since only live vnode can be opened, and the tmpfs node owns a reference on the object. Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 2 weeks
* The tmpfs_link() must not dereference the filesystem-specific data forkib2014-07-141-2/+2
| | | | | | | | | | a vnode until it is verified that the vnode indeed belongs to tmpfs mount. Otherwise, it might access random memory, at least in the debug kernel. Reported and tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 2 weeks
* Remove code separator lines which do not conform to style(9).kib2014-07-147-132/+0
| | | | | Sponsored by: The FreeBSD Foundation MFC after: 2 weeks
* In msdosfs_setattr(), add a check for result of the utimes(2)kib2014-06-173-24/+15
| | | | | | | | | | | | | | permissions test, forgotten in r164033. Refactor the permission checks for utimes(2) into vnode helper function vn_utimes_perm(9), and simplify its code comparing with the UFS origin, by writing the call to VOP_ACCESSX only once. Use the helper for UFS(5), tmpfs(5), devfs(5) and msdosfs(5). Reported by: bde Reviewed by: bde, trasz Sponsored by: The FreeBSD Foundation MFC after: 1 week
* Allow shared locking for the tmpfs vnodes.kib2014-06-041-0/+2
| | | | | | Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week
* Rename global cnt to vm_cnt to avoid shadowing.bdrewery2014-03-221-1/+1
| | | | | | | | | | | | | | To reduce the diff struct pcu.cnt field was not renamed, so PCPU_OP(cnt.field) is still used. pc_cnt and pcpu are also used in kvm(3) and vmstat(8). The goal was to not affect externally used KPI. Bump __FreeBSD_version_ in case some out-of-tree module/code relies on the the global cnt variable. Exp-run revealed no ports using it directly. No objection from: arch@ Sponsored by: EMC / Isilon Storage Division
* Add missing FALLTHROUGH comment in tmpfs_dir_getdents for looking up '.' andbdrewery2014-03-141-0/+1
| | | | | | | | '..'. Reviewed by: Russell Cattelan Sponsored by: EMC / Isilon Storage Division MFC after: 2 weeks
* Rename cnt to maxcookies and change its use as the condition for when tobdrewery2014-03-142-14/+21
| | | | | | | | | | | | lookup cookies to be less obscure. No functional change. Since r245115, cnt has not really been needed in tmpfs_dir_getdents(). Keep it for the MPASS() for now though. Sponsored by: EMC / Isilon Storage Division MFC after: 2 weeks
* Cleanup redundant logic and add some comments to help explain howbdrewery2014-03-141-14/+17
| | | | | | | it works in lieu of potentially less clear code. Sponsored by: EMC / Isilon Storage Division Discussed with: Russell Cattelan
* Fix -o size less than PAGE_SIZE resulting in SIZE_MAX being used.bdrewery2014-03-141-2/+4
| | | | | Discussed with: kib MFC after: 2 weeks
* Support storing 7 additional file flags in tmpfs:ken2013-08-281-3/+4
| | | | | | | | | | | UF_SYSTEM, UF_SPARSE, UF_OFFLINE, UF_REPARSE, UF_ARCHIVE, UF_READONLY, and UF_HIDDEN. Sort the file flags tmpfs supports alphabetically. tmpfs now supports the same flags as UFS, with the exception of SF_SNAPSHOT. Reported by: bdrewery, antoine Sponsored by: Spectra Logic
* Allow tmpfs be mounted inside jail.delphij2013-08-231-1/+7
|
* 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-092-14/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* The tmpfs_alloc_vp() is used to instantiate vnode for the tmpfs node,kib2013-08-052-0/+25
| | | | | | | | | | | | | | | | | | | | | | in particular, from the tmpfs_lookup VOP method. If LK_NOWAIT is not specified in the lkflags, the lookup is supposed to return an alive vnode whenever the underlying node is valid. Currently, the tmpfs_alloc_vp() returns ENOENT if the vnode attached to node exists and is being reclaimed. This causes spurious ENOENT errors from lookup on tmpfs and corresponding random 'No such file' failures from syscalls working with tmpfs files. Fix this by waiting for the doomed vnode to be detached from the tmpfs node if sleepable allocation is requested. Note that filesystems which use vfs_hash.c, correctly handle the case due to vfs_hash_get() looping when vget() returns ENOENT for sleepable requests. Reported and tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 2 weeks
* 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
* tmpfs works perfectly fine with -o union -- there is no reason to exclude itnwhitehorn2013-07-231-1/+1
| | | | from the list of options.
* 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
|
* Assert that OBJ_TMPFS flag on the vm object for the tmpfs node iskib2013-05-301-0/+2
| | | | | | cleared when the tmpfs node is going away. Tested by: bdrewery, pho
* 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-023-14/+34
| | | | | | | | | | | | | | 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-282-164/+103
| | | | | | | | | | | | | | | | | | 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.
* - Make 'flags' argument to chflags(2), fchflags(2) and lchflags(2) of typepjd2013-03-212-3/+4
| | | | | | | | | | | u_long. Before this change it was of type int for syscalls, but prototypes in sys/stat.h and documentation for chflags(2) and fchflags(2) (but not for lchflags(2)) stated that it was u_long. Now some related functions use u_long type for flags (strtofflags(3), fflagstostr(3)). - Make path argument of type 'const char *' for consistency. Discussed on: arch Sponsored by: The FreeBSD Foundation
* 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-202-27/+27
| | | | | | their "write" versions. Sponsored by: EMC / Isilon storage division
* Switch vm_object lock to be a rwlock.attilio2013-02-202-0/+4
| | | | | | | | * 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-064-312/+538
| | | | | | | | | | | | | | | | | | | | | 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
* Complete MPSAFE VFS interface and remove MNTK_MPSAFE flag.attilio2012-11-091-1/+0
| | | | | Porters should refer to __FreeBSD_version 1000021 for this change as it may have happened at the same timeframe.
* Fix up kernel sources to be ready for a 64-bit ino_t.mdf2012-09-271-1/+2
| | | | Original code by: Gleb Kurtsou
* After the PHYS_TO_VM_PAGE() function was de-inlined, the main reasonkib2012-08-052-0/+2
| | | | | | | | | | | | | 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
* Return EOPNOTSUPP rather than EPERM for the SF_SNAPSHOT flag becausejh2012-04-181-4/+1
| | | | | | tmpfs doesn't support snapshots. Suggested by: bde
OpenPOWER on IntegriCloud