diff options
-rw-r--r-- | fs/affs/affs.h | 6 | ||||
-rw-r--r-- | fs/affs/bitmap.c | 4 | ||||
-rw-r--r-- | fs/affs/super.c | 48 |
3 files changed, 45 insertions, 13 deletions
diff --git a/fs/affs/affs.h b/fs/affs/affs.h index 5a726e992245..3a130e27eb15 100644 --- a/fs/affs/affs.h +++ b/fs/affs/affs.h | |||
@@ -3,6 +3,7 @@ | |||
3 | #include <linux/buffer_head.h> | 3 | #include <linux/buffer_head.h> |
4 | #include <linux/amigaffs.h> | 4 | #include <linux/amigaffs.h> |
5 | #include <linux/mutex.h> | 5 | #include <linux/mutex.h> |
6 | #include <linux/workqueue.h> | ||
6 | 7 | ||
7 | /* AmigaOS allows file names with up to 30 characters length. | 8 | /* AmigaOS allows file names with up to 30 characters length. |
8 | * Names longer than that will be silently truncated. If you | 9 | * Names longer than that will be silently truncated. If you |
@@ -101,6 +102,9 @@ struct affs_sb_info { | |||
101 | char s_volume[32]; /* Volume prefix for absolute symlinks. */ | 102 | char s_volume[32]; /* Volume prefix for absolute symlinks. */ |
102 | spinlock_t symlink_lock; /* protects the previous two */ | 103 | spinlock_t symlink_lock; /* protects the previous two */ |
103 | struct super_block *sb; /* the VFS superblock object */ | 104 | struct super_block *sb; /* the VFS superblock object */ |
105 | int work_queued; /* non-zero delayed work is queued */ | ||
106 | struct delayed_work sb_work; /* superblock flush delayed work */ | ||
107 | spinlock_t work_lock; /* protects sb_work and work_queued */ | ||
104 | }; | 108 | }; |
105 | 109 | ||
106 | #define SF_INTL 0x0001 /* International filesystem. */ | 110 | #define SF_INTL 0x0001 /* International filesystem. */ |
@@ -121,6 +125,8 @@ static inline struct affs_sb_info *AFFS_SB(struct super_block *sb) | |||
121 | return sb->s_fs_info; | 125 | return sb->s_fs_info; |
122 | } | 126 | } |
123 | 127 | ||
128 | void affs_mark_sb_dirty(struct super_block *sb); | ||
129 | |||
124 | /* amigaffs.c */ | 130 | /* amigaffs.c */ |
125 | 131 | ||
126 | extern int affs_insert_hash(struct inode *inode, struct buffer_head *bh); | 132 | extern int affs_insert_hash(struct inode *inode, struct buffer_head *bh); |
diff --git a/fs/affs/bitmap.c b/fs/affs/bitmap.c index 3e262711ae06..6e0be43ef6ef 100644 --- a/fs/affs/bitmap.c +++ b/fs/affs/bitmap.c | |||
@@ -103,7 +103,7 @@ affs_free_block(struct super_block *sb, u32 block) | |||
103 | *(__be32 *)bh->b_data = cpu_to_be32(tmp - mask); | 103 | *(__be32 *)bh->b_data = cpu_to_be32(tmp - mask); |
104 | 104 | ||
105 | mark_buffer_dirty(bh); | 105 | mark_buffer_dirty(bh); |
106 | sb->s_dirt = 1; | 106 | affs_mark_sb_dirty(sb); |
107 | bm->bm_free++; | 107 | bm->bm_free++; |
108 | 108 | ||
109 | mutex_unlock(&sbi->s_bmlock); | 109 | mutex_unlock(&sbi->s_bmlock); |
@@ -248,7 +248,7 @@ find_bit: | |||
248 | *(__be32 *)bh->b_data = cpu_to_be32(tmp + mask); | 248 | *(__be32 *)bh->b_data = cpu_to_be32(tmp + mask); |
249 | 249 | ||
250 | mark_buffer_dirty(bh); | 250 | mark_buffer_dirty(bh); |
251 | sb->s_dirt = 1; | 251 | affs_mark_sb_dirty(sb); |
252 | 252 | ||
253 | mutex_unlock(&sbi->s_bmlock); | 253 | mutex_unlock(&sbi->s_bmlock); |
254 | 254 | ||
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 | ||
22 | extern struct timezone sys_tz; | 23 | extern 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 | ||
57 | static void | ||
58 | affs_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 | |||
66 | static int | 59 | static int |
67 | affs_sync_fs(struct super_block *sb, int wait) | 60 | affs_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 | ||
66 | static 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 | |||
81 | void 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 | |||
74 | static struct kmem_cache * affs_inode_cachep; | 98 | static struct kmem_cache * affs_inode_cachep; |
75 | 99 | ||
76 | static struct inode *affs_alloc_inode(struct super_block *sb) | 100 | static 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; |