Re: [PATCH] Give kjournald a IOPRIO_CLASS_RT io priority

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Andrew Morton
Date: Thursday, October 2, 2008 - 10:24 pm

On Thu, 2 Oct 2008 22:00:40 -0700 Arjan van de Ven <arjan@infradead.org> wrote:


If someone has an hour or so to kill, we can pretend to fix it:


 fs/ext3/super.c         |   12 +++++++++++-
 fs/jbd/transaction.c    |   13 +++++++++++--
 include/linux/ext3_fs.h |    1 +
 include/linux/jbd.h     |    1 +
 4 files changed, 24 insertions(+), 3 deletions(-)

diff -puN fs/ext3/super.c~a fs/ext3/super.c
--- a/fs/ext3/super.c~a
+++ a/fs/ext3/super.c
@@ -617,6 +617,8 @@ static int ext3_show_options(struct seq_
 		seq_puts(seq, ",barrier=1");
 	if (test_opt(sb, NOBH))
 		seq_puts(seq, ",nobh");
+	if (test_opt(sb, AKPM))
+		seq_puts(seq, ",akpm");
 
 	if (test_opt(sb, DATA_FLAGS) == EXT3_MOUNT_JOURNAL_DATA)
 		seq_puts(seq, ",data=journal");
@@ -757,7 +759,7 @@ enum {
 	Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
 	Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota,
 	Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota,
-	Opt_grpquota
+	Opt_grpquota, Opt_akpm,
 };
 
 static match_table_t tokens = {
@@ -808,6 +810,7 @@ static match_table_t tokens = {
 	{Opt_usrquota, "usrquota"},
 	{Opt_barrier, "barrier=%u"},
 	{Opt_resize, "resize"},
+	{Opt_akpm, "akpm"},
 	{Opt_err, NULL},
 };
 
@@ -1097,6 +1100,9 @@ set_qf_format:
 			set_opt(sbi->s_mount_opt, QUOTA);
 			set_opt(sbi->s_mount_opt, GRPQUOTA);
 			break;
+		case Opt_akpm:
+			set_opt(sbi->s_mount_opt, AKPM);
+			break;
 		case Opt_noquota:
 			if (sb_any_quota_enabled(sb) ||
 			    sb_any_quota_suspended(sb)) {
@@ -1986,6 +1992,10 @@ static void ext3_init_journal_params(str
 		journal->j_flags |= JFS_BARRIER;
 	else
 		journal->j_flags &= ~JFS_BARRIER;
+	if (test_opt(sb, AKPM))
+		journal->j_flags |= JFS_AKPM;
+	else
+		journal->j_flags &= ~JFS_AKPM;
 	spin_unlock(&journal->j_state_lock);
 }
 
diff -puN include/linux/ext3_fs.h~a include/linux/ext3_fs.h
--- a/include/linux/ext3_fs.h~a
+++ a/include/linux/ext3_fs.h
@@ -380,6 +380,7 @@ struct ext3_inode {
 #define EXT3_MOUNT_QUOTA		0x80000 /* Some quota option set */
 #define EXT3_MOUNT_USRQUOTA		0x100000 /* "old" user quota */
 #define EXT3_MOUNT_GRPQUOTA		0x200000 /* "old" group quota */
+#define EXT3_MOUNT_AKPM			0x400000
 
 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
 #ifndef _LINUX_EXT2_FS_H
diff -puN include/linux/jbd.h~a include/linux/jbd.h
--- a/include/linux/jbd.h~a
+++ a/include/linux/jbd.h
@@ -816,6 +816,7 @@ struct journal_s
 #define JFS_FLUSHED	0x008	/* The journal superblock has been flushed */
 #define JFS_LOADED	0x010	/* The journal superblock has been loaded */
 #define JFS_BARRIER	0x020	/* Use IDE barriers */
+#define JFS_AKPM	0x040
 
 /*
  * Function declarations for the journaling transaction and buffer
diff -puN fs/jbd/transaction.c~a fs/jbd/transaction.c
--- a/fs/jbd/transaction.c~a
+++ a/fs/jbd/transaction.c
@@ -537,6 +537,7 @@ do_get_write_access(handle_t *handle, st
 	int error;
 	char *frozen_buffer = NULL;
 	int need_copy = 0;
+	int locked;
 
 	if (is_handle_aborted(handle))
 		return -EROFS;
@@ -552,7 +553,14 @@ repeat:
 
 	/* @@@ Need to check for errors here at some point. */
 
-	lock_buffer(bh);
+	locked = 0;
+	if (journal->j_flags & JFS_AKPM) {
+		if (trylock_buffer(bh))
+			locked = 1;	/* lolz */
+	} else {
+		lock_buffer(bh);
+		locked = 1;
+	}
 	jbd_lock_bh_state(bh);
 
 	/* We now hold the buffer lock so it is safe to query the buffer
@@ -591,7 +599,8 @@ repeat:
 		jbd_unexpected_dirty_buffer(jh);
 	}
 
-	unlock_buffer(bh);
+	if (locked)
+		unlock_buffer(bh);
 
 	error = -EROFS;
 	if (is_handle_aborted(handle)) {
_


(might emit nasty warnings or assertion failures which will need to be
disabled)


Mount a junk partition with `-oakpm' and run some benchmarks.  If the
results are "wow" then it's worth spending time on.  If the results are
"meh" then we can not bother..

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] Give kjournald a IOPRIO_CLASS_RT io priority, Arjan van de Ven, (Wed Oct 1, 8:00 pm)
Re: [PATCH] Give kjournald a IOPRIO_CLASS_RT io priority, Andrew Morton, (Wed Oct 1, 11:55 pm)
Re: [PATCH] Give kjournald a IOPRIO_CLASS_RT io priority, Arjan van de Ven, (Thu Oct 2, 6:05 am)
Re: [PATCH] Give kjournald a IOPRIO_CLASS_RT io priority, Arjan van de Ven, (Thu Oct 2, 6:12 am)
Re: [PATCH] Give kjournald a IOPRIO_CLASS_RT io priority, Arjan van de Ven, (Thu Oct 2, 6:14 am)
Re: [PATCH] Give kjournald a IOPRIO_CLASS_RT io priority, Arjan van de Ven, (Thu Oct 2, 6:16 am)
Re: [PATCH] Give kjournald a IOPRIO_CLASS_RT io priority, Arjan van de Ven, (Thu Oct 2, 6:36 am)
Re: [PATCH] Give kjournald a IOPRIO_CLASS_RT io priority, Arjan van de Ven, (Thu Oct 2, 7:26 am)
Re: [PATCH] Give kjournald a IOPRIO_CLASS_RT io priority, Arjan van de Ven, (Thu Oct 2, 7:33 am)
Re: [PATCH] Give kjournald a IOPRIO_CLASS_RT io priority, Arjan van de Ven, (Thu Oct 2, 12:04 pm)
Re: [PATCH] Give kjournald a IOPRIO_CLASS_RT io priority, Arjan van de Ven, (Thu Oct 2, 9:01 pm)
Re: [PATCH] Give kjournald a IOPRIO_CLASS_RT io priority, Arjan van de Ven, (Thu Oct 2, 9:23 pm)
Re: [PATCH] Give kjournald a IOPRIO_CLASS_RT io priority, Arjan van de Ven, (Thu Oct 2, 9:43 pm)
Re: [PATCH] Give kjournald a IOPRIO_CLASS_RT io priority, Arjan van de Ven, (Thu Oct 2, 9:45 pm)
Re: [PATCH] Give kjournald a IOPRIO_CLASS_RT io priority, Arjan van de Ven, (Thu Oct 2, 10:00 pm)
Re: [PATCH] Give kjournald a IOPRIO_CLASS_RT io priority, Andrew Morton, (Thu Oct 2, 10:24 pm)
Re: [PATCH] Give kjournald a IOPRIO_CLASS_RT io priority, Arjan van de Ven, (Fri Oct 3, 10:21 am)
Re: [PATCH] Give kjournald a IOPRIO_CLASS_RT io priority, Joseph Fannin, (Sat Oct 4, 10:14 am)