Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Artem Bityutskiy and committed by
Al Viro
033369d1 5c5fd819

+55 -11
+4 -2
fs/reiserfs/journal.c
··· 1923 1923 * the workqueue job (flush_async_commit) needs this lock 1924 1924 */ 1925 1925 reiserfs_write_unlock(sb); 1926 + 1927 + cancel_delayed_work_sync(&REISERFS_SB(sb)->old_work); 1926 1928 flush_workqueue(commit_wq); 1927 1929 1928 1930 if (!reiserfs_mounted_fs_count) { ··· 3316 3314 journal->j_first = cn; 3317 3315 journal->j_last = cn; 3318 3316 } 3319 - sb->s_dirt = 1; 3317 + reiserfs_schedule_old_flush(sb); 3320 3318 return 0; 3321 3319 } 3322 3320 ··· 3954 3952 ** it tells us if we should continue with the journal_end, or just return 3955 3953 */ 3956 3954 if (!check_journal_end(th, sb, nblocks, flags)) { 3957 - sb->s_dirt = 1; 3955 + reiserfs_schedule_old_flush(sb); 3958 3956 wake_queued_writers(sb); 3959 3957 reiserfs_async_progress_wait(sb); 3960 3958 goto out;
+6
fs/reiserfs/reiserfs.h
··· 480 480 struct dentry *priv_root; /* root of /.reiserfs_priv */ 481 481 struct dentry *xattr_root; /* root of /.reiserfs_priv/xattrs */ 482 482 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 + 483 488 #ifdef CONFIG_QUOTA 484 489 char *s_qf_names[MAXQUOTAS]; 485 490 int s_jquota_fmt; ··· 2492 2487 int reiserfs_allocate_list_bitmaps(struct super_block *s, 2493 2488 struct reiserfs_list_bitmap *, unsigned int); 2494 2489 2490 + void reiserfs_schedule_old_flush(struct super_block *s); 2495 2491 void add_save_link(struct reiserfs_transaction_handle *th, 2496 2492 struct inode *inode, int truncate); 2497 2493 int remove_save_link(struct inode *inode, int truncate);
+45 -9
fs/reiserfs/super.c
··· 72 72 if (!journal_begin(&th, s, 1)) 73 73 if (!journal_end_sync(&th, s, 1)) 74 74 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 */ 77 75 reiserfs_write_unlock(s); 78 76 return 0; 79 77 } 80 78 81 - static void reiserfs_write_super(struct super_block *s) 79 + static void flush_old_commits(struct work_struct *work) 82 80 { 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 + 83 91 reiserfs_sync_fs(s, 1); 92 + } 93 + 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); 84 119 } 85 120 86 121 static int reiserfs_freeze(struct super_block *s) 87 122 { 88 123 struct reiserfs_transaction_handle th; 124 + 125 + cancel_old_flush(s); 126 + 89 127 reiserfs_write_lock(s); 90 128 if (!(s->s_flags & MS_RDONLY)) { 91 129 int err = journal_begin(&th, s, 1); ··· 137 99 journal_end_sync(&th, s, 1); 138 100 } 139 101 } 140 - s->s_dirt = 0; 141 102 reiserfs_write_unlock(s); 142 103 return 0; 143 104 } ··· 520 483 521 484 reiserfs_write_lock(s); 522 485 523 - if (s->s_dirt) 524 - reiserfs_write_super(s); 525 - 526 486 /* change file system state to current state if it was mounted with read-write permissions */ 527 487 if (!(s->s_flags & MS_RDONLY)) { 528 488 if (!journal_begin(&th, s, 10)) { ··· 726 692 .dirty_inode = reiserfs_dirty_inode, 727 693 .evict_inode = reiserfs_evict_inode, 728 694 .put_super = reiserfs_put_super, 729 - .write_super = reiserfs_write_super, 730 695 .sync_fs = reiserfs_sync_fs, 731 696 .freeze_fs = reiserfs_freeze, 732 697 .unfreeze_fs = reiserfs_unfreeze, ··· 1433 1400 err = journal_end(&th, s, 10); 1434 1401 if (err) 1435 1402 goto out_err; 1436 - s->s_dirt = 0; 1437 1403 1438 1404 if (!(*mount_flags & MS_RDONLY)) { 1439 1405 dquot_resume(s, -1); ··· 1773 1741 /* setup default block allocator options */ 1774 1742 reiserfs_init_alloc_options(s); 1775 1743 1744 + spin_lock_init(&sbi->old_work_lock); 1745 + INIT_DELAYED_WORK(&sbi->old_work, flush_old_commits); 1776 1746 mutex_init(&sbi->lock); 1777 1747 sbi->lock_depth = -1; 1778 1748 ··· 2036 2002 journal_release_error(NULL, s); 2037 2003 reiserfs_write_unlock(s); 2038 2004 } 2005 + 2006 + cancel_delayed_work_sync(&REISERFS_SB(s)->old_work); 2039 2007 2040 2008 reiserfs_free_bitmap_cache(s); 2041 2009 if (SB_BUFFER_WITH_SB(s))