Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3468275imu; Sun, 11 Nov 2018 15:48:10 -0800 (PST) X-Google-Smtp-Source: AJdET5dbLKhCRodAM+Q/cePunEi5y4NNoAe9AkCiIfEcr1Sj6WVA+sqXrOPyz1tjsaZcSGvXXZZz X-Received: by 2002:a62:2bd4:: with SMTP id r203-v6mr17963932pfr.105.1541980090781; Sun, 11 Nov 2018 15:48:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541980090; cv=none; d=google.com; s=arc-20160816; b=c6952A8aILNU7Bf+S4UvR5sAroKa3EZgkzLRGR7ouBONr2QO4ty/sYIdtXi5JS+rcd ht1j8d+ZpEhOGpDRBRirrxXLuOLHT1gkI5Y0yXxhS6o7zTeoDWO9ONjyMi+ng7M38oNJ FQQYJSIF5WTdD1jbpjdqGh4IO0r80X0d9anVO+k/OKCV5oT7AEe5fZXh+YWG2gbxZXpZ dZO/phzTRP+6javh8TnKTQCLEi5gGlQciHq98iCvFqDxgqE5lzJ6f60Q/+XmQsZqmJAz c8hIieP+0i1YjJI2BqoHxsjMyhgkQ6VUWHzGleujuNydkCfUIScokAFuXAiqZ3eEjo3e sNoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KiJDMfTIoyPQpNB45AFvNU+0Bx/KE2AkohZd0aX7Qgk=; b=M5J+k24ZQsI+YXZXur9VhrACKywI4gWbBBXeikDjnpOg7bcJ4UoXjN7V0EC8PFafSo fyPFw+A4h3hQkW0DDw9gDrn3EROw4NjsUIhXOD/DKFKEQvhWMBlC2TLa3AIPqOQb1pPl 6m77tVC85URf2nudEBFmW6jzMSo2zjh3JSonUAAUHqJdtM+kfbr43u9aMRcxvx5R6YXx tCafnhiRAn4bAbqNy6ZOihxuiAW6moQMPalzg+n0jthubZ7yPqN4sGKCtKZfSWZxgFxF lsCcGkLaPT4SrUdbC3I/AoH/ljG9DmRAdgGhmGTSAN/vj9o4RLTSO8ZA0LoyQVsqxFE8 vcew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zeuuB+4c; 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 d187-v6si17279182pfa.68.2018.11.11.15.47.55; Sun, 11 Nov 2018 15:48:10 -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=@kernel.org header.s=default header.b=zeuuB+4c; 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 S1733312AbeKLJh4 (ORCPT + 99 others); Mon, 12 Nov 2018 04:37:56 -0500 Received: from mail.kernel.org ([198.145.29.99]:39224 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733144AbeKLISr (ORCPT ); Mon, 12 Nov 2018 03:18:47 -0500 Received: from localhost (unknown [206.108.79.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 171B8216FD; Sun, 11 Nov 2018 22:28:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975331; bh=4wnDCUSvbIuBgEOeipk4UbHBaZirCYQFI+T/y9fnKD8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zeuuB+4caRV947FiAIJnUUMV19Kz937jbSyLoojUkW2HdQQhnpEIqIoke05jQJQCZ c8jfkSTAL7UoFMvtQahuJh8pXVJ5cn9REuJpcy/XvPwsXAk86CwZLni3jX6B1uJZGq yFc0kUER5F8CpxA7mF0VXmNyUyuR2VNpXS8a1aok= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Misono Tomohiro , Qu Wenruo , David Sterba Subject: [PATCH 4.19 344/361] btrfs: qgroup: Dirty all qgroups before rescan Date: Sun, 11 Nov 2018 14:21:31 -0800 Message-Id: <20181111221701.004871017@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Qu Wenruo commit 9c7b0c2e8dbfbcd80a71e2cbfe02704f26c185c6 upstream. [BUG] In the following case, rescan won't zero out the number of qgroup 1/0: $ mkfs.btrfs -fq $DEV $ mount $DEV /mnt $ btrfs quota enable /mnt $ btrfs qgroup create 1/0 /mnt $ btrfs sub create /mnt/sub $ btrfs qgroup assign 0/257 1/0 /mnt $ dd if=/dev/urandom of=/mnt/sub/file bs=1k count=1000 $ btrfs sub snap /mnt/sub /mnt/snap $ btrfs quota rescan -w /mnt $ btrfs qgroup show -pcre /mnt qgroupid rfer excl max_rfer max_excl parent child -------- ---- ---- -------- -------- ------ ----- 0/5 16.00KiB 16.00KiB none none --- --- 0/257 1016.00KiB 16.00KiB none none 1/0 --- 0/258 1016.00KiB 16.00KiB none none --- --- 1/0 1016.00KiB 16.00KiB none none --- 0/257 So far so good, but: $ btrfs qgroup remove 0/257 1/0 /mnt WARNING: quotas may be inconsistent, rescan needed $ btrfs quota rescan -w /mnt $ btrfs qgroup show -pcre /mnt qgoupid rfer excl max_rfer max_excl parent child -------- ---- ---- -------- -------- ------ ----- 0/5 16.00KiB 16.00KiB none none --- --- 0/257 1016.00KiB 16.00KiB none none --- --- 0/258 1016.00KiB 16.00KiB none none --- --- 1/0 1016.00KiB 16.00KiB none none --- --- ^^^^^^^^^^ ^^^^^^^^ not cleared [CAUSE] Before rescan we call qgroup_rescan_zero_tracking() to zero out all qgroups' accounting numbers. However we don't mark all qgroups dirty, but rely on rescan to do so. If we have any high level qgroup without children, it won't be marked dirty during rescan, since we cannot reach that qgroup. This will cause QGROUP_INFO items of childless qgroups never get updated in the quota tree, thus their numbers will stay the same in "btrfs qgroup show" output. [FIX] Just mark all qgroups dirty in qgroup_rescan_zero_tracking(), so even if we have childless qgroups, their QGROUP_INFO items will still get updated during rescan. Reported-by: Misono Tomohiro CC: stable@vger.kernel.org # 4.4+ Signed-off-by: Qu Wenruo Reviewed-by: Misono Tomohiro Tested-by: Misono Tomohiro Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/qgroup.c | 1 + 1 file changed, 1 insertion(+) --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c @@ -2897,6 +2897,7 @@ qgroup_rescan_zero_tracking(struct btrfs qgroup->rfer_cmpr = 0; qgroup->excl = 0; qgroup->excl_cmpr = 0; + qgroup_dirty(fs_info, qgroup); } spin_unlock(&fs_info->qgroup_lock); }