Btrfs: Give all the worker threads descriptive names
authorChris Mason <chris.mason@oracle.com>
Fri, 15 Aug 2008 19:34:16 +0000 (15:34 -0400)
committerChris Mason <chris.mason@oracle.com>
Thu, 25 Sep 2008 15:04:06 +0000 (11:04 -0400)
Signed-off-by: Chris Mason <chris.mason@oracle.com>
fs/btrfs/async-thread.c
fs/btrfs/async-thread.h
fs/btrfs/disk-io.c

index bc2980c433ef7a8b980972c87d75e0578f3ad33d..5f2f5a8c2289c3ff55669a45a7899ae96747c934 100644 (file)
@@ -153,7 +153,7 @@ int btrfs_stop_workers(struct btrfs_workers *workers)
 /*
  * simple init on struct btrfs_workers
  */
-void btrfs_init_workers(struct btrfs_workers *workers, int max)
+void btrfs_init_workers(struct btrfs_workers *workers, char *name, int max)
 {
        workers->num_workers = 0;
        INIT_LIST_HEAD(&workers->worker_list);
@@ -161,6 +161,7 @@ void btrfs_init_workers(struct btrfs_workers *workers, int max)
        spin_lock_init(&workers->lock);
        workers->max_workers = max;
        workers->idle_thresh = 32;
+       workers->name = name;
 }
 
 /*
@@ -184,7 +185,9 @@ int btrfs_start_workers(struct btrfs_workers *workers, int num_workers)
                INIT_LIST_HEAD(&worker->worker_list);
                spin_lock_init(&worker->lock);
                atomic_set(&worker->num_pending, 0);
-               worker->task = kthread_run(worker_loop, worker, "btrfs");
+               worker->task = kthread_run(worker_loop, worker,
+                                          "btrfs-%s-%d", workers->name,
+                                          workers->num_workers + i);
                worker->workers = workers;
                if (IS_ERR(worker->task)) {
                        kfree(worker);
index 3436ff897597fe50966f5c33ef958981591d9965..43e44d115dd1a914cf2c8dbac8aaf312c8cb8271 100644 (file)
@@ -69,11 +69,14 @@ struct btrfs_workers {
 
        /* lock for finding the next worker thread to queue on */
        spinlock_t lock;
+
+       /* extra name for this worker */
+       char *name;
 };
 
 int btrfs_queue_worker(struct btrfs_workers *workers, struct btrfs_work *work);
 int btrfs_start_workers(struct btrfs_workers *workers, int num_workers);
 int btrfs_stop_workers(struct btrfs_workers *workers);
-void btrfs_init_workers(struct btrfs_workers *workers, int max);
+void btrfs_init_workers(struct btrfs_workers *workers, char *name, int max);
 int btrfs_requeue_work(struct btrfs_work *work);
 #endif
index 9601b13c7d7a9486c814f176104520090610d425..1bf210dadef6f34109063cd62b82d7a1ec143837 100644 (file)
@@ -492,11 +492,11 @@ static int __btree_submit_bio_hook(struct inode *inode, int rw, struct bio *bio,
 
        /*
         * when we're called for a write, we're already in the async
-        * submission context.  Just jump ingo btrfs_map_bio
+        * submission context.  Just jump into btrfs_map_bio
         */
        if (rw & (1 << BIO_RW)) {
                return btrfs_map_bio(BTRFS_I(inode)->root, rw, bio,
-                                    mirror_num, 0);
+                                    mirror_num, 1);
        }
 
        /*
@@ -528,6 +528,12 @@ static int btree_writepage(struct page *page, struct writeback_control *wbc)
 {
        struct extent_io_tree *tree;
        tree = &BTRFS_I(page->mapping->host)->io_tree;
+
+       if (current->flags & PF_MEMALLOC) {
+               redirty_page_for_writepage(wbc, page);
+               unlock_page(page);
+               return 0;
+       }
        return extent_write_full_page(tree, page, btree_get_extent, wbc);
 }
 
@@ -1363,8 +1369,9 @@ struct btrfs_root *open_ctree(struct super_block *sb,
         * queue work function gets called at interrupt time, and so it
         * cannot dynamically grow.
         */
-       btrfs_init_workers(&fs_info->workers, fs_info->thread_pool_size);
-       btrfs_init_workers(&fs_info->submit_workers,
+       btrfs_init_workers(&fs_info->workers, "worker",
+                          fs_info->thread_pool_size);
+       btrfs_init_workers(&fs_info->submit_workers, "submit",
                           min_t(u64, fs_devices->num_devices,
                           fs_info->thread_pool_size));
 
@@ -1374,9 +1381,10 @@ struct btrfs_root *open_ctree(struct super_block *sb,
         */
        fs_info->submit_workers.idle_thresh = 64;
 
-       btrfs_init_workers(&fs_info->fixup_workers, 1);
-       btrfs_init_workers(&fs_info->endio_workers, fs_info->thread_pool_size);
-       btrfs_init_workers(&fs_info->endio_write_workers,
+       btrfs_init_workers(&fs_info->fixup_workers, "fixup", 1);
+       btrfs_init_workers(&fs_info->endio_workers, "endio",
+                          fs_info->thread_pool_size);
+       btrfs_init_workers(&fs_info->endio_write_workers, "endio-write",
                           fs_info->thread_pool_size);
 
        /*