aboutsummaryrefslogtreecommitdiffstats
path: root/fs/hfs/super.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/hfs/super.c')
-rw-r--r--fs/hfs/super.c73
1 files changed, 36 insertions, 37 deletions
diff --git a/fs/hfs/super.c b/fs/hfs/super.c
index 7b4c537d6e13..4eb873e0c07b 100644
--- a/fs/hfs/super.c
+++ b/fs/hfs/super.c
@@ -29,43 +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 lock_super(sb);
54 sb->s_dirt = 0;
55
56 /* sync everything to the buffers */
57 if (!(sb->s_flags & MS_RDONLY))
58 hfs_mdb_commit(sb);
59 unlock_super(sb);
60}
61
62static int hfs_sync_fs(struct super_block *sb, int wait) 32static int hfs_sync_fs(struct super_block *sb, int wait)
63{ 33{
64 lock_super(sb);
65 hfs_mdb_commit(sb); 34 hfs_mdb_commit(sb);
66 sb->s_dirt = 0;
67 unlock_super(sb);
68
69 return 0; 35 return 0;
70} 36}
71 37
@@ -78,13 +44,44 @@ static int hfs_sync_fs(struct super_block *sb, int wait)
78 */ 44 */
79static void hfs_put_super(struct super_block *sb) 45static void hfs_put_super(struct super_block *sb)
80{ 46{
81 if (sb->s_dirt) 47 cancel_delayed_work_sync(&HFS_SB(sb)->mdb_work);
82 hfs_write_super(sb);
83 hfs_mdb_close(sb); 48 hfs_mdb_close(sb);
84 /* release the MDB's resources */ 49 /* release the MDB's resources */
85 hfs_mdb_put(sb); 50 hfs_mdb_put(sb);
86} 51}
87 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
88/* 85/*
89 * hfs_statfs() 86 * hfs_statfs()
90 * 87 *
@@ -184,7 +181,6 @@ static const struct super_operations hfs_super_operations = {
184 .write_inode = hfs_write_inode, 181 .write_inode = hfs_write_inode,
185 .evict_inode = hfs_evict_inode, 182 .evict_inode = hfs_evict_inode,
186 .put_super = hfs_put_super, 183 .put_super = hfs_put_super,
187 .write_super = hfs_write_super,
188 .sync_fs = hfs_sync_fs, 184 .sync_fs = hfs_sync_fs,
189 .statfs = hfs_statfs, 185 .statfs = hfs_statfs,
190 .remount_fs = hfs_remount, 186 .remount_fs = hfs_remount,
@@ -387,7 +383,10 @@ static int hfs_fill_super(struct super_block *sb, void *data, int silent)
387 if (!sbi) 383 if (!sbi)
388 return -ENOMEM; 384 return -ENOMEM;
389 385
386 sbi->sb = sb;
390 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);
391 390
392 res = -EINVAL; 391 res = -EINVAL;
393 if (!parse_options((char *)data, sbi)) { 392 if (!parse_options((char *)data, sbi)) {