From mboxrd@z Thu Jan 1 00:00:00 1970 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=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,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 DF13BC3F35D for ; Thu, 27 Feb 2020 14:13:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A778924697 for ; Thu, 27 Feb 2020 14:13:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582812799; bh=brj/SN8Nv5cyMyCMHkqbOVzue6B+jN0Rrn+n6DFRH50=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=qQ1CVKMppO10rd+xUqXQFQm2FXmiVYhFPsP+/e8at2QFbNTFatDgCsD5mDKxCvxDk eazseiZ1f8gYlYm+z9HC0a1DkQQwImDH9gBhQKVBOzR1UD37BAT6LQ5kVO8CkHvX5I TCR4G+7fi0s9UeG4a0SFZdwCAR4IqhweM0B/X7Jw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730449AbgB0ONS (ORCPT ); Thu, 27 Feb 2020 09:13:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:52096 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388567AbgB0ONL (ORCPT ); Thu, 27 Feb 2020 09:13:11 -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 68458246A0; Thu, 27 Feb 2020 14:13:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582812790; bh=brj/SN8Nv5cyMyCMHkqbOVzue6B+jN0Rrn+n6DFRH50=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BClGrV7MMfc22cQpX80ZRe8/4QMG8vgW/+44jex1nJ5UhC7QmDXObHhRM9fiCs78r qp4gu8UB45SA+FwV/eLg72FfgSEYqZeddKXEVtlSiV+CRv7FBXKPdXogpaDxo2Mmv8 lsP2pCetBwgc9B2A/lJE/ieB/80eOjovVAwjtiGM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johannes Thumshirn , Nikolay Borisov , Qu Wenruo , Josef Bacik , David Sterba Subject: [PATCH 5.5 018/150] btrfs: handle logged extent failure properly Date: Thu, 27 Feb 2020 14:35:55 +0100 Message-Id: <20200227132235.357370622@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200227132232.815448360@linuxfoundation.org> References: <20200227132232.815448360@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Josef Bacik commit bd727173e4432fe6cb70ba108dc1f3602c5409d7 upstream. If we're allocating a logged extent we attempt to insert an extent record for the file extent directly. We increase space_info->bytes_reserved, because the extent entry addition will call btrfs_update_block_group(), which will convert the ->bytes_reserved to ->bytes_used. However if we fail at any point while inserting the extent entry we will bail and leave space on ->bytes_reserved, which will trigger a WARN_ON() on umount. Fix this by pinning the space if we fail to insert, which is what happens in every other failure case that involves adding the extent entry. CC: stable@vger.kernel.org # 5.4+ Reviewed-by: Johannes Thumshirn Reviewed-by: Nikolay Borisov Reviewed-by: Qu Wenruo Signed-off-by: Josef Bacik Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/extent-tree.c | 2 ++ 1 file changed, 2 insertions(+) --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -4430,6 +4430,8 @@ int btrfs_alloc_logged_file_extent(struc ret = alloc_reserved_file_extent(trans, 0, root_objectid, 0, owner, offset, ins, 1); + if (ret) + btrfs_pin_extent(fs_info, ins->objectid, ins->offset, 1); btrfs_put_block_group(block_group); return ret; }