Skip to content

Commit 5443be4

Browse files
committed
Btrfs: Give all the worker threads descriptive names
Signed-off-by: Chris Mason <chris.mason@oracle.com>
1 parent 777e6bd commit 5443be4

3 files changed

Lines changed: 24 additions & 10 deletions

File tree

‎fs/btrfs/async-thread.c‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,15 @@ int btrfs_stop_workers(struct btrfs_workers *workers)
153153
/*
154154
* simple init on struct btrfs_workers
155155
*/
156-
void btrfs_init_workers(struct btrfs_workers *workers, int max)
156+
void btrfs_init_workers(struct btrfs_workers *workers, char *name, int max)
157157
{
158158
workers->num_workers = 0;
159159
INIT_LIST_HEAD(&workers->worker_list);
160160
INIT_LIST_HEAD(&workers->idle_list);
161161
spin_lock_init(&workers->lock);
162162
workers->max_workers = max;
163163
workers->idle_thresh = 32;
164+
workers->name = name;
164165
}
165166

166167
/*
@@ -184,7 +185,9 @@ int btrfs_start_workers(struct btrfs_workers *workers, int num_workers)
184185
INIT_LIST_HEAD(&worker->worker_list);
185186
spin_lock_init(&worker->lock);
186187
atomic_set(&worker->num_pending, 0);
187-
worker->task = kthread_run(worker_loop, worker, "btrfs");
188+
worker->task = kthread_run(worker_loop, worker,
189+
"btrfs-%s-%d", workers->name,
190+
workers->num_workers + i);
188191
worker->workers = workers;
189192
if (IS_ERR(worker->task)) {
190193
kfree(worker);

‎fs/btrfs/async-thread.h‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,14 @@ struct btrfs_workers {
6969

7070
/* lock for finding the next worker thread to queue on */
7171
spinlock_t lock;
72+
73+
/* extra name for this worker */
74+
char *name;
7275
};
7376

7477
int btrfs_queue_worker(struct btrfs_workers *workers, struct btrfs_work *work);
7578
int btrfs_start_workers(struct btrfs_workers *workers, int num_workers);
7679
int btrfs_stop_workers(struct btrfs_workers *workers);
77-
void btrfs_init_workers(struct btrfs_workers *workers, int max);
80+
void btrfs_init_workers(struct btrfs_workers *workers, char *name, int max);
7881
int btrfs_requeue_work(struct btrfs_work *work);
7982
#endif

‎fs/btrfs/disk-io.c‎

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -492,11 +492,11 @@ static int __btree_submit_bio_hook(struct inode *inode, int rw, struct bio *bio,
492492

493493
/*
494494
* when we're called for a write, we're already in the async
495-
* submission context. Just jump ingo btrfs_map_bio
495+
* submission context. Just jump into btrfs_map_bio
496496
*/
497497
if (rw & (1 << BIO_RW)) {
498498
return btrfs_map_bio(BTRFS_I(inode)->root, rw, bio,
499-
mirror_num, 0);
499+
mirror_num, 1);
500500
}
501501

502502
/*
@@ -528,6 +528,12 @@ static int btree_writepage(struct page *page, struct writeback_control *wbc)
528528
{
529529
struct extent_io_tree *tree;
530530
tree = &BTRFS_I(page->mapping->host)->io_tree;
531+
532+
if (current->flags & PF_MEMALLOC) {
533+
redirty_page_for_writepage(wbc, page);
534+
unlock_page(page);
535+
return 0;
536+
}
531537
return extent_write_full_page(tree, page, btree_get_extent, wbc);
532538
}
533539

@@ -1363,8 +1369,9 @@ struct btrfs_root *open_ctree(struct super_block *sb,
13631369
* queue work function gets called at interrupt time, and so it
13641370
* cannot dynamically grow.
13651371
*/
1366-
btrfs_init_workers(&fs_info->workers, fs_info->thread_pool_size);
1367-
btrfs_init_workers(&fs_info->submit_workers,
1372+
btrfs_init_workers(&fs_info->workers, "worker",
1373+
fs_info->thread_pool_size);
1374+
btrfs_init_workers(&fs_info->submit_workers, "submit",
13681375
min_t(u64, fs_devices->num_devices,
13691376
fs_info->thread_pool_size));
13701377

@@ -1374,9 +1381,10 @@ struct btrfs_root *open_ctree(struct super_block *sb,
13741381
*/
13751382
fs_info->submit_workers.idle_thresh = 64;
13761383

1377-
btrfs_init_workers(&fs_info->fixup_workers, 1);
1378-
btrfs_init_workers(&fs_info->endio_workers, fs_info->thread_pool_size);
1379-
btrfs_init_workers(&fs_info->endio_write_workers,
1384+
btrfs_init_workers(&fs_info->fixup_workers, "fixup", 1);
1385+
btrfs_init_workers(&fs_info->endio_workers, "endio",
1386+
fs_info->thread_pool_size);
1387+
btrfs_init_workers(&fs_info->endio_write_workers, "endio-write",
13801388
fs_info->thread_pool_size);
13811389

13821390
/*

0 commit comments

Comments
 (0)