From patchwork Wed Apr 6 15:56:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastien Philbert X-Patchwork-Id: 8763591 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 3B6049F39A for ; Wed, 6 Apr 2016 15:57:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5D205201C8 for ; Wed, 6 Apr 2016 15:57:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6F2A3201EC for ; Wed, 6 Apr 2016 15:57:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752375AbcDFP4s (ORCPT ); Wed, 6 Apr 2016 11:56:48 -0400 Received: from mail-qk0-f193.google.com ([209.85.220.193]:36319 "EHLO mail-qk0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751226AbcDFP4r (ORCPT ); Wed, 6 Apr 2016 11:56:47 -0400 Received: by mail-qk0-f193.google.com with SMTP id e124so2342715qkc.3; Wed, 06 Apr 2016 08:56:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=6FqCEQiuy8JVHVyxCD+R6RlQfvnrCSr1IfkdMsxPPvw=; b=Gq0dRRFoMzFHv33zLog0LoIsgIoXGQGQYgAWSN1IgEjkvFzttjY+YgxjpgJfh6KSSM Q6+C4Jlu8crYXwQt1mBUUJ11zUBFpYpfjN2/09do/6722dN5xbU/7oSm2YAP5FLZy61z uJA/5bSRYclNzc6TDdzPJB4ocMqJF5svukLJ18CljCtMI+3IbOq6GRP2u5knItVFU28p AvLlVIeFa0PiXPRcRua61L1W+hsFWyV5tPqKzs/VBBgk68a7/SxGA68i906FI5iQdVzD EfcRIVTMpzTN+f96xGP1XJFW4jNw4LJ9L0J2XNnP6q4fPsEEj3yllQrCDCVx++dSwv5D fXTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=6FqCEQiuy8JVHVyxCD+R6RlQfvnrCSr1IfkdMsxPPvw=; b=an0gtVQ194JFf1C7313XSFjNYdQuBqbaL3gy4hlsznoMb5RMDGCi0LSV3cGap11VbM Q9pd4OyZO2QwNFWTAiGGPAo3qI9XOCAthc+EnXZJU55U0+OtrohfRV4rIiyZeSSMzHJe /cjabpLSIDv8OpHUCDDE9Krtm0OnWZLfn3R5GoKubFWEGn4pP36ajftjnSveZLmOrxaT loYTmDiJEOLoq3SyXhH2fJY9uNK4rOkjGQObLB21EHpngwkuU7tsye8JhW1m5j/35Ue8 ieVfS7LdR3IKMfd+U0Ejwv0GCeY9EWeEAK3dedzNtgAm3MdSMzykbk14YYxqxHIjPNkt tciw== X-Gm-Message-State: AD7BkJIcS0IYQhr0dFbXFIPXFV8cKvX6xWp7Sce7ReMsJZCVGcTT7qxVDgD3AHHGxzcCZQ== X-Received: by 10.55.78.70 with SMTP id c67mr47678838qkb.37.1459958200965; Wed, 06 Apr 2016 08:56:40 -0700 (PDT) Received: from nick-System-Product-Name.hitronhub.home (CPEbc4dfb2691f3-CMbc4dfb2691f0.cpe.net.cable.rogers.com. [99.231.110.121]) by smtp.googlemail.com with ESMTPSA id x189sm1503907qhb.43.2016.04.06.08.56.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 06 Apr 2016 08:56:40 -0700 (PDT) From: Bastien Philbert To: clm@fb.com Cc: jbacik@fb.com, dsterba@suse.com, linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] btrfs:Change BUG_ON to new error path in __clear_extent_bit Date: Wed, 6 Apr 2016 11:56:36 -0400 Message-Id: <1459958196-31346-1-git-send-email-bastienphilbert@gmail.com> X-Mailer: git-send-email 2.5.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This remove the unnessary BUG_ON if the allocation with alloc_extent_state_atomic fails due to this function failure not being unrecoverable. Instead we now change this BUG_ON into a new error path that jumps to the goto label, out from freeing previously allocated resources before returning the error code -ENOMEM to signal callers that the call to __clear_extent_bit failed due to a memory allocation failure. Signed-off-by: Bastien Philbert --- fs/btrfs/extent_io.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index d247fc0..4c87b77 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -682,7 +682,10 @@ hit_next: if (state->start < start) { prealloc = alloc_extent_state_atomic(prealloc); - BUG_ON(!prealloc); + if (!prealloc) { + err = -ENOMEM; + goto out; + } err = split_state(tree, state, prealloc, start); if (err) extent_io_tree_panic(tree, err);