Commit 88774498 authored by Brian Gerst's avatar Brian Gerst Committed by Linus Torvalds

[PATCH] struct super_block cleanup - smbfs

Seperates smb_sb_info from struct super_block.
parent 2191d229
...@@ -400,7 +400,7 @@ parse_options(struct smb_mount_data_kernel *mnt, char *options) ...@@ -400,7 +400,7 @@ parse_options(struct smb_mount_data_kernel *mnt, char *options)
static int static int
smb_show_options(struct seq_file *s, struct vfsmount *m) smb_show_options(struct seq_file *s, struct vfsmount *m)
{ {
struct smb_mount_data_kernel *mnt = m->mnt_sb->u.smbfs_sb.mnt; struct smb_mount_data_kernel *mnt = SMB_SB(m->mnt_sb)->mnt;
int i; int i;
for (i = 0; opts[i].name != NULL; i++) for (i = 0; opts[i].name != NULL; i++)
...@@ -435,7 +435,7 @@ smb_show_options(struct seq_file *s, struct vfsmount *m) ...@@ -435,7 +435,7 @@ smb_show_options(struct seq_file *s, struct vfsmount *m)
static void static void
smb_put_super(struct super_block *sb) smb_put_super(struct super_block *sb)
{ {
struct smb_sb_info *server = &(sb->u.smbfs_sb); struct smb_sb_info *server = SMB_SB(sb);
if (server->sock_file) { if (server->sock_file) {
smb_dont_catch_keepalive(server); smb_dont_catch_keepalive(server);
...@@ -457,11 +457,13 @@ smb_put_super(struct super_block *sb) ...@@ -457,11 +457,13 @@ smb_put_super(struct super_block *sb)
unload_nls(server->local_nls); unload_nls(server->local_nls);
server->local_nls = NULL; server->local_nls = NULL;
} }
sb->u.generic_sbp = NULL;
smb_kfree(server);
} }
int smb_fill_super(struct super_block *sb, void *raw_data, int silent) int smb_fill_super(struct super_block *sb, void *raw_data, int silent)
{ {
struct smb_sb_info *server = &sb->u.smbfs_sb; struct smb_sb_info *server;
struct smb_mount_data_kernel *mnt; struct smb_mount_data_kernel *mnt;
struct smb_mount_data *oldmnt; struct smb_mount_data *oldmnt;
struct inode *root_inode; struct inode *root_inode;
...@@ -482,6 +484,13 @@ int smb_fill_super(struct super_block *sb, void *raw_data, int silent) ...@@ -482,6 +484,13 @@ int smb_fill_super(struct super_block *sb, void *raw_data, int silent)
sb->s_magic = SMB_SUPER_MAGIC; sb->s_magic = SMB_SUPER_MAGIC;
sb->s_op = &smb_sops; sb->s_op = &smb_sops;
server = smb_kmalloc(sizeof(struct smb_sb_info), GFP_KERNEL);
if (!server)
goto out_no_server;
sb->u.generic_sbp = server;
memset(server, 0, sizeof(struct smb_sb_info));
server->super_block = sb;
server->mnt = NULL; server->mnt = NULL;
server->sock_file = NULL; server->sock_file = NULL;
init_MUTEX(&server->sem); init_MUTEX(&server->sem);
...@@ -578,6 +587,8 @@ int smb_fill_super(struct super_block *sb, void *raw_data, int silent) ...@@ -578,6 +587,8 @@ int smb_fill_super(struct super_block *sb, void *raw_data, int silent)
out_no_mem: out_no_mem:
if (!server->mnt) if (!server->mnt)
printk(KERN_ERR "smb_fill_super: allocation failure\n"); printk(KERN_ERR "smb_fill_super: allocation failure\n");
sb->u.generic_sbp = NULL;
smb_kfree(server);
goto out_fail; goto out_fail;
out_wrong_data: out_wrong_data:
printk(KERN_ERR "smbfs: mount_data version %d is not supported\n", ver); printk(KERN_ERR "smbfs: mount_data version %d is not supported\n", ver);
...@@ -586,6 +597,9 @@ int smb_fill_super(struct super_block *sb, void *raw_data, int silent) ...@@ -586,6 +597,9 @@ int smb_fill_super(struct super_block *sb, void *raw_data, int silent)
printk(KERN_ERR "smb_fill_super: missing data argument\n"); printk(KERN_ERR "smb_fill_super: missing data argument\n");
out_fail: out_fail:
return -EINVAL; return -EINVAL;
out_no_server:
printk(KERN_ERR "smb_fill_super: cannot allocate struct smb_sb_info\n");
return -ENOMEM;
} }
static int static int
......
...@@ -2884,7 +2884,7 @@ smb_proc_settime(struct dentry *dentry, struct smb_fattr *fattr) ...@@ -2884,7 +2884,7 @@ smb_proc_settime(struct dentry *dentry, struct smb_fattr *fattr)
int int
smb_proc_dskattr(struct super_block *sb, struct statfs *attr) smb_proc_dskattr(struct super_block *sb, struct statfs *attr)
{ {
struct smb_sb_info *server = &(sb->u.smbfs_sb); struct smb_sb_info *server = SMB_SB(sb);
int result; int result;
char *p; char *p;
long unit; long unit;
......
...@@ -653,7 +653,6 @@ struct quota_mount_options ...@@ -653,7 +653,6 @@ struct quota_mount_options
#include <linux/affs_fs_sb.h> #include <linux/affs_fs_sb.h>
#include <linux/ufs_fs_sb.h> #include <linux/ufs_fs_sb.h>
#include <linux/romfs_fs_sb.h> #include <linux/romfs_fs_sb.h>
#include <linux/smb_fs_sb.h>
#include <linux/hfs_fs_sb.h> #include <linux/hfs_fs_sb.h>
#include <linux/adfs_fs_sb.h> #include <linux/adfs_fs_sb.h>
#include <linux/qnx4_fs_sb.h> #include <linux/qnx4_fs_sb.h>
...@@ -705,7 +704,6 @@ struct super_block { ...@@ -705,7 +704,6 @@ struct super_block {
struct ufs_sb_info ufs_sb; struct ufs_sb_info ufs_sb;
struct shmem_sb_info shmem_sb; struct shmem_sb_info shmem_sb;
struct romfs_sb_info romfs_sb; struct romfs_sb_info romfs_sb;
struct smb_sb_info smbfs_sb;
struct hfs_sb_info hfs_sb; struct hfs_sb_info hfs_sb;
struct adfs_sb_info adfs_sb; struct adfs_sb_info adfs_sb;
struct qnx4_sb_info qnx4_sb; struct qnx4_sb_info qnx4_sb;
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <linux/smb.h> #include <linux/smb.h>
#include <linux/smb_fs_i.h> #include <linux/smb_fs_i.h>
#include <linux/smb_fs_sb.h>
/* /*
* ioctl commands * ioctl commands
...@@ -29,6 +30,11 @@ ...@@ -29,6 +30,11 @@
#include <linux/smb_mount.h> #include <linux/smb_mount.h>
#include <asm/unaligned.h> #include <asm/unaligned.h>
static inline struct smb_sb_info *SMB_SB(struct super_block *sb)
{
return sb->u.generic_sbp;
}
static inline struct smb_inode_info *SMB_I(struct inode *inode) static inline struct smb_inode_info *SMB_I(struct inode *inode)
{ {
return list_entry(inode, struct smb_inode_info, vfs_inode); return list_entry(inode, struct smb_inode_info, vfs_inode);
......
...@@ -15,10 +15,9 @@ ...@@ -15,10 +15,9 @@
#include <linux/smb.h> #include <linux/smb.h>
/* structure access macros */ /* structure access macros */
#define server_from_inode(inode) (&(inode)->i_sb->u.smbfs_sb) #define server_from_inode(inode) SMB_SB((inode)->i_sb)
#define server_from_dentry(dentry) (&(dentry)->d_sb->u.smbfs_sb) #define server_from_dentry(dentry) SMB_SB((dentry)->d_sb)
#define SB_of(server) ((struct super_block *) ((char *)(server) - \ #define SB_of(server) ((server)->super_block)
(unsigned long)(&((struct super_block *)0)->u.smbfs_sb)))
struct smb_sb_info { struct smb_sb_info {
enum smb_conn_state state; enum smb_conn_state state;
...@@ -55,6 +54,7 @@ struct smb_sb_info { ...@@ -55,6 +54,7 @@ struct smb_sb_info {
char *name_buf; char *name_buf;
struct smb_ops *ops; struct smb_ops *ops;
struct super_block *super_block;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment