Skip to content

Commit

Permalink
reiserfs: get rid of resierfs_sync_super
Browse files Browse the repository at this point in the history
This patch stops reiserfs using the VFS 'write_super()' method along with the
s_dirt 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 superblock 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 <[email protected]>
Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
dedekind authored and Al Viro committed Jun 1, 2012
1 parent 5c5fd81 commit 033369d
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 11 deletions.
6 changes: 4 additions & 2 deletions fs/reiserfs/journal.c
Original file line number Diff line number Diff line change
Expand Up @@ -1923,6 +1923,8 @@ static int do_journal_release(struct reiserfs_transaction_handle *th,
* the workqueue job (flush_async_commit) needs this lock
*/
reiserfs_write_unlock(sb);

cancel_delayed_work_sync(&REISERFS_SB(sb)->old_work);
flush_workqueue(commit_wq);

if (!reiserfs_mounted_fs_count) {
Expand Down Expand Up @@ -3314,7 +3316,7 @@ int journal_mark_dirty(struct reiserfs_transaction_handle *th,
journal->j_first = cn;
journal->j_last = cn;
}
sb->s_dirt = 1;
reiserfs_schedule_old_flush(sb);
return 0;
}

Expand Down Expand Up @@ -3952,7 +3954,7 @@ static int do_journal_end(struct reiserfs_transaction_handle *th,
** it tells us if we should continue with the journal_end, or just return
*/
if (!check_journal_end(th, sb, nblocks, flags)) {
sb->s_dirt = 1;
reiserfs_schedule_old_flush(sb);
wake_queued_writers(sb);
reiserfs_async_progress_wait(sb);
goto out;
Expand Down
6 changes: 6 additions & 0 deletions fs/reiserfs/reiserfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,11 @@ struct reiserfs_sb_info {
struct dentry *priv_root; /* root of /.reiserfs_priv */
struct dentry *xattr_root; /* root of /.reiserfs_priv/xattrs */
int j_errno;

int work_queued; /* non-zero delayed work is queued */
struct delayed_work old_work; /* old transactions flush delayed work */
spinlock_t old_work_lock; /* protects old_work and work_queued */

#ifdef CONFIG_QUOTA
char *s_qf_names[MAXQUOTAS];
int s_jquota_fmt;
Expand Down Expand Up @@ -2487,6 +2492,7 @@ void reiserfs_abort(struct super_block *sb, int errno, const char *fmt, ...);
int reiserfs_allocate_list_bitmaps(struct super_block *s,
struct reiserfs_list_bitmap *, unsigned int);

void reiserfs_schedule_old_flush(struct super_block *s);
void add_save_link(struct reiserfs_transaction_handle *th,
struct inode *inode, int truncate);
int remove_save_link(struct inode *inode, int truncate);
Expand Down
54 changes: 45 additions & 9 deletions fs/reiserfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,58 @@ static int reiserfs_sync_fs(struct super_block *s, int wait)
if (!journal_begin(&th, s, 1))
if (!journal_end_sync(&th, s, 1))
reiserfs_flush_old_commits(s);
s->s_dirt = 0; /* Even if it's not true.
* We'll loop forever in sync_supers otherwise */
reiserfs_write_unlock(s);
return 0;
}

static void reiserfs_write_super(struct super_block *s)
static void flush_old_commits(struct work_struct *work)
{
struct reiserfs_sb_info *sbi;
struct super_block *s;

sbi = container_of(work, struct reiserfs_sb_info, old_work.work);
s = sbi->s_journal->j_work_sb;

spin_lock(&sbi->old_work_lock);
sbi->work_queued = 0;
spin_unlock(&sbi->old_work_lock);

reiserfs_sync_fs(s, 1);
}

void reiserfs_schedule_old_flush(struct super_block *s)
{
struct reiserfs_sb_info *sbi = REISERFS_SB(s);
unsigned long delay;

if (s->s_flags & MS_RDONLY)
return;

spin_lock(&sbi->old_work_lock);
if (!sbi->work_queued) {
delay = msecs_to_jiffies(dirty_writeback_interval * 10);
queue_delayed_work(system_long_wq, &sbi->old_work, delay);
sbi->work_queued = 1;
}
spin_unlock(&sbi->old_work_lock);
}

static void cancel_old_flush(struct super_block *s)
{
struct reiserfs_sb_info *sbi = REISERFS_SB(s);

cancel_delayed_work_sync(&REISERFS_SB(s)->old_work);
spin_lock(&sbi->old_work_lock);
sbi->work_queued = 0;
spin_unlock(&sbi->old_work_lock);
}

static int reiserfs_freeze(struct super_block *s)
{
struct reiserfs_transaction_handle th;

cancel_old_flush(s);

reiserfs_write_lock(s);
if (!(s->s_flags & MS_RDONLY)) {
int err = journal_begin(&th, s, 1);
Expand All @@ -99,7 +137,6 @@ static int reiserfs_freeze(struct super_block *s)
journal_end_sync(&th, s, 1);
}
}
s->s_dirt = 0;
reiserfs_write_unlock(s);
return 0;
}
Expand Down Expand Up @@ -483,9 +520,6 @@ static void reiserfs_put_super(struct super_block *s)

reiserfs_write_lock(s);

if (s->s_dirt)
reiserfs_write_super(s);

/* change file system state to current state if it was mounted with read-write permissions */
if (!(s->s_flags & MS_RDONLY)) {
if (!journal_begin(&th, s, 10)) {
Expand Down Expand Up @@ -692,7 +726,6 @@ static const struct super_operations reiserfs_sops = {
.dirty_inode = reiserfs_dirty_inode,
.evict_inode = reiserfs_evict_inode,
.put_super = reiserfs_put_super,
.write_super = reiserfs_write_super,
.sync_fs = reiserfs_sync_fs,
.freeze_fs = reiserfs_freeze,
.unfreeze_fs = reiserfs_unfreeze,
Expand Down Expand Up @@ -1400,7 +1433,6 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)
err = journal_end(&th, s, 10);
if (err)
goto out_err;
s->s_dirt = 0;

if (!(*mount_flags & MS_RDONLY)) {
dquot_resume(s, -1);
Expand Down Expand Up @@ -1741,6 +1773,8 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
/* setup default block allocator options */
reiserfs_init_alloc_options(s);

spin_lock_init(&sbi->old_work_lock);
INIT_DELAYED_WORK(&sbi->old_work, flush_old_commits);
mutex_init(&sbi->lock);
sbi->lock_depth = -1;

Expand Down Expand Up @@ -2003,6 +2037,8 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
reiserfs_write_unlock(s);
}

cancel_delayed_work_sync(&REISERFS_SB(s)->old_work);

reiserfs_free_bitmap_cache(s);
if (SB_BUFFER_WITH_SB(s))
brelse(SB_BUFFER_WITH_SB(s));
Expand Down

0 comments on commit 033369d

Please sign in to comment.