浏览代码

ext4: disable synchronous transaction batching if max_batch_time==0

The mount manpage says of the max_batch_time option,

	This optimization can be turned off entirely
	by setting max_batch_time to 0.

But the code doesn't do that.  So fix the code to do
that.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Cc: stable@vger.kernel.org
Eric Sandeen 11 年之前
父节点
当前提交
5dd214248f
共有 2 个文件被更改,包括 4 次插入3 次删除
  1. 0 2
      fs/ext4/super.c
  2. 4 1
      fs/jbd2/transaction.c

+ 0 - 2
fs/ext4/super.c

@@ -1525,8 +1525,6 @@ static int handle_mount_opt(struct super_block *sb, char *opt, int token,
 			arg = JBD2_DEFAULT_MAX_COMMIT_AGE;
 			arg = JBD2_DEFAULT_MAX_COMMIT_AGE;
 		sbi->s_commit_interval = HZ * arg;
 		sbi->s_commit_interval = HZ * arg;
 	} else if (token == Opt_max_batch_time) {
 	} else if (token == Opt_max_batch_time) {
-		if (arg == 0)
-			arg = EXT4_DEF_MAX_BATCH_TIME;
 		sbi->s_max_batch_time = arg;
 		sbi->s_max_batch_time = arg;
 	} else if (token == Opt_min_batch_time) {
 	} else if (token == Opt_min_batch_time) {
 		sbi->s_min_batch_time = arg;
 		sbi->s_min_batch_time = arg;

+ 4 - 1
fs/jbd2/transaction.c

@@ -1588,9 +1588,12 @@ int jbd2_journal_stop(handle_t *handle)
 	 * to perform a synchronous write.  We do this to detect the
 	 * to perform a synchronous write.  We do this to detect the
 	 * case where a single process is doing a stream of sync
 	 * case where a single process is doing a stream of sync
 	 * writes.  No point in waiting for joiners in that case.
 	 * writes.  No point in waiting for joiners in that case.
+	 *
+	 * Setting max_batch_time to 0 disables this completely.
 	 */
 	 */
 	pid = current->pid;
 	pid = current->pid;
-	if (handle->h_sync && journal->j_last_sync_writer != pid) {
+	if (handle->h_sync && journal->j_last_sync_writer != pid &&
+	    journal->j_max_batch_time) {
 		u64 commit_time, trans_time;
 		u64 commit_time, trans_time;
 
 
 		journal->j_last_sync_writer = pid;
 		journal->j_last_sync_writer = pid;