From patchwork Wed Nov 21 19:05:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10693081 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2D95D13BF for ; Wed, 21 Nov 2018 19:06:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1BB632B64D for ; Wed, 21 Nov 2018 19:06:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1008B2B694; Wed, 21 Nov 2018 19:06:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AA8152B64D for ; Wed, 21 Nov 2018 19:06:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732222AbeKVFlb (ORCPT ); Thu, 22 Nov 2018 00:41:31 -0500 Received: from mail-yw1-f66.google.com ([209.85.161.66]:38768 "EHLO mail-yw1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730172AbeKVFlb (ORCPT ); Thu, 22 Nov 2018 00:41:31 -0500 Received: by mail-yw1-f66.google.com with SMTP id i20so2677947ywc.5 for ; Wed, 21 Nov 2018 11:05:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=DTDAD38vSYBkub9gfA4jndGSFn3T+R5a7UQKxBBUTEY=; b=pnm3x3FPGZ/7XQNGpCh4H6P78YO1XJ0ZW5XB0DZ1JzDp3GLFQhuxEORhS6BGXacr5Y G9eZSHhKVgCkYkk+YK8YLj/nYn0iBy/VRc+CX8LcRmVA8aUc1uHkH3R2boP9u+6LOazX 9d/Rv2c9mXdBihSZ9hFU4SvpF23UDAYCaC/jqRwlxQ4Z9XYKoaDOkXcJNyKFynkmPCId lfiCebhMgSAcUpTzWFevFVIo8Mb33QeSAdoKtaHf/4YMf8xSHWOe+6UVabFsbpb+Dm3f Z8ephzGZLgdWpXx9TrmSJMsODSj0LpCH7x5EnkZhZluRuqQR5wTSqsJWU2aw0l8hix7K 8deQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=DTDAD38vSYBkub9gfA4jndGSFn3T+R5a7UQKxBBUTEY=; b=kOC0PxDFYpehW7hDT46smrfE3CUtFLclbJDWKAjRNUnM/R02gI1/jeR+WslPt13L93 xF0CMzeqlQG822Ah1yPxTPJmtxW3hsNa7jD8uhZQ3GzbErFfMiysmIVm1BazzDxaGabD ZZF9+Q7S1R/XnpLGTJmbsNNvQ29B8eoztrx7O+uRdpI4FPJmDI6KAki3BDakv6WHOLM3 eJELLAJfHC1EAkQAl/0tLrJiqJuvLKMFoN2zIDm0dPkSpykSjKzfsHRaWtZ0bCzS8xXO f55vBRK8N1JmbKkIPghy3XdkmZxiyJaJgb3LzN4zzu440KXaflt4CCQ9FlE/w9ArN0Ys hKMg== X-Gm-Message-State: AGRZ1gIDp23nHUkQUpodlzkpsNOUf+0e3myVnGP3+ESZp7d2fBe8hxFG Qk3FvtpCNekf6UVrkEmCUrKT6Du7Cds= X-Google-Smtp-Source: AJdET5dkOdFj1CILR0ehTJbWQp8vneHfUz5cudnP3iUKl9L2PiVS6BM7vZpkwI4QThJeoJ/vYgENAA== X-Received: by 2002:a81:3358:: with SMTP id z85mr7788872ywz.398.1542827158041; Wed, 21 Nov 2018 11:05:58 -0800 (PST) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id k206sm1602455ywa.16.2018.11.21.11.05.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Nov 2018 11:05:57 -0800 (PST) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 6/7] btrfs: cleanup pending bgs on transaction abort Date: Wed, 21 Nov 2018 14:05:44 -0500 Message-Id: <20181121190545.24798-7-josef@toxicpanda.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20181121190545.24798-1-josef@toxicpanda.com> References: <20181121190545.24798-1-josef@toxicpanda.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We may abort the transaction during a commit and not have a chance to run the pending bgs stuff, which will leave block groups on our list and cause us accounting issues and leaked memory. Fix this by running the pending bgs when we cleanup a transaction. Reviewed-by: Omar Sandoval Signed-off-by: Josef Bacik --- fs/btrfs/transaction.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 826a15a07fce..3c1be9db897c 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c @@ -2269,6 +2269,10 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans) btrfs_scrub_continue(fs_info); cleanup_transaction: btrfs_trans_release_metadata(trans); + /* This cleans up the pending block groups list properly. */ + if (!trans->aborted) + trans->aborted = ret; + btrfs_create_pending_block_groups(trans); btrfs_trans_release_chunk_metadata(trans); trans->block_rsv = NULL; btrfs_warn(fs_info, "Skipping commit of aborted transaction.");