From patchwork Sat Jun 28 00:02:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 4438791 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 08CD79F2C8 for ; Sat, 28 Jun 2014 00:02:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3871120397 for ; Sat, 28 Jun 2014 00:02:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3B6F42038D for ; Sat, 28 Jun 2014 00:02:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752345AbaF1ACm (ORCPT ); Fri, 27 Jun 2014 20:02:42 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:41931 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751273AbaF1ACl (ORCPT ); Fri, 27 Jun 2014 20:02:41 -0400 Received: from pps.filterd (m0044010 [127.0.0.1]) by mx0a-00082601.pphosted.com (8.14.5/8.14.5) with SMTP id s5RNvmOc000874; Fri, 27 Jun 2014 17:02:39 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fb.com; h=from : to : subject : date : message-id : mime-version : content-type; s=facebook; bh=CazB7nihDCTZbaOSgv5XnrFqYDJCxFWGj+HcgNZNKkw=; b=Ev22j5H6sInDJtXm8ZUNyjP875wTXSdebqm47VqydxcjXJCVcU7RnTOGxWRzjH4hwWuQ 5LW3P2MUfRIg3aMLN2hOjXxKWnuwsgjSlKOHSrFm+2w0GEHM6pfkjrIwWJGDCFJ1PEl7 vKV8yKD/ubZM56LnlFkqfVtpuRn0tHP0U+g= Received: from mail.thefacebook.com (mailwest.thefacebook.com [173.252.71.148]) by mx0a-00082601.pphosted.com with ESMTP id 1mscamsfed-1 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=OK); Fri, 27 Jun 2014 17:02:38 -0700 Received: from prometheus.nomadrail.local (192.168.57.29) by mail.thefacebook.com (192.168.16.24) with Microsoft SMTP Server (TLS) id 14.3.174.1; Fri, 27 Jun 2014 17:02:37 -0700 From: Josef Bacik To: , Subject: [PATCH] Btrfs: make sure to use btrfs_header_owner when freeing tree block Date: Fri, 27 Jun 2014 17:02:30 -0700 Message-ID: <1403913750-20135-1-git-send-email-jbacik@fb.com> X-Mailer: git-send-email 2.0.0 MIME-Version: 1.0 X-Originating-IP: [192.168.57.29] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.12.52, 1.0.14, 0.0.0000 definitions=2014-06-27_07:2014-06-27, 2014-06-27, 1970-01-01 signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 kscore.is_bulkscore=3.05311331771918e-15 kscore.compositescore=0 circleOfTrustscore=8.84622405323311 compositescore=0.999231482873121 urlsuspect_oldscore=0.999231482873121 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=64355 rbsscore=0.999231482873121 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-1406270249 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=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,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 Mark noticed that his qgroup accounting for snapshot deletion wasn't working properly on a particular file system. Turns out we pass the root->objectid of the root we are deleting to btrfs_free_extent, and use that root always when we call btrfs_free_tree_block. This isn't correct, the owner must match the btrfs_header_owner() of the eb. So to fix this we need to use that when we call btrfs_free_extent, and we also need to use btrfs_header_owner(eb) in btrfs_free_tree_block as the root we pass in may not be the owner in the case of snapshot delete (though it is for all the normal cases which is why it wasn't noticed before.) With this patch on top of Mark's snapshot delete patch everything is working a-ok. Thanks, Signed-off-by: Josef Bacik --- fs/btrfs/extent-tree.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 7671b15..7f9bb7c 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -6189,7 +6189,7 @@ void btrfs_free_tree_block(struct btrfs_trans_handle *trans, if (root->root_key.objectid != BTRFS_TREE_LOG_OBJECTID) { ret = btrfs_add_delayed_tree_ref(root->fs_info, trans, buf->start, buf->len, - parent, root->root_key.objectid, + parent, btrfs_header_owner(eb), btrfs_header_level(buf), BTRFS_DROP_DELAYED_REF, NULL, 0); BUG_ON(ret); /* -ENOMEM */ @@ -7925,7 +7925,8 @@ skip: } ret = btrfs_free_extent(trans, root, bytenr, blocksize, parent, - root->root_key.objectid, level - 1, 0, 0); + btrfs_header_owner(next), level - 1, 0, + 0); BUG_ON(ret); /* -ENOMEM */ } btrfs_tree_unlock(next);