Received: by 10.213.65.68 with SMTP id h4csp2118698imn; Sun, 8 Apr 2018 20:10:07 -0700 (PDT) X-Google-Smtp-Source: AIpwx49sndQVB7k1ub/KimY09N3IXRQeDmKjSoQDoQSq6hZPb6KsudimcIhAs55sqxKC7k3DcSj4 X-Received: by 10.98.32.199 with SMTP id m68mr27799930pfj.218.1523243407936; Sun, 08 Apr 2018 20:10:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243407; cv=none; d=google.com; s=arc-20160816; b=LK9HJTN15RqMIKJJeeVl6enVWlukrgXq16CDqquphwYaXf14MoTPY1xJputf2eBMKN aA6mrWFLOjAxXPWCtW2O+907GSwDfKAuyAgayky5ELJVjBbfUu0BVJvu8LV1qKdUE6u5 vJILhU/l/r65aYo9bAuh8gJf7kwCEkrZCHGmZfmjs09ywPl1BJxFnQylNgB570GyI0l6 PfBVtQlIy7/2tlcddP+m60bOPgW7aMJpiB/U35Nra2pGOtn12V3PHKDXoyz6A6G0EEHS iW8cjK3G/59yqy4X5s+N3VBwZvWP5JwuYvwOSSV7U5PKRWUUTmR5/a+DDwvPZ76U1vD5 glXA== 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=wuU0FbaEJKfWe6ozW5SL1L69RyifRZCv+EmDToaZbcM=; b=a352ZSjWhcGDZJZX69wpNDw3XF+JWRbr8xTmJmvecQftbIS1Q2M7q7GqVmmTEnuNbO 9/eO55gev2vVEfisKe+bzJlYrWYJo+01hGO46S0NnOIART7WaK8ALEC6BBfa8WsTweVP b8zDiJ0w5SWWbMPKrVvTBViXTIAuxy8/zScMwNt4qzrgqtYSwOHgdyGDtY7IIKjRqxev UiSdjtBYq8hHhEXUsvgnCyEhVJIUrjRCa+YMm8UMLEgra7HgiO1qHYEnKAJgMzJUJdTa ggBHaCidYni86MoeGFT2+Vh4yacT+mjEEZQY+Kngv7ta3EiDg0/kVRN/nj6JW8xQn1ni RkUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=cKuYP6Ti; 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 g15si10507444pgf.541.2018.04.08.20.09.31; Sun, 08 Apr 2018 20:10:07 -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=cKuYP6Ti; 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 S1757244AbeDIBaN (ORCPT + 99 others); Sun, 8 Apr 2018 21:30:13 -0400 Received: from mail-sn1nam02on0133.outbound.protection.outlook.com ([104.47.36.133]:9440 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756636AbeDIAf6 (ORCPT ); Sun, 8 Apr 2018 20:35:58 -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=wuU0FbaEJKfWe6ozW5SL1L69RyifRZCv+EmDToaZbcM=; b=cKuYP6TiwQjqruML26FG6DHDgz10TU9OPcqkJ37QYPrEadsmkH9nTZIdytTs0YjQyDPBHIJkgig77iRWcvYRu/E1Qhl6n7cxOTDdtJTGaiFTXtEaOzDabkannhEgPSyePo3/vaVUUSsmNnauYA8Rg5xypmrHNVlLIcWcjZvvqO0= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0725.namprd21.prod.outlook.com (10.167.107.167) 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:35:56 +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:35:56 +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.4 046/162] Btrfs: skip commit transaction if we don't have enough pinned bytes Thread-Topic: [PATCH AUTOSEL for 4.4 046/162] Btrfs: skip commit transaction if we don't have enough pinned bytes Thread-Index: AQHTz5mm5PkghbLgwU6yMM5hc49jiQ== Date: Mon, 9 Apr 2018 00:28:15 +0000 Message-ID: <20180409002738.163941-46-alexander.levin@microsoft.com> References: <20180409002738.163941-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002738.163941-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;DM5PR2101MB0725;7:gY544n+dDgGf4TZcReXPt0Ef0nbdDNXvOaXD0JFquoahk8PX6yTdjqNpoUJnQW7FyZmvY0N31XQ0X+gqyqQ+GBwdzCmlKBjfVSZ4q62yhOE6fGyOTKh19rHssqyzZhphoPIWRJdsOocL3942UgX6g9mZpIlTZnqNc4SFRPMDOrznm1/bSNwTggC2oniZFnuQX8+ToHFrX4EdN/IRBurnOdO8w42xTFsL08Xy+iWrJkKvueHt9xuLsGI5pBrdxutJ;20:Tk60EHP5maWm0LZ0hKH6kCRxEK73RhM6CefesHetynYVvvOYbtQF+SI5K3WtCmWzwjhAY76WPY2hAXpR8++uP3QiFdrJWoe0yjCaQfdyIYNN6aAE3AhE+WNL8qDYj3tRiOd7eME9cBp1EyezQ6XnzQcL5DTxrtKWICXeq+BY9bI= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 6ead28c2-3d8b-4079-4028-08d59db1dc03 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0725; x-ms-traffictypediagnostic: DM5PR2101MB0725: 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)(10201501046)(3231221)(944501327)(52105095)(93006095)(93001095)(3002001)(6055026)(61426038)(61427038)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(20161123558120)(20161123560045)(6072148)(201708071742011);SRVR:DM5PR2101MB0725;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0725; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39860400002)(396003)(376002)(39380400002)(346002)(366004)(189003)(199004)(86612001)(102836004)(5660300001)(14454004)(476003)(68736007)(11346002)(66066001)(446003)(99286004)(76176011)(486006)(10090500001)(551934003)(3660700001)(110136005)(305945005)(106356001)(316002)(105586002)(3280700002)(59450400001)(3846002)(10290500003)(6116002)(22452003)(6506007)(2616005)(1076002)(7736002)(54906003)(478600001)(2900100001)(2501003)(5250100002)(8936002)(25786009)(81156014)(8676002)(6666003)(6436002)(4326008)(26005)(6512007)(6486002)(81166006)(107886003)(53936002)(2906002)(86362001)(186003)(97736004)(36756003)(72206003)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0725;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: N614DXd9GYdW+C+xv1ld25wayFI8XRp9K2gG1e6NrNz+OaDkqO+0IzFu2otN9xJcxugcq7TGr/d0LAgwLEUs1sn1KB1XhRVWksKO5/Mu/xBB4ZZz3aTaBhKfQnBdZQa+FMfn7I2GwCm8F9GUslPF4oN9dvq5cCg7YaxHrrdx3aXGzDU9F9XgIrnv2ltQcrkKjH6o9tv5WPaqKyvmydUJNGVQeiisIhzintQcS2Cr4O9b8dPUcGwS4+nCvDqm/r5dT/B+uphNdWMyI37XzFPoypp716rwSyl0byrLNZeEBhwc3d+nrUlvcuTNn0POplGGOwT4zuuaDHTwXqBFde3N4fsatRuRahL8yIG1VgahsI49Q7jkXrnNxHfgfZv3Nzj7UJzoRbl5HIX3AUz34lvmPqYEa0ONRs4tRAqjRBhf9Cc= 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: 6ead28c2-3d8b-4079-4028-08d59db1dc03 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:28:15.9581 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0725 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 260f94b019c9..875e179bb2d5 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -4672,7 +4672,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