summaryrefslogtreecommitdiffstats
path: root/fs/mount.h
Commit message (Collapse)AuthorAgeFilesLines
* RCU'd vfsmountsAl Viro2013-11-091-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * RCU-delayed freeing of vfsmounts * vfsmount_lock replaced with a seqlock (mount_lock) * sequence number from mount_lock is stored in nameidata->m_seq and used when we exit RCU mode * new vfsmount flag - MNT_SYNC_UMOUNT. Set by umount_tree() when its caller knows that vfsmount will have no surviving references. * synchronize_rcu() done between unlocking namespace_sem in namespace_unlock() and doing pending mntput(). * new helper: legitimize_mnt(mnt, seq). Checks the mount_lock sequence number against seq, then grabs reference to mnt. Then it rechecks mount_lock again to close the race and either returns success or drops the reference it has acquired. The subtle point is that in case of MNT_SYNC_UMOUNT we can simply decrement the refcount and sod off - aforementioned synchronize_rcu() makes sure that final mntput() won't come until we leave RCU mode. We need that, since we don't want to end up with some lazy pathwalk racing with umount() and stealing the final mntput() from it - caller of umount() may expect it to return only once the fs is shut down and we don't want to break that. In other cases (i.e. with MNT_SYNC_UMOUNT absent) we have to do full-blown mntput() in case of mount_lock sequence number mismatch happening just as we'd grabbed the reference, but in those cases we won't be stealing the final mntput() from anything that would care. * mntput_no_expire() doesn't lock anything on the fast path now. Incidentally, SMP and UP cases are handled the same way - no ifdefs there. * normal pathname resolution does *not* do any writes to mount_lock. It does, of course, bump the refcounts of vfsmount and dentry in the very end, but that's it. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* split __lookup_mnt() in two functionsAl Viro2013-10-251-1/+2
| | | | | | | | Instead of passing the direction as argument (and checking it on every step through the hash chain), just have separate __lookup_mnt() and __lookup_mnt_last(). And use the standard iterators... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* new helpers: lock_mount_hash/unlock_mount_hashAl Viro2013-10-251-0/+13
| | | | | | | aka br_write_{lock,unlock} of vfsmount_lock. Inlines in fs/mount.h, vfsmount_lock extern moved over there as well. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* namespace.c: get rid of mnt_ghostsAl Viro2013-10-251-1/+1
| | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* get rid of full-hash scan on detaching vfsmountsAl Viro2013-04-091-0/+7
| | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* proc: Usable inode numbers for the namespace file descriptors.Eric W. Biederman2012-11-201-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Assign a unique proc inode to each namespace, and use that inode number to ensure we only allocate at most one proc inode for every namespace in proc. A single proc inode per namespace allows userspace to test to see if two processes are in the same namespace. This has been a long requested feature and only blocked because a naive implementation would put the id in a global space and would ultimately require having a namespace for the names of namespaces, making migration and certain virtualization tricks impossible. We still don't have per superblock inode numbers for proc, which appears necessary for application unaware checkpoint/restart and migrations (if the application is using namespace file descriptors) but that is now allowd by the design if it becomes important. I have preallocated the ipc and uts initial proc inode numbers so their structures can be statically initialized. Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
* vfs: Add a user namespace reference from struct mnt_namespaceEric W. Biederman2012-11-191-0/+1
| | | | | | | This will allow for support for unprivileged mounts in a new user namespace. Acked-by: "Serge E. Hallyn" <serge@hallyn.com> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
* vfs: Add setns support for the mount namespaceEric W. Biederman2012-11-191-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | setns support for the mount namespace is a little tricky as an arbitrary decision must be made about what to set fs->root and fs->pwd to, as there is no expectation of a relationship between the two mount namespaces. Therefore I arbitrarily find the root mount point, and follow every mount on top of it to find the top of the mount stack. Then I set fs->root and fs->pwd to that location. The topmost root of the mount stack seems like a reasonable place to be. Bind mount support for the mount namespace inodes has the possibility of creating circular dependencies between mount namespaces. Circular dependencies can result in loops that prevent mount namespaces from every being freed. I avoid creating those circular dependencies by adding a sequence number to the mount namespace and require all bind mounts be of a younger mount namespace into an older mount namespace. Add a helper function proc_ns_inode so it is possible to detect when we are attempting to bind mound a namespace inode. Acked-by: Serge Hallyn <serge.hallyn@canonical.com> Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
* get rid of magic in proc_namespace.cAl Viro2012-07-141-1/+3
| | | | | | | | don't rely on proc_mounts->m being the first field; container_of() is there for purpose. No need to bother with ->private, while we are at it - the same container_of will do nicely. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* get rid of ->mnt_longtermAl Viro2012-07-141-1/+8
| | | | | | | | | it's enough to set ->mnt_ns of internal vfsmounts to something distinct from all struct mnt_namespace out there; then we can just use the check for ->mnt_ns != NULL in the fast path of mntput_no_expire() Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* vfs: keep list of mounts for each superblockMiklos Szeredi2012-01-071-0/+1
| | | | | | | | | Keep track of vfsmounts belonging to a superblock. List is protected by vfsmount_lock. Signed-off-by: Miklos Szeredi <mszeredi@suse.cz> Tested-by: Toshiyuki Okajima <toshi.okajima@jp.fujitsu.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* switch mnt_namespace ->root to struct mountAl Viro2012-01-041-1/+1
| | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* vfs: take /proc/*/mounts and friends to fs/proc_namespace.cAl Viro2012-01-041-0/+24
| | | | | | | rationale: that stuff is far tighter bound to fs/namespace.c than to the guts of procfs proper. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* vfs: move fsnotify junk to struct mountAl Viro2012-01-041-1/+4
| | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* vfs: move mnt_devnameAl Viro2012-01-041-1/+2
| | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* vfs: move mnt_list to struct mountAl Viro2012-01-041-1/+2
| | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* vfs: move the rest of int fields to struct mountAl Viro2012-01-041-0/+3
| | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* vfs: mnt_id/mnt_group_id movedAl Viro2012-01-041-0/+2
| | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* vfs: mnt_ns moved to struct mountAl Viro2012-01-041-0/+1
| | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* vfs: take mnt_share/mnt_slave/mnt_slave_list and mnt_expire to struct mountAl Viro2012-01-041-1/+5
| | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* vfs: and now we can make ->mnt_master point to struct mountAl Viro2012-01-041-1/+1
| | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* vfs: take mnt_master to struct mountAl Viro2012-01-041-0/+2
| | | | | | make IS_MNT_SLAVE take struct mount * at the same time Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* vfs: take mnt_child/mnt_mounts to struct mountAl Viro2012-01-041-0/+2
| | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* vfs: all counters taken to struct mountAl Viro2012-01-041-0/+12
| | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* vfs: move mnt_mountpoint to struct mountAl Viro2012-01-041-0/+1
| | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* vfs: now it can be done - make mnt_parent point to struct mountAl Viro2012-01-041-2/+2
| | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* vfs: mnt_parent moved to struct mountAl Viro2012-01-041-1/+2
| | | | | | the second victim... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* vfs: spread struct mount - mnt_has_parentAl Viro2012-01-041-2/+2
| | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* vfs: the first spoils - mnt_hash movedAl Viro2012-01-041-0/+1
| | | | | | taken out of struct vfsmount into struct mount Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* vfs: spread struct mount - __lookup_mnt() resultAl Viro2012-01-041-0/+2
| | | | | | switch __lookup_mnt() to returning struct mount *; callers adjusted. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* vfs: start hiding vfsmount guts seriesAl Viro2012-01-041-0/+9
| | | | | | | | | | | | | | | | | | Almost all fields of struct vfsmount are used only by core VFS (and a fairly small part of it, at that). The plan: embed struct vfsmount into struct mount, making the latter visible only to core parts of VFS. Then move fields from vfsmount to mount, eventually leaving only mnt_root/mnt_sb/mnt_flags in struct vfsmount. Filesystem code still gets pointers to struct vfsmount and remains unchanged; all such pointers go to struct vfsmount embedded into the instances of struct mount allocated by fs/namespace.c. When fs/namespace.c et.al. get a pointer to vfsmount, they turn it into pointer to mount (using container_of) and work with that. This is the first part of series; struct mount is introduced, allocation switched to using it. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* vfs: new internal helper: mnt_has_parent(mnt)Al Viro2012-01-041-0/+6
vfsmounts have ->mnt_parent pointing either to a different vfsmount or to itself; it's never NULL and termination condition in loops traversing the tree towards root is mnt == mnt->mnt_parent. At least one place (see the next patch) is confused about what's going on; let's add an explicit helper checking it right way and use it in all places where we need it. Not that there had been too many, but... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>