Received: by 10.213.65.68 with SMTP id h4csp2113693imn; Sun, 8 Apr 2018 20:03:45 -0700 (PDT) X-Google-Smtp-Source: AIpwx48ywKJFNSHekH8FYHMHfQHsjD8kOhsE0HaQewnXIx46TAEpsMds4RuBqAdrwAf1AdtdLgcY X-Received: by 2002:a17:902:ab88:: with SMTP id f8-v6mr36722552plr.34.1523243025067; Sun, 08 Apr 2018 20:03:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243025; cv=none; d=google.com; s=arc-20160816; b=C4ZB2Gq4RwhQni8roAPxr5GYmWS18pO+SBliEk1Cymml2IBM84w2I7EnaJrV6FlZPU MwDLDeYD/d94kjWkcam7JGrgCuShj0jwtcrzF+jwxC209EaDhOsi/+JjDlopNIP22YKO pKKWe+IfBf4Qqs0UUHqIITgHsrUfaWcac4bY4PrMut0S5TOTdfxXHAOJg0/oa0s2WgCH 0QnHR6vO/+tyIIfhLS5xAh6PPMRizB3NiPP7wVw9ANo0NkX4bJy7iRJtyBjdOpazrnKc KKtxz/mHXkSEADD3fSd1YKsre77FyiAhIMQlvKVNUBxj/o7EkxdGb7fm3RpaEja95qT0 0VGA== 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=trkcWN2d8W0YlgeGhGzE0O8Mu3YTCzRQKWmXW+clE5A=; b=g09YxLhalMSTf+Ss3k/iZR+aQt3vGdgJmWVw1c4CNt6sssldpwOnq4opy/kaCgIjEq vCyFi31KmX5Mlj0rXdLpN0XXbXRYxQSmZCI1Ux7UAQz0FQ75pndYUdfZU4dJqvyC+Iqi 6P+ms1rg6Q3gp4ON8ptEIjThn0OKPR4Ws53mU99SNGlygWlyelGsyAhH/xOnNBOstxxG dGJqr5JdU1y+m/bcnQPREt4sQ1tL9jYudoqnAcQvcwgXT8brqAaD3EFKOHmL5cyoZWRK Cg475E+TnqjX44VON4+oDmx5DugN1jz5z66I+piMDf6bCJXOXoCVRwqgcfCJYI5ZC9h8 l61A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=Vwk8F29D; 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 202si10482486pgg.261.2018.04.08.20.03.08; Sun, 08 Apr 2018 20:03:45 -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=@microsoft.com header.s=selector1 header.b=Vwk8F29D; 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 S1755004AbeDIA3M (ORCPT + 99 others); Sun, 8 Apr 2018 20:29:12 -0400 Received: from mail-by2nam03on0120.outbound.protection.outlook.com ([104.47.42.120]:61603 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754244AbeDIA3J (ORCPT ); Sun, 8 Apr 2018 20:29:09 -0400 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=trkcWN2d8W0YlgeGhGzE0O8Mu3YTCzRQKWmXW+clE5A=; b=Vwk8F29DbKmS8rbYJFdSqfYMzNR705otmomh6WRHdBduPGaW/1uGgiXl5RwNa9JkcVZbNEqav+YwFY/T0oaUGKVMQ86PwGLst3j2Ji2LFTKCpJstd5Ut1esGj5kf1mYKgn3OhxqulsaC1pVZgsQIdpxrSpdTMBcmti7GquAGN1g= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0967.namprd21.prod.outlook.com (52.132.133.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.0; Mon, 9 Apr 2018 00:29:08 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059%2]) with mapi id 15.20.0696.003; Mon, 9 Apr 2018 00:29:08 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Liu Bo , David Sterba , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 092/293] Btrfs: skip commit transaction if we don't have enough pinned bytes Thread-Topic: [PATCH AUTOSEL for 4.9 092/293] Btrfs: skip commit transaction if we don't have enough pinned bytes Thread-Index: AQHTz5kREOvLT90XcEyjnTHWIX1ezQ== Date: Mon, 9 Apr 2018 00:24:06 +0000 Message-ID: <20180409002239.163177-92-alexander.levin@microsoft.com> References: <20180409002239.163177-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002239.163177-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;DM5PR2101MB0967;7:FSwapj33pjNJIRZ+Vc+suZcqe8zvVgAut4LzVAD886YDfPOuAX37Rh0C3AKbtTltezpd20ZeiyVE9tPAZU/mawv3xr843x31l1+AFWFx7dopaxXvyECvlZBk9S0SHRYVbl17Wqk4RDQn0bY9ana5KGtyePxive79nAjJSuBACIWO40dyxgGXdaf5TgSJkd4jA0F/ed/ooeGp3BxAYyOJGSPrgJuuKkcD2N5TCe4tRV/UUk6o64TOhQdhQVjZCMOC;20:bn21CUqFJ8DlytWaoSWE4lp3H3TQYfSsFcLkXWXFuuh86ygvmnn2qrHID0BlL5zAKHw+gkXcs65yIUYovfCLHTcRosLJXLI7M2cLF1DmGtPkVlbYVS9p6PNtcenfs9ypn+o2roYVWGpSi7EFVr2fNDlPIFyR4Spz2e7+QUO+7FQ= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: f2dd97ba-7126-48ac-133b-08d59db0e88a x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0967; x-ms-traffictypediagnostic: DM5PR2101MB0967: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(146099531331640); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(3231221)(944501327)(52105095)(3002001)(10201501046)(6055026)(61426038)(61427038)(6041310)(20161123558120)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(6072148)(201708071742011);SRVR:DM5PR2101MB0967;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0967; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(396003)(39860400002)(366004)(376002)(39380400002)(346002)(199004)(189003)(6506007)(486006)(86362001)(14454004)(59450400001)(68736007)(102836004)(99286004)(26005)(551934003)(3846002)(6116002)(186003)(476003)(2616005)(1076002)(3280700002)(86612001)(72206003)(4326008)(446003)(54906003)(76176011)(11346002)(2906002)(22452003)(3660700001)(110136005)(97736004)(316002)(5660300001)(478600001)(8676002)(6512007)(8936002)(107886003)(6486002)(53936002)(81166006)(36756003)(81156014)(10290500003)(6436002)(10090500001)(25786009)(66066001)(106356001)(305945005)(7736002)(2501003)(5250100002)(105586002)(2900100001)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0967;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: GqdXEtEL5BrFJdrLK82Y+L9kTAmexAsaFATnJjkRPCiFwbk0Y83VR1wWM9q6dndSCzhSmfWhVLtkf4jq09+wgdw9TC72d9wy+ayixen/QgkJBJcEmH1acUW/WCAX534i8xLvxhdJctzFG+J2AUHoUmtB5OfeRxGDmJGxLl99IlktSNx8VZ3f1NWAEGoCst5A25bPim/X20ZFIjvhje2p3QQvWP86GJQiNAeyUUfIzn46gihAwbFsV5nyS4nzWVbGQhJA2tfJFpfedbYd+KvUvEhv7A1shL1tWMYKDU6SLdT1xn7YdxvHW4fSkPEczt4pSExH3wdZcspekCv9iQgrau2ySYdLXx4Y/CruzO1xnZFec5AWKIuO0wNcVFUOWdxGmutLHVSvzdqyEBPvIlOEM7HrSX8lMtPOpuS6NfZ5/xE= 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: f2dd97ba-7126-48ac-133b-08d59db0e88a X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:24:06.0187 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0967 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Liu Bo [ Upstream commit 28785f70ef882e4798cd5706066a55dbf7adf80e ] We commit transaction in order to reclaim space from pinned bytes because it could process delayed refs, and in may_commit_transaction(), we check first if pinned bytes are enough for the required space, we then check if that plus bytes reserved for delayed insert are enough for the required space. This changes the code to the above logic. Fixes: b150a4f10d87 ("Btrfs: use a percpu to keep track of possibly pinned = bytes") Tested-by: Nikolay Borisov Reported-by: Nikolay Borisov Reviewed-by: Nikolay Borisov Signed-off-by: Liu Bo Signed-off-by: David Sterba Signed-off-by: Sasha Levin --- fs/btrfs/extent-tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index a29730c44850..f9d87903ef48 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -4818,7 +4818,7 @@ static int may_commit_transaction(struct btrfs_root *= root, =20 spin_lock(&delayed_rsv->lock); if (percpu_counter_compare(&space_info->total_bytes_pinned, - bytes - delayed_rsv->size) >=3D 0) { + bytes - delayed_rsv->size) < 0) { spin_unlock(&delayed_rsv->lock); return -ENOSPC; } --=20 2.15.1