From patchwork Thu Jan 2 22:07:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 234691 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68F26C3276C for ; Thu, 2 Jan 2020 22:36:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3C1A221D7D for ; Thu, 2 Jan 2020 22:36:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578004593; bh=TrO/k8D3SWblGwhilHgaV+gXgyn2/xwQq4SJqBiDUd0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=rJ5QjrLehZofPrci1Ni7ThvYEZtlh2L5S2yQ1KLp+ykhMrXwf4Ib1LFa31m4jPmDF QiYn2g1YeA1CaalsHIYdj8NpQx6by0XXpUBx+aWAcFim6qP9JTFKyE9S+CyWde1DzU SzPHuxN0uJuN6kiDFha9XlQCuz/MvY/J+rbl9GmE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730560AbgABWgc (ORCPT ); Thu, 2 Jan 2020 17:36:32 -0500 Received: from mail.kernel.org ([198.145.29.99]:47772 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730589AbgABWg2 (ORCPT ); Thu, 2 Jan 2020 17:36:28 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DD57A22B48; Thu, 2 Jan 2020 22:36:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578004588; bh=TrO/k8D3SWblGwhilHgaV+gXgyn2/xwQq4SJqBiDUd0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Sh1KyxVRUE9dRGt2jOslYOEorxnRixETp7kZZyYnalHMeby5boxJvX6jolQnfnomj hL6yK2kOcXcgJ0HrMoPVdVwRSMLmF7gssvZxd711sp975+Pv/SNEWj/zx1lU5o8cD3 zgsyLV2h0nySkysDSwIIKYCUiAt9+zpZuHvOfw4A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Filipe Manana , Johannes Thumshirn , Josef Bacik , David Sterba , Sasha Levin Subject: [PATCH 4.4 070/137] btrfs: abort transaction after failed inode updates in create_subvol Date: Thu, 2 Jan 2020 23:07:23 +0100 Message-Id: <20200102220555.988675827@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200102220546.618583146@linuxfoundation.org> References: <20200102220546.618583146@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Josef Bacik [ Upstream commit c7e54b5102bf3614cadb9ca32d7be73bad6cecf0 ] We can just abort the transaction here, and in fact do that for every other failure in this function except these two cases. CC: stable@vger.kernel.org # 4.4+ Reviewed-by: Filipe Manana Reviewed-by: Johannes Thumshirn Signed-off-by: Josef Bacik Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Sasha Levin --- fs/btrfs/ioctl.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 3379490ce54d..119b1c5c279b 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -594,12 +594,18 @@ static noinline int create_subvol(struct inode *dir, btrfs_i_size_write(dir, dir->i_size + namelen * 2); ret = btrfs_update_inode(trans, root, dir); - BUG_ON(ret); + if (ret) { + btrfs_abort_transaction(trans, root, ret); + goto fail; + } ret = btrfs_add_root_ref(trans, root->fs_info->tree_root, objectid, root->root_key.objectid, btrfs_ino(dir), index, name, namelen); - BUG_ON(ret); + if (ret) { + btrfs_abort_transaction(trans, root, ret); + goto fail; + } ret = btrfs_uuid_tree_add(trans, root->fs_info->uuid_root, root_item.uuid, BTRFS_UUID_KEY_SUBVOL,