From patchwork Sat Jun 28 00:05:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 4438841 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C84D8BEEAA for ; Sat, 28 Jun 2014 00:05:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B07D02038D for ; Sat, 28 Jun 2014 00:05:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DE7912028D for ; Sat, 28 Jun 2014 00:05:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754411AbaF1AFX (ORCPT ); Fri, 27 Jun 2014 20:05:23 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:29339 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754400AbaF1AFV (ORCPT ); Fri, 27 Jun 2014 20:05:21 -0400 Received: from pps.filterd (m0044010 [127.0.0.1]) by mx0a-00082601.pphosted.com (8.14.5/8.14.5) with SMTP id s5S04l7s007252; Fri, 27 Jun 2014 17:05:19 -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=yAGZVi4ZyRatDLmcqQhOwOzckTA1S9UvtRR2av9ZpsE=; b=QwVhx8JOcY3nN+NVmURb5aVHBHJZ4XT2Afu86Wr8cXmKj/1NKTo8KQmidZmIUTMY1us2 foDfUFFYWyFBluK0hz+8c7TVZDmjaa9nT+Vz2s85giHrkaeSPbTXPP0Ozs4Hc0sQUpaV Oc/X1rc8TnFAz05NLvavx3axFhvCEhbaqHU= Received: from mail.thefacebook.com (mailwest.thefacebook.com [173.252.71.148]) by mx0a-00082601.pphosted.com with ESMTP id 1mscamsfm3-1 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=OK); Fri, 27 Jun 2014 17:05:18 -0700 Received: from prometheus.nomadrail.local (192.168.57.29) by mail.thefacebook.com (192.168.16.11) with Microsoft SMTP Server (TLS) id 14.3.174.1; Fri, 27 Jun 2014 17:05:17 -0700 From: Josef Bacik To: , Subject: [PATCH] Btrfs: make sure to use btrfs_header_owner when freeing tree block V2 Date: Fri, 27 Jun 2014 17:05:03 -0700 Message-ID: <1403913903-21132-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-1406270250 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 --- V1->V2: this one actually compiles. 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..abfd05e 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(buf), 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);