提交 9e6c5829 编写于 作者: A Artem Bityutskiy 提交者: Al Viro

hfsplus: get rid of write_super

This patch makes hfsplus 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: NArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
上级 58770d7e
...@@ -153,7 +153,7 @@ int hfsplus_block_allocate(struct super_block *sb, u32 size, ...@@ -153,7 +153,7 @@ int hfsplus_block_allocate(struct super_block *sb, u32 size,
kunmap(page); kunmap(page);
*max = offset + (curr - pptr) * 32 + i - start; *max = offset + (curr - pptr) * 32 + i - start;
sbi->free_blocks -= *max; sbi->free_blocks -= *max;
sb->s_dirt = 1; hfsplus_mark_mdb_dirty(sb);
dprint(DBG_BITMAP, "-> %u,%u\n", start, *max); dprint(DBG_BITMAP, "-> %u,%u\n", start, *max);
out: out:
mutex_unlock(&sbi->alloc_mutex); mutex_unlock(&sbi->alloc_mutex);
...@@ -228,7 +228,7 @@ int hfsplus_block_free(struct super_block *sb, u32 offset, u32 count) ...@@ -228,7 +228,7 @@ int hfsplus_block_free(struct super_block *sb, u32 offset, u32 count)
set_page_dirty(page); set_page_dirty(page);
kunmap(page); kunmap(page);
sbi->free_blocks += len; sbi->free_blocks += len;
sb->s_dirt = 1; hfsplus_mark_mdb_dirty(sb);
mutex_unlock(&sbi->alloc_mutex); mutex_unlock(&sbi->alloc_mutex);
return 0; return 0;
......
...@@ -316,7 +316,7 @@ static int hfsplus_link(struct dentry *src_dentry, struct inode *dst_dir, ...@@ -316,7 +316,7 @@ static int hfsplus_link(struct dentry *src_dentry, struct inode *dst_dir,
inode->i_ctime = CURRENT_TIME_SEC; inode->i_ctime = CURRENT_TIME_SEC;
mark_inode_dirty(inode); mark_inode_dirty(inode);
sbi->file_count++; sbi->file_count++;
dst_dir->i_sb->s_dirt = 1; hfsplus_mark_mdb_dirty(dst_dir->i_sb);
out: out:
mutex_unlock(&sbi->vh_mutex); mutex_unlock(&sbi->vh_mutex);
return res; return res;
......
...@@ -153,8 +153,11 @@ struct hfsplus_sb_info { ...@@ -153,8 +153,11 @@ struct hfsplus_sb_info {
gid_t gid; gid_t gid;
int part, session; int part, session;
unsigned long flags; unsigned long flags;
int work_queued; /* non-zero delayed work is queued */
struct delayed_work sync_work; /* FS sync delayed work */
spinlock_t work_lock; /* protects sync_work and work_queued */
}; };
#define HFSPLUS_SB_WRITEBACKUP 0 #define HFSPLUS_SB_WRITEBACKUP 0
...@@ -428,6 +431,7 @@ int hfsplus_show_options(struct seq_file *, struct dentry *); ...@@ -428,6 +431,7 @@ int hfsplus_show_options(struct seq_file *, struct dentry *);
/* super.c */ /* super.c */
struct inode *hfsplus_iget(struct super_block *, unsigned long); struct inode *hfsplus_iget(struct super_block *, unsigned long);
void hfsplus_mark_mdb_dirty(struct super_block *sb);
/* tables.c */ /* tables.c */
extern u16 hfsplus_case_fold_table[]; extern u16 hfsplus_case_fold_table[];
......
...@@ -431,7 +431,7 @@ struct inode *hfsplus_new_inode(struct super_block *sb, umode_t mode) ...@@ -431,7 +431,7 @@ struct inode *hfsplus_new_inode(struct super_block *sb, umode_t mode)
sbi->file_count++; sbi->file_count++;
insert_inode_hash(inode); insert_inode_hash(inode);
mark_inode_dirty(inode); mark_inode_dirty(inode);
sb->s_dirt = 1; hfsplus_mark_mdb_dirty(sb);
return inode; return inode;
} }
...@@ -442,7 +442,7 @@ void hfsplus_delete_inode(struct inode *inode) ...@@ -442,7 +442,7 @@ void hfsplus_delete_inode(struct inode *inode)
if (S_ISDIR(inode->i_mode)) { if (S_ISDIR(inode->i_mode)) {
HFSPLUS_SB(sb)->folder_count--; HFSPLUS_SB(sb)->folder_count--;
sb->s_dirt = 1; hfsplus_mark_mdb_dirty(sb);
return; return;
} }
HFSPLUS_SB(sb)->file_count--; HFSPLUS_SB(sb)->file_count--;
...@@ -455,7 +455,7 @@ void hfsplus_delete_inode(struct inode *inode) ...@@ -455,7 +455,7 @@ void hfsplus_delete_inode(struct inode *inode)
inode->i_size = 0; inode->i_size = 0;
hfsplus_file_truncate(inode); hfsplus_file_truncate(inode);
} }
sb->s_dirt = 1; hfsplus_mark_mdb_dirty(sb);
} }
void hfsplus_inode_read_fork(struct inode *inode, struct hfsplus_fork_raw *fork) void hfsplus_inode_read_fork(struct inode *inode, struct hfsplus_fork_raw *fork)
......
...@@ -124,7 +124,7 @@ static int hfsplus_system_write_inode(struct inode *inode) ...@@ -124,7 +124,7 @@ static int hfsplus_system_write_inode(struct inode *inode)
if (fork->total_size != cpu_to_be64(inode->i_size)) { if (fork->total_size != cpu_to_be64(inode->i_size)) {
set_bit(HFSPLUS_SB_WRITEBACKUP, &sbi->flags); set_bit(HFSPLUS_SB_WRITEBACKUP, &sbi->flags);
inode->i_sb->s_dirt = 1; hfsplus_mark_mdb_dirty(inode->i_sb);
} }
hfsplus_inode_write_fork(inode, fork); hfsplus_inode_write_fork(inode, fork);
if (tree) if (tree)
...@@ -173,8 +173,6 @@ static int hfsplus_sync_fs(struct super_block *sb, int wait) ...@@ -173,8 +173,6 @@ static int hfsplus_sync_fs(struct super_block *sb, int wait)
dprint(DBG_SUPER, "hfsplus_sync_fs\n"); dprint(DBG_SUPER, "hfsplus_sync_fs\n");
sb->s_dirt = 0;
/* /*
* Explicitly write out the special metadata inodes. * Explicitly write out the special metadata inodes.
* *
...@@ -226,12 +224,34 @@ static int hfsplus_sync_fs(struct super_block *sb, int wait) ...@@ -226,12 +224,34 @@ static int hfsplus_sync_fs(struct super_block *sb, int wait)
return error; return error;
} }
static void hfsplus_write_super(struct super_block *sb) static void delayed_sync_fs(struct work_struct *work)
{ {
if (!(sb->s_flags & MS_RDONLY)) struct hfsplus_sb_info *sbi;
hfsplus_sync_fs(sb, 1);
else sbi = container_of(work, struct hfsplus_sb_info, sync_work.work);
sb->s_dirt = 0;
spin_lock(&sbi->work_lock);
sbi->work_queued = 0;
spin_unlock(&sbi->work_lock);
hfsplus_sync_fs(sbi->alloc_file->i_sb, 1);
}
void hfsplus_mark_mdb_dirty(struct super_block *sb)
{
struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb);
unsigned long delay;
if (sb->s_flags & MS_RDONLY)
return;
spin_lock(&sbi->work_lock);
if (!sbi->work_queued) {
delay = msecs_to_jiffies(dirty_writeback_interval * 10);
queue_delayed_work(system_long_wq, &sbi->sync_work, delay);
sbi->work_queued = 1;
}
spin_unlock(&sbi->work_lock);
} }
static void hfsplus_put_super(struct super_block *sb) static void hfsplus_put_super(struct super_block *sb)
...@@ -240,6 +260,8 @@ static void hfsplus_put_super(struct super_block *sb) ...@@ -240,6 +260,8 @@ static void hfsplus_put_super(struct super_block *sb)
dprint(DBG_SUPER, "hfsplus_put_super\n"); dprint(DBG_SUPER, "hfsplus_put_super\n");
cancel_delayed_work_sync(&sbi->sync_work);
if (!(sb->s_flags & MS_RDONLY) && sbi->s_vhdr) { if (!(sb->s_flags & MS_RDONLY) && sbi->s_vhdr) {
struct hfsplus_vh *vhdr = sbi->s_vhdr; struct hfsplus_vh *vhdr = sbi->s_vhdr;
...@@ -325,7 +347,6 @@ static const struct super_operations hfsplus_sops = { ...@@ -325,7 +347,6 @@ static const struct super_operations hfsplus_sops = {
.write_inode = hfsplus_write_inode, .write_inode = hfsplus_write_inode,
.evict_inode = hfsplus_evict_inode, .evict_inode = hfsplus_evict_inode,
.put_super = hfsplus_put_super, .put_super = hfsplus_put_super,
.write_super = hfsplus_write_super,
.sync_fs = hfsplus_sync_fs, .sync_fs = hfsplus_sync_fs,
.statfs = hfsplus_statfs, .statfs = hfsplus_statfs,
.remount_fs = hfsplus_remount, .remount_fs = hfsplus_remount,
...@@ -352,6 +373,8 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent) ...@@ -352,6 +373,8 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent)
sb->s_fs_info = sbi; sb->s_fs_info = sbi;
mutex_init(&sbi->alloc_mutex); mutex_init(&sbi->alloc_mutex);
mutex_init(&sbi->vh_mutex); mutex_init(&sbi->vh_mutex);
spin_lock_init(&sbi->work_lock);
INIT_DELAYED_WORK(&sbi->sync_work, delayed_sync_fs);
hfsplus_fill_defaults(sbi); hfsplus_fill_defaults(sbi);
err = -EINVAL; err = -EINVAL;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册