From patchwork Tue Aug 12 18:36:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Mason X-Patchwork-Id: 4714521 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D0FEE9F319 for ; Tue, 12 Aug 2014 18:36:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DD7A22015A for ; Tue, 12 Aug 2014 18:36:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ED6B82014A for ; Tue, 12 Aug 2014 18:36:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753857AbaHLSgZ (ORCPT ); Tue, 12 Aug 2014 14:36:25 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:8019 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753574AbaHLSgY (ORCPT ); Tue, 12 Aug 2014 14:36:24 -0400 Received: from pps.filterd (m0004003 [127.0.0.1]) by mx0b-00082601.pphosted.com (8.14.5/8.14.5) with SMTP id s7CIYBsG007976; Tue, 12 Aug 2014 11:36:22 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fb.com; h=message-id : date : from : mime-version : to : cc : subject : references : in-reply-to : content-type : content-transfer-encoding; s=facebook; bh=NSaBCssX6J4g3PwZMJcl2NAxfLz7tJd9YjGHiEdRVg0=; b=AUEVHNOy8uTv7vh+D3wiHRieqcs6d6KKq34ZWn5BvLhLgxcfP4N2M7PxM7LQM5h0tIg+ 0pMTClLSKCeo98ur8w9e+1FSbs+hKswj3w89ZrAGNQABg5QYcHmPiCl5AMimo4DBJxtg O+wPjIEijfbJP2oltgHoNdkYlS3+2roFpVg= Received: from mail.thefacebook.com (mailwest.thefacebook.com [173.252.71.148]) by mx0b-00082601.pphosted.com with ESMTP id 1nqgkf1cnj-2 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=OK); Tue, 12 Aug 2014 11:36:21 -0700 Received: from [172.23.2.80] (192.168.16.4) by mail.thefacebook.com (192.168.16.23) with Microsoft SMTP Server (TLS) id 14.3.195.1; Tue, 12 Aug 2014 11:36:19 -0700 Message-ID: <53EA5EA1.8090505@fb.com> Date: Tue, 12 Aug 2014 14:36:17 -0400 From: Chris Mason User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: Mark Fasheh CC: , Josef Bacik Subject: Re: [PATCH 2/5] btrfs: qgroup: account shared subtrees during snapshot delete References: <1405625944-4883-1-git-send-email-mfasheh@suse.de> <1405625944-4883-3-git-send-email-mfasheh@suse.de> <53EA5B67.7040109@fb.com> <20140812183216.GR2203@wotan.suse.de> In-Reply-To: <20140812183216.GR2203@wotan.suse.de> X-Originating-IP: [192.168.16.4] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.12.52, 1.0.27, 0.0.0000 definitions=2014-08-12_07:2014-08-12, 2014-08-12, 1970-01-01 signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 kscore.is_bulkscore=6.38637476235715e-11 kscore.compositescore=0 circleOfTrustscore=7.22631635067273 compositescore=0.999231492611421 urlsuspect_oldscore=0.999231492611421 suspectscore=2 recipient_domain_to_sender_totalscore=0 phishscore=0 bulkscore=0 kscore.is_spamscore=0 recipient_to_sender_totalscore=0 recipient_domain_to_sender_domain_totalscore=62764 rbsscore=0.999231492611421 spamscore=0 recipient_to_sender_domain_totalscore=0 urlsuspectscore=0.9 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=7.0.1-1402240000 definitions=main-1408120197 X-FB-Internal: deliver Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 08/12/2014 02:32 PM, Mark Fasheh wrote: > On Tue, Aug 12, 2014 at 02:22:31PM -0400, Chris Mason wrote: >> >> >> On 07/17/2014 03:39 PM, Mark Fasheh wrote: >>> During its tree walk, btrfs_drop_snapshot() will skip any shared >>> subtrees it encounters. This is incorrect when we have qgroups >>> turned on as those subtrees need to have their contents >>> accounted. In particular, the case we're concerned with is when >>> removing our snapshot root leaves the subtree with only one root >>> reference. >>> >>> In those cases we need to find the last remaining root and add >>> each extent in the subtree to the corresponding qgroup exclusive >>> counts. >>> >>> This patch implements the shared subtree walk and a new qgroup >>> operation, BTRFS_QGROUP_OPER_SUB_SUBTREE. When an operation of >>> this type is encountered during qgroup accounting, we search for >>> any root references to that extent and in the case that we find >>> only one reference left, we go ahead and do the math on it's >>> exclusive counts. >>> >>> Signed-off-by: Mark Fasheh >>> Reviewed-by: Josef Bacik >>> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c >>> index 813537f..1aa4325 100644 >>> --- a/fs/btrfs/extent-tree.c >>> +++ b/fs/btrfs/extent-tree.c >>> @@ -8078,6 +8331,14 @@ int btrfs_drop_snapshot(struct btrfs_root *root, >>> } >>> root_dropped = true; >>> out_end_trans: >>> + ret = btrfs_delayed_qgroup_accounting(trans, root->fs_info); >> ^^^^^^^^^^^ >> >> CONFIG_DEBUG_PAGEALLOC noticed that root is already free at this point. >> I switched it to tree_root instead ;) > > Oh nice catch, thanks for pointing it out. > > Time to go update my suse patches. Grin, pretty sure it doesn't count as a catch if CONFIG_DEBUG_PAGEALLOC finds it. But it did make it through the balance test we were crashing in before. It's probably faster to hand edit the incremental in for the suse patch, but here you go just in case: --- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 763632d..ef0845d 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -8314,7 +8314,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root, } root_dropped = true; out_end_trans: - ret = btrfs_delayed_qgroup_accounting(trans, root->fs_info); + ret = btrfs_delayed_qgroup_accounting(trans, tree_root->fs_info); if (ret) printk_ratelimited(KERN_ERR "BTRFS: Failure %d " "running qgroup updates "