Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3426638imu; Sun, 11 Nov 2018 14:50:42 -0800 (PST) X-Google-Smtp-Source: AJdET5dtS9VlRbFsg8pzaxNIm+EAesmW0VRAvOtihe1ibemtEFI4i5r9nS/cpiZobvLZDCjXvDEa X-Received: by 2002:a63:1848:: with SMTP id 8mr15212571pgy.81.1541976642814; Sun, 11 Nov 2018 14:50:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541976642; cv=none; d=google.com; s=arc-20160816; b=nHV/3i9CPVcM0OVvoEQTZ99F+JkRd5yAHYnIu/CP9BVB5ex/k1f3HPzTbff4jxEBCW ZeLiCu1wXmkgEIvpjK+zZNQKR0USt4w7jPA0AGh97r4FYy1AlfnP05dDWuWJN8qLhTPD tq/gLHXYTiV6B8njKGOCWpuC6VAxGc0NgoSavBq9oDxl0yDGHSJbgIUhpkdcn1IsYyCL 5L0xBADV68CVp3zMO+kSgCyNtCkbqSspNdX6zt2pwcYUiotUc0kIlZjfBA0LPl5MMFe+ O5ykcDEUS5O/unMb/P7A5vcBqqbZCrFKnv4RgkVOF0Zo+o74euu4tpy1ZmbQRtwHv9tM TI3Q== 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=SqNRJhufXH3bSe3g4FpdabDhnR37wNYfmZ/AAIMLTJ4=; b=0YFhpk7pNHdiPVZhIbxhuLPqJUdDvZn30nmJxiiKWZSuEymjGsbN3dtK+d9ytFL+8D ODrgosqALtx1fnisiSeKB60fND8QlDx3Itu6u2h917ERS/esfdkhAtuABwhFrcIAOU33 T4q4JHWo9qMob42mcdquuuFcgkofjgXDQa0pSZKdjR55SKyEyCkFa+/lOKVYRiLW1/vf 7ufN93L6hd74NRxVoidqwO+U1V4A3mpNQQEsXhmTYNisgOh6VDxJ+dQ9gC2fs02E4Oj1 82dnvy0/gjxEDiMzRrkvKTdCrg2TFRjxhMMeHfCDYXC+lLhhemqVlQ8YS7oVovUc2M6L i3fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RWKmbl2S; 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 o3si13935772pgm.441.2018.11.11.14.50.27; Sun, 11 Nov 2018 14:50:42 -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=RWKmbl2S; 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 S2404258AbeKLIXL (ORCPT + 99 others); Mon, 12 Nov 2018 03:23:11 -0500 Received: from mail.kernel.org ([198.145.29.99]:55530 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404200AbeKLIXL (ORCPT ); Mon, 12 Nov 2018 03:23:11 -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 8E83D22353; Sun, 11 Nov 2018 22:33:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975593; bh=J9DOrsO8yPRIlAmZsx5X/Il0xZK49QJSZGzk53dJh2k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RWKmbl2SmUTmU3O63EI664gUO9dkKqiL5viAAWESBDg/I55h6B94NWL60i9CP05TE +/xoOdSrUO716Uz5k+N9j3/JgBtndrKALATvU9DT+b05aqyfB0ROLfwPtehGD/MQzM Y982Z9+wjsQG77qvDfZvYtOuHSE9RSjnfOkG/UlM= 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.14 210/222] btrfs: qgroup: Dirty all qgroups before rescan Date: Sun, 11 Nov 2018 14:25:07 -0800 Message-Id: <20181111221705.354600615@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221647.665769131@linuxfoundation.org> References: <20181111221647.665769131@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.14-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 @@ -2763,6 +2763,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); }