Skip to content

Commit 8ffcb32

Browse files
dhowellsAl Viro
authored andcommitted
VFS: Make delayed_free() call free_vfsmnt()
Make delayed_free() call free_vfsmnt() so that we don't have two functions doing the same job. This requires the calls to mnt_free_id() in free_vfsmnt() to be moved into the callers of that function. Signed-off-by: David Howells <dhowells@redhat.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 3ef120a commit 8ffcb32

1 file changed

Lines changed: 8 additions & 12 deletions

File tree

‎fs/namespace.c‎

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -568,13 +568,17 @@ int sb_prepare_remount_readonly(struct super_block *sb)
568568
static void free_vfsmnt(struct mount *mnt)
569569
{
570570
kfree(mnt->mnt_devname);
571-
mnt_free_id(mnt);
572571
#ifdef CONFIG_SMP
573572
free_percpu(mnt->mnt_pcp);
574573
#endif
575574
kmem_cache_free(mnt_cache, mnt);
576575
}
577576

577+
static void delayed_free_vfsmnt(struct rcu_head *head)
578+
{
579+
free_vfsmnt(container_of(head, struct mount, mnt_rcu));
580+
}
581+
578582
/* call under rcu_read_lock */
579583
bool legitimize_mnt(struct vfsmount *bastard, unsigned seq)
580584
{
@@ -846,6 +850,7 @@ vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void
846850

847851
root = mount_fs(type, flags, name, data);
848852
if (IS_ERR(root)) {
853+
mnt_free_id(mnt);
849854
free_vfsmnt(mnt);
850855
return ERR_CAST(root);
851856
}
@@ -926,20 +931,11 @@ static struct mount *clone_mnt(struct mount *old, struct dentry *root,
926931
return mnt;
927932

928933
out_free:
934+
mnt_free_id(mnt);
929935
free_vfsmnt(mnt);
930936
return ERR_PTR(err);
931937
}
932938

933-
static void delayed_free(struct rcu_head *head)
934-
{
935-
struct mount *mnt = container_of(head, struct mount, mnt_rcu);
936-
kfree(mnt->mnt_devname);
937-
#ifdef CONFIG_SMP
938-
free_percpu(mnt->mnt_pcp);
939-
#endif
940-
kmem_cache_free(mnt_cache, mnt);
941-
}
942-
943939
static void mntput_no_expire(struct mount *mnt)
944940
{
945941
put_again:
@@ -989,7 +985,7 @@ static void mntput_no_expire(struct mount *mnt)
989985
dput(mnt->mnt.mnt_root);
990986
deactivate_super(mnt->mnt.mnt_sb);
991987
mnt_free_id(mnt);
992-
call_rcu(&mnt->mnt_rcu, delayed_free);
988+
call_rcu(&mnt->mnt_rcu, delayed_free_vfsmnt);
993989
}
994990

995991
void mntput(struct vfsmount *mnt)

0 commit comments

Comments
 (0)