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

[PATCH] struct super_block cleanup - qnx4

Seperates qnx4_sb_info from struct super_block.
parent 88774498
......@@ -62,11 +62,11 @@ void count_bits(const register char *bmPart, register int size,
unsigned long qnx4_count_free_blocks(struct super_block *sb)
{
int start = le32_to_cpu(sb->u.qnx4_sb.BitMap->di_first_xtnt.xtnt_blk) - 1;
int start = le32_to_cpu(qnx4_sb(sb)->BitMap->di_first_xtnt.xtnt_blk) - 1;
int total = 0;
int total_free = 0;
int offset = 0;
int size = le32_to_cpu(sb->u.qnx4_sb.BitMap->di_size);
int size = le32_to_cpu(qnx4_sb(sb)->BitMap->di_size);
struct buffer_head *bh;
while (total < size) {
......@@ -87,8 +87,8 @@ unsigned long qnx4_count_free_blocks(struct super_block *sb)
int qnx4_is_free(struct super_block *sb, long block)
{
int start = le32_to_cpu(sb->u.qnx4_sb.BitMap->di_first_xtnt.xtnt_blk) - 1;
int size = le32_to_cpu(sb->u.qnx4_sb.BitMap->di_size);
int start = le32_to_cpu(qnx4_sb(sb)->BitMap->di_first_xtnt.xtnt_blk) - 1;
int size = le32_to_cpu(qnx4_sb(sb)->BitMap->di_size);
struct buffer_head *bh;
const char *g;
int ret = -EIO;
......@@ -116,8 +116,8 @@ int qnx4_is_free(struct super_block *sb, long block)
int qnx4_set_bitmap(struct super_block *sb, long block, int busy)
{
int start = le32_to_cpu(sb->u.qnx4_sb.BitMap->di_first_xtnt.xtnt_blk) - 1;
int size = le32_to_cpu(sb->u.qnx4_sb.BitMap->di_size);
int start = le32_to_cpu(qnx4_sb(sb)->BitMap->di_first_xtnt.xtnt_blk) - 1;
int size = le32_to_cpu(qnx4_sb(sb)->BitMap->di_size);
struct buffer_head *bh;
char *g;
......
......@@ -147,7 +147,7 @@ static int qnx4_remount(struct super_block *sb, int *flags, char *data)
{
struct qnx4_sb_info *qs;
qs = &sb->u.qnx4_sb;
qs = qnx4_sb(sb);
qs->Version = QNX4_VERSION;
if (*flags & MS_RDONLY) {
return 0;
......@@ -280,7 +280,7 @@ static int qnx4_statfs(struct super_block *sb, struct statfs *buf)
{
buf->f_type = sb->s_magic;
buf->f_bsize = sb->s_blocksize;
buf->f_blocks = le32_to_cpu(sb->u.qnx4_sb.BitMap->di_size) * 8;
buf->f_blocks = le32_to_cpu(qnx4_sb(sb)->BitMap->di_size) * 8;
buf->f_bfree = qnx4_count_free_blocks(sb);
buf->f_bavail = buf->f_bfree;
buf->f_namelen = QNX4_NAME_MAX;
......@@ -301,12 +301,12 @@ static const char *qnx4_checkroot(struct super_block *sb)
int i, j;
int found = 0;
if (*(sb->u.qnx4_sb.sb->RootDir.di_fname) != '/') {
if (*(qnx4_sb(sb)->sb->RootDir.di_fname) != '/') {
return "no qnx4 filesystem (no root dir).";
} else {
QNX4DEBUG(("QNX4 filesystem found on dev %s.\n", sb->s_id));
rd = le32_to_cpu(sb->u.qnx4_sb.sb->RootDir.di_first_xtnt.xtnt_blk) - 1;
rl = le32_to_cpu(sb->u.qnx4_sb.sb->RootDir.di_first_xtnt.xtnt_size);
rd = le32_to_cpu(qnx4_sb(sb)->sb->RootDir.di_first_xtnt.xtnt_blk) - 1;
rl = le32_to_cpu(qnx4_sb(sb)->sb->RootDir.di_first_xtnt.xtnt_size);
for (j = 0; j < rl; j++) {
bh = sb_bread(sb, rd + j); /* root dir, first block */
if (bh == NULL) {
......@@ -318,8 +318,8 @@ static const char *qnx4_checkroot(struct super_block *sb)
QNX4DEBUG(("Rootdir entry found : [%s]\n", rootdir->di_fname));
if (!strncmp(rootdir->di_fname, QNX4_BMNAME, sizeof QNX4_BMNAME)) {
found = 1;
sb->u.qnx4_sb.BitMap = kmalloc( sizeof( struct qnx4_inode_entry ), GFP_KERNEL );
memcpy( sb->u.qnx4_sb.BitMap, rootdir, sizeof( struct qnx4_inode_entry ) ); /* keep bitmap inode known */
qnx4_sb(sb)->BitMap = kmalloc( sizeof( struct qnx4_inode_entry ), GFP_KERNEL );
memcpy( qnx4_sb(sb)->BitMap, rootdir, sizeof( struct qnx4_inode_entry ) ); /* keep bitmap inode known */
break;
}
}
......@@ -341,6 +341,13 @@ static int qnx4_fill_super(struct super_block *s, void *data, int silent)
struct buffer_head *bh;
struct inode *root;
const char *errmsg;
struct qnx4_sb_info *qs;
qs = kmalloc(sizeof(struct qnx4_sb_info), GFP_KERNEL);
if (!qs)
return -ENOMEM;
s->u.generic_sbp = qs;
memset(qs, 0, sizeof(struct qnx4_sb_info));
sb_set_blocksize(s, QNX4_BLOCK_SIZE);
......@@ -369,8 +376,8 @@ static int qnx4_fill_super(struct super_block *s, void *data, int silent)
#ifndef CONFIG_QNX4FS_RW
s->s_flags |= MS_RDONLY; /* Yup, read-only yet */
#endif
s->u.qnx4_sb.sb_buf = bh;
s->u.qnx4_sb.sb = (struct qnx4_super_block *) bh->b_data;
qnx4_sb(s)->sb_buf = bh;
qnx4_sb(s)->sb = (struct qnx4_super_block *) bh->b_data;
/* check before allocating dentries, inodes, .. */
......@@ -401,13 +408,17 @@ static int qnx4_fill_super(struct super_block *s, void *data, int silent)
out:
brelse(bh);
outnobh:
kfree(qs);
s->u.generic_sbp = NULL;
return -EINVAL;
}
static void qnx4_put_super(struct super_block *sb)
{
kfree( sb->u.qnx4_sb.BitMap );
struct qnx4_sb_info *qs = qnx4_sb(sb);
kfree( qs->BitMap );
kfree( qs );
sb->u.generic_sbp = NULL;
return;
}
......
......@@ -655,7 +655,6 @@ struct quota_mount_options
#include <linux/romfs_fs_sb.h>
#include <linux/hfs_fs_sb.h>
#include <linux/adfs_fs_sb.h>
#include <linux/qnx4_fs_sb.h>
#include <linux/reiserfs_fs_sb.h>
#include <linux/bfs_fs_sb.h>
#include <linux/udf_fs_sb.h>
......@@ -706,7 +705,6 @@ struct super_block {
struct romfs_sb_info romfs_sb;
struct hfs_sb_info hfs_sb;
struct adfs_sb_info adfs_sb;
struct qnx4_sb_info qnx4_sb;
struct reiserfs_sb_info reiserfs_sb;
struct bfs_sb_info bfs_sb;
struct udf_sb_info udf_sb;
......
......@@ -97,6 +97,13 @@ struct qnx4_super_block {
#define QNX4DEBUG(X) (void) 0
#endif
struct qnx4_sb_info {
struct buffer_head *sb_buf; /* superblock buffer */
struct qnx4_super_block *sb; /* our superblock */
unsigned int Version; /* may be useful */
struct qnx4_inode_entry *BitMap; /* useful */
};
struct qnx4_inode_info {
struct qnx4_inode_entry raw;
unsigned long mmu_private;
......@@ -126,6 +133,11 @@ extern int qnx4_sync_file(struct file *file, struct dentry *dentry, int);
extern int qnx4_sync_inode(struct inode *inode);
extern int qnx4_get_block(struct inode *inode, sector_t iblock, struct buffer_head *bh, int create);
static inline struct qnx4_sb_info *qnx4_sb(struct super_block *sb)
{
return sb->u.generic_sbp;
}
static inline struct qnx4_inode_info *qnx4_i(struct inode *inode)
{
return list_entry(inode, struct qnx4_inode_info, vfs_inode);
......
/*
* Name : qnx4_fs_sb.h
* Author : Richard Frowijn
* Function : qnx4 superblock definitions
* Version : 1.0.2
* Last modified : 2000-01-06
*
* History : 23-03-1998 created
*
*/
#ifndef _QNX4_FS_SB
#define _QNX4_FS_SB
#include <linux/qnx4_fs.h>
/*
* qnx4 super-block data in memory
*/
struct qnx4_sb_info {
struct buffer_head *sb_buf; /* superblock buffer */
struct qnx4_super_block *sb; /* our superblock */
unsigned int Version; /* may be useful */
struct qnx4_inode_entry *BitMap; /* useful */
};
#endif
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