Received: by 10.223.176.5 with SMTP id f5csp985450wra; Fri, 2 Feb 2018 09:15:51 -0800 (PST) X-Google-Smtp-Source: AH8x226DoGf4sI6HELEk2vpZVppn7YTleGYDcS7lql8X1gDbyyh0oXKRPlxydDKpnMdIz45l6nyS X-Received: by 2002:a17:902:ab8d:: with SMTP id f13-v6mr1690421plr.215.1517591751338; Fri, 02 Feb 2018 09:15:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517591751; cv=none; d=google.com; s=arc-20160816; b=TP+ZnBZMjyBJODyOXWJof4Ue4WpmU5zAs3aD5Q8pFjTkRvq/sWFis0+IuNVU+AH43T 5DHUf2MBx51KCxvB5/fSnxZHGjplD2t46w3PGwoqDgpxsD7rPNhgMqBctqFbk7d6l11+ x0dZA3d9iKgoZ1CfueXtgyCYmXH/vCkNDPGO3tIc1lnexSsP0QM9JPCLnIV8uPhLoFVh ijXifGR7TULzZIH2OSXcrEPKButu9SyPxePLxniqKIJvY7PBeh2lMytRZA9wBa4pv7FA DFhQfmZgc2cU29NjqqtIFiThuJWb11oi4oin7kC786Ek+zD9RrlK4AGC7AvA3FozE5nk QEew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=DsQTHpx8GJx7/nIW69kAdC5H5+dmAwhGpK7MbaNCb+M=; b=rOSaCQbGuAxi/Pt9TrMCCNjJeetFFau3pVjB8iJQUwVwjagClN8aLoZ5oJpHGcxSRY cIbfhP1XMj8P1yoBDddtbAT+27GvJgCqBbc0zaYNiJPhqoCNGX62j2vfl+YWXs4tYvCQ LkaFulm9txNFvqClSuVYJ1D5KvU8PP6gGVA1Kvz9iDxEuUpjuxxlhVwHubZo9ZnNMQ/f P49SvQr1etYfEvKTe60y35TR7DZhOKOe0qnL7vMDprfvLvu+XUzDfo1GzFJyOELHG1Ai VDix3qrhGhHhYXZfgvsXarRZ0xiM2FRngHX/mMNFB0Y410w1FC0QIOUJ05xsYU9GASwI E9Ig== ARC-Authentication-Results: i=1; mx.google.com; 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 v81si638529pgb.570.2018.02.02.09.15.36; Fri, 02 Feb 2018 09:15:51 -0800 (PST) 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; 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 S1753713AbeBBRPK (ORCPT + 99 others); Fri, 2 Feb 2018 12:15:10 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:37814 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753043AbeBBRJK (ORCPT ); Fri, 2 Feb 2018 12:09:10 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 9AA6ADEE; Fri, 2 Feb 2018 17:09:09 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nikolay Borisov , David Sterba , Sasha Levin Subject: [PATCH 4.14 032/156] btrfs: Fix transaction abort during failure in btrfs_rm_dev_item Date: Fri, 2 Feb 2018 17:56:53 +0100 Message-Id: <20180202140841.784049008@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180202140840.242829545@linuxfoundation.org> References: <20180202140840.242829545@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Nikolay Borisov [ Upstream commit 5e9f2ad5b2904a7e81df6d9a3dbef29478952eac ] btrfs_rm_dev_item calls several function under an active transaction, however it fails to abort it if an error happens. Fix this by adding explicit btrfs_abort_transaction/btrfs_end_transaction calls. Signed-off-by: Nikolay Borisov Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/volumes.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -1765,20 +1765,24 @@ static int btrfs_rm_dev_item(struct btrf key.offset = device->devid; ret = btrfs_search_slot(trans, root, &key, path, -1, 1); - if (ret < 0) - goto out; - - if (ret > 0) { - ret = -ENOENT; + if (ret) { + if (ret > 0) + ret = -ENOENT; + btrfs_abort_transaction(trans, ret); + btrfs_end_transaction(trans); goto out; } ret = btrfs_del_item(trans, root, path); - if (ret) - goto out; + if (ret) { + btrfs_abort_transaction(trans, ret); + btrfs_end_transaction(trans); + } + out: btrfs_free_path(path); - btrfs_commit_transaction(trans); + if (!ret) + ret = btrfs_commit_transaction(trans); return ret; }