Skip to content

Commit

Permalink
BFS: clean up the superblock usage
Browse files Browse the repository at this point in the history
BFS is a very simple FS and its superblocks contains only static
information and is never changed. However, the BFS code for some
misterious reasons marked its buffer head as dirty from time to
time, but nothing in that buffer was ever changed.

This patch removes all the BFS superblock manipulation, simply
because it is not needed. It removes:

1. The si_sbh filed from 'struct bfs_sb_info' because it is not
   needed. We only need to read the SB once on mount to get the
   start of data blocks and the FS size. After this, we can forget
   about the SB.
2. All instances of 'mark_buffer_dirty(sbh)' for BFS SB because
   it is never changed.
3. The '->sync_fs()' method because there is nothing to sync
   (inodes are synched by VFS).
4. The '->write_super()' method, again, because the SB is never
   changed.

Tested-by: Artem Bityutskiy <[email protected]>
Signed-off-by: Artem Bityutskiy <[email protected]>
Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Artem Bityutskiy authored and Al Viro committed Aug 9, 2010
1 parent 7435d50 commit 4e29d50
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 43 deletions.
1 change: 0 additions & 1 deletion fs/bfs/bfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ struct bfs_sb_info {
unsigned long si_lf_eblk;
unsigned long si_lasti;
unsigned long *si_imap;
struct buffer_head *si_sbh; /* buffer header w/superblock */
struct mutex bfs_lock;
};

Expand Down
3 changes: 0 additions & 3 deletions fs/bfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ static int bfs_get_block(struct inode *inode, sector_t block,
struct super_block *sb = inode->i_sb;
struct bfs_sb_info *info = BFS_SB(sb);
struct bfs_inode_info *bi = BFS_I(inode);
struct buffer_head *sbh = info->si_sbh;

phys = bi->i_sblock + block;
if (!create) {
Expand Down Expand Up @@ -112,7 +111,6 @@ static int bfs_get_block(struct inode *inode, sector_t block,
info->si_freeb -= phys - bi->i_eblock;
info->si_lf_eblk = bi->i_eblock = phys;
mark_inode_dirty(inode);
mark_buffer_dirty(sbh);
err = 0;
goto out;
}
Expand Down Expand Up @@ -147,7 +145,6 @@ static int bfs_get_block(struct inode *inode, sector_t block,
*/
info->si_freeb -= bi->i_eblock - bi->i_sblock + 1 - inode->i_blocks;
mark_inode_dirty(inode);
mark_buffer_dirty(sbh);
map_bh(bh_result, sb, phys);
out:
mutex_unlock(&info->bfs_lock);
Expand Down
46 changes: 7 additions & 39 deletions fs/bfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ MODULE_LICENSE("GPL");
#define dprintf(x...)
#endif

static void bfs_write_super(struct super_block *s);
void dump_imap(const char *prefix, struct super_block *s);

struct inode *bfs_iget(struct super_block *sb, unsigned long ino)
Expand Down Expand Up @@ -204,33 +203,11 @@ static void bfs_evict_inode(struct inode *inode)
* "last block of the last file" even if there is no
* real file there, saves us 1 gap.
*/
if (info->si_lf_eblk == bi->i_eblock) {
if (info->si_lf_eblk == bi->i_eblock)
info->si_lf_eblk = bi->i_sblock - 1;
mark_buffer_dirty(info->si_sbh);
}
mutex_unlock(&info->bfs_lock);
}

static int bfs_sync_fs(struct super_block *sb, int wait)
{
struct bfs_sb_info *info = BFS_SB(sb);

mutex_lock(&info->bfs_lock);
mark_buffer_dirty(info->si_sbh);
sb->s_dirt = 0;
mutex_unlock(&info->bfs_lock);

return 0;
}

static void bfs_write_super(struct super_block *sb)
{
if (!(sb->s_flags & MS_RDONLY))
bfs_sync_fs(sb, 1);
else
sb->s_dirt = 0;
}

static void bfs_put_super(struct super_block *s)
{
struct bfs_sb_info *info = BFS_SB(s);
Expand All @@ -240,10 +217,6 @@ static void bfs_put_super(struct super_block *s)

lock_kernel();

if (s->s_dirt)
bfs_write_super(s);

brelse(info->si_sbh);
mutex_destroy(&info->bfs_lock);
kfree(info->si_imap);
kfree(info);
Expand Down Expand Up @@ -315,8 +288,6 @@ static const struct super_operations bfs_sops = {
.write_inode = bfs_write_inode,
.evict_inode = bfs_evict_inode,
.put_super = bfs_put_super,
.write_super = bfs_write_super,
.sync_fs = bfs_sync_fs,
.statfs = bfs_statfs,
};

Expand All @@ -343,7 +314,7 @@ void dump_imap(const char *prefix, struct super_block *s)

static int bfs_fill_super(struct super_block *s, void *data, int silent)
{
struct buffer_head *bh;
struct buffer_head *bh, *sbh;
struct bfs_super_block *bfs_sb;
struct inode *inode;
unsigned i, imap_len;
Expand All @@ -359,10 +330,10 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent)

sb_set_blocksize(s, BFS_BSIZE);

info->si_sbh = sb_bread(s, 0);
if (!info->si_sbh)
sbh = sb_bread(s, 0);
if (!sbh)
goto out;
bfs_sb = (struct bfs_super_block *)info->si_sbh->b_data;
bfs_sb = (struct bfs_super_block *)sbh->b_data;
if (le32_to_cpu(bfs_sb->s_magic) != BFS_MAGIC) {
if (!silent)
printf("No BFS filesystem on %s (magic=%08x)\n",
Expand Down Expand Up @@ -466,10 +437,7 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent)
info->si_lf_eblk = eblock;
}
brelse(bh);
if (!(s->s_flags & MS_RDONLY)) {
mark_buffer_dirty(info->si_sbh);
s->s_dirt = 1;
}
brelse(sbh);
dump_imap("read_super", s);
return 0;

Expand All @@ -479,7 +447,7 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent)
out2:
kfree(info->si_imap);
out1:
brelse(info->si_sbh);
brelse(sbh);
out:
mutex_destroy(&info->bfs_lock);
kfree(info);
Expand Down

0 comments on commit 4e29d50

Please sign in to comment.