add patch make-fsync-to-sync-parent-dir-in-no-journal-for-real-this-time
[ext4-patch-queue.git] / add-dirtytime-sysctl-tuning-knob
blob978c2fa9bba7c2f8413f862217a83f50ea4d3356
1 fs: add dirtytime_expire_seconds sysctl
3 Add a tuning knob so we can adjust the dirtytime expiration timeout,
4 which is very useful for testing lazytime.
6 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
7 Reviewed-by: Jan Kara <jack@suse.cz>
8 ---
9  fs/fs-writeback.c         | 11 +++++++++++
10  include/linux/writeback.h |  3 +++
11  kernel/sysctl.c           |  8 ++++++++
12  3 files changed, 22 insertions(+)
14 diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
15 index 2cfcd74..32a8bbd 100644
16 --- a/fs/fs-writeback.c
17 +++ b/fs/fs-writeback.c
18 @@ -1188,6 +1188,17 @@ static int __init start_dirtytime_writeback(void)
19  }
20  __initcall(start_dirtytime_writeback);
22 +int dirtytime_interval_handler(struct ctl_table *table, int write,
23 +                              void __user *buffer, size_t *lenp, loff_t *ppos)
25 +       int ret;
27 +       ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
28 +       if (ret == 0 && write)
29 +               mod_delayed_work(system_wq, &dirtytime_work, 0);
30 +       return ret;
33  static noinline void block_dump___mark_inode_dirty(struct inode *inode)
34  {
35         if (inode->i_ino || strcmp(inode->i_sb->s_id, "bdev")) {
36 diff --git a/include/linux/writeback.h b/include/linux/writeback.h
37 index 0004833..b2dd371e 100644
38 --- a/include/linux/writeback.h
39 +++ b/include/linux/writeback.h
40 @@ -130,6 +130,7 @@ extern int vm_dirty_ratio;
41  extern unsigned long vm_dirty_bytes;
42  extern unsigned int dirty_writeback_interval;
43  extern unsigned int dirty_expire_interval;
44 +extern unsigned int dirtytime_expire_interval;
45  extern int vm_highmem_is_dirtyable;
46  extern int block_dump;
47  extern int laptop_mode;
48 @@ -146,6 +147,8 @@ extern int dirty_ratio_handler(struct ctl_table *table, int write,
49  extern int dirty_bytes_handler(struct ctl_table *table, int write,
50                 void __user *buffer, size_t *lenp,
51                 loff_t *ppos);
52 +int dirtytime_interval_handler(struct ctl_table *table, int write,
53 +                              void __user *buffer, size_t *lenp, loff_t *ppos);
55  struct ctl_table;
56  int dirty_writeback_centisecs_handler(struct ctl_table *, int,
57 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
58 index 88ea2d6..ce410bb 100644
59 --- a/kernel/sysctl.c
60 +++ b/kernel/sysctl.c
61 @@ -1228,6 +1228,14 @@ static struct ctl_table vm_table[] = {
62                 .extra1         = &zero,
63         },
64         {
65 +               .procname       = "dirtytime_expire_seconds",
66 +               .data           = &dirtytime_expire_interval,
67 +               .maxlen         = sizeof(dirty_expire_interval),
68 +               .mode           = 0644,
69 +               .proc_handler   = dirtytime_interval_handler,
70 +               .extra1         = &zero,
71 +       },
72 +       {
73                 .procname       = "nr_pdflush_threads",
74                 .mode           = 0444 /* read-only */,
75                 .proc_handler   = pdflush_proc_obsolete,