Btrfs: set ioprio of scrub readahead to idle
authorStefan Behrens <sbehrens@giantdisaster.de>
Fri, 3 Feb 2012 10:20:04 +0000 (11:20 +0100)
committerJosef Bacik <josef@redhat.com>
Wed, 30 May 2012 14:23:43 +0000 (10:23 -0400)
Reduce ioprio class of scrub readahead threads to idle priority.
This setting is fixed. This priority has shown the best performance
during all measurements.

Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
fs/btrfs/ctree.h
fs/btrfs/reada.c

index e176f8c551f7b752352715869797b284e330a4b2..1c665ebe47e052565b66042433564df977f720bd 100644 (file)
@@ -173,6 +173,9 @@ static int btrfs_csum_sizes[] = { 4, 0 };
 #define BTRFS_FT_XATTR         8
 #define BTRFS_FT_MAX           9
 
+/* ioprio of readahead is set to idle */
+#define BTRFS_IOPRIO_READA (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_IDLE, 0))
+
 /*
  * The key defines the order in the tree, and so it also defines (optimal)
  * block layout.
index ac5d010858848d007e380d529476ad9eb4f6fb31..48a4882d8ad5955eaa0be2b940e35f0b3b2a7f6f 100644 (file)
@@ -718,13 +718,18 @@ static void reada_start_machine_worker(struct btrfs_work *work)
 {
        struct reada_machine_work *rmw;
        struct btrfs_fs_info *fs_info;
+       int old_ioprio;
 
        rmw = container_of(work, struct reada_machine_work, work);
        fs_info = rmw->fs_info;
 
        kfree(rmw);
 
+       old_ioprio = IOPRIO_PRIO_VALUE(task_nice_ioclass(current),
+                                      task_nice_ioprio(current));
+       set_task_ioprio(current, BTRFS_IOPRIO_READA);
        __reada_start_machine(fs_info);
+       set_task_ioprio(current, old_ioprio);
 }
 
 static void __reada_start_machine(struct btrfs_fs_info *fs_info)