diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2010-07-05 08:15:01 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2010-08-09 16:48:53 -0400 |
commit | 4e29d50a28c267bd1d1731a9fb8f773663d93e23 (patch) | |
tree | b1a299f96a513162db7d0ed1f198d820664e5bf5 /fs/bfs | |
parent | 7435d50611b04c1155a939a9f373154a53606592 (diff) |
BFS: clean up the superblock usage
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 <Artem.Bityutskiy@nokia.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/bfs')
-rw-r--r-- | fs/bfs/bfs.h | 1 | ||||
-rw-r--r-- | fs/bfs/file.c | 3 | ||||
-rw-r--r-- | fs/bfs/inode.c | 46 |
3 files changed, 7 insertions, 43 deletions
diff --git a/fs/bfs/bfs.h b/fs/bfs/bfs.h index 7109e451abf7..f7f87e233dd9 100644 --- a/fs/bfs/bfs.h +++ b/fs/bfs/bfs.h | |||
@@ -17,7 +17,6 @@ struct bfs_sb_info { | |||
17 | unsigned long si_lf_eblk; | 17 | unsigned long si_lf_eblk; |
18 | unsigned long si_lasti; | 18 | unsigned long si_lasti; |
19 | unsigned long *si_imap; | 19 | unsigned long *si_imap; |
20 | struct buffer_head *si_sbh; /* buffer header w/superblock */ | ||
21 | struct mutex bfs_lock; | 20 | struct mutex bfs_lock; |
22 | }; | 21 | }; |
23 | 22 | ||
diff --git a/fs/bfs/file.c b/fs/bfs/file.c index 8fc2e9c9739d..eb67edd0f8ea 100644 --- a/fs/bfs/file.c +++ b/fs/bfs/file.c | |||
@@ -70,7 +70,6 @@ static int bfs_get_block(struct inode *inode, sector_t block, | |||
70 | struct super_block *sb = inode->i_sb; | 70 | struct super_block *sb = inode->i_sb; |
71 | struct bfs_sb_info *info = BFS_SB(sb); | 71 | struct bfs_sb_info *info = BFS_SB(sb); |
72 | struct bfs_inode_info *bi = BFS_I(inode); | 72 | struct bfs_inode_info *bi = BFS_I(inode); |
73 | struct buffer_head *sbh = info->si_sbh; | ||
74 | 73 | ||
75 | phys = bi->i_sblock + block; | 74 | phys = bi->i_sblock + block; |
76 | if (!create) { | 75 | if (!create) { |
@@ -112,7 +111,6 @@ static int bfs_get_block(struct inode *inode, sector_t block, | |||
112 | info->si_freeb -= phys - bi->i_eblock; | 111 | info->si_freeb -= phys - bi->i_eblock; |
113 | info->si_lf_eblk = bi->i_eblock = phys; | 112 | info->si_lf_eblk = bi->i_eblock = phys; |
114 | mark_inode_dirty(inode); | 113 | mark_inode_dirty(inode); |
115 | mark_buffer_dirty(sbh); | ||
116 | err = 0; | 114 | err = 0; |
117 | goto out; | 115 | goto out; |
118 | } | 116 | } |
@@ -147,7 +145,6 @@ static int bfs_get_block(struct inode *inode, sector_t block, | |||
147 | */ | 145 | */ |
148 | info->si_freeb -= bi->i_eblock - bi->i_sblock + 1 - inode->i_blocks; | 146 | info->si_freeb -= bi->i_eblock - bi->i_sblock + 1 - inode->i_blocks; |
149 | mark_inode_dirty(inode); | 147 | mark_inode_dirty(inode); |
150 | mark_buffer_dirty(sbh); | ||
151 | map_bh(bh_result, sb, phys); | 148 | map_bh(bh_result, sb, phys); |
152 | out: | 149 | out: |
153 | mutex_unlock(&info->bfs_lock); | 150 | mutex_unlock(&info->bfs_lock); |
diff --git a/fs/bfs/inode.c b/fs/bfs/inode.c index 0499822b1568..c4daf0f5fc02 100644 --- a/fs/bfs/inode.c +++ b/fs/bfs/inode.c | |||
@@ -31,7 +31,6 @@ MODULE_LICENSE("GPL"); | |||
31 | #define dprintf(x...) | 31 | #define dprintf(x...) |
32 | #endif | 32 | #endif |
33 | 33 | ||
34 | static void bfs_write_super(struct super_block *s); | ||
35 | void dump_imap(const char *prefix, struct super_block *s); | 34 | void dump_imap(const char *prefix, struct super_block *s); |
36 | 35 | ||
37 | struct inode *bfs_iget(struct super_block *sb, unsigned long ino) | 36 | struct inode *bfs_iget(struct super_block *sb, unsigned long ino) |
@@ -204,33 +203,11 @@ static void bfs_evict_inode(struct inode *inode) | |||
204 | * "last block of the last file" even if there is no | 203 | * "last block of the last file" even if there is no |
205 | * real file there, saves us 1 gap. | 204 | * real file there, saves us 1 gap. |
206 | */ | 205 | */ |
207 | if (info->si_lf_eblk == bi->i_eblock) { | 206 | if (info->si_lf_eblk == bi->i_eblock) |
208 | info->si_lf_eblk = bi->i_sblock - 1; | 207 | info->si_lf_eblk = bi->i_sblock - 1; |
209 | mark_buffer_dirty(info->si_sbh); | ||
210 | } | ||
211 | mutex_unlock(&info->bfs_lock); | 208 | mutex_unlock(&info->bfs_lock); |
212 | } | 209 | } |
213 | 210 | ||
214 | static int bfs_sync_fs(struct super_block *sb, int wait) | ||
215 | { | ||
216 | struct bfs_sb_info *info = BFS_SB(sb); | ||
217 | |||
218 | mutex_lock(&info->bfs_lock); | ||
219 | mark_buffer_dirty(info->si_sbh); | ||
220 | sb->s_dirt = 0; | ||
221 | mutex_unlock(&info->bfs_lock); | ||
222 | |||
223 | return 0; | ||
224 | } | ||
225 | |||
226 | static void bfs_write_super(struct super_block *sb) | ||
227 | { | ||
228 | if (!(sb->s_flags & MS_RDONLY)) | ||
229 | bfs_sync_fs(sb, 1); | ||
230 | else | ||
231 | sb->s_dirt = 0; | ||
232 | } | ||
233 | |||
234 | static void bfs_put_super(struct super_block *s) | 211 | static void bfs_put_super(struct super_block *s) |
235 | { | 212 | { |
236 | struct bfs_sb_info *info = BFS_SB(s); | 213 | struct bfs_sb_info *info = BFS_SB(s); |
@@ -240,10 +217,6 @@ static void bfs_put_super(struct super_block *s) | |||
240 | 217 | ||
241 | lock_kernel(); | 218 | lock_kernel(); |
242 | 219 | ||
243 | if (s->s_dirt) | ||
244 | bfs_write_super(s); | ||
245 | |||
246 | brelse(info->si_sbh); | ||
247 | mutex_destroy(&info->bfs_lock); | 220 | mutex_destroy(&info->bfs_lock); |
248 | kfree(info->si_imap); | 221 | kfree(info->si_imap); |
249 | kfree(info); | 222 | kfree(info); |
@@ -315,8 +288,6 @@ static const struct super_operations bfs_sops = { | |||
315 | .write_inode = bfs_write_inode, | 288 | .write_inode = bfs_write_inode, |
316 | .evict_inode = bfs_evict_inode, | 289 | .evict_inode = bfs_evict_inode, |
317 | .put_super = bfs_put_super, | 290 | .put_super = bfs_put_super, |
318 | .write_super = bfs_write_super, | ||
319 | .sync_fs = bfs_sync_fs, | ||
320 | .statfs = bfs_statfs, | 291 | .statfs = bfs_statfs, |
321 | }; | 292 | }; |
322 | 293 | ||
@@ -343,7 +314,7 @@ void dump_imap(const char *prefix, struct super_block *s) | |||
343 | 314 | ||
344 | static int bfs_fill_super(struct super_block *s, void *data, int silent) | 315 | static int bfs_fill_super(struct super_block *s, void *data, int silent) |
345 | { | 316 | { |
346 | struct buffer_head *bh; | 317 | struct buffer_head *bh, *sbh; |
347 | struct bfs_super_block *bfs_sb; | 318 | struct bfs_super_block *bfs_sb; |
348 | struct inode *inode; | 319 | struct inode *inode; |
349 | unsigned i, imap_len; | 320 | unsigned i, imap_len; |
@@ -359,10 +330,10 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent) | |||
359 | 330 | ||
360 | sb_set_blocksize(s, BFS_BSIZE); | 331 | sb_set_blocksize(s, BFS_BSIZE); |
361 | 332 | ||
362 | info->si_sbh = sb_bread(s, 0); | 333 | sbh = sb_bread(s, 0); |
363 | if (!info->si_sbh) | 334 | if (!sbh) |
364 | goto out; | 335 | goto out; |
365 | bfs_sb = (struct bfs_super_block *)info->si_sbh->b_data; | 336 | bfs_sb = (struct bfs_super_block *)sbh->b_data; |
366 | if (le32_to_cpu(bfs_sb->s_magic) != BFS_MAGIC) { | 337 | if (le32_to_cpu(bfs_sb->s_magic) != BFS_MAGIC) { |
367 | if (!silent) | 338 | if (!silent) |
368 | printf("No BFS filesystem on %s (magic=%08x)\n", | 339 | printf("No BFS filesystem on %s (magic=%08x)\n", |
@@ -466,10 +437,7 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent) | |||
466 | info->si_lf_eblk = eblock; | 437 | info->si_lf_eblk = eblock; |
467 | } | 438 | } |
468 | brelse(bh); | 439 | brelse(bh); |
469 | if (!(s->s_flags & MS_RDONLY)) { | 440 | brelse(sbh); |
470 | mark_buffer_dirty(info->si_sbh); | ||
471 | s->s_dirt = 1; | ||
472 | } | ||
473 | dump_imap("read_super", s); | 441 | dump_imap("read_super", s); |
474 | return 0; | 442 | return 0; |
475 | 443 | ||
@@ -479,7 +447,7 @@ out3: | |||
479 | out2: | 447 | out2: |
480 | kfree(info->si_imap); | 448 | kfree(info->si_imap); |
481 | out1: | 449 | out1: |
482 | brelse(info->si_sbh); | 450 | brelse(sbh); |
483 | out: | 451 | out: |
484 | mutex_destroy(&info->bfs_lock); | 452 | mutex_destroy(&info->bfs_lock); |
485 | kfree(info); | 453 | kfree(info); |