Skip to content

Commit 797d901

Browse files
jeffmahoneyjankara
authored andcommitted
reiserfs: use per-fs commit workqueues
The reiserfs write lock hasn't been the BKL for some time. There's no need to have different file systems queued up on the same workqueue. Signed-off-by: Jeff Mahoney <jeffm@suse.com> Signed-off-by: Jan Kara <jack@suse.cz>
1 parent 38583f0 commit 797d901

File tree

3 files changed

+20
-25
lines changed

3 files changed

+20
-25
lines changed

fs/reiserfs/journal.c

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,6 @@
5858
#define JOURNAL_WORK_ENTRY(h) (list_entry((h), struct reiserfs_journal_list, \
5959
j_working_list))
6060

61-
/* the number of mounted filesystems. This is used to decide when to
62-
** start and kill the commit workqueue
63-
*/
64-
static int reiserfs_mounted_fs_count;
65-
66-
static struct workqueue_struct *commit_wq;
67-
6861
#define JOURNAL_TRANS_HALF 1018 /* must be correct to keep the desc and commit
6962
structs at 4k */
7063
#define BUFNR 64 /*read ahead */
@@ -1882,7 +1875,6 @@ static int do_journal_release(struct reiserfs_transaction_handle *th,
18821875
}
18831876
}
18841877

1885-
reiserfs_mounted_fs_count--;
18861878
/* wait for all commits to finish */
18871879
cancel_delayed_work(&SB_JOURNAL(sb)->j_work);
18881880

@@ -1893,12 +1885,7 @@ static int do_journal_release(struct reiserfs_transaction_handle *th,
18931885
reiserfs_write_unlock(sb);
18941886

18951887
cancel_delayed_work_sync(&REISERFS_SB(sb)->old_work);
1896-
flush_workqueue(commit_wq);
1897-
1898-
if (!reiserfs_mounted_fs_count) {
1899-
destroy_workqueue(commit_wq);
1900-
commit_wq = NULL;
1901-
}
1888+
flush_workqueue(REISERFS_SB(sb)->commit_wq);
19021889

19031890
free_journal_ram(sb);
19041891

@@ -2807,10 +2794,6 @@ int journal_init(struct super_block *sb, const char *j_dev_name,
28072794
goto free_and_return;
28082795
}
28092796

2810-
reiserfs_mounted_fs_count++;
2811-
if (reiserfs_mounted_fs_count <= 1)
2812-
commit_wq = alloc_workqueue("reiserfs", WQ_MEM_RECLAIM, 0);
2813-
28142797
INIT_DELAYED_WORK(&journal->j_work, flush_async_commits);
28152798
journal->j_work_sb = sb;
28162799
return 0;
@@ -4134,7 +4117,8 @@ static int do_journal_end(struct reiserfs_transaction_handle *th,
41344117
flush_commit_list(sb, jl, 1);
41354118
flush_journal_list(sb, jl, 1);
41364119
} else if (!(jl->j_state & LIST_COMMIT_PENDING))
4137-
queue_delayed_work(commit_wq, &journal->j_work, HZ / 10);
4120+
queue_delayed_work(REISERFS_SB(sb)->commit_wq,
4121+
&journal->j_work, HZ / 10);
41384122

41394123
/* if the next transaction has any chance of wrapping, flush
41404124
** transactions that might get overwritten. If any journal lists are very

fs/reiserfs/reiserfs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,8 @@ struct reiserfs_sb_info {
431431
/* Depth of the lock, start from -1 like the bkl */
432432
int lock_depth;
433433

434+
struct workqueue_struct *commit_wq;
435+
434436
/* Comment? -Hans */
435437
void (*end_io_handler) (struct buffer_head *, int);
436438
hashf_t s_hash_function; /* pointer to function which is used

fs/reiserfs/super.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,7 @@ static void reiserfs_put_super(struct super_block *s)
559559

560560
reiserfs_write_unlock(s);
561561
mutex_destroy(&REISERFS_SB(s)->lock);
562+
destroy_workqueue(REISERFS_SB(s)->commit_wq);
562563
kfree(s->s_fs_info);
563564
s->s_fs_info = NULL;
564565
}
@@ -1796,6 +1797,14 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
17961797
mutex_init(&sbi->lock);
17971798
sbi->lock_depth = -1;
17981799

1800+
sbi->commit_wq = alloc_workqueue("reiserfs/%s", WQ_MEM_RECLAIM, 0,
1801+
s->s_id);
1802+
if (!sbi->commit_wq) {
1803+
SWARN(silent, s, "", "Cannot allocate commit workqueue");
1804+
errval = -ENOMEM;
1805+
goto error_unlocked;
1806+
}
1807+
17991808
jdev_name = NULL;
18001809
if (reiserfs_parse_options
18011810
(s, (char *)data, &(sbi->s_mount_opt), &blocks, &jdev_name,
@@ -2402,18 +2411,18 @@ static int __init init_reiserfs_fs(void)
24022411
{
24032412
int ret;
24042413

2405-
if ((ret = init_inodecache())) {
2414+
ret = init_inodecache();
2415+
if (ret)
24062416
return ret;
2407-
}
24082417

24092418
reiserfs_proc_info_global_init();
24102419

24112420
ret = register_filesystem(&reiserfs_fs_type);
2421+
if (ret)
2422+
goto out;
24122423

2413-
if (ret == 0) {
2414-
return 0;
2415-
}
2416-
2424+
return 0;
2425+
out:
24172426
reiserfs_proc_info_global_done();
24182427
destroy_inodecache();
24192428

0 commit comments

Comments
 (0)