Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1825524imm; Mon, 3 Sep 2018 10:24:55 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYQSnXRwKQ2mTbG/AER/339quwXwnUXvrEeZn4bXNaruxqjRZTMvdrFaVMtq+w1rtPfbJKv X-Received: by 2002:a17:902:d688:: with SMTP id v8-v6mr29320200ply.278.1535995495546; Mon, 03 Sep 2018 10:24:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535995495; cv=none; d=google.com; s=arc-20160816; b=UHIhj1omZS1TN4hcsaGtIHZch5w9hBzxly4YZuONjc/nHM/GL6iadYlnZ3ZKksqSQU ykXXbY8iGuzzyiEeSQoiRpvG+yx2kplneizsdl64mC2nr/ArGhmp08BE0IbePwQqTOmN 2cuAjJtJd4OHLdvDXEf1fyJej2/DSFHSYB5VEm+b0VlZ1TOkr+piTPL7HWLLWG9wLm2c XNh+BBY1ZxGDp/OyfufJ8coXGBfimwckLhldQJ5RDN6il9wzUsIjAujK8IA8SNCVUYJj q1PYZ0fFDYHv12mRxLY7SIWQ18Lvc7inimodH6orjp0KaA9ImBwgYHG7O8RfmCjcaYr4 NWfQ== 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=Bhi/tYzgO0h9Lx3lRTKmw+oEND8vcqfOs0ocA+Pcs7M=; b=aVM/0F7dxVshx92nyzwrwd8y7UFRx8D/gHMfHdl4uQ5f5Y+MEEFZk7qPC0qKe/wBPd MJR922tjvzM/aC4EJa4plOS8UrMGRoxuOBeXsAG6UEcgWaCRYnOMh/ZpBCaCfb9mz9IK bciAlb/Uvb7yvfAaNP/ynO3ujfz37r68xrT2corx8GTjIfoPwNKmyra+rzDNl1+BAmJd T9IhUvm/oV76MOU2V57yCkeamG+OhsFRr+YzlPHHN6XWrwMVsj9QBKY0+d2pDvQXeNMr xxwy7ZuQ34FaOxwjMcHodVsRQ/+8IjJsGs/smgt2bBCrjGRGBBb1zH4kJqbAd+suKPrS 6PMg== 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 q13-v6si18307365pgc.670.2018.09.03.10.24.40; Mon, 03 Sep 2018 10:24: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; 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 S1730462AbeICVoD (ORCPT + 99 others); Mon, 3 Sep 2018 17:44:03 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:45374 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728372AbeICVoC (ORCPT ); Mon, 3 Sep 2018 17:44:02 -0400 Received: from localhost (ip-213-127-74-90.ip.prioritytelecom.net [213.127.74.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 19B29D0A; Mon, 3 Sep 2018 17:22:55 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ethan Lien , Nikolay Borisov , David Sterba Subject: [PATCH 4.14 090/165] btrfs: use correct compare function of dirty_metadata_bytes Date: Mon, 3 Sep 2018 18:56:16 +0200 Message-Id: <20180903165700.004639117@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180903165655.003605184@linuxfoundation.org> References: <20180903165655.003605184@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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: Ethan Lien commit d814a49198eafa6163698bdd93961302f3a877a4 upstream. We use customized, nodesize batch value to update dirty_metadata_bytes. We should also use batch version of compare function or we will easily goto fast path and get false result from percpu_counter_compare(). Fixes: e2d845211eda ("Btrfs: use percpu counter for dirty metadata count") CC: stable@vger.kernel.org # 4.4+ Signed-off-by: Ethan Lien Reviewed-by: Nikolay Borisov Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/disk-io.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -1098,8 +1098,9 @@ static int btree_writepages(struct addre fs_info = BTRFS_I(mapping->host)->root->fs_info; /* this is a bit racy, but that's ok */ - ret = percpu_counter_compare(&fs_info->dirty_metadata_bytes, - BTRFS_DIRTY_METADATA_THRESH); + ret = __percpu_counter_compare(&fs_info->dirty_metadata_bytes, + BTRFS_DIRTY_METADATA_THRESH, + fs_info->dirty_metadata_batch); if (ret < 0) return 0; } @@ -4030,8 +4031,9 @@ static void __btrfs_btree_balance_dirty( if (flush_delayed) btrfs_balance_delayed_items(fs_info); - ret = percpu_counter_compare(&fs_info->dirty_metadata_bytes, - BTRFS_DIRTY_METADATA_THRESH); + ret = __percpu_counter_compare(&fs_info->dirty_metadata_bytes, + BTRFS_DIRTY_METADATA_THRESH, + fs_info->dirty_metadata_batch); if (ret > 0) { balance_dirty_pages_ratelimited(fs_info->btree_inode->i_mapping); }