diff options
author | Mark Fasheh <mark.fasheh@oracle.com> | 2007-11-07 17:40:36 -0500 |
---|---|---|
committer | Mark Fasheh <mark.fasheh@oracle.com> | 2008-01-25 18:05:42 -0500 |
commit | d147b3d630edef1d34de6ea819787a1ac1b8603b (patch) | |
tree | bd417b27fd58fa3c44be6b8451d929f848981ffd /fs | |
parent | 0957f00796157564281ea6ff2cea7ef4f897775a (diff) |
ocfs2: Support commit= mount option
Mostly taken from ext3. This allows the user to set the jbd commit interval,
in seconds. The default of 5 seconds stays the same, but now users can
easily increase the commit interval. Typically, this would be increased in
order to benefit performance at the expense of data-safety.
Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ocfs2/journal.c | 8 | ||||
-rw-r--r-- | fs/ocfs2/ocfs2.h | 1 | ||||
-rw-r--r-- | fs/ocfs2/super.c | 23 |
3 files changed, 30 insertions, 2 deletions
diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c index 4f440a88bf53..8b9ce2a729ab 100644 --- a/fs/ocfs2/journal.c +++ b/fs/ocfs2/journal.c | |||
@@ -313,14 +313,18 @@ int ocfs2_journal_dirty_data(handle_t *handle, | |||
313 | return err; | 313 | return err; |
314 | } | 314 | } |
315 | 315 | ||
316 | #define OCFS2_DEFAULT_COMMIT_INTERVAL (HZ * 5) | 316 | #define OCFS2_DEFAULT_COMMIT_INTERVAL (HZ * JBD_DEFAULT_MAX_COMMIT_AGE) |
317 | 317 | ||
318 | void ocfs2_set_journal_params(struct ocfs2_super *osb) | 318 | void ocfs2_set_journal_params(struct ocfs2_super *osb) |
319 | { | 319 | { |
320 | journal_t *journal = osb->journal->j_journal; | 320 | journal_t *journal = osb->journal->j_journal; |
321 | unsigned long commit_interval = OCFS2_DEFAULT_COMMIT_INTERVAL; | ||
322 | |||
323 | if (osb->osb_commit_interval) | ||
324 | commit_interval = osb->osb_commit_interval; | ||
321 | 325 | ||
322 | spin_lock(&journal->j_state_lock); | 326 | spin_lock(&journal->j_state_lock); |
323 | journal->j_commit_interval = OCFS2_DEFAULT_COMMIT_INTERVAL; | 327 | journal->j_commit_interval = commit_interval; |
324 | if (osb->s_mount_opt & OCFS2_MOUNT_BARRIER) | 328 | if (osb->s_mount_opt & OCFS2_MOUNT_BARRIER) |
325 | journal->j_flags |= JFS_BARRIER; | 329 | journal->j_flags |= JFS_BARRIER; |
326 | else | 330 | else |
diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h index f8f866144c6a..82802f5672a1 100644 --- a/fs/ocfs2/ocfs2.h +++ b/fs/ocfs2/ocfs2.h | |||
@@ -229,6 +229,7 @@ struct ocfs2_super | |||
229 | wait_queue_head_t checkpoint_event; | 229 | wait_queue_head_t checkpoint_event; |
230 | atomic_t needs_checkpoint; | 230 | atomic_t needs_checkpoint; |
231 | struct ocfs2_journal *journal; | 231 | struct ocfs2_journal *journal; |
232 | unsigned long osb_commit_interval; | ||
232 | 233 | ||
233 | enum ocfs2_local_alloc_state local_alloc_state; | 234 | enum ocfs2_local_alloc_state local_alloc_state; |
234 | struct buffer_head *local_alloc_bh; | 235 | struct buffer_head *local_alloc_bh; |
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c index 479ac50c86d9..8044ed97d362 100644 --- a/fs/ocfs2/super.c +++ b/fs/ocfs2/super.c | |||
@@ -83,6 +83,7 @@ MODULE_LICENSE("GPL"); | |||
83 | 83 | ||
84 | struct mount_options | 84 | struct mount_options |
85 | { | 85 | { |
86 | unsigned long commit_interval; | ||
86 | unsigned long mount_opt; | 87 | unsigned long mount_opt; |
87 | unsigned int atime_quantum; | 88 | unsigned int atime_quantum; |
88 | signed short slot; | 89 | signed short slot; |
@@ -149,6 +150,7 @@ enum { | |||
149 | Opt_data_writeback, | 150 | Opt_data_writeback, |
150 | Opt_atime_quantum, | 151 | Opt_atime_quantum, |
151 | Opt_slot, | 152 | Opt_slot, |
153 | Opt_commit, | ||
152 | Opt_err, | 154 | Opt_err, |
153 | }; | 155 | }; |
154 | 156 | ||
@@ -164,6 +166,7 @@ static match_table_t tokens = { | |||
164 | {Opt_data_writeback, "data=writeback"}, | 166 | {Opt_data_writeback, "data=writeback"}, |
165 | {Opt_atime_quantum, "atime_quantum=%u"}, | 167 | {Opt_atime_quantum, "atime_quantum=%u"}, |
166 | {Opt_slot, "preferred_slot=%u"}, | 168 | {Opt_slot, "preferred_slot=%u"}, |
169 | {Opt_commit, "commit=%u"}, | ||
167 | {Opt_err, NULL} | 170 | {Opt_err, NULL} |
168 | }; | 171 | }; |
169 | 172 | ||
@@ -442,6 +445,8 @@ unlock_osb: | |||
442 | osb->s_mount_opt = parsed_options.mount_opt; | 445 | osb->s_mount_opt = parsed_options.mount_opt; |
443 | osb->s_atime_quantum = parsed_options.atime_quantum; | 446 | osb->s_atime_quantum = parsed_options.atime_quantum; |
444 | osb->preferred_slot = parsed_options.slot; | 447 | osb->preferred_slot = parsed_options.slot; |
448 | if (parsed_options.commit_interval) | ||
449 | osb->osb_commit_interval = parsed_options.commit_interval; | ||
445 | 450 | ||
446 | if (!ocfs2_is_hard_readonly(osb)) | 451 | if (!ocfs2_is_hard_readonly(osb)) |
447 | ocfs2_set_journal_params(osb); | 452 | ocfs2_set_journal_params(osb); |
@@ -596,6 +601,7 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) | |||
596 | osb->s_mount_opt = parsed_options.mount_opt; | 601 | osb->s_mount_opt = parsed_options.mount_opt; |
597 | osb->s_atime_quantum = parsed_options.atime_quantum; | 602 | osb->s_atime_quantum = parsed_options.atime_quantum; |
598 | osb->preferred_slot = parsed_options.slot; | 603 | osb->preferred_slot = parsed_options.slot; |
604 | osb->osb_commit_interval = parsed_options.commit_interval; | ||
599 | 605 | ||
600 | sb->s_magic = OCFS2_SUPER_MAGIC; | 606 | sb->s_magic = OCFS2_SUPER_MAGIC; |
601 | 607 | ||
@@ -746,6 +752,7 @@ static int ocfs2_parse_options(struct super_block *sb, | |||
746 | mlog_entry("remount: %d, options: \"%s\"\n", is_remount, | 752 | mlog_entry("remount: %d, options: \"%s\"\n", is_remount, |
747 | options ? options : "(none)"); | 753 | options ? options : "(none)"); |
748 | 754 | ||
755 | mopt->commit_interval = 0; | ||
749 | mopt->mount_opt = 0; | 756 | mopt->mount_opt = 0; |
750 | mopt->atime_quantum = OCFS2_DEFAULT_ATIME_QUANTUM; | 757 | mopt->atime_quantum = OCFS2_DEFAULT_ATIME_QUANTUM; |
751 | mopt->slot = OCFS2_INVALID_SLOT; | 758 | mopt->slot = OCFS2_INVALID_SLOT; |
@@ -815,6 +822,18 @@ static int ocfs2_parse_options(struct super_block *sb, | |||
815 | if (option) | 822 | if (option) |
816 | mopt->slot = (s16)option; | 823 | mopt->slot = (s16)option; |
817 | break; | 824 | break; |
825 | case Opt_commit: | ||
826 | option = 0; | ||
827 | if (match_int(&args[0], &option)) { | ||
828 | status = 0; | ||
829 | goto bail; | ||
830 | } | ||
831 | if (option < 0) | ||
832 | return 0; | ||
833 | if (option == 0) | ||
834 | option = JBD_DEFAULT_MAX_COMMIT_AGE; | ||
835 | mopt->commit_interval = HZ * option; | ||
836 | break; | ||
818 | default: | 837 | default: |
819 | mlog(ML_ERROR, | 838 | mlog(ML_ERROR, |
820 | "Unrecognized mount option \"%s\" " | 839 | "Unrecognized mount option \"%s\" " |
@@ -863,6 +882,10 @@ static int ocfs2_show_options(struct seq_file *s, struct vfsmount *mnt) | |||
863 | if (osb->s_atime_quantum != OCFS2_DEFAULT_ATIME_QUANTUM) | 882 | if (osb->s_atime_quantum != OCFS2_DEFAULT_ATIME_QUANTUM) |
864 | seq_printf(s, ",atime_quantum=%u", osb->s_atime_quantum); | 883 | seq_printf(s, ",atime_quantum=%u", osb->s_atime_quantum); |
865 | 884 | ||
885 | if (osb->osb_commit_interval) | ||
886 | seq_printf(s, ",commit=%u", | ||
887 | (unsigned) (osb->osb_commit_interval / HZ)); | ||
888 | |||
866 | return 0; | 889 | return 0; |
867 | } | 890 | } |
868 | 891 | ||