From patchwork Fri Dec 12 21:01:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 5485531 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 707B6BEEA8 for ; Fri, 12 Dec 2014 21:01:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6CEE2201C8 for ; Fri, 12 Dec 2014 21:01:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6D55A20172 for ; Fri, 12 Dec 2014 21:01:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966496AbaLLVBW (ORCPT ); Fri, 12 Dec 2014 16:01:22 -0500 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:16443 "EHLO mx0b-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754981AbaLLVBV (ORCPT ); Fri, 12 Dec 2014 16:01:21 -0500 Received: from pps.filterd (m0004077 [127.0.0.1]) by mx0b-00082601.pphosted.com (8.14.5/8.14.5) with SMTP id sBCKvp5T022862 for ; Fri, 12 Dec 2014 13:01:20 -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=SUKeOMvjKky4IJyiHJ20yzbwA5hKDqsW8wfypyyRrQ4=; b=IBdXOnZ7baDdNqgUhaB1kE+UBYmPecsoOGBzEzwye5SbCGDcouIF2RMfrtXT5zml0iD2 LdUaZ2LTcaLZP/1wvLqu0xodzSRS9bUD/OPPGsymoPD/FkTVs/a1XVa+f+x/MNIxS6L6 51OAZXS6M3+t8ZkRRFaX1gsQHR0frlKqGxg= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0b-00082601.pphosted.com with ESMTP id 1r84s4rtru-1 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=OK) for ; Fri, 12 Dec 2014 13:01:20 -0800 Received: from localhost (192.168.57.29) by mail.thefacebook.com (192.168.16.15) with Microsoft SMTP Server (TLS) id 14.3.195.1; Fri, 12 Dec 2014 13:01:18 -0800 From: Josef Bacik To: Subject: [PATCH] Btrfs: separate out the extent root update Date: Fri, 12 Dec 2014 16:01:17 -0500 Message-ID: <1418418077-1223-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=1 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 Depending on where the extent root shows up in the dirty list we could end up recowing the extent root a few times during commit. This is inefficient, so instead only track the other COW only roots and update them all at once, and then do the extent root/block group update loop by itself to try and reduce the amount of churn we do at commit time. Thanks, Signed-off-by: Josef Bacik --- fs/btrfs/disk-io.c | 1 - fs/btrfs/transaction.c | 34 +++++++++++++++++++--------------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 2409718..b69402a 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -2713,7 +2713,6 @@ retry_root_backup: ret = PTR_ERR(extent_root); goto recovery_tree_root; } - set_bit(BTRFS_ROOT_TRACK_DIRTY, &extent_root->state); fs_info->extent_root = extent_root; location.objectid = BTRFS_DEV_TREE_OBJECTID; diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index dcaae36..1b84595 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c @@ -933,17 +933,16 @@ int btrfs_write_and_wait_transaction(struct btrfs_trans_handle *trans, } /* - * this is used to update the root pointer in the tree of tree roots. + * Update the extent_root pointer in the tree of tree roots. * - * But, in the case of the extent allocation tree, updating the root - * pointer may allocate blocks which may change the root of the extent - * allocation tree. + * In the case of the extent allocation tree, updating the root pointer may + * allocate blocks which may change the root of the extent allocation tree. * * So, this loops and repeats and makes sure the cowonly root didn't * change while the root pointer was being updated in the metadata. */ -static int update_cowonly_root(struct btrfs_trans_handle *trans, - struct btrfs_root *root) +static int update_extent_root(struct btrfs_trans_handle *trans, + struct btrfs_root *root) { int ret; u64 old_root_bytenr; @@ -986,6 +985,7 @@ static noinline int commit_cowonly_roots(struct btrfs_trans_handle *trans, struct btrfs_root *root) { struct btrfs_fs_info *fs_info = root->fs_info; + struct btrfs_root *tree_root = fs_info->tree_root; struct list_head *next; struct extent_buffer *eb; int ret; @@ -1017,26 +1017,30 @@ static noinline int commit_cowonly_roots(struct btrfs_trans_handle *trans, if (ret) return ret; - /* run_qgroups might have added some more refs */ - ret = btrfs_run_delayed_refs(trans, root, (unsigned long)-1); - if (ret) - return ret; - while (!list_empty(&fs_info->dirty_cowonly_roots)) { next = fs_info->dirty_cowonly_roots.next; list_del_init(next); root = list_entry(next, struct btrfs_root, dirty_list); - if (root != fs_info->extent_root) - list_add_tail(&root->dirty_list, - &trans->transaction->switch_commits); - ret = update_cowonly_root(trans, root); + list_add_tail(&root->dirty_list, + &trans->transaction->switch_commits); + btrfs_set_root_node(&root->root_item, root->node); + ret = btrfs_update_root(trans, tree_root, &root->root_key, + &root->root_item); if (ret) return ret; } + ret = btrfs_run_delayed_refs(trans, root, (unsigned long)-1); + if (ret) + return ret; + list_add_tail(&fs_info->extent_root->dirty_list, &trans->transaction->switch_commits); + ret = update_extent_root(trans, fs_info->extent_root); + if (ret) + return ret; + btrfs_after_dev_replace_commit(fs_info); return 0;