aboutsummaryrefslogtreecommitdiffstats
path: root/fs/affs/super.c
diff options
context:
space:
mode:
authorArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2012-06-06 11:56:57 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2012-07-14 08:32:45 -0400
commit3dd847820d138c9d60764b0e920380373285ff10 (patch)
tree3eb6584eac00b8a6cf859d003ad0c1940e7e299c /fs/affs/super.c
parenta215fef7edfdcd8948037ceb3060b9ae7ebcef8b (diff)
affs: get rid of affs_sync_super
This patch makes affs stop using the VFS '->write_super()' method along with the 's_dirt' superblock flag, because they are on their way out. The whole "superblock write-out" VFS infrastructure is served by the 'sync_supers()' kernel thread, which wakes up every 5 (by default) seconds and writes out all dirty superblocks using the '->write_super()' call-back. But the problem with this thread is that it wastes power by waking up the system every 5 seconds, even if there are no diry superblocks, or there are no client file-systems which would need this (e.g., btrfs does not use '->write_super()'). So we want to kill it completely and thus, we need to make file-systems to stop using the '->write_super()' VFS service, and then remove it together with the kernel thread. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/affs/super.c')
-rw-r--r--fs/affs/super.c48
1 files changed, 37 insertions, 11 deletions
diff --git a/fs/affs/super.c b/fs/affs/super.c
index 0496cbbeda1b..c70f1e5fc024 100644
--- a/fs/affs/super.c
+++ b/fs/affs/super.c
@@ -17,6 +17,7 @@
17#include <linux/magic.h> 17#include <linux/magic.h>
18#include <linux/sched.h> 18#include <linux/sched.h>
19#include <linux/slab.h> 19#include <linux/slab.h>
20#include <linux/writeback.h>
20#include "affs.h" 21#include "affs.h"
21 22
22extern struct timezone sys_tz; 23extern struct timezone sys_tz;
@@ -47,6 +48,7 @@ affs_put_super(struct super_block *sb)
47 struct affs_sb_info *sbi = AFFS_SB(sb); 48 struct affs_sb_info *sbi = AFFS_SB(sb);
48 pr_debug("AFFS: put_super()\n"); 49 pr_debug("AFFS: put_super()\n");
49 50
51 cancel_delayed_work_sync(&sbi->sb_work);
50 kfree(sbi->s_prefix); 52 kfree(sbi->s_prefix);
51 affs_free_bitmap(sb); 53 affs_free_bitmap(sb);
52 affs_brelse(sbi->s_root_bh); 54 affs_brelse(sbi->s_root_bh);
@@ -54,23 +56,45 @@ affs_put_super(struct super_block *sb)
54 sb->s_fs_info = NULL; 56 sb->s_fs_info = NULL;
55} 57}
56 58
57static void
58affs_write_super(struct super_block *sb)
59{
60 if (!(sb->s_flags & MS_RDONLY))
61 affs_commit_super(sb, 1);
62 sb->s_dirt = 0;
63 pr_debug("AFFS: write_super() at %lu, clean=2\n", get_seconds());
64}
65
66static int 59static int
67affs_sync_fs(struct super_block *sb, int wait) 60affs_sync_fs(struct super_block *sb, int wait)
68{ 61{
69 affs_commit_super(sb, wait); 62 affs_commit_super(sb, wait);
70 sb->s_dirt = 0;
71 return 0; 63 return 0;
72} 64}
73 65
66static void flush_superblock(struct work_struct *work)
67{
68 struct affs_sb_info *sbi;
69 struct super_block *sb;
70
71 sbi = container_of(work, struct affs_sb_info, sb_work.work);
72 sb = sbi->sb;
73
74 spin_lock(&sbi->work_lock);
75 sbi->work_queued = 0;
76 spin_unlock(&sbi->work_lock);
77
78 affs_commit_super(sb, 1);
79}
80
81void affs_mark_sb_dirty(struct super_block *sb)
82{
83 struct affs_sb_info *sbi = AFFS_SB(sb);
84 unsigned long delay;
85
86 if (sb->s_flags & MS_RDONLY)
87 return;
88
89 spin_lock(&sbi->work_lock);
90 if (!sbi->work_queued) {
91 delay = msecs_to_jiffies(dirty_writeback_interval * 10);
92 queue_delayed_work(system_long_wq, &sbi->sb_work, delay);
93 sbi->work_queued = 1;
94 }
95 spin_unlock(&sbi->work_lock);
96}
97
74static struct kmem_cache * affs_inode_cachep; 98static struct kmem_cache * affs_inode_cachep;
75 99
76static struct inode *affs_alloc_inode(struct super_block *sb) 100static struct inode *affs_alloc_inode(struct super_block *sb)
@@ -132,7 +156,6 @@ static const struct super_operations affs_sops = {
132 .write_inode = affs_write_inode, 156 .write_inode = affs_write_inode,
133 .evict_inode = affs_evict_inode, 157 .evict_inode = affs_evict_inode,
134 .put_super = affs_put_super, 158 .put_super = affs_put_super,
135 .write_super = affs_write_super,
136 .sync_fs = affs_sync_fs, 159 .sync_fs = affs_sync_fs,
137 .statfs = affs_statfs, 160 .statfs = affs_statfs,
138 .remount_fs = affs_remount, 161 .remount_fs = affs_remount,
@@ -302,6 +325,8 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent)
302 sbi->sb = sb; 325 sbi->sb = sb;
303 mutex_init(&sbi->s_bmlock); 326 mutex_init(&sbi->s_bmlock);
304 spin_lock_init(&sbi->symlink_lock); 327 spin_lock_init(&sbi->symlink_lock);
328 spin_lock_init(&sbi->work_lock);
329 INIT_DELAYED_WORK(&sbi->sb_work, flush_superblock);
305 330
306 if (!parse_options(data,&uid,&gid,&i,&reserved,&root_block, 331 if (!parse_options(data,&uid,&gid,&i,&reserved,&root_block,
307 &blocksize,&sbi->s_prefix, 332 &blocksize,&sbi->s_prefix,
@@ -526,6 +551,7 @@ affs_remount(struct super_block *sb, int *flags, char *data)
526 return -EINVAL; 551 return -EINVAL;
527 } 552 }
528 553
554 flush_delayed_work_sync(&sbi->sb_work);
529 replace_mount_options(sb, new_opts); 555 replace_mount_options(sb, new_opts);
530 556
531 sbi->s_flags = mount_flags; 557 sbi->s_flags = mount_flags;