]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
btrfs: account for trans_block_rsv in may_commit_transaction
authorJosef Bacik <josef@toxicpanda.com>
Fri, 13 Mar 2020 19:58:07 +0000 (15:58 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 22 Jun 2020 07:32:24 +0000 (09:32 +0200)
[ Upstream commit bb4f58a747f0421b10645fbf75a6acc88da0de50 ]

On ppc64le with 64k page size (respectively 64k block size) generic/320
was failing and debug output showed we were getting a premature ENOSPC
with a bunch of space in btrfs_fs_info::trans_block_rsv.

This meant there were still open transaction handles holding space, yet
the flusher didn't commit the transaction because it deemed the freed
space won't be enough to satisfy the current reserve ticket. Fix this
by accounting for space in trans_block_rsv when deciding whether the
current transaction should be committed or not.

Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Tested-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/btrfs/space-info.c

index ff17a44203588c8ea98f7bbbbc35c8a5fd73431d..3c0e9999bfd75ceaf4283db48819b5902316da11 100644 (file)
@@ -626,6 +626,7 @@ static int may_commit_transaction(struct btrfs_fs_info *fs_info,
        struct reserve_ticket *ticket = NULL;
        struct btrfs_block_rsv *delayed_rsv = &fs_info->delayed_block_rsv;
        struct btrfs_block_rsv *delayed_refs_rsv = &fs_info->delayed_refs_rsv;
+       struct btrfs_block_rsv *trans_rsv = &fs_info->trans_block_rsv;
        struct btrfs_trans_handle *trans;
        u64 bytes_needed;
        u64 reclaim_bytes = 0;
@@ -688,6 +689,11 @@ static int may_commit_transaction(struct btrfs_fs_info *fs_info,
        spin_lock(&delayed_refs_rsv->lock);
        reclaim_bytes += delayed_refs_rsv->reserved;
        spin_unlock(&delayed_refs_rsv->lock);
+
+       spin_lock(&trans_rsv->lock);
+       reclaim_bytes += trans_rsv->reserved;
+       spin_unlock(&trans_rsv->lock);
+
        if (reclaim_bytes >= bytes_needed)
                goto commit;
        bytes_needed -= reclaim_bytes;