From patchwork Fri Dec 12 21:00:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 5485521 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 49EB69F1CD for ; Fri, 12 Dec 2014 21:01:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 39A5F201C8 for ; Fri, 12 Dec 2014 21:00:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 10E9C20172 for ; Fri, 12 Dec 2014 21:00:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966185AbaLLVAs (ORCPT ); Fri, 12 Dec 2014 16:00:48 -0500 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:38722 "EHLO mx0b-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964796AbaLLVAr (ORCPT ); Fri, 12 Dec 2014 16:00:47 -0500 Received: from pps.filterd (m0004060 [127.0.0.1]) by mx0b-00082601.pphosted.com (8.14.5/8.14.5) with SMTP id sBCKtbxa012062 for ; Fri, 12 Dec 2014 13:00:46 -0800 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=i8SGZ3XQhLSBjKNgx2zVmWsAy/+5iLsC+jglm/S/EHE=; b=ntamzbx5scoBzJ8lV2Y5aIbFxb1CI04azPr6VH9eBNB34oJbrn/P4xVHwL2r9hE5s88m 4TFirHrVktWNpr5YpFlnJ+Xbabu+qXB6N+6xfSHDZs6Rv9GBhvJXCSsL9y+6Uka1d70D z1vGh/9JHKxJLef9AySDgMMp+jJyHJVSQdU= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0b-00082601.pphosted.com with ESMTP id 1r85wggh1r-1 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=OK) for ; Fri, 12 Dec 2014 13:00:46 -0800 Received: from localhost (192.168.57.29) by mail.thefacebook.com (192.168.16.22) with Microsoft SMTP Server (TLS) id 14.3.195.1; Fri, 12 Dec 2014 13:00:44 -0800 From: Josef Bacik To: Subject: [PATCH] Btrfs: don't delete csum for free space cache Date: Fri, 12 Dec 2014 16:00:42 -0500 Message-ID: <1418418042-1105-1-git-send-email-jbacik@fb.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 X-Originating-IP: [192.168.57.29] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.13.68, 1.0.33, 0.0.0000 definitions=2014-12-12_07:2014-12-12, 2014-12-12, 1970-01-01 signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 kscore.is_bulkscore=6.45594688819529e-14 kscore.compositescore=0 circleOfTrustscore=502.112 compositescore=0.996334338755742 urlsuspect_oldscore=0.996334338755742 suspectscore=3 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.996334338755742 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-1412120194 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 We unconditionally delete csums for data extents, but we don't have csums for free space cache, so all this does is force us to recow the csum root, which will cause us to re-write the block group cache. This patch fixes this by noticing if we're a free space cache extent and simply skipping the delete csum step. Thanks, Signed-off-by: Josef Bacik --- fs/btrfs/delayed-ref.c | 8 ++++++++ fs/btrfs/delayed-ref.h | 1 + fs/btrfs/extent-tree.c | 8 ++++++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c index 6d16bea..7c729c3 100644 --- a/fs/btrfs/delayed-ref.c +++ b/fs/btrfs/delayed-ref.c @@ -605,6 +605,7 @@ add_delayed_ref_head(struct btrfs_fs_info *fs_info, head_ref->is_data = is_data; head_ref->ref_root = RB_ROOT; head_ref->processing = 0; + head_ref->no_csums = 0; spin_lock_init(&head_ref->lock); mutex_init(&head_ref->mutex); @@ -848,6 +849,13 @@ int btrfs_add_delayed_data_ref(struct btrfs_fs_info *fs_info, head_ref = add_delayed_ref_head(fs_info, trans, &head_ref->node, bytenr, num_bytes, action, 1); + /* + * If ref_root is the tree root then this is a block group space cache + * extent and doesn't have csums, so we can set no_csums. + */ + if (ref_root == BTRFS_ROOT_TREE_OBJECTID) + head_ref->no_csums = 1; + add_delayed_data_ref(fs_info, trans, head_ref, &ref->node, bytenr, num_bytes, parent, ref_root, owner, offset, action, no_quota); diff --git a/fs/btrfs/delayed-ref.h b/fs/btrfs/delayed-ref.h index a764e23..c464dd3 100644 --- a/fs/btrfs/delayed-ref.h +++ b/fs/btrfs/delayed-ref.h @@ -101,6 +101,7 @@ struct btrfs_delayed_ref_head { * the free has happened. */ unsigned int must_insert_reserved:1; + unsigned int no_csums:1; unsigned int is_data:1; unsigned int processing:1; }; diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 74eb29d..23b704e 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -2312,7 +2312,7 @@ static int run_one_delayed_ref(struct btrfs_trans_handle *trans, if (insert_reserved) { btrfs_pin_extent(root, node->bytenr, node->num_bytes, 1); - if (head->is_data) { + if (head->is_data && !head->no_csums) { ret = btrfs_del_csums(trans, root, node->bytenr, node->num_bytes); @@ -6094,7 +6094,11 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans, } btrfs_release_path(path); - if (is_data) { + /* + * If the ref root is the tree root then this is a nodatasum + * extent and we can skip the btrfs_del_csums step. + */ + if (is_data && (root_objectid != BTRFS_ROOT_TREE_OBJECTID)) { ret = btrfs_del_csums(trans, root, bytenr, num_bytes); if (ret) { btrfs_abort_transaction(trans, extent_root, ret);