lkml.org 
[lkml]   [2013]   [Oct]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [RFC][PATCH 2/3] vfs: Add a function to lazily unmount all mounts from any dentry.
    Quoting Eric W. Biederman (ebiederm@xmission.com):
    >
    > Signed-off-by: Eric W. Biederman <ebiederman@twitter.com>
    > ---
    > fs/mount.h | 1 +
    > fs/namespace.c | 24 ++++++++++++++++++++++++
    > 2 files changed, 25 insertions(+), 0 deletions(-)
    >
    > diff --git a/fs/mount.h b/fs/mount.h
    > index e4342b8dfab1..7a6a2bb3f290 100644
    > --- a/fs/mount.h
    > +++ b/fs/mount.h
    > @@ -79,6 +79,7 @@ static inline int is_mounted(struct vfsmount *mnt)
    > }
    >
    > extern struct mount *__lookup_mnt(struct vfsmount *, struct dentry *, int);
    > +extern void detach_mounts(struct dentry *dentry);
    >
    > static inline void get_mnt_ns(struct mnt_namespace *ns)
    > {
    > diff --git a/fs/namespace.c b/fs/namespace.c
    > index d092964fe7f9..8eaee0c14fdb 100644
    > --- a/fs/namespace.c
    > +++ b/fs/namespace.c
    > @@ -1294,6 +1294,30 @@ static int do_umount(struct mount *mnt, int flags)
    > return retval;
    > }
    >
    > +void detach_mounts(struct dentry *dentry)
    > +{
    > + struct mount *mnt, *next;
    > + struct mountpoint *mp;
    > +
    > + namespace_lock();
    > + if (!d_mountpoint(dentry)) {
    > + namespace_unlock();
    > + return;
    > + }
    > + mp = new_mountpoint(dentry);
    > + if (IS_ERR(mp)) {

    namespace_unlock();

    > + return;
    > + }
    > + br_write_lock(&vfsmount_lock);
    > + list_for_each_entry_safe(mnt, next, &mp->m_list, mnt_mp_list) {
    > + if (!list_empty(&mnt->mnt_list))
    > + umount_tree(mnt, 1);
    > + }
    > + br_write_unlock(&vfsmount_lock);
    > + put_mountpoint(mp);
    > + namespace_unlock();
    > +}
    > +
    > /*
    > * Is the caller allowed to modify his namespace?
    > */
    > --
    > 1.7.5.4


    \
     
     \ /
      Last update: 2013-10-07 06:41    [W:3.859 / U:0.044 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site