diff options
author | David Sterba <dsterba@suse.com> | 2020-07-07 18:30:06 +0200 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2021-06-21 15:19:06 +0200 |
commit | 6819703f5a365c95488b07066a8744841bf14231 (patch) | |
tree | 57bd25309dcc5b41f5f0aa5c9c057f98db45b476 | |
parent | 8c5ec995616f1202ab92e195fd75d6f60d86f85c (diff) | |
download | lwn-6819703f5a365c95488b07066a8744841bf14231.tar.gz lwn-6819703f5a365c95488b07066a8744841bf14231.zip |
btrfs: clear defrag status of a root if starting transaction fails
The defrag loop processes leaves in batches and starting transaction for
each. The whole defragmentation on a given root is protected by a bit
but in case the transaction fails, the bit is not cleared
In case the transaction fails the bit would prevent starting
defragmentation again, so make sure it's cleared.
CC: stable@vger.kernel.org # 4.4+
Reviewed-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r-- | fs/btrfs/transaction.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index e0a82aa7da89..22951621363f 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c @@ -1406,8 +1406,10 @@ int btrfs_defrag_root(struct btrfs_root *root) while (1) { trans = btrfs_start_transaction(root, 0); - if (IS_ERR(trans)) - return PTR_ERR(trans); + if (IS_ERR(trans)) { + ret = PTR_ERR(trans); + break; + } ret = btrfs_defrag_leaves(trans, root); |