diff options
author | Josef Bacik <josef@redhat.com> | 2011-04-05 11:57:27 -0400 |
---|---|---|
committer | Josef Bacik <josef@redhat.com> | 2011-04-08 13:00:32 -0400 |
commit | 06d5a5899d6d3ac401d2359b5eac6d2a3a0fe331 (patch) | |
tree | ff26c40dec6e649dca7316ce10412cc6c0ace985 /fs/btrfs | |
parent | be1a12a0dfed06cf1e62e35bf91620dc610a451a (diff) | |
download | op-kernel-dev-06d5a5899d6d3ac401d2359b5eac6d2a3a0fe331.zip op-kernel-dev-06d5a5899d6d3ac401d2359b5eac6d2a3a0fe331.tar.gz |
Btrfs: only retry transaction reservation once
I saw a lockup where we kept getting into this start transaction->commit
transaction loop because of enospce. The fact is if we fail to make our
reservation, we've tried _everything_ several times, so we only need to try and
commit the transaction once, and if that doesn't work then we really are out of
space and need to just exit. Thanks,
Signed-off-by: Josef Bacik <josef@redhat.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r-- | fs/btrfs/transaction.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 5b158da..4583008 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c @@ -181,6 +181,7 @@ static struct btrfs_trans_handle *start_transaction(struct btrfs_root *root, { struct btrfs_trans_handle *h; struct btrfs_transaction *cur_trans; + int retries = 0; int ret; if (root->fs_info->fs_state & BTRFS_SUPER_FLAG_ERROR) @@ -224,10 +225,18 @@ again: if (num_items > 0) { ret = btrfs_trans_reserve_metadata(h, root, num_items); - if (ret == -EAGAIN) { + if (ret == -EAGAIN && !retries) { + retries++; btrfs_commit_transaction(h, root); goto again; + } else if (ret == -EAGAIN) { + /* + * We have already retried and got EAGAIN, so really we + * don't have space, so set ret to -ENOSPC. + */ + ret = -ENOSPC; } + if (ret < 0) { btrfs_end_transaction(h, root); return ERR_PTR(ret); |