[PATCH] (part 5) fs/super.c cleanups

Alexander Viro (viro@math.psu.edu)
Fri, 25 May 2001 14:39:16 -0400 (EDT)


Takes allocation/initalization of vfsmounts into separate function.
We will need this separation to deal with several places where we need
a non-blocking (and non-failing) equivalent of add_vfsmnt(). There allocation
will be done outside of critical area.

Please, apply.

diff -urN S5-pre6-MNT_VISIBLE/fs/super.c S5-pre6-alloc_vfsmnt/fs/super.c
--- S5-pre6-MNT_VISIBLE/fs/super.c Thu May 24 23:57:23 2001
+++ S5-pre6-alloc_vfsmnt/fs/super.c Fri May 25 04:13:30 2001
@@ -282,6 +282,21 @@

static LIST_HEAD(vfsmntlist);

+struct vfsmount *alloc_vfsmnt(void)
+{
+ struct vfsmount *mnt = kmalloc(sizeof(struct vfsmount), GFP_KERNEL);
+ if (mnt) {
+ memset(mnt, 0, sizeof(struct vfsmount));
+ atomic_set(&mnt->mnt_count,1);
+ INIT_LIST_HEAD(&mnt->mnt_clash);
+ INIT_LIST_HEAD(&mnt->mnt_child);
+ INIT_LIST_HEAD(&mnt->mnt_mounts);
+ INIT_LIST_HEAD(&mnt->mnt_list);
+ mnt->mnt_owner = current->uid;
+ }
+ return mnt;
+}
+
static void detach_mnt(struct vfsmount *mnt, struct nameidata *old_nd)
{
old_nd->dentry = mnt->mnt_mountpoint;
@@ -324,10 +339,9 @@
struct super_block *sb = root->d_inode->i_sb;
char *name;

- mnt = kmalloc(sizeof(struct vfsmount), GFP_KERNEL);
+ mnt = alloc_vfsmnt();
if (!mnt)
goto out;
- memset(mnt, 0, sizeof(struct vfsmount));

/* It may be NULL, but who cares? */
if (dev_name) {
@@ -337,8 +351,6 @@
mnt->mnt_devname = name;
}
}
- mnt->mnt_owner = current->uid;
- atomic_set(&mnt->mnt_count,1);
mnt->mnt_sb = sb;

spin_lock(&dcache_lock);
@@ -351,10 +363,7 @@
} else {
mnt->mnt_mountpoint = mnt->mnt_root;
mnt->mnt_parent = mnt;
- INIT_LIST_HEAD(&mnt->mnt_child);
- INIT_LIST_HEAD(&mnt->mnt_clash);
}
- INIT_LIST_HEAD(&mnt->mnt_mounts);
list_add(&mnt->mnt_instances, &sb->s_mounts);
if (nd || dev_name)
list_add(&mnt->mnt_list, vfsmntlist.prev);

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/