Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Artem Bityutskiy and committed by
Al Viro
4e29d50a 7435d506

+7 -43
-1
fs/bfs/bfs.h
··· 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
-3
fs/bfs/file.c
··· 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) { ··· 111 112 info->si_freeb -= phys - bi->i_eblock; 112 113 info->si_lf_eblk = bi->i_eblock = phys; 113 114 mark_inode_dirty(inode); 114 - mark_buffer_dirty(sbh); 115 115 err = 0; 116 116 goto out; 117 117 } ··· 145 147 */ 146 148 info->si_freeb -= bi->i_eblock - bi->i_sblock + 1 - inode->i_blocks; 147 149 mark_inode_dirty(inode); 148 - mark_buffer_dirty(sbh); 149 150 map_bh(bh_result, sb, phys); 150 151 out: 151 152 mutex_unlock(&info->bfs_lock);
+7 -39
fs/bfs/inode.c
··· 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) ··· 203 204 * "last block of the last file" even if there is no 204 205 * real file there, saves us 1 gap. 205 206 */ 206 - if (info->si_lf_eblk == bi->i_eblock) { 207 + if (info->si_lf_eblk == bi->i_eblock) 207 208 info->si_lf_eblk = bi->i_sblock - 1; 208 - mark_buffer_dirty(info->si_sbh); 209 - } 210 209 mutex_unlock(&info->bfs_lock); 211 - } 212 - 213 - static int bfs_sync_fs(struct super_block *sb, int wait) 214 - { 215 - struct bfs_sb_info *info = BFS_SB(sb); 216 - 217 - mutex_lock(&info->bfs_lock); 218 - mark_buffer_dirty(info->si_sbh); 219 - sb->s_dirt = 0; 220 - mutex_unlock(&info->bfs_lock); 221 - 222 - return 0; 223 - } 224 - 225 - static void bfs_write_super(struct super_block *sb) 226 - { 227 - if (!(sb->s_flags & MS_RDONLY)) 228 - bfs_sync_fs(sb, 1); 229 - else 230 - sb->s_dirt = 0; 231 210 } 232 211 233 212 static void bfs_put_super(struct super_block *s) ··· 217 240 218 241 lock_kernel(); 219 242 220 - if (s->s_dirt) 221 - bfs_write_super(s); 222 - 223 - brelse(info->si_sbh); 224 243 mutex_destroy(&info->bfs_lock); 225 244 kfree(info->si_imap); 226 245 kfree(info); ··· 288 315 .write_inode = bfs_write_inode, 289 316 .evict_inode = bfs_evict_inode, 290 317 .put_super = bfs_put_super, 291 - .write_super = bfs_write_super, 292 - .sync_fs = bfs_sync_fs, 293 318 .statfs = bfs_statfs, 294 319 }; 295 320 ··· 314 343 315 344 static int bfs_fill_super(struct super_block *s, void *data, int silent) 316 345 { 317 - struct buffer_head *bh; 346 + struct buffer_head *bh, *sbh; 318 347 struct bfs_super_block *bfs_sb; 319 348 struct inode *inode; 320 349 unsigned i, imap_len; ··· 330 359 331 360 sb_set_blocksize(s, BFS_BSIZE); 332 361 333 - info->si_sbh = sb_bread(s, 0); 334 - if (!info->si_sbh) 362 + sbh = sb_bread(s, 0); 363 + if (!sbh) 335 364 goto out; 336 - bfs_sb = (struct bfs_super_block *)info->si_sbh->b_data; 365 + bfs_sb = (struct bfs_super_block *)sbh->b_data; 337 366 if (le32_to_cpu(bfs_sb->s_magic) != BFS_MAGIC) { 338 367 if (!silent) 339 368 printf("No BFS filesystem on %s (magic=%08x)\n", ··· 437 466 info->si_lf_eblk = eblock; 438 467 } 439 468 brelse(bh); 440 - if (!(s->s_flags & MS_RDONLY)) { 441 - mark_buffer_dirty(info->si_sbh); 442 - s->s_dirt = 1; 443 - } 469 + brelse(sbh); 444 470 dump_imap("read_super", s); 445 471 return 0; 446 472 ··· 447 479 out2: 448 480 kfree(info->si_imap); 449 481 out1: 450 - brelse(info->si_sbh); 482 + brelse(sbh); 451 483 out: 452 484 mutex_destroy(&info->bfs_lock); 453 485 kfree(info);