2002-03-13 03:11:00

by Brian Gerst

[permalink] [raw]
Subject: [PATCH] struct super_block cleanup - efs

diff -urN linux-2.5.7-pre1/fs/efs/super.c linux/fs/efs/super.c
--- linux-2.5.7-pre1/fs/efs/super.c Tue Mar 12 17:35:10 2002
+++ linux/fs/efs/super.c Tue Mar 12 22:03:48 2002
@@ -70,10 +70,17 @@
printk(KERN_INFO "efs_inode_cache: not all structures were freed\n");
}

+void efs_put_super(struct super_block *s)
+{
+ kfree(s->u.generic_sbp);
+ s->u.generic_sbp = NULL;
+}
+
static struct super_operations efs_superblock_operations = {
alloc_inode: efs_alloc_inode,
destroy_inode: efs_destroy_inode,
read_inode: efs_read_inode,
+ put_super: efs_put_super,
statfs: efs_statfs,
};

@@ -205,7 +212,11 @@
struct efs_sb_info *sb;
struct buffer_head *bh;

- sb = SUPER_INFO(s);
+ sb = kmalloc(sizeof(struct efs_sb_info), GFP_KERNEL);
+ if (!sb)
+ return -ENOMEM;
+ s->u.generic_sbp = sb;
+ memset(sb, 0, sizeof(struct efs_sb_info));

s->s_magic = EFS_SUPER_MAGIC;
sb_set_blocksize(s, EFS_BLOCKSIZE);
@@ -263,6 +274,8 @@

out_no_fs_ul:
out_no_fs:
+ s->u.generic_sbp = NULL;
+ kfree(sb);
return -EINVAL;
}

diff -urN linux-2.5.7-pre1/include/linux/efs_fs.h linux/include/linux/efs_fs.h
--- linux-2.5.7-pre1/include/linux/efs_fs.h Thu Mar 7 21:18:27 2002
+++ linux/include/linux/efs_fs.h Tue Mar 12 22:06:27 2002
@@ -29,6 +29,7 @@

#include <linux/fs.h>
#include <linux/efs_fs_i.h>
+#include <linux/efs_fs_sb.h>
#include <linux/efs_dir.h>

#ifndef MIN
@@ -42,7 +43,11 @@
{
return list_entry(inode, struct efs_inode_info, vfs_inode);
}
-#define SUPER_INFO(s) &((s)->u.efs_sb)
+
+static inline struct efs_sb_info *SUPER_INFO(struct super_block *sb)
+{
+ return sb->u.generic_sbp;
+}

extern struct inode_operations efs_dir_inode_operations;
extern struct file_operations efs_dir_operations;
diff -urN linux-2.5.7-pre1/include/linux/fs.h linux/include/linux/fs.h
--- linux-2.5.7-pre1/include/linux/fs.h Tue Mar 12 20:22:02 2002
+++ linux/include/linux/fs.h Tue Mar 12 22:06:23 2002
@@ -658,7 +658,6 @@
#include <linux/sysv_fs_sb.h>
#include <linux/affs_fs_sb.h>
#include <linux/ufs_fs_sb.h>
-#include <linux/efs_fs_sb.h>
#include <linux/romfs_fs_sb.h>
#include <linux/smb_fs_sb.h>
#include <linux/hfs_fs_sb.h>
@@ -714,7 +713,6 @@
struct sysv_sb_info sysv_sb;
struct affs_sb_info affs_sb;
struct ufs_sb_info ufs_sb;
- struct efs_sb_info efs_sb;
struct shmem_sb_info shmem_sb;
struct romfs_sb_info romfs_sb;
struct smb_sb_info smbfs_sb;


Attachments:
sb-efs-1 (2.34 kB)