Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp313075ybi; Wed, 29 May 2019 22:03:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqxtOocN8ugprSFKYY/x42TuHsjjdXoGmrwK8SZVG8jFscwv2XNqu3T64F53XkFbOZJtul2g X-Received: by 2002:a17:902:108a:: with SMTP id c10mr1992996pla.48.1559192635911; Wed, 29 May 2019 22:03:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559192635; cv=none; d=google.com; s=arc-20160816; b=fMYUXrLyqRWl9QWtMeh8TCHvM9AvJ0iwFYD8MtUPu8/ePmXYhTri98Mz4eKR5SCYce HvPl1lTB72cFmaVYyj5iECoQU2OHWrmxLh396f5yaCV+dSG5ofu5nr1qse48eB3ShJxe b5wH7qGhrJ2g7T2hM/nugJ7upXwVsP+p58IYtukH00BELqdm9tdKhH9HcaCuviLxEi4E m0LSpAu7QzR0J0Fezdb7LFvN+yKe4FvTHo46IFMBwTyQfFJg+ZKXBeed3QvM9i88Y07Y gjptsqehbcdpzsvXwxWX5Cp5OFgKKQJ78Axh3mWQKFv4Mfxqzk2TFvq1k+1ARGix+NmX 8MGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=gQ0bBASo8xkRy8wu3e4K132GXrcjdxU2L/Vya+ceKMk=; b=zRnSsYslLAfGqB03VgOrJzMNVykQF/8Pgf1XEJigHhYmUY6SZwSF7Q8VTHEOwaseAY aUcLsmvUrOmMmIjuPQEn2zwBV354Jknm5r413BfR3Mw1cl7dJptbos3vJ9E7UPTvuiJe fclNEpl58RK3Evae3wwstIaWo2YxzDTnBecZwYEjPGKghCr1eOu+cTpxukGp2y3/j6hI AucNwgfGnFMbhQNS+6UBHoaER/cG/8+JiC3h27yPIQTtxsU1JMlevIUTn53zGBJ8jHqd 8uK3O1ngRtb4Jv5eI+nSXrYuZxy71ca6I4Tsy9bZzBmd6KiP69bwlAcsU4vk4lNFKNmp 3yEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LSxh7EZM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o94si2007816pjb.37.2019.05.29.22.03.38; Wed, 29 May 2019 22:03:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LSxh7EZM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389163AbfE3FAR (ORCPT + 99 others); Thu, 30 May 2019 01:00:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:44488 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727623AbfE3DJd (ORCPT ); Wed, 29 May 2019 23:09:33 -0400 Received: from localhost (ip67-88-213-2.z213-88-67.customer.algx.net [67.88.213.2]) (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 B98D724488; Thu, 30 May 2019 03:09:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559185772; bh=IMvOMrwfmvlEvp9BbnZTOcWW0xU9lq/DlMKMHRjOHos=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LSxh7EZMlVPTy6UG1KNpoUUfcDXRUyeNVBJyvMnBRs5nZo7tjo81ocxoujIYrMm93 cKXzV4coeNEhI85jBAVkwM+rRvT8AhOocghwsWcE6q1ZLyTdhC/1vuZ7aVoQDbd5zq A12Tr3xg6VhoMJIIODdL4uDc3vYSq4UhsIjbVpNg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Filipe Manana , Anand Jain , David Sterba Subject: [PATCH 5.1 025/405] Btrfs: do not abort transaction at btrfs_update_root() after failure to COW path Date: Wed, 29 May 2019 20:00:23 -0700 Message-Id: <20190530030541.927906826@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530030540.291644921@linuxfoundation.org> References: <20190530030540.291644921@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: Filipe Manana commit 72bd2323ec87722c115a5906bc6a1b31d11e8f54 upstream. Currently when we fail to COW a path at btrfs_update_root() we end up always aborting the transaction. However all the current callers of btrfs_update_root() are able to deal with errors returned from it, many do end up aborting the transaction themselves (directly or not, such as the transaction commit path), other BUG_ON() or just gracefully cancel whatever they were doing. When syncing the fsync log, we call btrfs_update_root() through tree-log.c:update_log_root(), and if it returns an -ENOSPC error, the log sync code does not abort the transaction, instead it gracefully handles the error and returns -EAGAIN to the fsync handler, so that it falls back to a transaction commit. Any other error different from -ENOSPC, makes the log sync code abort the transaction. So remove the transaction abort from btrfs_update_log() when we fail to COW a path to update the root item, so that if an -ENOSPC failure happens we avoid aborting the current transaction and have a chance of the fsync succeeding after falling back to a transaction commit. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=203413 Fixes: 79787eaab46121 ("btrfs: replace many BUG_ONs with proper error handling") Cc: stable@vger.kernel.org # 4.4+ Signed-off-by: Filipe Manana Reviewed-by: Anand Jain Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/root-tree.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) --- a/fs/btrfs/root-tree.c +++ b/fs/btrfs/root-tree.c @@ -132,10 +132,8 @@ int btrfs_update_root(struct btrfs_trans return -ENOMEM; ret = btrfs_search_slot(trans, root, key, path, 0, 1); - if (ret < 0) { - btrfs_abort_transaction(trans, ret); + if (ret < 0) goto out; - } if (ret != 0) { btrfs_print_leaf(path->nodes[0]);