Commit ebc1ac164560a241d9bf1b7519062910c3f90a01
Committed by
Al Viro
1 parent
01ba687577
Exists in
master
and in
4 other branches
->write_super lock_super pushdown
Push down lock_super into ->write_super instances and remove it from the caller. Following filesystem don't need ->s_lock in ->write_super and are skipped: * bfs, nilfs2 - no other uses of s_lock and have internal locks in ->write_super * ext2 - uses BKL in ext2_write_super and has internal calls without s_lock * reiserfs - no other uses of s_lock as has reiserfs_write_lock (BKL) in ->write_super * xfs - no other uses of s_lock and uses internal lock (buffer lock on superblock buffer) to serialize ->write_super. Also xfs_fs_write_super is superflous and will go away in the next merge window Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Showing 11 changed files with 32 additions and 17 deletions Side-by-side Diff
fs/affs/super.c
... | ... | @@ -54,6 +54,7 @@ |
54 | 54 | int clean = 2; |
55 | 55 | struct affs_sb_info *sbi = AFFS_SB(sb); |
56 | 56 | |
57 | + lock_super(sb); | |
57 | 58 | if (!(sb->s_flags & MS_RDONLY)) { |
58 | 59 | // if (sbi->s_bitmap[i].bm_bh) { |
59 | 60 | // if (buffer_dirty(sbi->s_bitmap[i].bm_bh)) { |
... | ... | @@ -66,6 +67,7 @@ |
66 | 67 | sb->s_dirt = !clean; /* redo until bitmap synced */ |
67 | 68 | } else |
68 | 69 | sb->s_dirt = 0; |
70 | + unlock_super(sb); | |
69 | 71 | |
70 | 72 | pr_debug("AFFS: write_super() at %lu, clean=%d\n", get_seconds(), clean); |
71 | 73 | } |
fs/exofs/super.c
... | ... | @@ -214,6 +214,7 @@ |
214 | 214 | return; |
215 | 215 | } |
216 | 216 | |
217 | + lock_super(sb); | |
217 | 218 | lock_kernel(); |
218 | 219 | sbi = sb->s_fs_info; |
219 | 220 | fscb->s_nextid = cpu_to_le64(sbi->s_nextid); |
... | ... | @@ -246,6 +247,7 @@ |
246 | 247 | if (or) |
247 | 248 | osd_end_request(or); |
248 | 249 | unlock_kernel(); |
250 | + unlock_super(sb); | |
249 | 251 | kfree(fscb); |
250 | 252 | } |
251 | 253 |
fs/ext4/super.c
... | ... | @@ -579,7 +579,7 @@ |
579 | 579 | lock_super(sb); |
580 | 580 | lock_kernel(); |
581 | 581 | if (sb->s_dirt) |
582 | - ext4_write_super(sb); | |
582 | + ext4_commit_super(sb, 1); | |
583 | 583 | |
584 | 584 | ext4_release_system_zone(sb); |
585 | 585 | ext4_mb_release(sb); |
586 | 586 | |
... | ... | @@ -3336,7 +3336,9 @@ |
3336 | 3336 | |
3337 | 3337 | static void ext4_write_super(struct super_block *sb) |
3338 | 3338 | { |
3339 | + lock_super(sb); | |
3339 | 3340 | ext4_commit_super(sb, 1); |
3341 | + unlock_super(sb); | |
3340 | 3342 | } |
3341 | 3343 | |
3342 | 3344 | static int ext4_sync_fs(struct super_block *sb, int wait) |
fs/fat/inode.c
... | ... | @@ -441,10 +441,12 @@ |
441 | 441 | |
442 | 442 | static void fat_write_super(struct super_block *sb) |
443 | 443 | { |
444 | + lock_super(sb); | |
444 | 445 | sb->s_dirt = 0; |
445 | 446 | |
446 | 447 | if (!(sb->s_flags & MS_RDONLY)) |
447 | 448 | fat_clusters_flush(sb); |
449 | + unlock_super(sb); | |
448 | 450 | } |
449 | 451 | |
450 | 452 | static void fat_put_super(struct super_block *sb) |
fs/hfs/super.c
... | ... | @@ -49,11 +49,13 @@ |
49 | 49 | */ |
50 | 50 | static void hfs_write_super(struct super_block *sb) |
51 | 51 | { |
52 | + lock_super(sb); | |
52 | 53 | sb->s_dirt = 0; |
53 | - if (sb->s_flags & MS_RDONLY) | |
54 | - return; | |
54 | + | |
55 | 55 | /* sync everything to the buffers */ |
56 | - hfs_mdb_commit(sb); | |
56 | + if (!(sb->s_flags & MS_RDONLY)) | |
57 | + hfs_mdb_commit(sb); | |
58 | + unlock_super(sb); | |
57 | 59 | } |
58 | 60 | |
59 | 61 | /* |
fs/hfsplus/super.c
... | ... | @@ -157,10 +157,12 @@ |
157 | 157 | struct hfsplus_vh *vhdr = HFSPLUS_SB(sb).s_vhdr; |
158 | 158 | |
159 | 159 | dprint(DBG_SUPER, "hfsplus_write_super\n"); |
160 | + | |
161 | + lock_super(sb); | |
160 | 162 | sb->s_dirt = 0; |
161 | 163 | if (sb->s_flags & MS_RDONLY) |
162 | 164 | /* warn? */ |
163 | - return; | |
165 | + goto out; | |
164 | 166 | |
165 | 167 | vhdr->free_blocks = cpu_to_be32(HFSPLUS_SB(sb).free_blocks); |
166 | 168 | vhdr->next_alloc = cpu_to_be32(HFSPLUS_SB(sb).next_alloc); |
... | ... | @@ -192,6 +194,8 @@ |
192 | 194 | } |
193 | 195 | HFSPLUS_SB(sb).flags &= ~HFSPLUS_SB_WRITEBACKUP; |
194 | 196 | } |
197 | + out: | |
198 | + unlock_super(sb); | |
195 | 199 | } |
196 | 200 | |
197 | 201 | static void hfsplus_put_super(struct super_block *sb) |
fs/jffs2/super.c
... | ... | @@ -56,15 +56,18 @@ |
56 | 56 | static void jffs2_write_super(struct super_block *sb) |
57 | 57 | { |
58 | 58 | struct jffs2_sb_info *c = JFFS2_SB_INFO(sb); |
59 | + | |
60 | + lock_super(sb); | |
59 | 61 | sb->s_dirt = 0; |
60 | 62 | |
61 | - if (sb->s_flags & MS_RDONLY) | |
62 | - return; | |
63 | + if (!(sb->s_flags & MS_RDONLY)) { | |
64 | + D1(printk(KERN_DEBUG "jffs2_write_super()\n")); | |
65 | + jffs2_garbage_collect_trigger(c); | |
66 | + jffs2_erase_pending_blocks(c, 0); | |
67 | + jffs2_flush_wbuf_gc(c, 0); | |
68 | + } | |
63 | 69 | |
64 | - D1(printk(KERN_DEBUG "jffs2_write_super()\n")); | |
65 | - jffs2_garbage_collect_trigger(c); | |
66 | - jffs2_erase_pending_blocks(c, 0); | |
67 | - jffs2_flush_wbuf_gc(c, 0); | |
70 | + unlock_super(sb); | |
68 | 71 | } |
69 | 72 | |
70 | 73 | static int jffs2_sync_fs(struct super_block *sb, int wait) |
fs/super.c
fs/sync.c
... | ... | @@ -33,10 +33,8 @@ |
33 | 33 | else |
34 | 34 | sync_quota_sb(sb, -1); |
35 | 35 | sync_inodes_sb(sb, wait); |
36 | - lock_super(sb); | |
37 | 36 | if (sb->s_dirt && sb->s_op->write_super) |
38 | 37 | sb->s_op->write_super(sb); |
39 | - unlock_super(sb); | |
40 | 38 | if (sb->s_op->sync_fs) |
41 | 39 | sb->s_op->sync_fs(sb, wait); |
42 | 40 | return __sync_blockdev(sb->s_bdev, wait); |
43 | 41 | |
... | ... | @@ -164,10 +162,8 @@ |
164 | 162 | |
165 | 163 | /* sync the superblock to buffers */ |
166 | 164 | sb = inode->i_sb; |
167 | - lock_super(sb); | |
168 | 165 | if (sb->s_dirt && sb->s_op->write_super) |
169 | 166 | sb->s_op->write_super(sb); |
170 | - unlock_super(sb); | |
171 | 167 | |
172 | 168 | /* .. finally sync the buffers to disk */ |
173 | 169 | err = sync_blockdev(sb->s_bdev); |
fs/sysv/inode.c
... | ... | @@ -37,6 +37,7 @@ |
37 | 37 | struct sysv_sb_info *sbi = SYSV_SB(sb); |
38 | 38 | unsigned long time = get_seconds(), old_time; |
39 | 39 | |
40 | + lock_super(sb); | |
40 | 41 | lock_kernel(); |
41 | 42 | if (sb->s_flags & MS_RDONLY) |
42 | 43 | goto clean; |
... | ... | @@ -56,6 +57,7 @@ |
56 | 57 | clean: |
57 | 58 | sb->s_dirt = 0; |
58 | 59 | unlock_kernel(); |
60 | + unlock_super(sb); | |
59 | 61 | } |
60 | 62 | |
61 | 63 | static int sysv_remount(struct super_block *sb, int *flags, char *data) |
fs/ufs/super.c
... | ... | @@ -1131,6 +1131,7 @@ |
1131 | 1131 | struct ufs_super_block_third * usb3; |
1132 | 1132 | unsigned flags; |
1133 | 1133 | |
1134 | + lock_super(sb); | |
1134 | 1135 | lock_kernel(); |
1135 | 1136 | UFSD("ENTER\n"); |
1136 | 1137 | flags = UFS_SB(sb)->s_flags; |
... | ... | @@ -1150,6 +1151,7 @@ |
1150 | 1151 | sb->s_dirt = 0; |
1151 | 1152 | UFSD("EXIT\n"); |
1152 | 1153 | unlock_kernel(); |
1154 | + unlock_super(sb); | |
1153 | 1155 | } |
1154 | 1156 | |
1155 | 1157 | static void ufs_put_super(struct super_block *sb) |