aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2012-07-12 10:28:49 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2012-07-22 15:58:09 -0400
commit5687b5780e90278a62d4cd916a3632087066f59d (patch)
tree362f5c4b25cc1edd9ae69ac561192859cfd9c201
parentb16ca626358cbf056b752eab63ba8f20087afeaf (diff)
hfs: get rid of hfs_sync_super
This patch makes hfs 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. Tested using fsstress from the LTP project. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--fs/hfs/extent.c2
-rw-r--r--fs/hfs/hfs_fs.h9
-rw-r--r--fs/hfs/inode.c11
-rw-r--r--fs/hfs/super.c65
4 files changed, 48 insertions, 39 deletions
diff --git a/fs/hfs/extent.c b/fs/hfs/extent.c
index 2c16316d291..a67955a0c36 100644
--- a/fs/hfs/extent.c
+++ b/fs/hfs/extent.c
@@ -432,7 +432,7 @@ out:
432 if (inode->i_ino < HFS_FIRSTUSER_CNID) 432 if (inode->i_ino < HFS_FIRSTUSER_CNID)
433 set_bit(HFS_FLG_ALT_MDB_DIRTY, &HFS_SB(sb)->flags); 433 set_bit(HFS_FLG_ALT_MDB_DIRTY, &HFS_SB(sb)->flags);
434 set_bit(HFS_FLG_MDB_DIRTY, &HFS_SB(sb)->flags); 434 set_bit(HFS_FLG_MDB_DIRTY, &HFS_SB(sb)->flags);
435 sb->s_dirt = 1; 435 hfs_mark_mdb_dirty(sb);
436 } 436 }
437 return res; 437 return res;
438 438
diff --git a/fs/hfs/hfs_fs.h b/fs/hfs/hfs_fs.h
index 351561223ec..8275175acf6 100644
--- a/fs/hfs/hfs_fs.h
+++ b/fs/hfs/hfs_fs.h
@@ -14,6 +14,7 @@
14#include <linux/mutex.h> 14#include <linux/mutex.h>
15#include <linux/buffer_head.h> 15#include <linux/buffer_head.h>
16#include <linux/fs.h> 16#include <linux/fs.h>
17#include <linux/workqueue.h>
17 18
18#include <asm/byteorder.h> 19#include <asm/byteorder.h>
19#include <asm/uaccess.h> 20#include <asm/uaccess.h>
@@ -143,6 +144,9 @@ struct hfs_sb_info {
143 u16 blockoffset; 144 u16 blockoffset;
144 int fs_div; 145 int fs_div;
145 struct super_block *sb; 146 struct super_block *sb;
147 int work_queued; /* non-zero delayed work is queued */
148 struct delayed_work mdb_work; /* MDB flush delayed work */
149 spinlock_t work_lock; /* protects mdb_work and work_queued */
146}; 150};
147 151
148#define HFS_FLG_BITMAP_DIRTY 0 152#define HFS_FLG_BITMAP_DIRTY 0
@@ -222,6 +226,9 @@ extern int hfs_compare_dentry(const struct dentry *parent,
222extern void hfs_asc2mac(struct super_block *, struct hfs_name *, struct qstr *); 226extern void hfs_asc2mac(struct super_block *, struct hfs_name *, struct qstr *);
223extern int hfs_mac2asc(struct super_block *, char *, const struct hfs_name *); 227extern int hfs_mac2asc(struct super_block *, char *, const struct hfs_name *);
224 228
229/* super.c */
230extern void hfs_mark_mdb_dirty(struct super_block *sb);
231
225extern struct timezone sys_tz; 232extern struct timezone sys_tz;
226 233
227/* 234/*
@@ -249,7 +256,7 @@ static inline const char *hfs_mdb_name(struct super_block *sb)
249static inline void hfs_bitmap_dirty(struct super_block *sb) 256static inline void hfs_bitmap_dirty(struct super_block *sb)
250{ 257{
251 set_bit(HFS_FLG_BITMAP_DIRTY, &HFS_SB(sb)->flags); 258 set_bit(HFS_FLG_BITMAP_DIRTY, &HFS_SB(sb)->flags);
252 sb->s_dirt = 1; 259 hfs_mark_mdb_dirty(sb);
253} 260}
254 261
255#define sb_bread512(sb, sec, data) ({ \ 262#define sb_bread512(sb, sec, data) ({ \
diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c
index 90c1ccbff8e..ee1bc55677f 100644
--- a/fs/hfs/inode.c
+++ b/fs/hfs/inode.c
@@ -220,7 +220,7 @@ struct inode *hfs_new_inode(struct inode *dir, struct qstr *name, umode_t mode)
220 insert_inode_hash(inode); 220 insert_inode_hash(inode);
221 mark_inode_dirty(inode); 221 mark_inode_dirty(inode);
222 set_bit(HFS_FLG_MDB_DIRTY, &HFS_SB(sb)->flags); 222 set_bit(HFS_FLG_MDB_DIRTY, &HFS_SB(sb)->flags);
223 sb->s_dirt = 1; 223 hfs_mark_mdb_dirty(sb);
224 224
225 return inode; 225 return inode;
226} 226}
@@ -235,7 +235,7 @@ void hfs_delete_inode(struct inode *inode)
235 if (HFS_I(inode)->cat_key.ParID == cpu_to_be32(HFS_ROOT_CNID)) 235 if (HFS_I(inode)->cat_key.ParID == cpu_to_be32(HFS_ROOT_CNID))
236 HFS_SB(sb)->root_dirs--; 236 HFS_SB(sb)->root_dirs--;
237 set_bit(HFS_FLG_MDB_DIRTY, &HFS_SB(sb)->flags); 237 set_bit(HFS_FLG_MDB_DIRTY, &HFS_SB(sb)->flags);
238 sb->s_dirt = 1; 238 hfs_mark_mdb_dirty(sb);
239 return; 239 return;
240 } 240 }
241 HFS_SB(sb)->file_count--; 241 HFS_SB(sb)->file_count--;
@@ -248,7 +248,7 @@ void hfs_delete_inode(struct inode *inode)
248 } 248 }
249 } 249 }
250 set_bit(HFS_FLG_MDB_DIRTY, &HFS_SB(sb)->flags); 250 set_bit(HFS_FLG_MDB_DIRTY, &HFS_SB(sb)->flags);
251 sb->s_dirt = 1; 251 hfs_mark_mdb_dirty(sb);
252} 252}
253 253
254void hfs_inode_read_fork(struct inode *inode, struct hfs_extent *ext, 254void hfs_inode_read_fork(struct inode *inode, struct hfs_extent *ext,
@@ -644,10 +644,7 @@ static int hfs_file_fsync(struct file *filp, loff_t start, loff_t end,
644 644
645 /* sync the superblock to buffers */ 645 /* sync the superblock to buffers */
646 sb = inode->i_sb; 646 sb = inode->i_sb;
647 if (sb->s_dirt) { 647 flush_delayed_work_sync(&HFS_SB(sb)->mdb_work);
648 sb->s_dirt = 0;
649 hfs_mdb_commit(sb);
650 }
651 /* .. finally sync the buffers to disk */ 648 /* .. finally sync the buffers to disk */
652 err = sync_blockdev(sb->s_bdev); 649 err = sync_blockdev(sb->s_bdev);
653 if (!ret) 650 if (!ret)
diff --git a/fs/hfs/super.c b/fs/hfs/super.c
index 99c6239bc3a..4eb873e0c07 100644
--- a/fs/hfs/super.c
+++ b/fs/hfs/super.c
@@ -29,38 +29,9 @@ static struct kmem_cache *hfs_inode_cachep;
29 29
30MODULE_LICENSE("GPL"); 30MODULE_LICENSE("GPL");
31 31
32/*
33 * hfs_write_super()
34 *
35 * Description:
36 * This function is called by the VFS only. When the filesystem
37 * is mounted r/w it updates the MDB on disk.
38 * Input Variable(s):
39 * struct super_block *sb: Pointer to the hfs superblock
40 * Output Variable(s):
41 * NONE
42 * Returns:
43 * void
44 * Preconditions:
45 * 'sb' points to a "valid" (struct super_block).
46 * Postconditions:
47 * The MDB is marked 'unsuccessfully unmounted' by clearing bit 8 of drAtrb
48 * (hfs_put_super() must set this flag!). Some MDB fields are updated
49 * and the MDB buffer is written to disk by calling hfs_mdb_commit().
50 */
51static void hfs_write_super(struct super_block *sb)
52{
53 sb->s_dirt = 0;
54
55 /* sync everything to the buffers */
56 hfs_mdb_commit(sb);
57}
58
59static int hfs_sync_fs(struct super_block *sb, int wait) 32static int hfs_sync_fs(struct super_block *sb, int wait)
60{ 33{
61 hfs_mdb_commit(sb); 34 hfs_mdb_commit(sb);
62 sb->s_dirt = 0;
63
64 return 0; 35 return 0;
65} 36}
66 37
@@ -73,11 +44,44 @@ static int hfs_sync_fs(struct super_block *sb, int wait)
73 */ 44 */
74static void hfs_put_super(struct super_block *sb) 45static void hfs_put_super(struct super_block *sb)
75{ 46{
47 cancel_delayed_work_sync(&HFS_SB(sb)->mdb_work);
76 hfs_mdb_close(sb); 48 hfs_mdb_close(sb);
77 /* release the MDB's resources */ 49 /* release the MDB's resources */
78 hfs_mdb_put(sb); 50 hfs_mdb_put(sb);
79} 51}
80 52
53static void flush_mdb(struct work_struct *work)
54{
55 struct hfs_sb_info *sbi;
56 struct super_block *sb;
57
58 sbi = container_of(work, struct hfs_sb_info, mdb_work.work);
59 sb = sbi->sb;
60
61 spin_lock(&sbi->work_lock);
62 sbi->work_queued = 0;
63 spin_unlock(&sbi->work_lock);
64
65 hfs_mdb_commit(sb);
66}
67
68void hfs_mark_mdb_dirty(struct super_block *sb)
69{
70 struct hfs_sb_info *sbi = HFS_SB(sb);
71 unsigned long delay;
72
73 if (sb->s_flags & MS_RDONLY)
74 return;
75
76 spin_lock(&sbi->work_lock);
77 if (!sbi->work_queued) {
78 delay = msecs_to_jiffies(dirty_writeback_interval * 10);
79 queue_delayed_work(system_long_wq, &sbi->mdb_work, delay);
80 sbi->work_queued = 1;
81 }
82 spin_unlock(&sbi->work_lock);
83}
84
81/* 85/*
82 * hfs_statfs() 86 * hfs_statfs()
83 * 87 *
@@ -177,7 +181,6 @@ static const struct super_operations hfs_super_operations = {
177 .write_inode = hfs_write_inode, 181 .write_inode = hfs_write_inode,
178 .evict_inode = hfs_evict_inode, 182 .evict_inode = hfs_evict_inode,
179 .put_super = hfs_put_super, 183 .put_super = hfs_put_super,
180 .write_super = hfs_write_super,
181 .sync_fs = hfs_sync_fs, 184 .sync_fs = hfs_sync_fs,
182 .statfs = hfs_statfs, 185 .statfs = hfs_statfs,
183 .remount_fs = hfs_remount, 186 .remount_fs = hfs_remount,
@@ -382,6 +385,8 @@ static int hfs_fill_super(struct super_block *sb, void *data, int silent)
382 385
383 sbi->sb = sb; 386 sbi->sb = sb;
384 sb->s_fs_info = sbi; 387 sb->s_fs_info = sbi;
388 spin_lock_init(&sbi->work_lock);
389 INIT_DELAYED_WORK(&sbi->mdb_work, flush_mdb);
385 390
386 res = -EINVAL; 391 res = -EINVAL;
387 if (!parse_options((char *)data, sbi)) { 392 if (!parse_options((char *)data, sbi)) {