diff options
author | Christoph Hellwig <hch@lst.de> | 2009-05-11 17:35:03 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2009-06-11 21:36:09 -0400 |
commit | ebc1ac164560a241d9bf1b7519062910c3f90a01 (patch) | |
tree | db17fd3043b15f8269cce2c2d00213814022fc30 | |
parent | 01ba687577647beef6c5f2ea59bfb56fac9fcde2 (diff) |
->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>
-rw-r--r-- | fs/affs/super.c | 2 | ||||
-rw-r--r-- | fs/exofs/super.c | 2 | ||||
-rw-r--r-- | fs/ext4/super.c | 4 | ||||
-rw-r--r-- | fs/fat/inode.c | 2 | ||||
-rw-r--r-- | fs/hfs/super.c | 8 | ||||
-rw-r--r-- | fs/hfsplus/super.c | 6 | ||||
-rw-r--r-- | fs/jffs2/super.c | 15 | ||||
-rw-r--r-- | fs/super.c | 2 | ||||
-rw-r--r-- | fs/sync.c | 4 | ||||
-rw-r--r-- | fs/sysv/inode.c | 2 | ||||
-rw-r--r-- | fs/ufs/super.c | 2 |
11 files changed, 32 insertions, 17 deletions
diff --git a/fs/affs/super.c b/fs/affs/super.c index d7386462a8e7..280d361af41f 100644 --- a/fs/affs/super.c +++ b/fs/affs/super.c | |||
@@ -54,6 +54,7 @@ affs_write_super(struct super_block *sb) | |||
54 | int clean = 2; | 54 | int clean = 2; |
55 | struct affs_sb_info *sbi = AFFS_SB(sb); | 55 | struct affs_sb_info *sbi = AFFS_SB(sb); |
56 | 56 | ||
57 | lock_super(sb); | ||
57 | if (!(sb->s_flags & MS_RDONLY)) { | 58 | if (!(sb->s_flags & MS_RDONLY)) { |
58 | // if (sbi->s_bitmap[i].bm_bh) { | 59 | // if (sbi->s_bitmap[i].bm_bh) { |
59 | // if (buffer_dirty(sbi->s_bitmap[i].bm_bh)) { | 60 | // if (buffer_dirty(sbi->s_bitmap[i].bm_bh)) { |
@@ -66,6 +67,7 @@ affs_write_super(struct super_block *sb) | |||
66 | sb->s_dirt = !clean; /* redo until bitmap synced */ | 67 | sb->s_dirt = !clean; /* redo until bitmap synced */ |
67 | } else | 68 | } else |
68 | sb->s_dirt = 0; | 69 | sb->s_dirt = 0; |
70 | unlock_super(sb); | ||
69 | 71 | ||
70 | pr_debug("AFFS: write_super() at %lu, clean=%d\n", get_seconds(), clean); | 72 | pr_debug("AFFS: write_super() at %lu, clean=%d\n", get_seconds(), clean); |
71 | } | 73 | } |
diff --git a/fs/exofs/super.c b/fs/exofs/super.c index cd1f8b18a218..49e16af4e619 100644 --- a/fs/exofs/super.c +++ b/fs/exofs/super.c | |||
@@ -214,6 +214,7 @@ static void exofs_write_super(struct super_block *sb) | |||
214 | return; | 214 | return; |
215 | } | 215 | } |
216 | 216 | ||
217 | lock_super(sb); | ||
217 | lock_kernel(); | 218 | lock_kernel(); |
218 | sbi = sb->s_fs_info; | 219 | sbi = sb->s_fs_info; |
219 | fscb->s_nextid = cpu_to_le64(sbi->s_nextid); | 220 | fscb->s_nextid = cpu_to_le64(sbi->s_nextid); |
@@ -246,6 +247,7 @@ out: | |||
246 | if (or) | 247 | if (or) |
247 | osd_end_request(or); | 248 | osd_end_request(or); |
248 | unlock_kernel(); | 249 | unlock_kernel(); |
250 | unlock_super(sb); | ||
249 | kfree(fscb); | 251 | kfree(fscb); |
250 | } | 252 | } |
251 | 253 | ||
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index a9c683425929..c17200a42301 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c | |||
@@ -579,7 +579,7 @@ static void ext4_put_super(struct super_block *sb) | |||
579 | lock_super(sb); | 579 | lock_super(sb); |
580 | lock_kernel(); | 580 | lock_kernel(); |
581 | if (sb->s_dirt) | 581 | if (sb->s_dirt) |
582 | ext4_write_super(sb); | 582 | ext4_commit_super(sb, 1); |
583 | 583 | ||
584 | ext4_release_system_zone(sb); | 584 | ext4_release_system_zone(sb); |
585 | ext4_mb_release(sb); | 585 | ext4_mb_release(sb); |
@@ -3336,7 +3336,9 @@ int ext4_force_commit(struct super_block *sb) | |||
3336 | 3336 | ||
3337 | static void ext4_write_super(struct super_block *sb) | 3337 | static void ext4_write_super(struct super_block *sb) |
3338 | { | 3338 | { |
3339 | lock_super(sb); | ||
3339 | ext4_commit_super(sb, 1); | 3340 | ext4_commit_super(sb, 1); |
3341 | unlock_super(sb); | ||
3340 | } | 3342 | } |
3341 | 3343 | ||
3342 | static int ext4_sync_fs(struct super_block *sb, int wait) | 3344 | static int ext4_sync_fs(struct super_block *sb, int wait) |
diff --git a/fs/fat/inode.c b/fs/fat/inode.c index 2b88c93af227..2292cbf7d364 100644 --- a/fs/fat/inode.c +++ b/fs/fat/inode.c | |||
@@ -441,10 +441,12 @@ static void fat_clear_inode(struct inode *inode) | |||
441 | 441 | ||
442 | static void fat_write_super(struct super_block *sb) | 442 | static void fat_write_super(struct super_block *sb) |
443 | { | 443 | { |
444 | lock_super(sb); | ||
444 | sb->s_dirt = 0; | 445 | sb->s_dirt = 0; |
445 | 446 | ||
446 | if (!(sb->s_flags & MS_RDONLY)) | 447 | if (!(sb->s_flags & MS_RDONLY)) |
447 | fat_clusters_flush(sb); | 448 | fat_clusters_flush(sb); |
449 | unlock_super(sb); | ||
448 | } | 450 | } |
449 | 451 | ||
450 | static void fat_put_super(struct super_block *sb) | 452 | static void fat_put_super(struct super_block *sb) |
diff --git a/fs/hfs/super.c b/fs/hfs/super.c index 9f5eaa01cc77..3aac41751030 100644 --- a/fs/hfs/super.c +++ b/fs/hfs/super.c | |||
@@ -49,11 +49,13 @@ MODULE_LICENSE("GPL"); | |||
49 | */ | 49 | */ |
50 | static void hfs_write_super(struct super_block *sb) | 50 | static void hfs_write_super(struct super_block *sb) |
51 | { | 51 | { |
52 | lock_super(sb); | ||
52 | sb->s_dirt = 0; | 53 | sb->s_dirt = 0; |
53 | if (sb->s_flags & MS_RDONLY) | 54 | |
54 | return; | ||
55 | /* sync everything to the buffers */ | 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 | /* |
diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c index 9b292dcc39c8..1aab8aa7801e 100644 --- a/fs/hfsplus/super.c +++ b/fs/hfsplus/super.c | |||
@@ -157,10 +157,12 @@ static void hfsplus_write_super(struct super_block *sb) | |||
157 | struct hfsplus_vh *vhdr = HFSPLUS_SB(sb).s_vhdr; | 157 | struct hfsplus_vh *vhdr = HFSPLUS_SB(sb).s_vhdr; |
158 | 158 | ||
159 | dprint(DBG_SUPER, "hfsplus_write_super\n"); | 159 | dprint(DBG_SUPER, "hfsplus_write_super\n"); |
160 | |||
161 | lock_super(sb); | ||
160 | sb->s_dirt = 0; | 162 | sb->s_dirt = 0; |
161 | if (sb->s_flags & MS_RDONLY) | 163 | if (sb->s_flags & MS_RDONLY) |
162 | /* warn? */ | 164 | /* warn? */ |
163 | return; | 165 | goto out; |
164 | 166 | ||
165 | vhdr->free_blocks = cpu_to_be32(HFSPLUS_SB(sb).free_blocks); | 167 | vhdr->free_blocks = cpu_to_be32(HFSPLUS_SB(sb).free_blocks); |
166 | vhdr->next_alloc = cpu_to_be32(HFSPLUS_SB(sb).next_alloc); | 168 | vhdr->next_alloc = cpu_to_be32(HFSPLUS_SB(sb).next_alloc); |
@@ -192,6 +194,8 @@ static void hfsplus_write_super(struct super_block *sb) | |||
192 | } | 194 | } |
193 | HFSPLUS_SB(sb).flags &= ~HFSPLUS_SB_WRITEBACKUP; | 195 | HFSPLUS_SB(sb).flags &= ~HFSPLUS_SB_WRITEBACKUP; |
194 | } | 196 | } |
197 | out: | ||
198 | unlock_super(sb); | ||
195 | } | 199 | } |
196 | 200 | ||
197 | static void hfsplus_put_super(struct super_block *sb) | 201 | static void hfsplus_put_super(struct super_block *sb) |
diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c index a80a50e445e2..f7bfd3ac8bfa 100644 --- a/fs/jffs2/super.c +++ b/fs/jffs2/super.c | |||
@@ -56,15 +56,18 @@ static void jffs2_i_init_once(void *foo) | |||
56 | static void jffs2_write_super(struct super_block *sb) | 56 | static void jffs2_write_super(struct super_block *sb) |
57 | { | 57 | { |
58 | struct jffs2_sb_info *c = JFFS2_SB_INFO(sb); | 58 | struct jffs2_sb_info *c = JFFS2_SB_INFO(sb); |
59 | |||
60 | lock_super(sb); | ||
59 | sb->s_dirt = 0; | 61 | sb->s_dirt = 0; |
60 | 62 | ||
61 | if (sb->s_flags & MS_RDONLY) | 63 | if (!(sb->s_flags & MS_RDONLY)) { |
62 | return; | 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")); | 70 | unlock_super(sb); |
65 | jffs2_garbage_collect_trigger(c); | ||
66 | jffs2_erase_pending_blocks(c, 0); | ||
67 | jffs2_flush_wbuf_gc(c, 0); | ||
68 | } | 71 | } |
69 | 72 | ||
70 | static int jffs2_sync_fs(struct super_block *sb, int wait) | 73 | static int jffs2_sync_fs(struct super_block *sb, int wait) |
diff --git a/fs/super.c b/fs/super.c index a64f36208797..1905f4af01cc 100644 --- a/fs/super.c +++ b/fs/super.c | |||
@@ -420,10 +420,8 @@ restart: | |||
420 | spin_unlock(&sb_lock); | 420 | spin_unlock(&sb_lock); |
421 | 421 | ||
422 | down_read(&sb->s_umount); | 422 | down_read(&sb->s_umount); |
423 | lock_super(sb); | ||
424 | if (sb->s_root && sb->s_dirt) | 423 | if (sb->s_root && sb->s_dirt) |
425 | sb->s_op->write_super(sb); | 424 | sb->s_op->write_super(sb); |
426 | unlock_super(sb); | ||
427 | up_read(&sb->s_umount); | 425 | up_read(&sb->s_umount); |
428 | 426 | ||
429 | spin_lock(&sb_lock); | 427 | spin_lock(&sb_lock); |
@@ -33,10 +33,8 @@ static int __sync_filesystem(struct super_block *sb, int wait) | |||
33 | else | 33 | else |
34 | sync_quota_sb(sb, -1); | 34 | sync_quota_sb(sb, -1); |
35 | sync_inodes_sb(sb, wait); | 35 | sync_inodes_sb(sb, wait); |
36 | lock_super(sb); | ||
37 | if (sb->s_dirt && sb->s_op->write_super) | 36 | if (sb->s_dirt && sb->s_op->write_super) |
38 | sb->s_op->write_super(sb); | 37 | sb->s_op->write_super(sb); |
39 | unlock_super(sb); | ||
40 | if (sb->s_op->sync_fs) | 38 | if (sb->s_op->sync_fs) |
41 | sb->s_op->sync_fs(sb, wait); | 39 | sb->s_op->sync_fs(sb, wait); |
42 | return __sync_blockdev(sb->s_bdev, wait); | 40 | return __sync_blockdev(sb->s_bdev, wait); |
@@ -164,10 +162,8 @@ int file_fsync(struct file *filp, struct dentry *dentry, int datasync) | |||
164 | 162 | ||
165 | /* sync the superblock to buffers */ | 163 | /* sync the superblock to buffers */ |
166 | sb = inode->i_sb; | 164 | sb = inode->i_sb; |
167 | lock_super(sb); | ||
168 | if (sb->s_dirt && sb->s_op->write_super) | 165 | if (sb->s_dirt && sb->s_op->write_super) |
169 | sb->s_op->write_super(sb); | 166 | sb->s_op->write_super(sb); |
170 | unlock_super(sb); | ||
171 | 167 | ||
172 | /* .. finally sync the buffers to disk */ | 168 | /* .. finally sync the buffers to disk */ |
173 | err = sync_blockdev(sb->s_bdev); | 169 | err = sync_blockdev(sb->s_bdev); |
diff --git a/fs/sysv/inode.c b/fs/sysv/inode.c index e0a39f1fb88e..a3f45fc626a1 100644 --- a/fs/sysv/inode.c +++ b/fs/sysv/inode.c | |||
@@ -37,6 +37,7 @@ static void sysv_write_super(struct super_block *sb) | |||
37 | struct sysv_sb_info *sbi = SYSV_SB(sb); | 37 | struct sysv_sb_info *sbi = SYSV_SB(sb); |
38 | unsigned long time = get_seconds(), old_time; | 38 | unsigned long time = get_seconds(), old_time; |
39 | 39 | ||
40 | lock_super(sb); | ||
40 | lock_kernel(); | 41 | lock_kernel(); |
41 | if (sb->s_flags & MS_RDONLY) | 42 | if (sb->s_flags & MS_RDONLY) |
42 | goto clean; | 43 | goto clean; |
@@ -56,6 +57,7 @@ static void sysv_write_super(struct super_block *sb) | |||
56 | clean: | 57 | clean: |
57 | sb->s_dirt = 0; | 58 | sb->s_dirt = 0; |
58 | unlock_kernel(); | 59 | unlock_kernel(); |
60 | unlock_super(sb); | ||
59 | } | 61 | } |
60 | 62 | ||
61 | static int sysv_remount(struct super_block *sb, int *flags, char *data) | 63 | static int sysv_remount(struct super_block *sb, int *flags, char *data) |
diff --git a/fs/ufs/super.c b/fs/ufs/super.c index a5ecabfdc976..c97210ee0670 100644 --- a/fs/ufs/super.c +++ b/fs/ufs/super.c | |||
@@ -1131,6 +1131,7 @@ static void ufs_write_super(struct super_block *sb) | |||
1131 | struct ufs_super_block_third * usb3; | 1131 | struct ufs_super_block_third * usb3; |
1132 | unsigned flags; | 1132 | unsigned flags; |
1133 | 1133 | ||
1134 | lock_super(sb); | ||
1134 | lock_kernel(); | 1135 | lock_kernel(); |
1135 | UFSD("ENTER\n"); | 1136 | UFSD("ENTER\n"); |
1136 | flags = UFS_SB(sb)->s_flags; | 1137 | flags = UFS_SB(sb)->s_flags; |
@@ -1150,6 +1151,7 @@ static void ufs_write_super(struct super_block *sb) | |||
1150 | sb->s_dirt = 0; | 1151 | sb->s_dirt = 0; |
1151 | UFSD("EXIT\n"); | 1152 | UFSD("EXIT\n"); |
1152 | unlock_kernel(); | 1153 | unlock_kernel(); |
1154 | unlock_super(sb); | ||
1153 | } | 1155 | } |
1154 | 1156 | ||
1155 | static void ufs_put_super(struct super_block *sb) | 1157 | static void ufs_put_super(struct super_block *sb) |