Commit 4e29d50a28c267bd1d1731a9fb8f773663d93e23

Authored by Artem Bityutskiy
Committed by Al Viro
1 parent 7435d50611

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>

Showing 3 changed files with 7 additions and 43 deletions Side-by-side Diff

... ... @@ -17,7 +17,6 @@
17 17 unsigned long si_lf_eblk;
18 18 unsigned long si_lasti;
19 19 unsigned long *si_imap;
20   - struct buffer_head *si_sbh; /* buffer header w/superblock */
21 20 struct mutex bfs_lock;
22 21 };
23 22  
... ... @@ -70,7 +70,6 @@
70 70 struct super_block *sb = inode->i_sb;
71 71 struct bfs_sb_info *info = BFS_SB(sb);
72 72 struct bfs_inode_info *bi = BFS_I(inode);
73   - struct buffer_head *sbh = info->si_sbh;
74 73  
75 74 phys = bi->i_sblock + block;
76 75 if (!create) {
... ... @@ -112,7 +111,6 @@
112 111 info->si_freeb -= phys - bi->i_eblock;
113 112 info->si_lf_eblk = bi->i_eblock = phys;
114 113 mark_inode_dirty(inode);
115   - mark_buffer_dirty(sbh);
116 114 err = 0;
117 115 goto out;
118 116 }
... ... @@ -147,7 +145,6 @@
147 145 */
148 146 info->si_freeb -= bi->i_eblock - bi->i_sblock + 1 - inode->i_blocks;
149 147 mark_inode_dirty(inode);
150   - mark_buffer_dirty(sbh);
151 148 map_bh(bh_result, sb, phys);
152 149 out:
153 150 mutex_unlock(&info->bfs_lock);
... ... @@ -31,7 +31,6 @@
31 31 #define dprintf(x...)
32 32 #endif
33 33  
34   -static void bfs_write_super(struct super_block *s);
35 34 void dump_imap(const char *prefix, struct super_block *s);
36 35  
37 36 struct inode *bfs_iget(struct super_block *sb, unsigned long ino)
38 37  
39 38  
... ... @@ -204,33 +203,11 @@
204 203 * "last block of the last file" even if there is no
205 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 207 info->si_lf_eblk = bi->i_sblock - 1;
209   - mark_buffer_dirty(info->si_sbh);
210   - }
211 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 211 static void bfs_put_super(struct super_block *s)
235 212 {
236 213 struct bfs_sb_info *info = BFS_SB(s);
... ... @@ -240,10 +217,6 @@
240 217  
241 218 lock_kernel();
242 219  
243   - if (s->s_dirt)
244   - bfs_write_super(s);
245   -
246   - brelse(info->si_sbh);
247 220 mutex_destroy(&info->bfs_lock);
248 221 kfree(info->si_imap);
249 222 kfree(info);
... ... @@ -315,8 +288,6 @@
315 288 .write_inode = bfs_write_inode,
316 289 .evict_inode = bfs_evict_inode,
317 290 .put_super = bfs_put_super,
318   - .write_super = bfs_write_super,
319   - .sync_fs = bfs_sync_fs,
320 291 .statfs = bfs_statfs,
321 292 };
322 293  
... ... @@ -343,7 +314,7 @@
343 314  
344 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 318 struct bfs_super_block *bfs_sb;
348 319 struct inode *inode;
349 320 unsigned i, imap_len;
350 321  
... ... @@ -359,10 +330,10 @@
359 330  
360 331 sb_set_blocksize(s, BFS_BSIZE);
361 332  
362   - info->si_sbh = sb_bread(s, 0);
363   - if (!info->si_sbh)
  333 + sbh = sb_bread(s, 0);
  334 + if (!sbh)
364 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 337 if (le32_to_cpu(bfs_sb->s_magic) != BFS_MAGIC) {
367 338 if (!silent)
368 339 printf("No BFS filesystem on %s (magic=%08x)\n",
... ... @@ -466,10 +437,7 @@
466 437 info->si_lf_eblk = eblock;
467 438 }
468 439 brelse(bh);
469   - if (!(s->s_flags & MS_RDONLY)) {
470   - mark_buffer_dirty(info->si_sbh);
471   - s->s_dirt = 1;
472   - }
  440 + brelse(sbh);
473 441 dump_imap("read_super", s);
474 442 return 0;
475 443  
... ... @@ -479,7 +447,7 @@
479 447 out2:
480 448 kfree(info->si_imap);
481 449 out1:
482   - brelse(info->si_sbh);
  450 + brelse(sbh);
483 451 out:
484 452 mutex_destroy(&info->bfs_lock);
485 453 kfree(info);