Commit db748675 authored by Andrew Morton's avatar Andrew Morton Committed by Christoph Hellwig

[PATCH] ext3 ceanup: use EXT3_SB

Patch from Jani Monoses <jani@iv.ro>

"This turns the remaining parts of ext3 to EXT3_SB and turns the
 latter from a macro to inline function which returns the generic_sbp
 field of u.

 linux/fs.h is not touched by this patch though.

 Intermezzo's three uses of ext3_sb are also not changed."
parent 73960360
...@@ -46,18 +46,18 @@ struct ext3_group_desc * ext3_get_group_desc(struct super_block * sb, ...@@ -46,18 +46,18 @@ struct ext3_group_desc * ext3_get_group_desc(struct super_block * sb,
unsigned long desc; unsigned long desc;
struct ext3_group_desc * gdp; struct ext3_group_desc * gdp;
if (block_group >= sb->u.ext3_sb.s_groups_count) { if (block_group >= EXT3_SB(sb)->s_groups_count) {
ext3_error (sb, "ext3_get_group_desc", ext3_error (sb, "ext3_get_group_desc",
"block_group >= groups_count - " "block_group >= groups_count - "
"block_group = %d, groups_count = %lu", "block_group = %d, groups_count = %lu",
block_group, sb->u.ext3_sb.s_groups_count); block_group, EXT3_SB(sb)->s_groups_count);
return NULL; return NULL;
} }
group_desc = block_group / EXT3_DESC_PER_BLOCK(sb); group_desc = block_group / EXT3_DESC_PER_BLOCK(sb);
desc = block_group % EXT3_DESC_PER_BLOCK(sb); desc = block_group % EXT3_DESC_PER_BLOCK(sb);
if (!sb->u.ext3_sb.s_group_desc[group_desc]) { if (!EXT3_SB(sb)->s_group_desc[group_desc]) {
ext3_error (sb, "ext3_get_group_desc", ext3_error (sb, "ext3_get_group_desc",
"Group descriptor not loaded - " "Group descriptor not loaded - "
"block_group = %d, group_desc = %lu, desc = %lu", "block_group = %d, group_desc = %lu, desc = %lu",
...@@ -66,9 +66,9 @@ struct ext3_group_desc * ext3_get_group_desc(struct super_block * sb, ...@@ -66,9 +66,9 @@ struct ext3_group_desc * ext3_get_group_desc(struct super_block * sb,
} }
gdp = (struct ext3_group_desc *) gdp = (struct ext3_group_desc *)
sb->u.ext3_sb.s_group_desc[group_desc]->b_data; EXT3_SB(sb)->s_group_desc[group_desc]->b_data;
if (bh) if (bh)
*bh = sb->u.ext3_sb.s_group_desc[group_desc]; *bh = EXT3_SB(sb)->s_group_desc[group_desc];
return gdp + desc; return gdp + desc;
} }
...@@ -119,7 +119,7 @@ void ext3_free_blocks (handle_t *handle, struct inode * inode, ...@@ -119,7 +119,7 @@ void ext3_free_blocks (handle_t *handle, struct inode * inode,
return; return;
} }
lock_super (sb); lock_super (sb);
es = sb->u.ext3_sb.s_es; es = EXT3_SB(sb)->s_es;
if (block < le32_to_cpu(es->s_first_data_block) || if (block < le32_to_cpu(es->s_first_data_block) ||
(block + count) > le32_to_cpu(es->s_blocks_count)) { (block + count) > le32_to_cpu(es->s_blocks_count)) {
ext3_error (sb, "ext3_free_blocks", ext3_error (sb, "ext3_free_blocks",
...@@ -155,9 +155,9 @@ void ext3_free_blocks (handle_t *handle, struct inode * inode, ...@@ -155,9 +155,9 @@ void ext3_free_blocks (handle_t *handle, struct inode * inode,
if (in_range (le32_to_cpu(gdp->bg_block_bitmap), block, count) || if (in_range (le32_to_cpu(gdp->bg_block_bitmap), block, count) ||
in_range (le32_to_cpu(gdp->bg_inode_bitmap), block, count) || in_range (le32_to_cpu(gdp->bg_inode_bitmap), block, count) ||
in_range (block, le32_to_cpu(gdp->bg_inode_table), in_range (block, le32_to_cpu(gdp->bg_inode_table),
sb->u.ext3_sb.s_itb_per_group) || EXT3_SB(sb)->s_itb_per_group) ||
in_range (block + count - 1, le32_to_cpu(gdp->bg_inode_table), in_range (block + count - 1, le32_to_cpu(gdp->bg_inode_table),
sb->u.ext3_sb.s_itb_per_group)) EXT3_SB(sb)->s_itb_per_group))
ext3_error (sb, "ext3_free_blocks", ext3_error (sb, "ext3_free_blocks",
"Freeing blocks in system zones - " "Freeing blocks in system zones - "
"Block = %lu, count = %lu", "Block = %lu, count = %lu",
...@@ -183,8 +183,8 @@ void ext3_free_blocks (handle_t *handle, struct inode * inode, ...@@ -183,8 +183,8 @@ void ext3_free_blocks (handle_t *handle, struct inode * inode,
if (err) if (err)
goto error_return; goto error_return;
BUFFER_TRACE(sb->u.ext3_sb.s_sbh, "get_write_access"); BUFFER_TRACE(EXT3_SB(sb)->s_sbh, "get_write_access");
err = ext3_journal_get_write_access(handle, sb->u.ext3_sb.s_sbh); err = ext3_journal_get_write_access(handle, EXT3_SB(sb)->s_sbh);
if (err) if (err)
goto error_return; goto error_return;
...@@ -253,8 +253,8 @@ void ext3_free_blocks (handle_t *handle, struct inode * inode, ...@@ -253,8 +253,8 @@ void ext3_free_blocks (handle_t *handle, struct inode * inode,
if (!err) err = ret; if (!err) err = ret;
/* And the superblock */ /* And the superblock */
BUFFER_TRACE(sb->u.ext3_sb.s_sbh, "dirtied superblock"); BUFFER_TRACE(EXT3_SB(sb)->s_sbh, "dirtied superblock");
ret = ext3_journal_dirty_metadata(handle, sb->u.ext3_sb.s_sbh); ret = ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh);
if (!err) err = ret; if (!err) err = ret;
if (overflow && !err) { if (overflow && !err) {
...@@ -408,12 +408,12 @@ ext3_new_block(handle_t *handle, struct inode *inode, unsigned long goal, ...@@ -408,12 +408,12 @@ ext3_new_block(handle_t *handle, struct inode *inode, unsigned long goal,
} }
lock_super(sb); lock_super(sb);
es = sb->u.ext3_sb.s_es; es = EXT3_SB(sb)->s_es;
if (le32_to_cpu(es->s_free_blocks_count) <= if (le32_to_cpu(es->s_free_blocks_count) <=
le32_to_cpu(es->s_r_blocks_count) && le32_to_cpu(es->s_r_blocks_count) &&
((sb->u.ext3_sb.s_resuid != current->fsuid) && ((EXT3_SB(sb)->s_resuid != current->fsuid) &&
(sb->u.ext3_sb.s_resgid == 0 || (EXT3_SB(sb)->s_resgid == 0 ||
!in_group_p(sb->u.ext3_sb.s_resgid)) && !in_group_p(EXT3_SB(sb)->s_resgid)) &&
!capable(CAP_SYS_RESOURCE))) !capable(CAP_SYS_RESOURCE)))
goto out; goto out;
...@@ -464,9 +464,9 @@ ext3_new_block(handle_t *handle, struct inode *inode, unsigned long goal, ...@@ -464,9 +464,9 @@ ext3_new_block(handle_t *handle, struct inode *inode, unsigned long goal,
* Now search the rest of the groups. We assume that * Now search the rest of the groups. We assume that
* i and gdp correctly point to the last group visited. * i and gdp correctly point to the last group visited.
*/ */
for (bit = 0; bit < sb->u.ext3_sb.s_groups_count; bit++) { for (bit = 0; bit < EXT3_SB(sb)->s_groups_count; bit++) {
group_no++; group_no++;
if (group_no >= sb->u.ext3_sb.s_groups_count) if (group_no >= EXT3_SB(sb)->s_groups_count)
group_no = 0; group_no = 0;
gdp = ext3_get_group_desc(sb, group_no, &gdp_bh); gdp = ext3_get_group_desc(sb, group_no, &gdp_bh);
if (!gdp) { if (!gdp) {
...@@ -518,8 +518,8 @@ ext3_new_block(handle_t *handle, struct inode *inode, unsigned long goal, ...@@ -518,8 +518,8 @@ ext3_new_block(handle_t *handle, struct inode *inode, unsigned long goal,
if (fatal) if (fatal)
goto out; goto out;
BUFFER_TRACE(sb->u.ext3_sb.s_sbh, "get_write_access"); BUFFER_TRACE(EXT3_SB(sb)->s_sbh, "get_write_access");
fatal = ext3_journal_get_write_access(handle, sb->u.ext3_sb.s_sbh); fatal = ext3_journal_get_write_access(handle, EXT3_SB(sb)->s_sbh);
if (fatal) if (fatal)
goto out; goto out;
...@@ -529,7 +529,7 @@ ext3_new_block(handle_t *handle, struct inode *inode, unsigned long goal, ...@@ -529,7 +529,7 @@ ext3_new_block(handle_t *handle, struct inode *inode, unsigned long goal,
if (target_block == le32_to_cpu(gdp->bg_block_bitmap) || if (target_block == le32_to_cpu(gdp->bg_block_bitmap) ||
target_block == le32_to_cpu(gdp->bg_inode_bitmap) || target_block == le32_to_cpu(gdp->bg_inode_bitmap) ||
in_range(target_block, le32_to_cpu(gdp->bg_inode_table), in_range(target_block, le32_to_cpu(gdp->bg_inode_table),
sb->u.ext3_sb.s_itb_per_group)) EXT3_SB(sb)->s_itb_per_group))
ext3_error(sb, "ext3_new_block", ext3_error(sb, "ext3_new_block",
"Allocating block in system zone - " "Allocating block in system zone - "
"block = %u", target_block); "block = %u", target_block);
...@@ -594,9 +594,9 @@ ext3_new_block(handle_t *handle, struct inode *inode, unsigned long goal, ...@@ -594,9 +594,9 @@ ext3_new_block(handle_t *handle, struct inode *inode, unsigned long goal,
if (!fatal) if (!fatal)
fatal = err; fatal = err;
BUFFER_TRACE(sb->u.ext3_sb.s_sbh, BUFFER_TRACE(EXT3_SB(sb)->s_sbh,
"journal_dirty_metadata for superblock"); "journal_dirty_metadata for superblock");
err = ext3_journal_dirty_metadata(handle, sb->u.ext3_sb.s_sbh); err = ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh);
if (!fatal) if (!fatal)
fatal = err; fatal = err;
...@@ -637,11 +637,11 @@ unsigned long ext3_count_free_blocks(struct super_block *sb) ...@@ -637,11 +637,11 @@ unsigned long ext3_count_free_blocks(struct super_block *sb)
int i; int i;
lock_super(sb); lock_super(sb);
es = sb->u.ext3_sb.s_es; es = EXT3_SB(sb)->s_es;
desc_count = 0; desc_count = 0;
bitmap_count = 0; bitmap_count = 0;
gdp = NULL; gdp = NULL;
for (i = 0; i < sb->u.ext3_sb.s_groups_count; i++) { for (i = 0; i < EXT3_SB(sb)->s_groups_count; i++) {
gdp = ext3_get_group_desc(sb, i, NULL); gdp = ext3_get_group_desc(sb, i, NULL);
if (!gdp) if (!gdp)
continue; continue;
...@@ -662,7 +662,7 @@ unsigned long ext3_count_free_blocks(struct super_block *sb) ...@@ -662,7 +662,7 @@ unsigned long ext3_count_free_blocks(struct super_block *sb)
unlock_super(sb); unlock_super(sb);
return bitmap_count; return bitmap_count;
#else #else
return le32_to_cpu(sb->u.ext3_sb.s_es->s_free_blocks_count); return le32_to_cpu(EXT3_SB(sb)->s_es->s_free_blocks_count);
#endif #endif
} }
...@@ -671,7 +671,7 @@ static inline int block_in_use(unsigned long block, ...@@ -671,7 +671,7 @@ static inline int block_in_use(unsigned long block,
unsigned char * map) unsigned char * map)
{ {
return ext3_test_bit ((block - return ext3_test_bit ((block -
le32_to_cpu(sb->u.ext3_sb.s_es->s_first_data_block)) % le32_to_cpu(EXT3_SB(sb)->s_es->s_first_data_block)) %
EXT3_BLOCKS_PER_GROUP(sb), map); EXT3_BLOCKS_PER_GROUP(sb), map);
} }
...@@ -738,11 +738,11 @@ void ext3_check_blocks_bitmap (struct super_block * sb) ...@@ -738,11 +738,11 @@ void ext3_check_blocks_bitmap (struct super_block * sb)
struct ext3_group_desc *gdp; struct ext3_group_desc *gdp;
int i; int i;
es = sb->u.ext3_sb.s_es; es = EXT3_SB(sb)->s_es;
desc_count = 0; desc_count = 0;
bitmap_count = 0; bitmap_count = 0;
gdp = NULL; gdp = NULL;
for (i = 0; i < sb->u.ext3_sb.s_groups_count; i++) { for (i = 0; i < EXT3_SB(sb)->s_groups_count; i++) {
gdp = ext3_get_group_desc (sb, i, NULL); gdp = ext3_get_group_desc (sb, i, NULL);
if (!gdp) if (!gdp)
continue; continue;
...@@ -776,7 +776,7 @@ void ext3_check_blocks_bitmap (struct super_block * sb) ...@@ -776,7 +776,7 @@ void ext3_check_blocks_bitmap (struct super_block * sb)
"Inode bitmap for group %d is marked free", "Inode bitmap for group %d is marked free",
i); i);
for (j = 0; j < sb->u.ext3_sb.s_itb_per_group; j++) for (j = 0; j < EXT3_SB(sb)->s_itb_per_group; j++)
if (!block_in_use (le32_to_cpu(gdp->bg_inode_table) + j, if (!block_in_use (le32_to_cpu(gdp->bg_inode_table) + j,
sb, bitmap_bh->b_data)) sb, bitmap_bh->b_data))
ext3_error (sb, "ext3_check_blocks_bitmap", ext3_error (sb, "ext3_check_blocks_bitmap",
......
...@@ -54,7 +54,7 @@ int ext3_check_dir_entry (const char * function, struct inode * dir, ...@@ -54,7 +54,7 @@ int ext3_check_dir_entry (const char * function, struct inode * dir,
else if (((char *) de - bh->b_data) + rlen > dir->i_sb->s_blocksize) else if (((char *) de - bh->b_data) + rlen > dir->i_sb->s_blocksize)
error_msg = "directory entry across blocks"; error_msg = "directory entry across blocks";
else if (le32_to_cpu(de->inode) > else if (le32_to_cpu(de->inode) >
le32_to_cpu(dir->i_sb->u.ext3_sb.s_es->s_inodes_count)) le32_to_cpu(EXT3_SB(dir->i_sb)->s_es->s_inodes_count))
error_msg = "inode out of bounds"; error_msg = "inode out of bounds";
if (error_msg != NULL) if (error_msg != NULL)
......
...@@ -127,7 +127,7 @@ void ext3_free_inode (handle_t *handle, struct inode * inode) ...@@ -127,7 +127,7 @@ void ext3_free_inode (handle_t *handle, struct inode * inode)
clear_inode (inode); clear_inode (inode);
lock_super (sb); lock_super (sb);
es = sb->u.ext3_sb.s_es; es = EXT3_SB(sb)->s_es;
if (ino < EXT3_FIRST_INO(sb) || ino > le32_to_cpu(es->s_inodes_count)) { if (ino < EXT3_FIRST_INO(sb) || ino > le32_to_cpu(es->s_inodes_count)) {
ext3_error (sb, "ext3_free_inode", ext3_error (sb, "ext3_free_inode",
"reserved or nonexistent inode %lu", ino); "reserved or nonexistent inode %lu", ino);
...@@ -155,8 +155,8 @@ void ext3_free_inode (handle_t *handle, struct inode * inode) ...@@ -155,8 +155,8 @@ void ext3_free_inode (handle_t *handle, struct inode * inode)
fatal = ext3_journal_get_write_access(handle, bh2); fatal = ext3_journal_get_write_access(handle, bh2);
if (fatal) goto error_return; if (fatal) goto error_return;
BUFFER_TRACE(sb->u.ext3_sb.s_sbh, "get write access"); BUFFER_TRACE(EXT3_SB(sb)->s_sbh, "get write access");
fatal = ext3_journal_get_write_access(handle, sb->u.ext3_sb.s_sbh); fatal = ext3_journal_get_write_access(handle, EXT3_SB(sb)->s_sbh);
if (fatal) goto error_return; if (fatal) goto error_return;
if (gdp) { if (gdp) {
...@@ -171,9 +171,9 @@ void ext3_free_inode (handle_t *handle, struct inode * inode) ...@@ -171,9 +171,9 @@ void ext3_free_inode (handle_t *handle, struct inode * inode)
if (!fatal) fatal = err; if (!fatal) fatal = err;
es->s_free_inodes_count = es->s_free_inodes_count =
cpu_to_le32(le32_to_cpu(es->s_free_inodes_count) + 1); cpu_to_le32(le32_to_cpu(es->s_free_inodes_count) + 1);
BUFFER_TRACE(sb->u.ext3_sb.s_sbh, BUFFER_TRACE(EXT3_SB(sb)->s_sbh,
"call ext3_journal_dirty_metadata"); "call ext3_journal_dirty_metadata");
err = ext3_journal_dirty_metadata(handle, sb->u.ext3_sb.s_sbh); err = ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh);
if (!fatal) fatal = err; if (!fatal) fatal = err;
} }
BUFFER_TRACE(bitmap_bh, "call ext3_journal_dirty_metadata"); BUFFER_TRACE(bitmap_bh, "call ext3_journal_dirty_metadata");
...@@ -222,16 +222,16 @@ struct inode *ext3_new_inode(handle_t *handle, struct inode * dir, int mode) ...@@ -222,16 +222,16 @@ struct inode *ext3_new_inode(handle_t *handle, struct inode * dir, int mode)
ei = EXT3_I(inode); ei = EXT3_I(inode);
lock_super (sb); lock_super (sb);
es = sb->u.ext3_sb.s_es; es = EXT3_SB(sb)->s_es;
repeat: repeat:
gdp = NULL; gdp = NULL;
i = 0; i = 0;
if (S_ISDIR(mode)) { if (S_ISDIR(mode)) {
avefreei = le32_to_cpu(es->s_free_inodes_count) / avefreei = le32_to_cpu(es->s_free_inodes_count) /
sb->u.ext3_sb.s_groups_count; EXT3_SB(sb)->s_groups_count;
if (!gdp) { if (!gdp) {
for (j = 0; j < sb->u.ext3_sb.s_groups_count; j++) { for (j = 0; j < EXT3_SB(sb)->s_groups_count; j++) {
struct buffer_head *temp_buffer; struct buffer_head *temp_buffer;
tmp = ext3_get_group_desc (sb, j, &temp_buffer); tmp = ext3_get_group_desc (sb, j, &temp_buffer);
if (tmp && if (tmp &&
...@@ -261,10 +261,10 @@ struct inode *ext3_new_inode(handle_t *handle, struct inode * dir, int mode) ...@@ -261,10 +261,10 @@ struct inode *ext3_new_inode(handle_t *handle, struct inode * dir, int mode)
* Use a quadratic hash to find a group with a * Use a quadratic hash to find a group with a
* free inode * free inode
*/ */
for (j = 1; j < sb->u.ext3_sb.s_groups_count; j <<= 1) { for (j = 1; j < EXT3_SB(sb)->s_groups_count; j <<= 1) {
i += j; i += j;
if (i >= sb->u.ext3_sb.s_groups_count) if (i >= EXT3_SB(sb)->s_groups_count)
i -= sb->u.ext3_sb.s_groups_count; i -= EXT3_SB(sb)->s_groups_count;
tmp = ext3_get_group_desc (sb, i, &bh2); tmp = ext3_get_group_desc (sb, i, &bh2);
if (tmp && if (tmp &&
le16_to_cpu(tmp->bg_free_inodes_count)) { le16_to_cpu(tmp->bg_free_inodes_count)) {
...@@ -278,8 +278,8 @@ struct inode *ext3_new_inode(handle_t *handle, struct inode * dir, int mode) ...@@ -278,8 +278,8 @@ struct inode *ext3_new_inode(handle_t *handle, struct inode * dir, int mode)
* That failed: try linear search for a free inode * That failed: try linear search for a free inode
*/ */
i = EXT3_I(dir)->i_block_group + 1; i = EXT3_I(dir)->i_block_group + 1;
for (j = 2; j < sb->u.ext3_sb.s_groups_count; j++) { for (j = 2; j < EXT3_SB(sb)->s_groups_count; j++) {
if (++i >= sb->u.ext3_sb.s_groups_count) if (++i >= EXT3_SB(sb)->s_groups_count)
i = 0; i = 0;
tmp = ext3_get_group_desc (sb, i, &bh2); tmp = ext3_get_group_desc (sb, i, &bh2);
if (tmp && if (tmp &&
...@@ -357,13 +357,13 @@ struct inode *ext3_new_inode(handle_t *handle, struct inode * dir, int mode) ...@@ -357,13 +357,13 @@ struct inode *ext3_new_inode(handle_t *handle, struct inode * dir, int mode)
err = ext3_journal_dirty_metadata(handle, bh2); err = ext3_journal_dirty_metadata(handle, bh2);
if (err) goto fail; if (err) goto fail;
BUFFER_TRACE(sb->u.ext3_sb.s_sbh, "get_write_access"); BUFFER_TRACE(EXT3_SB(sb)->s_sbh, "get_write_access");
err = ext3_journal_get_write_access(handle, sb->u.ext3_sb.s_sbh); err = ext3_journal_get_write_access(handle, EXT3_SB(sb)->s_sbh);
if (err) goto fail; if (err) goto fail;
es->s_free_inodes_count = es->s_free_inodes_count =
cpu_to_le32(le32_to_cpu(es->s_free_inodes_count) - 1); cpu_to_le32(le32_to_cpu(es->s_free_inodes_count) - 1);
BUFFER_TRACE(sb->u.ext3_sb.s_sbh, "call ext3_journal_dirty_metadata"); BUFFER_TRACE(EXT3_SB(sb)->s_sbh, "call ext3_journal_dirty_metadata");
err = ext3_journal_dirty_metadata(handle, sb->u.ext3_sb.s_sbh); err = ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh);
sb->s_dirt = 1; sb->s_dirt = 1;
if (err) goto fail; if (err) goto fail;
...@@ -417,7 +417,7 @@ struct inode *ext3_new_inode(handle_t *handle, struct inode * dir, int mode) ...@@ -417,7 +417,7 @@ struct inode *ext3_new_inode(handle_t *handle, struct inode * dir, int mode)
if (IS_DIRSYNC(inode)) if (IS_DIRSYNC(inode))
handle->h_sync = 1; handle->h_sync = 1;
insert_inode_hash(inode); insert_inode_hash(inode);
inode->i_generation = sb->u.ext3_sb.s_next_generation++; inode->i_generation = EXT3_SB(sb)->s_next_generation++;
ei->i_state = EXT3_STATE_NEW; ei->i_state = EXT3_STATE_NEW;
err = ext3_mark_inode_dirty(handle, inode); err = ext3_mark_inode_dirty(handle, inode);
...@@ -512,11 +512,11 @@ unsigned long ext3_count_free_inodes (struct super_block * sb) ...@@ -512,11 +512,11 @@ unsigned long ext3_count_free_inodes (struct super_block * sb)
int i; int i;
lock_super (sb); lock_super (sb);
es = sb->u.ext3_sb.s_es; es = EXT3_SB(sb)->s_es;
desc_count = 0; desc_count = 0;
bitmap_count = 0; bitmap_count = 0;
gdp = NULL; gdp = NULL;
for (i = 0; i < sb->u.ext3_sb.s_groups_count; i++) { for (i = 0; i < EXT3_SB(sb)->s_groups_count; i++) {
gdp = ext3_get_group_desc (sb, i, NULL); gdp = ext3_get_group_desc (sb, i, NULL);
if (!gdp) if (!gdp)
continue; continue;
...@@ -537,7 +537,7 @@ unsigned long ext3_count_free_inodes (struct super_block * sb) ...@@ -537,7 +537,7 @@ unsigned long ext3_count_free_inodes (struct super_block * sb)
unlock_super(sb); unlock_super(sb);
return desc_count; return desc_count;
#else #else
return le32_to_cpu(sb->u.ext3_sb.s_es->s_free_inodes_count); return le32_to_cpu(EXT3_SB(sb)->s_es->s_free_inodes_count);
#endif #endif
} }
...@@ -551,11 +551,11 @@ void ext3_check_inodes_bitmap (struct super_block * sb) ...@@ -551,11 +551,11 @@ void ext3_check_inodes_bitmap (struct super_block * sb)
struct ext3_group_desc * gdp; struct ext3_group_desc * gdp;
int i; int i;
es = sb->u.ext3_sb.s_es; es = EXT3_SB(sb)->s_es;
desc_count = 0; desc_count = 0;
bitmap_count = 0; bitmap_count = 0;
gdp = NULL; gdp = NULL;
for (i = 0; i < sb->u.ext3_sb.s_groups_count; i++) { for (i = 0; i < EXT3_SB(sb)->s_groups_count; i++) {
gdp = ext3_get_group_desc (sb, i, NULL); gdp = ext3_get_group_desc (sb, i, NULL);
if (!gdp) if (!gdp)
continue; continue;
......
...@@ -471,7 +471,7 @@ static inline unsigned long ext3_find_near(struct inode *inode, Indirect *ind) ...@@ -471,7 +471,7 @@ static inline unsigned long ext3_find_near(struct inode *inode, Indirect *ind)
* the same cylinder group then. * the same cylinder group then.
*/ */
return (ei->i_block_group * EXT3_BLOCKS_PER_GROUP(inode->i_sb)) + return (ei->i_block_group * EXT3_BLOCKS_PER_GROUP(inode->i_sb)) +
le32_to_cpu(inode->i_sb->u.ext3_sb.s_es->s_first_data_block); le32_to_cpu(EXT3_SB(inode->i_sb)->s_es->s_first_data_block);
} }
/** /**
...@@ -2141,20 +2141,20 @@ int ext3_get_inode_loc (struct inode *inode, struct ext3_iloc *iloc) ...@@ -2141,20 +2141,20 @@ int ext3_get_inode_loc (struct inode *inode, struct ext3_iloc *iloc)
inode->i_ino != EXT3_JOURNAL_INO && inode->i_ino != EXT3_JOURNAL_INO &&
inode->i_ino < EXT3_FIRST_INO(inode->i_sb)) || inode->i_ino < EXT3_FIRST_INO(inode->i_sb)) ||
inode->i_ino > le32_to_cpu( inode->i_ino > le32_to_cpu(
inode->i_sb->u.ext3_sb.s_es->s_inodes_count)) { EXT3_SB(inode->i_sb)->s_es->s_inodes_count)) {
ext3_error (inode->i_sb, "ext3_get_inode_loc", ext3_error (inode->i_sb, "ext3_get_inode_loc",
"bad inode number: %lu", inode->i_ino); "bad inode number: %lu", inode->i_ino);
goto bad_inode; goto bad_inode;
} }
block_group = (inode->i_ino - 1) / EXT3_INODES_PER_GROUP(inode->i_sb); block_group = (inode->i_ino - 1) / EXT3_INODES_PER_GROUP(inode->i_sb);
if (block_group >= inode->i_sb->u.ext3_sb.s_groups_count) { if (block_group >= EXT3_SB(inode->i_sb)->s_groups_count) {
ext3_error (inode->i_sb, "ext3_get_inode_loc", ext3_error (inode->i_sb, "ext3_get_inode_loc",
"group >= groups count"); "group >= groups count");
goto bad_inode; goto bad_inode;
} }
group_desc = block_group >> EXT3_DESC_PER_BLOCK_BITS(inode->i_sb); group_desc = block_group >> EXT3_DESC_PER_BLOCK_BITS(inode->i_sb);
desc = block_group & (EXT3_DESC_PER_BLOCK(inode->i_sb) - 1); desc = block_group & (EXT3_DESC_PER_BLOCK(inode->i_sb) - 1);
bh = inode->i_sb->u.ext3_sb.s_group_desc[group_desc]; bh = EXT3_SB(inode->i_sb)->s_group_desc[group_desc];
if (!bh) { if (!bh) {
ext3_error (inode->i_sb, "ext3_get_inode_loc", ext3_error (inode->i_sb, "ext3_get_inode_loc",
"Descriptor not loaded"); "Descriptor not loaded");
...@@ -2224,7 +2224,7 @@ void ext3_read_inode(struct inode * inode) ...@@ -2224,7 +2224,7 @@ void ext3_read_inode(struct inode * inode)
*/ */
if (inode->i_nlink == 0) { if (inode->i_nlink == 0) {
if (inode->i_mode == 0 || if (inode->i_mode == 0 ||
!(inode->i_sb->u.ext3_sb.s_mount_state & EXT3_ORPHAN_FS)) { !(EXT3_SB(inode->i_sb)->s_mount_state & EXT3_ORPHAN_FS)) {
/* this inode is deleted */ /* this inode is deleted */
brelse (bh); brelse (bh);
goto bad_inode; goto bad_inode;
...@@ -2394,7 +2394,7 @@ static int ext3_do_update_inode(handle_t *handle, ...@@ -2394,7 +2394,7 @@ static int ext3_do_update_inode(handle_t *handle,
* created, add a flag to the superblock. * created, add a flag to the superblock.
*/ */
err = ext3_journal_get_write_access(handle, err = ext3_journal_get_write_access(handle,
sb->u.ext3_sb.s_sbh); EXT3_SB(sb)->s_sbh);
if (err) if (err)
goto out_brelse; goto out_brelse;
ext3_update_dynamic_rev(sb); ext3_update_dynamic_rev(sb);
...@@ -2403,7 +2403,7 @@ static int ext3_do_update_inode(handle_t *handle, ...@@ -2403,7 +2403,7 @@ static int ext3_do_update_inode(handle_t *handle,
sb->s_dirt = 1; sb->s_dirt = 1;
handle->h_sync = 1; handle->h_sync = 1;
err = ext3_journal_dirty_metadata(handle, err = ext3_journal_dirty_metadata(handle,
sb->u.ext3_sb.s_sbh); EXT3_SB(sb)->s_sbh);
} }
} }
} }
......
...@@ -159,12 +159,12 @@ int ext3_ioctl (struct inode * inode, struct file * filp, unsigned int cmd, ...@@ -159,12 +159,12 @@ int ext3_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
int ret = 0; int ret = 0;
set_current_state(TASK_INTERRUPTIBLE); set_current_state(TASK_INTERRUPTIBLE);
add_wait_queue(&sb->u.ext3_sb.ro_wait_queue, &wait); add_wait_queue(&EXT3_SB(sb)->ro_wait_queue, &wait);
if (timer_pending(&sb->u.ext3_sb.turn_ro_timer)) { if (timer_pending(&EXT3_SB(sb)->turn_ro_timer)) {
schedule(); schedule();
ret = 1; ret = 1;
} }
remove_wait_queue(&sb->u.ext3_sb.ro_wait_queue, &wait); remove_wait_queue(&EXT3_SB(sb)->ro_wait_queue, &wait);
return ret; return ret;
} }
#endif #endif
......
...@@ -729,8 +729,8 @@ int ext3_orphan_add(handle_t *handle, struct inode *inode) ...@@ -729,8 +729,8 @@ int ext3_orphan_add(handle_t *handle, struct inode *inode)
J_ASSERT ((S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) || J_ASSERT ((S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
S_ISLNK(inode->i_mode)) || inode->i_nlink == 0); S_ISLNK(inode->i_mode)) || inode->i_nlink == 0);
BUFFER_TRACE(sb->u.ext3_sb.s_sbh, "get_write_access"); BUFFER_TRACE(EXT3_SB(sb)->s_sbh, "get_write_access");
err = ext3_journal_get_write_access(handle, sb->u.ext3_sb.s_sbh); err = ext3_journal_get_write_access(handle, EXT3_SB(sb)->s_sbh);
if (err) if (err)
goto out_unlock; goto out_unlock;
...@@ -741,7 +741,7 @@ int ext3_orphan_add(handle_t *handle, struct inode *inode) ...@@ -741,7 +741,7 @@ int ext3_orphan_add(handle_t *handle, struct inode *inode)
/* Insert this inode at the head of the on-disk orphan list... */ /* Insert this inode at the head of the on-disk orphan list... */
NEXT_ORPHAN(inode) = le32_to_cpu(EXT3_SB(sb)->s_es->s_last_orphan); NEXT_ORPHAN(inode) = le32_to_cpu(EXT3_SB(sb)->s_es->s_last_orphan);
EXT3_SB(sb)->s_es->s_last_orphan = cpu_to_le32(inode->i_ino); EXT3_SB(sb)->s_es->s_last_orphan = cpu_to_le32(inode->i_ino);
err = ext3_journal_dirty_metadata(handle, sb->u.ext3_sb.s_sbh); err = ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh);
rc = ext3_mark_iloc_dirty(handle, inode, &iloc); rc = ext3_mark_iloc_dirty(handle, inode, &iloc);
if (!err) if (!err)
err = rc; err = rc;
......
...@@ -120,7 +120,7 @@ static int ext3_error_behaviour(struct super_block *sb) ...@@ -120,7 +120,7 @@ static int ext3_error_behaviour(struct super_block *sb)
/* If no overrides were specified on the mount, then fall back /* If no overrides were specified on the mount, then fall back
* to the default behaviour set in the filesystem's superblock * to the default behaviour set in the filesystem's superblock
* on disk. */ * on disk. */
switch (le16_to_cpu(sb->u.ext3_sb.s_es->s_errors)) { switch (le16_to_cpu(EXT3_SB(sb)->s_es->s_errors)) {
case EXT3_ERRORS_PANIC: case EXT3_ERRORS_PANIC:
return EXT3_ERRORS_PANIC; return EXT3_ERRORS_PANIC;
case EXT3_ERRORS_RO: case EXT3_ERRORS_RO:
...@@ -268,9 +268,9 @@ void ext3_abort (struct super_block * sb, const char * function, ...@@ -268,9 +268,9 @@ void ext3_abort (struct super_block * sb, const char * function,
return; return;
printk (KERN_CRIT "Remounting filesystem read-only\n"); printk (KERN_CRIT "Remounting filesystem read-only\n");
sb->u.ext3_sb.s_mount_state |= EXT3_ERROR_FS; EXT3_SB(sb)->s_mount_state |= EXT3_ERROR_FS;
sb->s_flags |= MS_RDONLY; sb->s_flags |= MS_RDONLY;
sb->u.ext3_sb.s_mount_opt |= EXT3_MOUNT_ABORT; EXT3_SB(sb)->s_mount_opt |= EXT3_MOUNT_ABORT;
journal_abort(EXT3_SB(sb)->s_journal, -EIO); journal_abort(EXT3_SB(sb)->s_journal, -EIO);
} }
...@@ -439,7 +439,8 @@ void ext3_put_super (struct super_block * sb) ...@@ -439,7 +439,8 @@ void ext3_put_super (struct super_block * sb)
ext3_blkdev_remove(sbi); ext3_blkdev_remove(sbi);
} }
clear_ro_after(sb); clear_ro_after(sb);
sb->u.generic_sbp = NULL;
kfree(sbi);
return; return;
} }
...@@ -877,7 +878,7 @@ static void ext3_orphan_cleanup (struct super_block * sb, ...@@ -877,7 +878,7 @@ static void ext3_orphan_cleanup (struct super_block * sb,
sb->s_flags &= ~MS_RDONLY; sb->s_flags &= ~MS_RDONLY;
} }
if (sb->u.ext3_sb.s_mount_state & EXT3_ERROR_FS) { if (EXT3_SB(sb)->s_mount_state & EXT3_ERROR_FS) {
if (es->s_last_orphan) if (es->s_last_orphan)
jbd_debug(1, "Errors on filesystem, " jbd_debug(1, "Errors on filesystem, "
"clearing orphan list.\n"); "clearing orphan list.\n");
...@@ -949,7 +950,7 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) ...@@ -949,7 +950,7 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
{ {
struct buffer_head * bh; struct buffer_head * bh;
struct ext3_super_block *es = 0; struct ext3_super_block *es = 0;
struct ext3_sb_info *sbi = EXT3_SB(sb); struct ext3_sb_info *sbi;
unsigned long sb_block = 1; unsigned long sb_block = 1;
unsigned long logic_sb_block = 1; unsigned long logic_sb_block = 1;
unsigned long offset = 0; unsigned long offset = 0;
...@@ -970,7 +971,11 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) ...@@ -970,7 +971,11 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
* This is important for devices that have a hardware * This is important for devices that have a hardware
* sectorsize that is larger than the default. * sectorsize that is larger than the default.
*/ */
sbi = kmalloc(sizeof(*sbi), GFP_KERNEL);
if (!sbi)
return -ENOMEM;
sb->u.generic_sbp = sbi;
memset(sbi, 0, sizeof(*sbi));
sbi->s_mount_opt = 0; sbi->s_mount_opt = 0;
sbi->s_resuid = EXT3_DEF_RESUID; sbi->s_resuid = EXT3_DEF_RESUID;
sbi->s_resgid = EXT3_DEF_RESGID; sbi->s_resgid = EXT3_DEF_RESGID;
...@@ -1266,6 +1271,8 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) ...@@ -1266,6 +1271,8 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
ext3_blkdev_remove(sbi); ext3_blkdev_remove(sbi);
brelse(bh); brelse(bh);
out_fail: out_fail:
sb->u.generic_sbp = NULL;
kfree(sbi);
return -EINVAL; return -EINVAL;
} }
...@@ -1520,11 +1527,11 @@ static void ext3_commit_super (struct super_block * sb, ...@@ -1520,11 +1527,11 @@ static void ext3_commit_super (struct super_block * sb,
int sync) int sync)
{ {
es->s_wtime = cpu_to_le32(CURRENT_TIME); es->s_wtime = cpu_to_le32(CURRENT_TIME);
BUFFER_TRACE(sb->u.ext3_sb.s_sbh, "marking dirty"); BUFFER_TRACE(EXT3_SB(sb)->s_sbh, "marking dirty");
mark_buffer_dirty(sb->u.ext3_sb.s_sbh); mark_buffer_dirty(EXT3_SB(sb)->s_sbh);
if (sync) { if (sync) {
ll_rw_block(WRITE, 1, &sb->u.ext3_sb.s_sbh); ll_rw_block(WRITE, 1, &EXT3_SB(sb)->s_sbh);
wait_on_buffer(sb->u.ext3_sb.s_sbh); wait_on_buffer(EXT3_SB(sb)->s_sbh);
} }
} }
...@@ -1575,7 +1582,7 @@ static void ext3_clear_journal_err(struct super_block * sb, ...@@ -1575,7 +1582,7 @@ static void ext3_clear_journal_err(struct super_block * sb,
ext3_warning(sb, __FUNCTION__, "Marking fs in need of " ext3_warning(sb, __FUNCTION__, "Marking fs in need of "
"filesystem check."); "filesystem check.");
sb->u.ext3_sb.s_mount_state |= EXT3_ERROR_FS; EXT3_SB(sb)->s_mount_state |= EXT3_ERROR_FS;
es->s_state |= cpu_to_le16(EXT3_ERROR_FS); es->s_state |= cpu_to_le16(EXT3_ERROR_FS);
ext3_commit_super (sb, es, 1); ext3_commit_super (sb, es, 1);
......
...@@ -97,9 +97,9 @@ ...@@ -97,9 +97,9 @@
# define EXT3_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10) # define EXT3_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10)
#endif #endif
#ifdef __KERNEL__ #ifdef __KERNEL__
#define EXT3_ADDR_PER_BLOCK_BITS(s) ((s)->u.ext3_sb.s_addr_per_block_bits) #define EXT3_ADDR_PER_BLOCK_BITS(s) (EXT3_SB(s)->s_addr_per_block_bits)
#define EXT3_INODE_SIZE(s) ((s)->u.ext3_sb.s_inode_size) #define EXT3_INODE_SIZE(s) (EXT3_SB(s)->s_inode_size)
#define EXT3_FIRST_INO(s) ((s)->u.ext3_sb.s_first_ino) #define EXT3_FIRST_INO(s) (EXT3_SB(s)->s_first_ino)
#else #else
#define EXT3_INODE_SIZE(s) (((s)->s_rev_level == EXT3_GOOD_OLD_REV) ? \ #define EXT3_INODE_SIZE(s) (((s)->s_rev_level == EXT3_GOOD_OLD_REV) ? \
EXT3_GOOD_OLD_INODE_SIZE : \ EXT3_GOOD_OLD_INODE_SIZE : \
...@@ -116,8 +116,8 @@ ...@@ -116,8 +116,8 @@
#define EXT3_MAX_FRAG_SIZE 4096 #define EXT3_MAX_FRAG_SIZE 4096
#define EXT3_MIN_FRAG_LOG_SIZE 10 #define EXT3_MIN_FRAG_LOG_SIZE 10
#ifdef __KERNEL__ #ifdef __KERNEL__
# define EXT3_FRAG_SIZE(s) ((s)->u.ext3_sb.s_frag_size) # define EXT3_FRAG_SIZE(s) (EXT3_SB(s)->s_frag_size)
# define EXT3_FRAGS_PER_BLOCK(s) ((s)->u.ext3_sb.s_frags_per_block) # define EXT3_FRAGS_PER_BLOCK(s) (EXT3_SB(s)->s_frags_per_block)
#else #else
# define EXT3_FRAG_SIZE(s) (EXT3_MIN_FRAG_SIZE << (s)->s_log_frag_size) # define EXT3_FRAG_SIZE(s) (EXT3_MIN_FRAG_SIZE << (s)->s_log_frag_size)
# define EXT3_FRAGS_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / EXT3_FRAG_SIZE(s)) # define EXT3_FRAGS_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / EXT3_FRAG_SIZE(s))
...@@ -164,10 +164,10 @@ struct ext3_group_desc ...@@ -164,10 +164,10 @@ struct ext3_group_desc
* Macro-instructions used to manage group descriptors * Macro-instructions used to manage group descriptors
*/ */
#ifdef __KERNEL__ #ifdef __KERNEL__
# define EXT3_BLOCKS_PER_GROUP(s) ((s)->u.ext3_sb.s_blocks_per_group) # define EXT3_BLOCKS_PER_GROUP(s) (EXT3_SB(s)->s_blocks_per_group)
# define EXT3_DESC_PER_BLOCK(s) ((s)->u.ext3_sb.s_desc_per_block) # define EXT3_DESC_PER_BLOCK(s) (EXT3_SB(s)->s_desc_per_block)
# define EXT3_INODES_PER_GROUP(s) ((s)->u.ext3_sb.s_inodes_per_group) # define EXT3_INODES_PER_GROUP(s) (EXT3_SB(s)->s_inodes_per_group)
# define EXT3_DESC_PER_BLOCK_BITS(s) ((s)->u.ext3_sb.s_desc_per_block_bits) # define EXT3_DESC_PER_BLOCK_BITS(s) (EXT3_SB(s)->s_desc_per_block_bits)
#else #else
# define EXT3_BLOCKS_PER_GROUP(s) ((s)->s_blocks_per_group) # define EXT3_BLOCKS_PER_GROUP(s) ((s)->s_blocks_per_group)
# define EXT3_DESC_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / sizeof (struct ext3_group_desc)) # define EXT3_DESC_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / sizeof (struct ext3_group_desc))
...@@ -346,7 +346,7 @@ struct ext3_inode { ...@@ -346,7 +346,7 @@ struct ext3_inode {
#ifndef _LINUX_EXT2_FS_H #ifndef _LINUX_EXT2_FS_H
#define clear_opt(o, opt) o &= ~EXT3_MOUNT_##opt #define clear_opt(o, opt) o &= ~EXT3_MOUNT_##opt
#define set_opt(o, opt) o |= EXT3_MOUNT_##opt #define set_opt(o, opt) o |= EXT3_MOUNT_##opt
#define test_opt(sb, opt) ((sb)->u.ext3_sb.s_mount_opt & \ #define test_opt(sb, opt) (EXT3_SB(sb)->s_mount_opt & \
EXT3_MOUNT_##opt) EXT3_MOUNT_##opt)
#else #else
#define EXT2_MOUNT_NOLOAD EXT3_MOUNT_NOLOAD #define EXT2_MOUNT_NOLOAD EXT3_MOUNT_NOLOAD
...@@ -444,7 +444,10 @@ struct ext3_super_block { ...@@ -444,7 +444,10 @@ struct ext3_super_block {
}; };
#ifdef __KERNEL__ #ifdef __KERNEL__
#define EXT3_SB(sb) (&((sb)->u.ext3_sb)) static inline struct ext3_sb_info * EXT3_SB(struct super_block *sb)
{
return sb->u.generic_sbp;
}
static inline struct ext3_inode_info *EXT3_I(struct inode *inode) static inline struct ext3_inode_info *EXT3_I(struct inode *inode)
{ {
return container_of(inode, struct ext3_inode_info, vfs_inode); return container_of(inode, struct ext3_inode_info, vfs_inode);
......
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