Commit 3f0be882 authored by Dave Hansen's avatar Dave Hansen Committed by Linus Torvalds

[PATCH] Locking in sync_old_buffers

Move BKL into the fs-specific write_super()'s.
parent d5cedb89
...@@ -110,7 +110,7 @@ put_inode: no ...@@ -110,7 +110,7 @@ put_inode: no
delete_inode: no delete_inode: no
clear_inode: no clear_inode: no
put_super: yes yes maybe (see below) put_super: yes yes maybe (see below)
write_super: yes yes maybe (see below) write_super: no yes maybe (see below)
statfs: yes no no statfs: yes no no
remount_fs: yes yes maybe (see below) remount_fs: yes yes maybe (see below)
umount_begin: yes no maybe (see below) umount_begin: yes no maybe (see below)
......
...@@ -38,7 +38,7 @@ static void ...@@ -38,7 +38,7 @@ static void
affs_put_super(struct super_block *sb) affs_put_super(struct super_block *sb)
{ {
struct affs_sb_info *sbi = AFFS_SB(sb); struct affs_sb_info *sbi = AFFS_SB(sb);
lock_kernel();
pr_debug("AFFS: put_super()\n"); pr_debug("AFFS: put_super()\n");
if (!(sb->s_flags & MS_RDONLY)) { if (!(sb->s_flags & MS_RDONLY)) {
...@@ -56,7 +56,7 @@ affs_put_super(struct super_block *sb) ...@@ -56,7 +56,7 @@ affs_put_super(struct super_block *sb)
affs_brelse(sbi->s_root_bh); affs_brelse(sbi->s_root_bh);
kfree(sbi); kfree(sbi);
sb->u.generic_sbp = NULL; sb->u.generic_sbp = NULL;
unlock_kernel();
return; return;
} }
...@@ -65,7 +65,7 @@ affs_write_super(struct super_block *sb) ...@@ -65,7 +65,7 @@ affs_write_super(struct super_block *sb)
{ {
int clean = 2; int clean = 2;
struct affs_sb_info *sbi = AFFS_SB(sb); struct affs_sb_info *sbi = AFFS_SB(sb);
lock_kernel();
if (!(sb->s_flags & MS_RDONLY)) { if (!(sb->s_flags & MS_RDONLY)) {
// if (sbi->s_bitmap[i].bm_bh) { // if (sbi->s_bitmap[i].bm_bh) {
// if (buffer_dirty(sbi->s_bitmap[i].bm_bh)) { // if (buffer_dirty(sbi->s_bitmap[i].bm_bh)) {
...@@ -80,6 +80,7 @@ affs_write_super(struct super_block *sb) ...@@ -80,6 +80,7 @@ affs_write_super(struct super_block *sb)
sb->s_dirt = 0; sb->s_dirt = 0;
pr_debug("AFFS: write_super() at %lu, clean=%d\n", CURRENT_TIME, clean); pr_debug("AFFS: write_super() at %lu, clean=%d\n", CURRENT_TIME, clean);
unlock_kernel();
} }
static kmem_cache_t * affs_inode_cachep; static kmem_cache_t * affs_inode_cachep;
......
...@@ -206,9 +206,11 @@ static int bfs_statfs(struct super_block *s, struct statfs *buf) ...@@ -206,9 +206,11 @@ static int bfs_statfs(struct super_block *s, struct statfs *buf)
static void bfs_write_super(struct super_block *s) static void bfs_write_super(struct super_block *s)
{ {
lock_kernel();
if (!(s->s_flags & MS_RDONLY)) if (!(s->s_flags & MS_RDONLY))
mark_buffer_dirty(BFS_SB(s)->si_sbh); mark_buffer_dirty(BFS_SB(s)->si_sbh);
s->s_dirt = 0; s->s_dirt = 0;
unlock_kernel();
} }
static kmem_cache_t * bfs_inode_cachep; static kmem_cache_t * bfs_inode_cachep;
......
...@@ -2612,10 +2612,8 @@ void __init buffer_init(unsigned long mempages) ...@@ -2612,10 +2612,8 @@ void __init buffer_init(unsigned long mempages)
static void sync_old_buffers(unsigned long dummy) static void sync_old_buffers(unsigned long dummy)
{ {
lock_kernel();
sync_unlocked_inodes(); sync_unlocked_inodes();
sync_supers(); sync_supers();
unlock_kernel();
for (;;) { for (;;) {
struct buffer_head *bh; struct buffer_head *bh;
......
...@@ -754,7 +754,7 @@ static void ext2_sync_super(struct super_block *sb, struct ext2_super_block *es) ...@@ -754,7 +754,7 @@ static void ext2_sync_super(struct super_block *sb, struct ext2_super_block *es)
void ext2_write_super (struct super_block * sb) void ext2_write_super (struct super_block * sb)
{ {
struct ext2_super_block * es; struct ext2_super_block * es;
lock_kernel();
if (!(sb->s_flags & MS_RDONLY)) { if (!(sb->s_flags & MS_RDONLY)) {
es = EXT2_SB(sb)->s_es; es = EXT2_SB(sb)->s_es;
...@@ -768,6 +768,7 @@ void ext2_write_super (struct super_block * sb) ...@@ -768,6 +768,7 @@ void ext2_write_super (struct super_block * sb)
ext2_commit_super (sb, es); ext2_commit_super (sb, es);
} }
sb->s_dirt = 0; sb->s_dirt = 0;
unlock_kernel();
} }
int ext2_remount (struct super_block * sb, int * flags, char * data) int ext2_remount (struct super_block * sb, int * flags, char * data)
......
...@@ -501,7 +501,7 @@ static struct super_operations ext3_sops = { ...@@ -501,7 +501,7 @@ static struct super_operations ext3_sops = {
put_inode: ext3_put_inode, /* BKL not held. Don't need */ put_inode: ext3_put_inode, /* BKL not held. Don't need */
delete_inode: ext3_delete_inode, /* BKL not held. We take it */ delete_inode: ext3_delete_inode, /* BKL not held. We take it */
put_super: ext3_put_super, /* BKL held */ put_super: ext3_put_super, /* BKL held */
write_super: ext3_write_super, /* BKL held */ write_super: ext3_write_super, /* BKL not held. We take it. Needed? */
write_super_lockfs: ext3_write_super_lockfs, /* BKL not held. Take it */ write_super_lockfs: ext3_write_super_lockfs, /* BKL not held. Take it */
unlockfs: ext3_unlockfs, /* BKL not held. We take it */ unlockfs: ext3_unlockfs, /* BKL not held. We take it */
statfs: ext3_statfs, /* BKL held */ statfs: ext3_statfs, /* BKL held */
...@@ -1599,7 +1599,7 @@ MODULE_PARM_DESC(do_sync_supers, "Write superblocks synchronously"); ...@@ -1599,7 +1599,7 @@ MODULE_PARM_DESC(do_sync_supers, "Write superblocks synchronously");
void ext3_write_super (struct super_block * sb) void ext3_write_super (struct super_block * sb)
{ {
tid_t target; tid_t target;
lock_kernel();
if (down_trylock(&sb->s_lock) == 0) if (down_trylock(&sb->s_lock) == 0)
BUG(); /* aviro detector */ BUG(); /* aviro detector */
sb->s_dirt = 0; sb->s_dirt = 0;
...@@ -1610,6 +1610,7 @@ void ext3_write_super (struct super_block * sb) ...@@ -1610,6 +1610,7 @@ void ext3_write_super (struct super_block * sb)
log_wait_commit(EXT3_SB(sb)->s_journal, target); log_wait_commit(EXT3_SB(sb)->s_journal, target);
lock_super(sb); lock_super(sb);
} }
unlock_kernel();
} }
/* /*
......
...@@ -146,9 +146,10 @@ static void hfs_read_inode(struct inode *inode) ...@@ -146,9 +146,10 @@ static void hfs_read_inode(struct inode *inode)
static void hfs_write_super(struct super_block *sb) static void hfs_write_super(struct super_block *sb)
{ {
struct hfs_mdb *mdb = HFS_SB(sb)->s_mdb; struct hfs_mdb *mdb = HFS_SB(sb)->s_mdb;
lock_kernel();
/* is this a valid hfs superblock? */ /* is this a valid hfs superblock? */
if (!sb || sb->s_magic != HFS_SUPER_MAGIC) { if (!sb || sb->s_magic != HFS_SUPER_MAGIC) {
unlock_kernel();
return; return;
} }
...@@ -157,6 +158,7 @@ static void hfs_write_super(struct super_block *sb) ...@@ -157,6 +158,7 @@ static void hfs_write_super(struct super_block *sb)
hfs_mdb_commit(mdb, 0); hfs_mdb_commit(mdb, 0);
} }
sb->s_dirt = 0; sb->s_dirt = 0;
unlock_kernel();
} }
/* /*
......
...@@ -1746,8 +1746,9 @@ void ...@@ -1746,8 +1746,9 @@ void
jffs_write_super(struct super_block *sb) jffs_write_super(struct super_block *sb)
{ {
struct jffs_control *c = (struct jffs_control *)sb->u.generic_sbp; struct jffs_control *c = (struct jffs_control *)sb->u.generic_sbp;
lock_kernel();
jffs_garbage_collect_trigger(c); jffs_garbage_collect_trigger(c);
unlock_kernel();
} }
static struct super_operations jffs_ops = static struct super_operations jffs_ops =
......
...@@ -320,16 +320,21 @@ int jffs2_remount_fs (struct super_block *sb, int *flags, char *data) ...@@ -320,16 +320,21 @@ int jffs2_remount_fs (struct super_block *sb, int *flags, char *data)
void jffs2_write_super (struct super_block *sb) void jffs2_write_super (struct super_block *sb)
{ {
struct jffs2_sb_info *c = JFFS2_SB_INFO(sb); struct jffs2_sb_info *c = JFFS2_SB_INFO(sb);
lock_kernel();
sb->s_dirt = 0; sb->s_dirt = 0;
if (sb->s_flags & MS_RDONLY) if (sb->s_flags & MS_RDONLY) {
unlock_kernel();
return; return;
}
D1(printk("jffs2_write_super(): flush_wbuf before gc-trigger\n")); D1(printk("jffs2_write_super(): flush_wbuf before gc-trigger\n"));
jffs2_flush_wbuf(c, 2); jffs2_flush_wbuf(c, 2);
jffs2_garbage_collect_trigger(c); jffs2_garbage_collect_trigger(c);
jffs2_erase_pending_blocks(c); jffs2_erase_pending_blocks(c);
jffs2_mark_erased_blocks(c); jffs2_mark_erased_blocks(c);
unlock_kernel();
} }
......
...@@ -72,8 +72,10 @@ static void qnx4_delete_inode(struct inode *inode) ...@@ -72,8 +72,10 @@ static void qnx4_delete_inode(struct inode *inode)
static void qnx4_write_super(struct super_block *sb) static void qnx4_write_super(struct super_block *sb)
{ {
lock_kernel();
QNX4DEBUG(("qnx4: write_super\n")); QNX4DEBUG(("qnx4: write_super\n"));
sb->s_dirt = 0; sb->s_dirt = 0;
unlock_kernel();
} }
static void qnx4_write_inode(struct inode *inode, int unused) static void qnx4_write_inode(struct inode *inode, int unused)
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
/* This is only called on sync() and umount(), when s_dirt=1. */ /* This is only called on sync() and umount(), when s_dirt=1. */
static void sysv_write_super(struct super_block *sb) static void sysv_write_super(struct super_block *sb)
{ {
lock_kernel();
if (!(sb->s_flags & MS_RDONLY)) { if (!(sb->s_flags & MS_RDONLY)) {
/* If we are going to write out the super block, /* If we are going to write out the super block,
then attach current time stamp. then attach current time stamp.
...@@ -46,6 +47,7 @@ static void sysv_write_super(struct super_block *sb) ...@@ -46,6 +47,7 @@ static void sysv_write_super(struct super_block *sb)
mark_buffer_dirty(sb->sv_bh2); mark_buffer_dirty(sb->sv_bh2);
} }
sb->s_dirt = 0; sb->s_dirt = 0;
unlock_kernel();
} }
static void sysv_put_super(struct super_block *sb) static void sysv_put_super(struct super_block *sb)
......
...@@ -359,9 +359,11 @@ udf_parse_options(char *options, struct udf_options *uopt) ...@@ -359,9 +359,11 @@ udf_parse_options(char *options, struct udf_options *uopt)
void void
udf_write_super(struct super_block *sb) udf_write_super(struct super_block *sb)
{ {
lock_kernel();
if (!(sb->s_flags & MS_RDONLY)) if (!(sb->s_flags & MS_RDONLY))
udf_open_lvid(sb); udf_open_lvid(sb);
sb->s_dirt = 0; sb->s_dirt = 0;
unlock_kernel();
} }
static int static int
......
...@@ -822,6 +822,8 @@ void ufs_write_super (struct super_block * sb) { ...@@ -822,6 +822,8 @@ void ufs_write_super (struct super_block * sb) {
struct ufs_super_block_third * usb3; struct ufs_super_block_third * usb3;
unsigned flags; unsigned flags;
lock_kernel();
UFSD(("ENTER\n")) UFSD(("ENTER\n"))
flags = sb->u.ufs_sb.s_flags; flags = sb->u.ufs_sb.s_flags;
uspi = sb->u.ufs_sb.s_uspi; uspi = sb->u.ufs_sb.s_uspi;
...@@ -838,6 +840,7 @@ void ufs_write_super (struct super_block * sb) { ...@@ -838,6 +840,7 @@ void ufs_write_super (struct super_block * sb) {
} }
sb->s_dirt = 0; sb->s_dirt = 0;
UFSD(("EXIT\n")) UFSD(("EXIT\n"))
unlock_kernel();
} }
void ufs_put_super (struct super_block * sb) void ufs_put_super (struct super_block * sb)
......
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