Skip to content

Commit 033369d

Browse files
dedekindAl Viro
authored andcommitted
reiserfs: get rid of resierfs_sync_super
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 <artem.bityutskiy@linux.intel.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 5c5fd81 commit 033369d

3 files changed

Lines changed: 55 additions & 11 deletions

File tree

‎fs/reiserfs/journal.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1923,6 +1923,8 @@ static int do_journal_release(struct reiserfs_transaction_handle *th,
19231923
* the workqueue job (flush_async_commit) needs this lock
19241924
*/
19251925
reiserfs_write_unlock(sb);
1926+
1927+
cancel_delayed_work_sync(&REISERFS_SB(sb)->old_work);
19261928
flush_workqueue(commit_wq);
19271929

19281930
if (!reiserfs_mounted_fs_count) {
@@ -3314,7 +3316,7 @@ int journal_mark_dirty(struct reiserfs_transaction_handle *th,
33143316
journal->j_first = cn;
33153317
journal->j_last = cn;
33163318
}
3317-
sb->s_dirt = 1;
3319+
reiserfs_schedule_old_flush(sb);
33183320
return 0;
33193321
}
33203322

@@ -3952,7 +3954,7 @@ static int do_journal_end(struct reiserfs_transaction_handle *th,
39523954
** it tells us if we should continue with the journal_end, or just return
39533955
*/
39543956
if (!check_journal_end(th, sb, nblocks, flags)) {
3955-
sb->s_dirt = 1;
3957+
reiserfs_schedule_old_flush(sb);
39563958
wake_queued_writers(sb);
39573959
reiserfs_async_progress_wait(sb);
39583960
goto out;

‎fs/reiserfs/reiserfs.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,11 @@ struct reiserfs_sb_info {
480480
struct dentry *priv_root; /* root of /.reiserfs_priv */
481481
struct dentry *xattr_root; /* root of /.reiserfs_priv/xattrs */
482482
int j_errno;
483+
484+
int work_queued; /* non-zero delayed work is queued */
485+
struct delayed_work old_work; /* old transactions flush delayed work */
486+
spinlock_t old_work_lock; /* protects old_work and work_queued */
487+
483488
#ifdef CONFIG_QUOTA
484489
char *s_qf_names[MAXQUOTAS];
485490
int s_jquota_fmt;
@@ -2487,6 +2492,7 @@ void reiserfs_abort(struct super_block *sb, int errno, const char *fmt, ...);
24872492
int reiserfs_allocate_list_bitmaps(struct super_block *s,
24882493
struct reiserfs_list_bitmap *, unsigned int);
24892494

2495+
void reiserfs_schedule_old_flush(struct super_block *s);
24902496
void add_save_link(struct reiserfs_transaction_handle *th,
24912497
struct inode *inode, int truncate);
24922498
int remove_save_link(struct inode *inode, int truncate);

‎fs/reiserfs/super.c‎

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,20 +72,58 @@ static int reiserfs_sync_fs(struct super_block *s, int wait)
7272
if (!journal_begin(&th, s, 1))
7373
if (!journal_end_sync(&th, s, 1))
7474
reiserfs_flush_old_commits(s);
75-
s->s_dirt = 0; /* Even if it's not true.
76-
* We'll loop forever in sync_supers otherwise */
7775
reiserfs_write_unlock(s);
7876
return 0;
7977
}
8078

81-
static void reiserfs_write_super(struct super_block *s)
79+
static void flush_old_commits(struct work_struct *work)
8280
{
81+
struct reiserfs_sb_info *sbi;
82+
struct super_block *s;
83+
84+
sbi = container_of(work, struct reiserfs_sb_info, old_work.work);
85+
s = sbi->s_journal->j_work_sb;
86+
87+
spin_lock(&sbi->old_work_lock);
88+
sbi->work_queued = 0;
89+
spin_unlock(&sbi->old_work_lock);
90+
8391
reiserfs_sync_fs(s, 1);
8492
}
8593

94+
void reiserfs_schedule_old_flush(struct super_block *s)
95+
{
96+
struct reiserfs_sb_info *sbi = REISERFS_SB(s);
97+
unsigned long delay;
98+
99+
if (s->s_flags & MS_RDONLY)
100+
return;
101+
102+
spin_lock(&sbi->old_work_lock);
103+
if (!sbi->work_queued) {
104+
delay = msecs_to_jiffies(dirty_writeback_interval * 10);
105+
queue_delayed_work(system_long_wq, &sbi->old_work, delay);
106+
sbi->work_queued = 1;
107+
}
108+
spin_unlock(&sbi->old_work_lock);
109+
}
110+
111+
static void cancel_old_flush(struct super_block *s)
112+
{
113+
struct reiserfs_sb_info *sbi = REISERFS_SB(s);
114+
115+
cancel_delayed_work_sync(&REISERFS_SB(s)->old_work);
116+
spin_lock(&sbi->old_work_lock);
117+
sbi->work_queued = 0;
118+
spin_unlock(&sbi->old_work_lock);
119+
}
120+
86121
static int reiserfs_freeze(struct super_block *s)
87122
{
88123
struct reiserfs_transaction_handle th;
124+
125+
cancel_old_flush(s);
126+
89127
reiserfs_write_lock(s);
90128
if (!(s->s_flags & MS_RDONLY)) {
91129
int err = journal_begin(&th, s, 1);
@@ -99,7 +137,6 @@ static int reiserfs_freeze(struct super_block *s)
99137
journal_end_sync(&th, s, 1);
100138
}
101139
}
102-
s->s_dirt = 0;
103140
reiserfs_write_unlock(s);
104141
return 0;
105142
}
@@ -483,9 +520,6 @@ static void reiserfs_put_super(struct super_block *s)
483520

484521
reiserfs_write_lock(s);
485522

486-
if (s->s_dirt)
487-
reiserfs_write_super(s);
488-
489523
/* change file system state to current state if it was mounted with read-write permissions */
490524
if (!(s->s_flags & MS_RDONLY)) {
491525
if (!journal_begin(&th, s, 10)) {
@@ -692,7 +726,6 @@ static const struct super_operations reiserfs_sops = {
692726
.dirty_inode = reiserfs_dirty_inode,
693727
.evict_inode = reiserfs_evict_inode,
694728
.put_super = reiserfs_put_super,
695-
.write_super = reiserfs_write_super,
696729
.sync_fs = reiserfs_sync_fs,
697730
.freeze_fs = reiserfs_freeze,
698731
.unfreeze_fs = reiserfs_unfreeze,
@@ -1400,7 +1433,6 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)
14001433
err = journal_end(&th, s, 10);
14011434
if (err)
14021435
goto out_err;
1403-
s->s_dirt = 0;
14041436

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

1776+
spin_lock_init(&sbi->old_work_lock);
1777+
INIT_DELAYED_WORK(&sbi->old_work, flush_old_commits);
17441778
mutex_init(&sbi->lock);
17451779
sbi->lock_depth = -1;
17461780

@@ -2003,6 +2037,8 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
20032037
reiserfs_write_unlock(s);
20042038
}
20052039

2040+
cancel_delayed_work_sync(&REISERFS_SB(s)->old_work);
2041+
20062042
reiserfs_free_bitmap_cache(s);
20072043
if (SB_BUFFER_WITH_SB(s))
20082044
brelse(SB_BUFFER_WITH_SB(s));

0 commit comments

Comments
 (0)