Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3004622imu; Sun, 9 Dec 2018 14:53:39 -0800 (PST) X-Google-Smtp-Source: AFSGD/XGSVumXO2dXVguzNYh0FGYf5Fcei7ZqZcsA8qtm1SbLWLNxXz1h2yJB5ZI9jIODRNVZ/TQ X-Received: by 2002:a17:902:724a:: with SMTP id c10mr10218432pll.51.1544396019877; Sun, 09 Dec 2018 14:53:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544396019; cv=none; d=google.com; s=arc-20160816; b=VPKEu9bB3i2bZsTeXhFY0wx1KBInD0zZ1qgjfhIJax8YbHnN1zLcGbR6gtfGVL4C4h H16Ao8H8enUZc1EHh27tSp0PSHLX1eg2GsvZn1RCMzKDh4V05DMNe+zG+3Jy+g4gxVeF B+52ewe0Pkg0nntwRZxQVd91WuMnWBw8IA+pLOiPMmsc3C7mvOfOo3LK8qRFrd6hPORh gWC0dkVGFoECYso2oOMc+D/j5UI85AopWXFgD26JiJyMNHX27GsnxSyeAHuzpmMpvQFx a+V6eLXdZv2SdMwhfUZL6XGAn6onW9TBbQUNrwGgwcgSUi5ZZevg2ndH0AirRLYFlR9V 2Xbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=ESkkMSuzc/arxrqtYtyKgy32Yn0KnOZOK826WryzDLg=; b=Ki7MTCm7kxm7g4TLyI/22lnEgaVaJdFAuwYOsSDeQXQiP/uikyqAzFtWElqvrepLRb maHDrMZWQ1WcMKg749lnE72eiQsMzha+zQQc7qQfCuFnFq1W21UHiQTHtA+yyVyZPO78 VlgvCXjXX0GS7puyNA4vtwrpPkPQvCOpyCY5/FoVODUCkplVpAvAqwPecscmQmtFQMd+ bj/8BLZtpr+nItmpCecWhDB4dK8uRCXPuJ9XuhRNdmy1xQU5stwa4tCumMVMxt8+tLEP 0ohXeN5DgQxZ6u+wiysG8CuKe2aYx2flE03A8Mtd/XQsthqcp+JiKWDdVzTttpKC21Rv lsQA== 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 d4si8796122pfa.150.2018.12.09.14.53.24; Sun, 09 Dec 2018 14:53:39 -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 S1727521AbeLIWG0 (ORCPT + 99 others); Sun, 9 Dec 2018 17:06:26 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:37062 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727724AbeLIWGO (ORCPT ); Sun, 9 Dec 2018 17:06:14 -0500 Received: from pub.yeoldevic.com ([81.174.156.145] helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gW73I-0002io-Jk; Sun, 09 Dec 2018 21:55:52 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gW72c-0003Lw-Ai; Sun, 09 Dec 2018 21:55:10 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Ethan Lien" , "David Sterba" , "Nikolay Borisov" Date: Sun, 09 Dec 2018 21:50:33 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 109/328] btrfs: use correct compare function of dirty_metadata_bytes In-Reply-To: X-SA-Exim-Connect-IP: 81.174.156.145 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.62-rc1 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") Signed-off-by: Ethan Lien Reviewed-by: Nikolay Borisov Signed-off-by: David Sterba [bwh: Backported to 3.16: In __btrfs_btree_balance_dirty(), use root->fs_info instead of fs_info] Signed-off-by: Ben Hutchings --- 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 @@ -991,8 +991,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; } @@ -3793,8 +3794,9 @@ static void __btrfs_btree_balance_dirty( if (flush_delayed) btrfs_balance_delayed_items(root); - ret = percpu_counter_compare(&root->fs_info->dirty_metadata_bytes, - BTRFS_DIRTY_METADATA_THRESH); + ret = __percpu_counter_compare(&root->fs_info->dirty_metadata_bytes, + BTRFS_DIRTY_METADATA_THRESH, + root->fs_info->dirty_metadata_batch); if (ret > 0) { balance_dirty_pages_ratelimited( root->fs_info->btree_inode->i_mapping);