Received: by 10.223.176.46 with SMTP id f43csp287611wra; Tue, 23 Jan 2018 21:07:08 -0800 (PST) X-Google-Smtp-Source: AH8x2247yimd95Z8amtj/0B4o/QCwg+VdbQbtOJlfB4X5HuBWglhRTUgLcJ9xOxjsdOj/v8wcOyd X-Received: by 2002:a17:902:b195:: with SMTP id s21-v6mr2120228plr.253.1516770428825; Tue, 23 Jan 2018 21:07:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516770428; cv=none; d=google.com; s=arc-20160816; b=xF8EnrfJ5y+NRKv8Fq9zrrIKjxZPmZoBY00N96js9WGqDQ421pjCpPdROfWOtn9heF uYudOMRaRZZwKQYQT33uytfCw4G3fwdBg2qtN1LeDroSy07h9OvRRSMVNSXYI9ROHWG3 RBh3LlASuU7dLdx+W2IKf1ccZBUNHxiMwdwiYMgOO3nbgfezrGQstdP4clGQ/12ggLi7 hkoDsiEXZudcpZzlVhbBD1wkMqN5XoheDJogeY/FuzHUYV23ucjc8k+W43vFgztY+WD2 CnULJBNLSIkryiVYxUsdeOKRObt0icubVzW75g2mqJSy0q5x6KRI5SR8VWsssqykxM54 Hgww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=GH0eJtuYNh+cRUy6Nj1OdmlTQ8UTPgM/WJcKtynxWBU=; b=b/gOVqMZHXQwMEBelzmVdVaF7rGbjeHlM9gSn8lRAdJ6sVR8CNgSJf4k6BiWRdLnJ8 UhoB0EbalePpNxrat4jEW68D3QJb+GgwZNWVxTM6Hv0SKGrNAW/K/Fpmi1yneOFwaaOy kqb8/NgdE4MW9GDa4ZN87nsAqfzglMtdEyIL0bG5GGUTEp3WeQbMCKp5t59H6DpnEH7I 2Ba0veGZkTtD/yoiqqM2OM0gX0DAhkKpfm30pQkySGGE7MGfGsqLrLUlrKxaeNMTGRYK +PTiHcKc0ht2Rq8fOvrY4DNsGnzglTWaAVR0OYispCRuEsItRLkUEz77HA5EY1MUqbzE OztQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=eZ1pui37; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m4-v6si392161plt.112.2018.01.23.21.06.55; Tue, 23 Jan 2018 21:07:08 -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; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=eZ1pui37; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752546AbeAXEO1 (ORCPT + 99 others); Tue, 23 Jan 2018 23:14:27 -0500 Received: from mail-cys01nam02on0106.outbound.protection.outlook.com ([104.47.37.106]:53792 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752172AbeAXEOY (ORCPT ); Tue, 23 Jan 2018 23:14:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=GH0eJtuYNh+cRUy6Nj1OdmlTQ8UTPgM/WJcKtynxWBU=; b=eZ1pui37CZeJLBVyG362zd2r9r1AZTsWQpjXFEALjewIRbeQK1lVZBrtOxXRRqXVxjRbQT3BvnuJhReaHSPaKksumtDtR5zvpbzmzjjkKNejE3Gv4RDd8jEGdejIpUAXr14EqhiXR9X9yNWGy84dtKg+jOHZZFszZwBhaqNBlfg= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0920.namprd21.prod.outlook.com (52.132.132.165) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.464.3; Wed, 24 Jan 2018 04:14:21 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::6485:b98:d15e:9da7]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::6485:b98:d15e:9da7%2]) with mapi id 15.20.0464.000; Wed, 24 Jan 2018 04:14:21 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Nikolay Borisov , David Sterba , Sasha Levin Subject: [PATCH AUTOSEL for 4.14 002/100] btrfs: Fix transaction abort during failure in btrfs_rm_dev_item Thread-Topic: [PATCH AUTOSEL for 4.14 002/100] btrfs: Fix transaction abort during failure in btrfs_rm_dev_item Thread-Index: AQHTlMnPDRNW3BZvnU6OWGKEGvxPxw== Date: Wed, 24 Jan 2018 04:14:21 +0000 Message-ID: <20180124041414.32065-2-alexander.levin@microsoft.com> References: <20180124041414.32065-1-alexander.levin@microsoft.com> In-Reply-To: <20180124041414.32065-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB0920;6:H+hdvhoe1ILUG0R4SfrinKS0KuckofCHp4SGm7UkgHub809M62uTQ3CifgYUwtzcNlRmIp9WXtyw/GrMN7QpqrPiS3E2m1yhV4wEpnbHPYl60c4RDGSwuKsk5RLSuRjxCEsKQEGIcYUtH53xXzdQoA5TCSptZ219NwqV4sjoT3gX77z5lkCpxgScvfF/4hUSOl0JVBoWeRvaA0eVG8uReJ9L5puRKBuJ4K9Zrx1HJoxrMToC/bVrbAebfFFpPG8jrGH0dFNCJRbGqGP9FHUMIcuGZbsHSNnx2EBEIFdLQPFUjqT73lMK3YaEZIfRMw/2ylAbp6LNm/E85IfHZ8ltDqHrl4iAKQ+wXHg2uBmod0rJtRghazPoTv81oXr9c78K;5:L/+lcFygVIXWoZZu3jHTyWlbbbsnW7xlinak7bR4JYoyR8ZgeNcMM7tsUrSpp2ceADfxu1+34vnYd5vitGDiQ1I/txT3sqxGPu/3vuJ7dHIxDs6jpsb1FSrMizkWLNMHDEnGc4HOlbDMh+YCVrZNQHXvNt+0ijAN7OyAo3vQneM=;24:7JRa17gwTj4sqmlu0Yf4JPL8RviseZbELOW0FDau9kmqTK8UKTARZGU5qKGLjEovv4F6ILM2rBiUxtolXrK86k3Ex4ZGYtyziWYLCXG9k5Q=;7:BJgyQQyMks3MivJHy6up5nFlYY60NAFlXWcvJo1wpbAs/zjVuJTAr5ZJZUAsoRV1EOVxc5U0QH6/y+PaUHBS9oRF7moLZ5FljPJce+9qLfDeo+UxrDBmRbhYkqMC9mxKbK5lNWG5cOLRz6OdoTvqft74BW4yU6wAPdlQst+7ICt94RHSX1OCSLnFbx3hPlUpwwDmmkG5XAaUMHMTCRUlf1oMvRLh1uVOSWyI/Xl5FVawq9w8ancuWRoVZHfR7A9B x-ms-exchange-antispam-srfa-diagnostics: SSOS;SSOR; x-ms-office365-filtering-correlation-id: 35ba452f-d6f5-4097-fbb5-08d562e0f238 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(2017052603307)(7193020);SRVR:DM5PR2101MB0920; x-ms-traffictypediagnostic: DM5PR2101MB0920: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(61425038)(6040501)(2401047)(8121501046)(5005006)(3231046)(2400081)(944501161)(93006095)(93001095)(3002001)(10201501046)(6055026)(61426038)(61427038)(6041288)(20161123558120)(20161123564045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(6072148)(201708071742011);SRVR:DM5PR2101MB0920;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0920; x-forefront-prvs: 056297E276 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39860400002)(366004)(376002)(396003)(39380400002)(346002)(189003)(199004)(105586002)(106356001)(551934003)(86362001)(2900100001)(66066001)(305945005)(14454004)(22452003)(72206003)(3280700002)(3660700001)(10290500003)(5660300001)(36756003)(2950100002)(7736002)(478600001)(110136005)(316002)(97736004)(81166006)(6116002)(3846002)(26005)(1076002)(6346003)(54906003)(25786009)(81156014)(6436002)(10090500001)(68736007)(107886003)(99286004)(8676002)(8936002)(4326008)(5250100002)(2501003)(86612001)(6486002)(2906002)(6506007)(76176011)(6512007)(102836004)(53936002)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0920;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-message-info: 5TOjMTZahi4HmYdXNgjmH2BFZPZGXLLof8L9izV5ywT62rQdpOVstlMoJOe8HvI/0L8IYVSVAoZdOTf9MSnCUw== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 35ba452f-d6f5-4097-fbb5-08d562e0f238 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Jan 2018 04:14:21.6999 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0920 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- fs/btrfs/volumes.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 0c11121a8ace..4006b2a1233d 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -1765,20 +1765,24 @@ static int btrfs_rm_dev_item(struct btrfs_fs_info *= fs_info, key.offset =3D device->devid; =20 ret =3D btrfs_search_slot(trans, root, &key, path, -1, 1); - if (ret < 0) - goto out; - - if (ret > 0) { - ret =3D -ENOENT; + if (ret) { + if (ret > 0) + ret =3D -ENOENT; + btrfs_abort_transaction(trans, ret); + btrfs_end_transaction(trans); goto out; } =20 ret =3D 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 =3D btrfs_commit_transaction(trans); return ret; } =20 --=20 2.11.0