Skip to content

Commit

Permalink
Btrfs: be more polite in the async caching threads
Browse files Browse the repository at this point in the history
The semaphore used by the async caching threads can prevent a
transaction commit, which can make the FS appear to stall.  This
releases the semaphore more often when a transaction commit is
in progress.

Signed-off-by: Chris Mason <chris.mason@oracle.com>
  • Loading branch information
Chris Mason committed Jul 30, 2009
1 parent 276e680 commit f36f304
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
5 changes: 3 additions & 2 deletions fs/btrfs/extent-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,11 @@ static int caching_kthread(void *data)
else if (ret)
break;

if (need_resched()) {
if (need_resched() ||
btrfs_transaction_in_commit(fs_info)) {
btrfs_release_path(fs_info->extent_root, path);
up_read(&fs_info->extent_commit_sem);
cond_resched();
schedule_timeout(1);
goto again;
}

Expand Down
10 changes: 10 additions & 0 deletions fs/btrfs/transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,16 @@ static void update_super_roots(struct btrfs_root *root)
super->root_level = root_item->level;
}

int btrfs_transaction_in_commit(struct btrfs_fs_info *info)
{
int ret = 0;
spin_lock(&info->new_trans_lock);
if (info->running_transaction)
ret = info->running_transaction->in_commit;
spin_unlock(&info->new_trans_lock);
return ret;
}

int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
struct btrfs_root *root)
{
Expand Down
1 change: 1 addition & 0 deletions fs/btrfs/transaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,5 @@ int btrfs_record_root_in_trans(struct btrfs_trans_handle *trans,
struct btrfs_root *root);
int btrfs_write_and_wait_marked_extents(struct btrfs_root *root,
struct extent_io_tree *dirty_pages);
int btrfs_transaction_in_commit(struct btrfs_fs_info *info);
#endif

0 comments on commit f36f304

Please sign in to comment.