From patchwork Thu Jan 26 21:00:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13117763 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2654DC05027 for ; Thu, 26 Jan 2023 21:01:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231887AbjAZVBL (ORCPT ); Thu, 26 Jan 2023 16:01:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229510AbjAZVBK (ORCPT ); Thu, 26 Jan 2023 16:01:10 -0500 Received: from mail-qt1-x82c.google.com (mail-qt1-x82c.google.com [IPv6:2607:f8b0:4864:20::82c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F182036474 for ; Thu, 26 Jan 2023 13:01:04 -0800 (PST) Received: by mail-qt1-x82c.google.com with SMTP id m26so2400736qtp.9 for ; Thu, 26 Jan 2023 13:01:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=HwdnYcIiWi7wHi2bXU/Fk7/olRy/K+ncT86VsG5nZ9o=; b=dQ72jJbfdA296BDHhKL8Utno7XtXzSf+heK+rKl+qrYuId6E3Asmtxwz2o5NJQlW5t NOCTbwVVgPnP43RKTYu56jOnI4S2VwtJstlMQcoVdG5+Nbda6tQwtFKl575k1nCxTyo7 fRvAMjoUmaUlrTeHIh59XAfPuUKfRLpa2NqD7h+OphmsJEzuPCG7x1aUmAxYdmmb7b1Y Sk5SZnXHRjSbq0qAAulizvsetyAsyFRwbkjQgH81Up0NljAcLgyD9s5wEqYCpkMvaMGZ QAcUf9cReQHaBjF563EHQYMjROr8yGNXfrvzqZVQGYTKjCYtmT4EXYGhwUvxKRSIHtxF ErQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HwdnYcIiWi7wHi2bXU/Fk7/olRy/K+ncT86VsG5nZ9o=; b=WheOYP60pLGdyUe2U78Ta6mz6cTZveaox5kf9FioBWjsyLH+Fe0oUik46fj1LwFWXB 9TiaTVHfQOfnZrYEFde5K75nvhlpS2RhVBnDjXmUO+WnoUXzxLU9jLKagqzalHgm2U13 7xaJeBq8i08cQKRjLqxZbJgewYNaII2kjcVtq/lzwz5adtXpMgegAi74nfjBTSBaan+H jq64sfaSZVu6/0X4ssevuv/Bzpf01/bVTUO2SE4QDHZFnIQbmDby8Uf2/KB3taSMuIKL k2uwT3lbT4MPujv4W/xzqPs4HpRd56WE82y4mzRNvCyH1wPVtok2VsO6KNVouai0VI+5 Dyrw== X-Gm-Message-State: AO0yUKVectUccedTiHG3S5JaK6bTAxk0FqBZEsQI9KYN0eO8o0O1qcH2 X1jlNUbMv0Y8kQw8atoQmde6QSwEQgG7KBS7R4o= X-Google-Smtp-Source: AK7set+Gy+TGpBLSYSfAW5k0TqC9faBsy/GYtzLQo2bm+RJmxBCRf5AklYBKHdaQq+TfzfZerEkLVA== X-Received: by 2002:ac8:5cc6:0:b0:3b6:414f:c2ba with SMTP id s6-20020ac85cc6000000b003b6414fc2bamr13287426qta.38.1674766863696; Thu, 26 Jan 2023 13:01:03 -0800 (PST) Received: from localhost (cpe-174-109-170-245.nc.res.rr.com. [174.109.170.245]) by smtp.gmail.com with ESMTPSA id s20-20020a05622a179400b003b81a90f117sm665624qtk.60.2023.01.26.13.01.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Jan 2023 13:01:03 -0800 (PST) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH v3 1/7] btrfs: always lock the block before calling btrfs_clean_tree_block Date: Thu, 26 Jan 2023 16:00:54 -0500 Message-Id: <298b929ac0435fce236af750f62cbd9423c0ed12.1674766637.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org We want to clean up the dirty handling for extent buffers so it's a little more consistent, so skip the check for generation == transid and simply always lock the extent buffer before calling btrfs_clean_tree_block. Signed-off-by: Josef Bacik --- fs/btrfs/extent-tree.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 876bea67f9a1..c85af644e353 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -5534,8 +5534,7 @@ static noinline int walk_up_proc(struct btrfs_trans_handle *trans, } } /* make block locked assertion in btrfs_clean_tree_block happy */ - if (!path->locks[level] && - btrfs_header_generation(eb) == trans->transid) { + if (!path->locks[level]) { btrfs_tree_lock(eb); path->locks[level] = BTRFS_WRITE_LOCK; } From patchwork Thu Jan 26 21:00:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13117765 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 688EFC05027 for ; Thu, 26 Jan 2023 21:01:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231985AbjAZVBO (ORCPT ); Thu, 26 Jan 2023 16:01:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231828AbjAZVBN (ORCPT ); Thu, 26 Jan 2023 16:01:13 -0500 Received: from mail-vs1-xe29.google.com (mail-vs1-xe29.google.com [IPv6:2607:f8b0:4864:20::e29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71E471CF50 for ; Thu, 26 Jan 2023 13:01:06 -0800 (PST) Received: by mail-vs1-xe29.google.com with SMTP id h19so1502716vsv.13 for ; Thu, 26 Jan 2023 13:01:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=GjVusJAN+I02YWCK7n1qvVRKflEz3wYbD533NUmx614=; b=fLDjLvpM9TR8AjM7jfxMfMfQm7rSHTo2EJizd/g2YHqkPlx3u7Xer3j001+I4Dxv3S AzT2EYNeHFKXDB8LjNcT7LJcWLx1kGg//d6k9ynQNvAuP3SuQS6fKWPh7gUJb7mBGtwg EXjMWr4Mm71zShNNg/ftnUkQ3gwPfv1rMGDMEuUD9sM5MJVQ3k7U6vzktYek7mpSKQQS 5LvGWtv7tNY6KQaumDlbeR2BGpC/y0XCYhlZYn3Cuv0fyeW6mVWulWxEqYMwyPoBsCdS besIKTY4CxlQppfwqvIzmBCZlB8tX0a0lbAGZbLCy2BLQHXqMch3qfNyBkAOv+x0kCkl gnBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GjVusJAN+I02YWCK7n1qvVRKflEz3wYbD533NUmx614=; b=AGWnWvgyj+3pb9I1l4GwPyDb5aTv8JHC9vNxvFtlUoQKr0XPpsVquoSjfjD6gqahqu JCQQ8P67Lb+q/1sJwTfbZp0fHAEvWSIO7I4bPgYiL5YFBjpZnXaIGBKmvZXhdgfeYvpb dttlsTfp10SHDhnDf027HjWUr1BD9P5HA9ECMIlTTJMmA0+t/8RpqNUWEngikKKjqZ8A bz53XBdQUTTv9yiSh4F4XUuCOhdg3UdJiVzQHkldC3iq6iAhEeRpGgQn0ChLs2asriGl igOd8ZuKtu3ZfzhcZ1J6ESsOIzU4bAs/grmuitoZUoXOOyACjvGRfEE0oN1IrdRnPeGk RORQ== X-Gm-Message-State: AFqh2kq9ZTRKpw9yAyB9gM3qbwupAecdLRzKi4QK/yKfdl+Es0L0qpG8 2xsYeABXvXRsfF0u8x+bEHqmUul8RfMwbBDKhuo= X-Google-Smtp-Source: AMrXdXv4Z5TMbynTplNC/MpCVUOXjUJRe3a4JxgZZZOtUtjvomWEzaLAu/k9ftELOgVMKSdgt90HXQ== X-Received: by 2002:a67:f692:0:b0:3c4:997b:667b with SMTP id n18-20020a67f692000000b003c4997b667bmr21476887vso.6.1674766865092; Thu, 26 Jan 2023 13:01:05 -0800 (PST) Received: from localhost (cpe-174-109-170-245.nc.res.rr.com. [174.109.170.245]) by smtp.gmail.com with ESMTPSA id h22-20020a05620a285600b006faaf6dc55asm1603256qkp.22.2023.01.26.13.01.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Jan 2023 13:01:04 -0800 (PST) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH v3 2/7] btrfs: add trans argument to btrfs_clean_tree_block Date: Thu, 26 Jan 2023 16:00:55 -0500 Message-Id: X-Mailer: git-send-email 2.26.3 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org We check the header generation in the extent buffer against the current running transaction id to see if it's safe to clear DIRTY on this buffer. Generally speaking if we're clearing the buffer dirty we're holding the transaction open, but in the case of cleaning up an aborted transaction we don't, so we have extra checks in that path to check the transid. To allow for a future cleanup go ahead and pass in the trans handle so we don't have to rely on ->running_transaction being set. Signed-off-by: Josef Bacik --- fs/btrfs/ctree.c | 31 ++++++++++++++++--------------- fs/btrfs/disk-io.c | 6 +++--- fs/btrfs/disk-io.h | 3 ++- fs/btrfs/extent-tree.c | 4 ++-- fs/btrfs/free-space-tree.c | 2 +- fs/btrfs/ioctl.c | 2 +- fs/btrfs/qgroup.c | 2 +- fs/btrfs/tree-log.c | 6 +++--- 8 files changed, 29 insertions(+), 27 deletions(-) diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index 5476d90a76ce..a4acc0e953c4 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c @@ -459,7 +459,7 @@ static noinline int update_ref_for_cow(struct btrfs_trans_handle *trans, if (ret) return ret; } - btrfs_clean_tree_block(buf); + btrfs_clean_tree_block(trans, buf); *last_ref = 1; } return 0; @@ -1026,7 +1026,7 @@ static noinline int balance_level(struct btrfs_trans_handle *trans, path->locks[level] = 0; path->nodes[level] = NULL; - btrfs_clean_tree_block(mid); + btrfs_clean_tree_block(trans, mid); btrfs_tree_unlock(mid); /* once for the path */ free_extent_buffer(mid); @@ -1087,7 +1087,7 @@ static noinline int balance_level(struct btrfs_trans_handle *trans, if (wret < 0 && wret != -ENOSPC) ret = wret; if (btrfs_header_nritems(right) == 0) { - btrfs_clean_tree_block(right); + btrfs_clean_tree_block(trans, right); btrfs_tree_unlock(right); del_ptr(root, path, level + 1, pslot + 1); root_sub_used(root, right->len); @@ -1133,7 +1133,7 @@ static noinline int balance_level(struct btrfs_trans_handle *trans, BUG_ON(wret == 1); } if (btrfs_header_nritems(mid) == 0) { - btrfs_clean_tree_block(mid); + btrfs_clean_tree_block(trans, mid); btrfs_tree_unlock(mid); del_ptr(root, path, level + 1, pslot); root_sub_used(root, mid->len); @@ -3008,7 +3008,8 @@ noinline int btrfs_leaf_free_space(struct extent_buffer *leaf) * min slot controls the lowest index we're willing to push to the * right. We'll push up to and including min_slot, but no lower */ -static noinline int __push_leaf_right(struct btrfs_path *path, +static noinline int __push_leaf_right(struct btrfs_trans_handle *trans, + struct btrfs_path *path, int data_size, int empty, struct extent_buffer *right, int free_space, u32 left_nritems, @@ -3106,7 +3107,7 @@ static noinline int __push_leaf_right(struct btrfs_path *path, if (left_nritems) btrfs_mark_buffer_dirty(left); else - btrfs_clean_tree_block(left); + btrfs_clean_tree_block(trans, left); btrfs_mark_buffer_dirty(right); @@ -3118,7 +3119,7 @@ static noinline int __push_leaf_right(struct btrfs_path *path, if (path->slots[0] >= left_nritems) { path->slots[0] -= left_nritems; if (btrfs_header_nritems(path->nodes[0]) == 0) - btrfs_clean_tree_block(path->nodes[0]); + btrfs_clean_tree_block(trans, path->nodes[0]); btrfs_tree_unlock(path->nodes[0]); free_extent_buffer(path->nodes[0]); path->nodes[0] = right; @@ -3210,8 +3211,8 @@ static int push_leaf_right(struct btrfs_trans_handle *trans, struct btrfs_root return 0; } - return __push_leaf_right(path, min_data_size, empty, - right, free_space, left_nritems, min_slot); + return __push_leaf_right(trans, path, min_data_size, empty, right, + free_space, left_nritems, min_slot); out_unlock: btrfs_tree_unlock(right); free_extent_buffer(right); @@ -3226,7 +3227,8 @@ static int push_leaf_right(struct btrfs_trans_handle *trans, struct btrfs_root * item at 'max_slot' won't be touched. Use (u32)-1 to make us do all the * items */ -static noinline int __push_leaf_left(struct btrfs_path *path, int data_size, +static noinline int __push_leaf_left(struct btrfs_trans_handle *trans, + struct btrfs_path *path, int data_size, int empty, struct extent_buffer *left, int free_space, u32 right_nritems, u32 max_slot) @@ -3330,7 +3332,7 @@ static noinline int __push_leaf_left(struct btrfs_path *path, int data_size, if (right_nritems) btrfs_mark_buffer_dirty(right); else - btrfs_clean_tree_block(right); + btrfs_clean_tree_block(trans, right); btrfs_item_key(right, &disk_key, 0); fixup_low_keys(path, &disk_key, 1); @@ -3416,9 +3418,8 @@ static int push_leaf_left(struct btrfs_trans_handle *trans, struct btrfs_root ret = -EUCLEAN; goto out; } - return __push_leaf_left(path, min_data_size, - empty, left, free_space, right_nritems, - max_slot); + return __push_leaf_left(trans, path, min_data_size, empty, left, + free_space, right_nritems, max_slot); out: btrfs_tree_unlock(left); free_extent_buffer(left); @@ -4367,7 +4368,7 @@ int btrfs_del_items(struct btrfs_trans_handle *trans, struct btrfs_root *root, if (leaf == root->node) { btrfs_set_header_level(leaf, 0); } else { - btrfs_clean_tree_block(leaf); + btrfs_clean_tree_block(trans, leaf); btrfs_del_leaf(trans, root, path, leaf); } } else { diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index d0ed52cab304..5942005d50fe 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -965,11 +965,11 @@ struct extent_buffer *read_tree_block(struct btrfs_fs_info *fs_info, u64 bytenr, } -void btrfs_clean_tree_block(struct extent_buffer *buf) +void btrfs_clean_tree_block(struct btrfs_trans_handle *trans, + struct extent_buffer *buf) { struct btrfs_fs_info *fs_info = buf->fs_info; - if (btrfs_header_generation(buf) == - fs_info->running_transaction->transid) { + if (btrfs_header_generation(buf) == trans->transid) { btrfs_assert_tree_write_locked(buf); if (test_and_clear_bit(EXTENT_BUFFER_DIRTY, &buf->bflags)) { diff --git a/fs/btrfs/disk-io.h b/fs/btrfs/disk-io.h index f2c507fd0e04..9ccb44adc5c3 100644 --- a/fs/btrfs/disk-io.h +++ b/fs/btrfs/disk-io.h @@ -39,7 +39,8 @@ struct extent_buffer *btrfs_find_create_tree_block( struct btrfs_fs_info *fs_info, u64 bytenr, u64 owner_root, int level); -void btrfs_clean_tree_block(struct extent_buffer *buf); +void btrfs_clean_tree_block(struct btrfs_trans_handle *trans, + struct extent_buffer *buf); void btrfs_clear_oneshot_options(struct btrfs_fs_info *fs_info); int btrfs_start_pre_rw_mount(struct btrfs_fs_info *fs_info); int btrfs_check_super_csum(struct btrfs_fs_info *fs_info, diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index c85af644e353..241a92a25b52 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -4908,7 +4908,7 @@ btrfs_init_new_buffer(struct btrfs_trans_handle *trans, struct btrfs_root *root, btrfs_set_buffer_lockdep_class(lockdep_owner, buf, level); __btrfs_tree_lock(buf, nest); - btrfs_clean_tree_block(buf); + btrfs_clean_tree_block(trans, buf); clear_bit(EXTENT_BUFFER_STALE, &buf->bflags); clear_bit(EXTENT_BUFFER_NO_CHECK, &buf->bflags); @@ -5538,7 +5538,7 @@ static noinline int walk_up_proc(struct btrfs_trans_handle *trans, btrfs_tree_lock(eb); path->locks[level] = BTRFS_WRITE_LOCK; } - btrfs_clean_tree_block(eb); + btrfs_clean_tree_block(trans, eb); } if (eb == root->node) { diff --git a/fs/btrfs/free-space-tree.c b/fs/btrfs/free-space-tree.c index c667e878ef1a..ab206af5b2f5 100644 --- a/fs/btrfs/free-space-tree.c +++ b/fs/btrfs/free-space-tree.c @@ -1283,7 +1283,7 @@ int btrfs_clear_free_space_tree(struct btrfs_fs_info *fs_info) list_del(&free_space_root->dirty_list); btrfs_tree_lock(free_space_root->node); - btrfs_clean_tree_block(free_space_root->node); + btrfs_clean_tree_block(trans, free_space_root->node); btrfs_tree_unlock(free_space_root->node); btrfs_free_tree_block(trans, btrfs_root_id(free_space_root), free_space_root->node, 0, 1); diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index a64a71d882dc..82afb1aef744 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -707,7 +707,7 @@ static noinline int create_subvol(struct user_namespace *mnt_userns, * exists). */ btrfs_tree_lock(leaf); - btrfs_clean_tree_block(leaf); + btrfs_clean_tree_block(trans, leaf); btrfs_tree_unlock(leaf); btrfs_free_tree_block(trans, objectid, leaf, 0, 1); free_extent_buffer(leaf); diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c index 35856ea28e32..6aadf620eb14 100644 --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c @@ -1303,7 +1303,7 @@ int btrfs_quota_disable(struct btrfs_fs_info *fs_info) list_del("a_root->dirty_list); btrfs_tree_lock(quota_root->node); - btrfs_clean_tree_block(quota_root->node); + btrfs_clean_tree_block(trans, quota_root->node); btrfs_tree_unlock(quota_root->node); btrfs_free_tree_block(trans, btrfs_root_id(quota_root), quota_root->node, 0, 1); diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index 8fcfaf015a70..d0c40a4af48d 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -2637,7 +2637,7 @@ static noinline int walk_down_log_tree(struct btrfs_trans_handle *trans, if (trans) { btrfs_tree_lock(next); - btrfs_clean_tree_block(next); + btrfs_clean_tree_block(trans, next); btrfs_wait_tree_block_writeback(next); btrfs_tree_unlock(next); ret = btrfs_pin_reserved_extent(trans, @@ -2707,7 +2707,7 @@ static noinline int walk_up_log_tree(struct btrfs_trans_handle *trans, if (trans) { btrfs_tree_lock(next); - btrfs_clean_tree_block(next); + btrfs_clean_tree_block(trans, next); btrfs_wait_tree_block_writeback(next); btrfs_tree_unlock(next); ret = btrfs_pin_reserved_extent(trans, @@ -2790,7 +2790,7 @@ static int walk_log_tree(struct btrfs_trans_handle *trans, if (trans) { btrfs_tree_lock(next); - btrfs_clean_tree_block(next); + btrfs_clean_tree_block(trans, next); btrfs_wait_tree_block_writeback(next); btrfs_tree_unlock(next); ret = btrfs_pin_reserved_extent(trans, From patchwork Thu Jan 26 21:00:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13117766 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 53588C54EAA for ; Thu, 26 Jan 2023 21:01:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231754AbjAZVBU (ORCPT ); Thu, 26 Jan 2023 16:01:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232176AbjAZVBQ (ORCPT ); Thu, 26 Jan 2023 16:01:16 -0500 Received: from mail-qv1-xf2b.google.com (mail-qv1-xf2b.google.com [IPv6:2607:f8b0:4864:20::f2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E63AF3669D for ; Thu, 26 Jan 2023 13:01:07 -0800 (PST) Received: by mail-qv1-xf2b.google.com with SMTP id m12so2395660qvt.9 for ; Thu, 26 Jan 2023 13:01:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=ZkZEpr2L5P1ocWqg9oO0bXldfdgVY0am7oJTJOgUCP4=; b=GbtLuqu6eAXPCRaLo1/NQb8HDYR/cbyd46ittlH9WFRafyRnWL/4tgVgfXI87ouX7C 0IxpHV4LfMqXY67FIcbcJLTn5y0r9T5v6BgO0itL/NIGdWYvnq6aePu17wtwURtsW8a/ WsyFSOK0i2a92EApT8IFltG4r3ABcVnE6wuC0/5F9GLS22QHnqaa7GGjthuP/Q66SBen pTdKTDtpKoaH/vU56RlZ/GJQjdqwPFxiQpoeilQAyai9lg0JU+3IjiTArBb798exPDGE KE7a8k1Mv7sKBiMVsp7U+pwdcxaAPZMXISEGKIWR+fnj4ON3XK+cZaCTnDawi/qqGDLi Yabg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZkZEpr2L5P1ocWqg9oO0bXldfdgVY0am7oJTJOgUCP4=; b=nP252qHKGF3u01XyzZWrS1GVA7AgEQBRZSCBzJHeHX5lW0YwHjq1o3cn9i+sW2XQz6 ZFbwp5HLsc3gUj1r0oMKnznVqPvulDajwMD6yGVXugu+6PkKeLsObsBVMEWpY5E7zcjE 2BOhnXfPQxQCMhB5Bwqcq5ibCESZ+ES/Dmxk03tc63FSxhXqSuGqePMUbmjIkfSzUS+Z X2EgZyQil5QFSoof4Qn34AHChSog71r6mXmWGDhGeeLQZHOLF173waIVFeu57rMLcVXw DDNn4dBTCUlWFK1YZBCD832t6XCZMCOf8y5bpiZ2oXiGFwdfRTtq5awGEZugk6zuGSto za5Q== X-Gm-Message-State: AO0yUKWuXYxwW4myrMAsPtJC0nZvOEomjOUF0gJdw5GUyzA3XASdvpnx xYjaVFQFJ17cp43M+S3HfTkEiQ0pL/Peh591AvA= X-Google-Smtp-Source: AK7set/Nc6Zhp8GA9zRmGNuoxW+W6xFMMQfO3xMsa69TmxYwfTmFCvC9WaQfMh2P2w96XmZGbUL9WA== X-Received: by 2002:a05:6214:924:b0:4c7:3c7c:4d1e with SMTP id dk4-20020a056214092400b004c73c7c4d1emr4587185qvb.15.1674766866603; Thu, 26 Jan 2023 13:01:06 -0800 (PST) Received: from localhost (cpe-174-109-170-245.nc.res.rr.com. [174.109.170.245]) by smtp.gmail.com with ESMTPSA id b4-20020a378004000000b0070736988c10sm1552242qkd.110.2023.01.26.13.01.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Jan 2023 13:01:06 -0800 (PST) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH v3 3/7] btrfs: replace clearing extent buffer dirty bit with btrfs_clean_block Date: Thu, 26 Jan 2023 16:00:56 -0500 Message-Id: <0e818f6eca3cf65a4eb9ce844d8c93d40054e8e1.1674766637.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Now that we're passing in the trans into btrfs_clean_tree_block, we can easily roll in the handling of the !trans case and replace all occurrences of if (test_and_clear_bit(EXTENT_BUFFER_DIRTY, &eb->bflags)) clear_extent_buffer_dirty(eb); with btrfs_tree_lock(eb); btrfs_clean_tree_block(eb); btrfs_tree_unlock(eb); We need the lock because if we are actually dirty we need to make sure we aren't racing with anything that's starting writeout currently. This also makes sure that we're accounting fs_info->dirty_metadata_bytes appropriately. Signed-off-by: Josef Bacik --- fs/btrfs/disk-io.c | 11 ++++++----- fs/btrfs/tree-log.c | 34 +++++++++++++++------------------- 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 5942005d50fe..5bcb77662b1d 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -969,7 +969,7 @@ void btrfs_clean_tree_block(struct btrfs_trans_handle *trans, struct extent_buffer *buf) { struct btrfs_fs_info *fs_info = buf->fs_info; - if (btrfs_header_generation(buf) == trans->transid) { + if (!trans || btrfs_header_generation(buf) == trans->transid) { btrfs_assert_tree_write_locked(buf); if (test_and_clear_bit(EXTENT_BUFFER_DIRTY, &buf->bflags)) { @@ -5077,11 +5077,12 @@ static int btrfs_destroy_marked_extents(struct btrfs_fs_info *fs_info, start += fs_info->nodesize; if (!eb) continue; - wait_on_extent_buffer_writeback(eb); - if (test_and_clear_bit(EXTENT_BUFFER_DIRTY, - &eb->bflags)) - clear_extent_buffer_dirty(eb); + btrfs_tree_lock(eb); + wait_on_extent_buffer_writeback(eb); + btrfs_clean_tree_block(NULL, eb); + btrfs_tree_unlock(eb); + free_extent_buffer_stale(eb); } } diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index d0c40a4af48d..f543af4328b6 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -2635,11 +2635,12 @@ static noinline int walk_down_log_tree(struct btrfs_trans_handle *trans, return ret; } + btrfs_tree_lock(next); + btrfs_clean_tree_block(trans, next); + btrfs_wait_tree_block_writeback(next); + btrfs_tree_unlock(next); + if (trans) { - btrfs_tree_lock(next); - btrfs_clean_tree_block(trans, next); - btrfs_wait_tree_block_writeback(next); - btrfs_tree_unlock(next); ret = btrfs_pin_reserved_extent(trans, bytenr, blocksize); if (ret) { @@ -2649,8 +2650,6 @@ static noinline int walk_down_log_tree(struct btrfs_trans_handle *trans, btrfs_redirty_list_add( trans->transaction, next); } else { - if (test_and_clear_bit(EXTENT_BUFFER_DIRTY, &next->bflags)) - clear_extent_buffer_dirty(next); unaccount_log_buffer(fs_info, bytenr); } } @@ -2705,11 +2704,12 @@ static noinline int walk_up_log_tree(struct btrfs_trans_handle *trans, next = path->nodes[*level]; + btrfs_tree_lock(next); + btrfs_clean_tree_block(trans, next); + btrfs_wait_tree_block_writeback(next); + btrfs_tree_unlock(next); + if (trans) { - btrfs_tree_lock(next); - btrfs_clean_tree_block(trans, next); - btrfs_wait_tree_block_writeback(next); - btrfs_tree_unlock(next); ret = btrfs_pin_reserved_extent(trans, path->nodes[*level]->start, path->nodes[*level]->len); @@ -2718,9 +2718,6 @@ static noinline int walk_up_log_tree(struct btrfs_trans_handle *trans, btrfs_redirty_list_add(trans->transaction, next); } else { - if (test_and_clear_bit(EXTENT_BUFFER_DIRTY, &next->bflags)) - clear_extent_buffer_dirty(next); - unaccount_log_buffer(fs_info, path->nodes[*level]->start); } @@ -2788,19 +2785,18 @@ static int walk_log_tree(struct btrfs_trans_handle *trans, next = path->nodes[orig_level]; + btrfs_tree_lock(next); + btrfs_clean_tree_block(trans, next); + btrfs_wait_tree_block_writeback(next); + btrfs_tree_unlock(next); + if (trans) { - btrfs_tree_lock(next); - btrfs_clean_tree_block(trans, next); - btrfs_wait_tree_block_writeback(next); - btrfs_tree_unlock(next); ret = btrfs_pin_reserved_extent(trans, next->start, next->len); if (ret) goto out; btrfs_redirty_list_add(trans->transaction, next); } else { - if (test_and_clear_bit(EXTENT_BUFFER_DIRTY, &next->bflags)) - clear_extent_buffer_dirty(next); unaccount_log_buffer(fs_info, next->start); } } From patchwork Thu Jan 26 21:00:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13117767 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ED17AC61DA3 for ; Thu, 26 Jan 2023 21:01:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229495AbjAZVBU (ORCPT ); Thu, 26 Jan 2023 16:01:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231828AbjAZVBS (ORCPT ); Thu, 26 Jan 2023 16:01:18 -0500 Received: from mail-yw1-x112b.google.com (mail-yw1-x112b.google.com [IPv6:2607:f8b0:4864:20::112b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B41C4A1E8 for ; Thu, 26 Jan 2023 13:01:09 -0800 (PST) Received: by mail-yw1-x112b.google.com with SMTP id 00721157ae682-4b718cab0e4so40448237b3.9 for ; Thu, 26 Jan 2023 13:01:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=/iqMaeL2/3iIa7APep2tYpwUpwF7cWyXv1iyiMsdJsQ=; b=6Vw7XA+WFa+m8oBLm3NrUwpez50KrHB2n8kvvEXcko5eILHN5vCTGrZ6Ez73Cxm4B9 W1Jjr+eN22uPLfVYHv2kR61tNwX7E8wqhWDksJLoQU/zrXnJ5lKoa+5d7rczOyUCdh6v d7X+qY2YMaWGCxaq1xAsGzvbxypnKrnmTWXp/i6BFkMSMDFHEyWZE3Stlybqyt5jgAFC 83iPf+V6NSKKdjunKOO5y/soIjGuxzl0cmDBMaW5aO8ykcLg5qy/mY//B39ms5+gyucr hU67NW94lAnJaaHdqgi/d/NJSG7NajfIsp4KhO2CM9/5GpRARm3yzqTfVvCrDB3ka6EY 3AlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/iqMaeL2/3iIa7APep2tYpwUpwF7cWyXv1iyiMsdJsQ=; b=hFgUGHuzWDGwBm1+B8zet8OINr0n+PlSF1CLMGBaHN8emH4iEN0wD1+ZlE/nVTFRjE 5yc1pTPh5LTS5qk0cCaJHgbeCVau10CV6Ra9oSyOlpyvivad7+OHjMYOj0rnOjyHxttF yc8iQfu4RQ04J5EvkigXH8SJWJVteHkF6/m9NKCTadZz+W8lobisbbSe2+zqBBJRbaYP Kvm+dh4JSiCNKsM3jVT020ZjdxXsZ1I0f1srmFUWpLQzRBixQ9yWyB41DzKDi5C1CNvL ww3R/Utr/W+tlAndbarTodV83tKh5Vr3wkdVioE44e43SP16zLv8D8DylSAb2dluyPLr xUVw== X-Gm-Message-State: AFqh2kpmfghgnEQxd/1hIfwC5MxKJyBu++9DcVGf2TaYG6gKTIvRR0hW 8XYJL6Hc4oinKFlKqTUD+uwcHi0bhN0w31URmSw= X-Google-Smtp-Source: AMrXdXuFb7E7mtGj1nRQt8QipIQvqBl4BaWvzd43TPvAZlgNaJ///62pVf6ocae/itOb4YZpvBRmdA== X-Received: by 2002:a0d:fd86:0:b0:4c5:2b26:8cee with SMTP id n128-20020a0dfd86000000b004c52b268ceemr27390501ywf.13.1674766868082; Thu, 26 Jan 2023 13:01:08 -0800 (PST) Received: from localhost (cpe-174-109-170-245.nc.res.rr.com. [174.109.170.245]) by smtp.gmail.com with ESMTPSA id c139-20020ae9ed91000000b00704a9942708sm1592097qkg.73.2023.01.26.13.01.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Jan 2023 13:01:07 -0800 (PST) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH v3 4/7] btrfs: do not increment dirty_metadata_bytes in set_btree_ioerr Date: Thu, 26 Jan 2023 16:00:57 -0500 Message-Id: X-Mailer: git-send-email 2.26.3 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org We only add if we set the extent buffer dirty, and we subtract when we clear the extent buffer dirty. If we end up in set_btree_ioerr we have already cleared the buffer dirty, and we aren't resetting dirty on the extent buffer, so this is simply wrong. Signed-off-by: Josef Bacik --- fs/btrfs/extent_io.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index c87be46e0663..7cd4065acc82 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -2467,13 +2467,6 @@ static void set_btree_ioerr(struct page *page, struct extent_buffer *eb) */ mapping_set_error(page->mapping, -EIO); - /* - * If we error out, we should add back the dirty_metadata_bytes - * to make it consistent. - */ - percpu_counter_add_batch(&fs_info->dirty_metadata_bytes, - eb->len, fs_info->dirty_metadata_batch); - /* * If writeback for a btree extent that doesn't belong to a log tree * failed, increment the counter transaction->eb_write_errors. From patchwork Thu Jan 26 21:00:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13117768 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23830C05027 for ; Thu, 26 Jan 2023 21:01:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232338AbjAZVBX (ORCPT ); Thu, 26 Jan 2023 16:01:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232216AbjAZVBW (ORCPT ); Thu, 26 Jan 2023 16:01:22 -0500 Received: from mail-qt1-x836.google.com (mail-qt1-x836.google.com [IPv6:2607:f8b0:4864:20::836]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E42D14A20F for ; Thu, 26 Jan 2023 13:01:10 -0800 (PST) Received: by mail-qt1-x836.google.com with SMTP id o5so2394831qtr.11 for ; Thu, 26 Jan 2023 13:01:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=YYEdTm+PXISxVNJJbhRYvaUQOlxI/mJ7RBKfYxSAgj0=; b=5LEWSBzKLBzWYqHbgiLFnfAo3TYM9wOYMws5JUG++69yHEDzfwUQ399bS4xZ79kymj vtiANcLOcglrxW6aPzFgfwOQlqSVVJRRuoshHTOu/XxqpjWV4ImU0cWJhxVivzoRLDvw wd+eT+YOhJJL/GH4VyWo3W8p5ZtcOXEO8kXDUcHhFuMgzfrcIV1zqzi8eTQQQuNnNhEj YuwzNqVtR42YB3NvyA9Tj4JIhD/0iV+6qDhlTaz1iR8NmmOiCtudXH17gvthpLg6A5bZ D96+PLeQyOOPpImdqImgBAcqbHC64J6N9SnuBk2FRkaNxwjpU9zrqQw5oUKox1rY29pV j1qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YYEdTm+PXISxVNJJbhRYvaUQOlxI/mJ7RBKfYxSAgj0=; b=lTIi23Lre4tWKt8IUalOtSl8jcXz+/sNE1VJEBF6RVQO7xLmpniIdp1OGmx7YhAWcl 9o8Te8UJ6/BsyVJMbFRj8nuB0MmY58ZjJNROZwapZdNHLW5Nw2K7/WxpbouHt013sKs1 Bl0F8wZyOoMhU1PLcJfxRP9wjtNPQpLB8LWJ5IrNpdkRhC0SFpgkpLGp/nfsRfPzSLyI bMHO6MFoGmkqtezsSafpwIrLGFy85nta9IWzLb7iQUtmyzDTRewEhjEM2e4n3kWnOtDo d4D13Mwtyk/Iu2XSGccCFzuUs7gawqLocYP9MQXkbxwM/jqdnGUvbJQLGYmWdHArvu6G 6cMg== X-Gm-Message-State: AO0yUKVrZ/kPVgCE5noCYP+YsKC5hTesDArf4zcOoCP55zYgMcEsEfd0 rb7AzLfJJ7c7R+AipHxxboPtsUYHRo8epjGHEjw= X-Google-Smtp-Source: AK7set9IurkbUBgxwrINOhiLyCkt7DNV4sf2mLnJ3WRm7vz0BSyG0rt0bH+RVkfQH45pCb6SyVQEYQ== X-Received: by 2002:ac8:5bcd:0:b0:3b1:c537:38f1 with SMTP id b13-20020ac85bcd000000b003b1c53738f1mr12773638qtb.19.1674766869481; Thu, 26 Jan 2023 13:01:09 -0800 (PST) Received: from localhost (cpe-174-109-170-245.nc.res.rr.com. [174.109.170.245]) by smtp.gmail.com with ESMTPSA id a24-20020ac84d98000000b003b643951117sm1388352qtw.38.2023.01.26.13.01.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Jan 2023 13:01:09 -0800 (PST) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH v3 5/7] btrfs: rename btrfs_clean_tree_block => btrfs_clear_buffer_dirty Date: Thu, 26 Jan 2023 16:00:58 -0500 Message-Id: <85687150062b95fb20c495441b5b83f36e972204.1674766637.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org btrfs_clean_tree_block is a misnomer, it's just clear_extent_buffer_dirty with some extra accounting around it. Rename this to btrfs_clear_buffer_dirty to make it more clear it belongs with it's setter, btrfs_mark_buffer_dirty. Signed-off-by: Josef Bacik --- fs/btrfs/ctree.c | 16 ++++++++-------- fs/btrfs/disk-io.c | 6 +++--- fs/btrfs/disk-io.h | 4 ++-- fs/btrfs/extent-tree.c | 6 +++--- fs/btrfs/free-space-tree.c | 2 +- fs/btrfs/ioctl.c | 2 +- fs/btrfs/qgroup.c | 2 +- fs/btrfs/tree-log.c | 6 +++--- 8 files changed, 22 insertions(+), 22 deletions(-) diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index a4acc0e953c4..c648a3493542 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c @@ -459,7 +459,7 @@ static noinline int update_ref_for_cow(struct btrfs_trans_handle *trans, if (ret) return ret; } - btrfs_clean_tree_block(trans, buf); + btrfs_clear_buffer_dirty(trans, buf); *last_ref = 1; } return 0; @@ -1026,7 +1026,7 @@ static noinline int balance_level(struct btrfs_trans_handle *trans, path->locks[level] = 0; path->nodes[level] = NULL; - btrfs_clean_tree_block(trans, mid); + btrfs_clear_buffer_dirty(trans, mid); btrfs_tree_unlock(mid); /* once for the path */ free_extent_buffer(mid); @@ -1087,7 +1087,7 @@ static noinline int balance_level(struct btrfs_trans_handle *trans, if (wret < 0 && wret != -ENOSPC) ret = wret; if (btrfs_header_nritems(right) == 0) { - btrfs_clean_tree_block(trans, right); + btrfs_clear_buffer_dirty(trans, right); btrfs_tree_unlock(right); del_ptr(root, path, level + 1, pslot + 1); root_sub_used(root, right->len); @@ -1133,7 +1133,7 @@ static noinline int balance_level(struct btrfs_trans_handle *trans, BUG_ON(wret == 1); } if (btrfs_header_nritems(mid) == 0) { - btrfs_clean_tree_block(trans, mid); + btrfs_clear_buffer_dirty(trans, mid); btrfs_tree_unlock(mid); del_ptr(root, path, level + 1, pslot); root_sub_used(root, mid->len); @@ -3107,7 +3107,7 @@ static noinline int __push_leaf_right(struct btrfs_trans_handle *trans, if (left_nritems) btrfs_mark_buffer_dirty(left); else - btrfs_clean_tree_block(trans, left); + btrfs_clear_buffer_dirty(trans, left); btrfs_mark_buffer_dirty(right); @@ -3119,7 +3119,7 @@ static noinline int __push_leaf_right(struct btrfs_trans_handle *trans, if (path->slots[0] >= left_nritems) { path->slots[0] -= left_nritems; if (btrfs_header_nritems(path->nodes[0]) == 0) - btrfs_clean_tree_block(trans, path->nodes[0]); + btrfs_clear_buffer_dirty(trans, path->nodes[0]); btrfs_tree_unlock(path->nodes[0]); free_extent_buffer(path->nodes[0]); path->nodes[0] = right; @@ -3332,7 +3332,7 @@ static noinline int __push_leaf_left(struct btrfs_trans_handle *trans, if (right_nritems) btrfs_mark_buffer_dirty(right); else - btrfs_clean_tree_block(trans, right); + btrfs_clear_buffer_dirty(trans, right); btrfs_item_key(right, &disk_key, 0); fixup_low_keys(path, &disk_key, 1); @@ -4368,7 +4368,7 @@ int btrfs_del_items(struct btrfs_trans_handle *trans, struct btrfs_root *root, if (leaf == root->node) { btrfs_set_header_level(leaf, 0); } else { - btrfs_clean_tree_block(trans, leaf); + btrfs_clear_buffer_dirty(trans, leaf); btrfs_del_leaf(trans, root, path, leaf); } } else { diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 5bcb77662b1d..319d664e1782 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -965,8 +965,8 @@ struct extent_buffer *read_tree_block(struct btrfs_fs_info *fs_info, u64 bytenr, } -void btrfs_clean_tree_block(struct btrfs_trans_handle *trans, - struct extent_buffer *buf) +void btrfs_clear_buffer_dirty(struct btrfs_trans_handle *trans, + struct extent_buffer *buf) { struct btrfs_fs_info *fs_info = buf->fs_info; if (!trans || btrfs_header_generation(buf) == trans->transid) { @@ -5080,7 +5080,7 @@ static int btrfs_destroy_marked_extents(struct btrfs_fs_info *fs_info, btrfs_tree_lock(eb); wait_on_extent_buffer_writeback(eb); - btrfs_clean_tree_block(NULL, eb); + btrfs_clear_buffer_dirty(NULL, eb); btrfs_tree_unlock(eb); free_extent_buffer_stale(eb); diff --git a/fs/btrfs/disk-io.h b/fs/btrfs/disk-io.h index 9ccb44adc5c3..13687458a321 100644 --- a/fs/btrfs/disk-io.h +++ b/fs/btrfs/disk-io.h @@ -39,8 +39,8 @@ struct extent_buffer *btrfs_find_create_tree_block( struct btrfs_fs_info *fs_info, u64 bytenr, u64 owner_root, int level); -void btrfs_clean_tree_block(struct btrfs_trans_handle *trans, - struct extent_buffer *buf); +void btrfs_clear_buffer_dirty(struct btrfs_trans_handle *trans, + struct extent_buffer *buf); void btrfs_clear_oneshot_options(struct btrfs_fs_info *fs_info); int btrfs_start_pre_rw_mount(struct btrfs_fs_info *fs_info); int btrfs_check_super_csum(struct btrfs_fs_info *fs_info, diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 241a92a25b52..b1d3e37a6398 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -4908,7 +4908,7 @@ btrfs_init_new_buffer(struct btrfs_trans_handle *trans, struct btrfs_root *root, btrfs_set_buffer_lockdep_class(lockdep_owner, buf, level); __btrfs_tree_lock(buf, nest); - btrfs_clean_tree_block(trans, buf); + btrfs_clear_buffer_dirty(trans, buf); clear_bit(EXTENT_BUFFER_STALE, &buf->bflags); clear_bit(EXTENT_BUFFER_NO_CHECK, &buf->bflags); @@ -5533,12 +5533,12 @@ static noinline int walk_up_proc(struct btrfs_trans_handle *trans, } } } - /* make block locked assertion in btrfs_clean_tree_block happy */ + /* make block locked assertion in btrfs_clear_buffer_dirty happy */ if (!path->locks[level]) { btrfs_tree_lock(eb); path->locks[level] = BTRFS_WRITE_LOCK; } - btrfs_clean_tree_block(trans, eb); + btrfs_clear_buffer_dirty(trans, eb); } if (eb == root->node) { diff --git a/fs/btrfs/free-space-tree.c b/fs/btrfs/free-space-tree.c index ab206af5b2f5..4d155a48ec59 100644 --- a/fs/btrfs/free-space-tree.c +++ b/fs/btrfs/free-space-tree.c @@ -1283,7 +1283,7 @@ int btrfs_clear_free_space_tree(struct btrfs_fs_info *fs_info) list_del(&free_space_root->dirty_list); btrfs_tree_lock(free_space_root->node); - btrfs_clean_tree_block(trans, free_space_root->node); + btrfs_clear_buffer_dirty(trans, free_space_root->node); btrfs_tree_unlock(free_space_root->node); btrfs_free_tree_block(trans, btrfs_root_id(free_space_root), free_space_root->node, 0, 1); diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 82afb1aef744..f0babad56ad3 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -707,7 +707,7 @@ static noinline int create_subvol(struct user_namespace *mnt_userns, * exists). */ btrfs_tree_lock(leaf); - btrfs_clean_tree_block(trans, leaf); + btrfs_clear_buffer_dirty(trans, leaf); btrfs_tree_unlock(leaf); btrfs_free_tree_block(trans, objectid, leaf, 0, 1); free_extent_buffer(leaf); diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c index 6aadf620eb14..1d06a93edc35 100644 --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c @@ -1303,7 +1303,7 @@ int btrfs_quota_disable(struct btrfs_fs_info *fs_info) list_del("a_root->dirty_list); btrfs_tree_lock(quota_root->node); - btrfs_clean_tree_block(trans, quota_root->node); + btrfs_clear_buffer_dirty(trans, quota_root->node); btrfs_tree_unlock(quota_root->node); btrfs_free_tree_block(trans, btrfs_root_id(quota_root), quota_root->node, 0, 1); diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index f543af4328b6..050ae214fb4f 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -2636,7 +2636,7 @@ static noinline int walk_down_log_tree(struct btrfs_trans_handle *trans, } btrfs_tree_lock(next); - btrfs_clean_tree_block(trans, next); + btrfs_clear_buffer_dirty(trans, next); btrfs_wait_tree_block_writeback(next); btrfs_tree_unlock(next); @@ -2705,7 +2705,7 @@ static noinline int walk_up_log_tree(struct btrfs_trans_handle *trans, next = path->nodes[*level]; btrfs_tree_lock(next); - btrfs_clean_tree_block(trans, next); + btrfs_clear_buffer_dirty(trans, next); btrfs_wait_tree_block_writeback(next); btrfs_tree_unlock(next); @@ -2786,7 +2786,7 @@ static int walk_log_tree(struct btrfs_trans_handle *trans, next = path->nodes[orig_level]; btrfs_tree_lock(next); - btrfs_clean_tree_block(trans, next); + btrfs_clear_buffer_dirty(trans, next); btrfs_wait_tree_block_writeback(next); btrfs_tree_unlock(next); From patchwork Thu Jan 26 21:00:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13117769 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC43AC54EAA for ; Thu, 26 Jan 2023 21:01:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231828AbjAZVBY (ORCPT ); Thu, 26 Jan 2023 16:01:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232218AbjAZVBX (ORCPT ); Thu, 26 Jan 2023 16:01:23 -0500 Received: from mail-yb1-xb31.google.com (mail-yb1-xb31.google.com [IPv6:2607:f8b0:4864:20::b31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A9984ABE2 for ; Thu, 26 Jan 2023 13:01:12 -0800 (PST) Received: by mail-yb1-xb31.google.com with SMTP id d132so3627143ybb.5 for ; Thu, 26 Jan 2023 13:01:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=69AIUmk2BRx6jNUD0FIu6c40P8sXnw5ME97i0/q1z8o=; b=bOUWDoWQoWUFbNVS3USYcgFYtRItyI5VmDY/EBPIa+tDBA/EW3Hrf/WioVEt6mCuht gWF/2M0oNCZU1NlA7mLwd+514CAPdu1Rj7jsQzB0v44nflX9QotvK+dvlIsxNWSk6g6K x7iKE2rATNlYCfbEMFP2d5x+1UfRxUQEJxeyk/UQQj5imtSPOXDJsPauoT51JjPNblUM MLs3tRYkBL//lwnWdWqK+L7QGoLuYNhnY7db5jRqFbprWgVxywepTrSnClh53n+b/pLH KtHoaX0e6tBIGreJqCERZGApkzVFJ94hQy9pJymRAlM0iCYk4eYDJxvuZYD6NxxuIAy9 C7wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=69AIUmk2BRx6jNUD0FIu6c40P8sXnw5ME97i0/q1z8o=; b=uXvU/mcIO32T0IoXc1PDQas4MXcI8cfAM/olxcebCqTIpiHRYj13aZigjY/e05j8Qu 3zT1iv9M1vmFnY0mP0E9ZuGZo6hPGmrck23FFbasGsqs06c309tPiJW8g2ocznxrYrtO 34QL2r9k8HQAL8Qjin2sUGOTlHJ5qN7ULcuC4iPolu12fdn/zIkZHKqXESeJwIV5jX8s sD0T8JVpiAbypjRLL3jWTE+DUjK5rDFIUIvM2Mbd5zGtg660VUc/xQMIHlJq3pDGz0h4 9cePZy0Y0grRgdpQJItxibRXjSX5NJV8ga1+SQ6CikKcX8/7aOFU3K5Hh0NF07jRTd9I pxww== X-Gm-Message-State: AFqh2koXF3IRiXH0GlGJVHA/Uz2xi3Nfmh44VLYBJXnCn5sZcKkISFKE 8ZM/nOg4PfF6DVV8bwqy//knuEArU77/tNXd9vI= X-Google-Smtp-Source: AMrXdXsMR2bQFGdbEVs8k/1FjOKcVu5/n4cCR1MtISDC4Rbrbz8b3JDgVPpCdlwoEbVcL4iOgtQtAA== X-Received: by 2002:a25:ec0c:0:b0:802:a54a:9123 with SMTP id j12-20020a25ec0c000000b00802a54a9123mr15690716ybh.11.1674766870851; Thu, 26 Jan 2023 13:01:10 -0800 (PST) Received: from localhost (cpe-174-109-170-245.nc.res.rr.com. [174.109.170.245]) by smtp.gmail.com with ESMTPSA id t18-20020a05620a451200b00706adbdf8b8sm1599168qkp.83.2023.01.26.13.01.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Jan 2023 13:01:10 -0800 (PST) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH v3 6/7] btrfs: combine btrfs_clear_buffer_dirty and clear_extent_buffer_dirty Date: Thu, 26 Jan 2023 16:00:59 -0500 Message-Id: <71d246feb82c0d657ad24ea5106b549e334be17f.1674766637.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org btrfs_clear_buffer_dirty just does the test_clear_bit() and then calls clear_extent_buffer_dirty and does the dirty metadata accounting. Combine this into clear_extent_buffer_dirty and make the result btrfs_clear_buffer_dirty. Signed-off-by: Josef Bacik --- fs/btrfs/disk-io.c | 16 ---------------- fs/btrfs/extent_io.c | 16 +++++++++++++++- fs/btrfs/extent_io.h | 5 ++++- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 319d664e1782..68b40c3b0dbb 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -965,22 +965,6 @@ struct extent_buffer *read_tree_block(struct btrfs_fs_info *fs_info, u64 bytenr, } -void btrfs_clear_buffer_dirty(struct btrfs_trans_handle *trans, - struct extent_buffer *buf) -{ - struct btrfs_fs_info *fs_info = buf->fs_info; - if (!trans || btrfs_header_generation(buf) == trans->transid) { - btrfs_assert_tree_write_locked(buf); - - if (test_and_clear_bit(EXTENT_BUFFER_DIRTY, &buf->bflags)) { - percpu_counter_add_batch(&fs_info->dirty_metadata_bytes, - -buf->len, - fs_info->dirty_metadata_batch); - clear_extent_buffer_dirty(buf); - } - } -} - static void __setup_root(struct btrfs_root *root, struct btrfs_fs_info *fs_info, u64 objectid) { diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 7cd4065acc82..62ca6a23d99b 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -36,6 +36,7 @@ #include "file.h" #include "dev-replace.h" #include "super.h" +#include "transaction.h" static struct kmem_cache *extent_buffer_cache; @@ -4813,12 +4814,25 @@ static void clear_subpage_extent_buffer_dirty(const struct extent_buffer *eb) WARN_ON(atomic_read(&eb->refs) == 0); } -void clear_extent_buffer_dirty(const struct extent_buffer *eb) +void btrfs_clear_buffer_dirty(struct btrfs_trans_handle *trans, + struct extent_buffer *eb) { + struct btrfs_fs_info *fs_info = eb->fs_info; int i; int num_pages; struct page *page; + btrfs_assert_tree_write_locked(eb); + + if (trans && btrfs_header_generation(eb) != trans->transid) + return; + + if (!test_and_clear_bit(EXTENT_BUFFER_DIRTY, &eb->bflags)) + return; + + percpu_counter_add_batch(&fs_info->dirty_metadata_bytes, -eb->len, + fs_info->dirty_metadata_batch); + if (eb->fs_info->nodesize < PAGE_SIZE) return clear_subpage_extent_buffer_dirty(eb); diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h index a024655d4237..abebe803bcad 100644 --- a/fs/btrfs/extent_io.h +++ b/fs/btrfs/extent_io.h @@ -11,6 +11,8 @@ #include "ulist.h" #include "misc.h" +struct btrfs_trans_handle; + enum { EXTENT_BUFFER_UPTODATE, EXTENT_BUFFER_DIRTY, @@ -261,7 +263,6 @@ void extent_buffer_bitmap_set(const struct extent_buffer *eb, unsigned long star void extent_buffer_bitmap_clear(const struct extent_buffer *eb, unsigned long start, unsigned long pos, unsigned long len); -void clear_extent_buffer_dirty(const struct extent_buffer *eb); bool set_extent_buffer_dirty(struct extent_buffer *eb); void set_extent_buffer_uptodate(struct extent_buffer *eb); void clear_extent_buffer_uptodate(struct extent_buffer *eb); @@ -273,6 +274,8 @@ void extent_clear_unlock_delalloc(struct btrfs_inode *inode, u64 start, u64 end, u32 bits_to_clear, unsigned long page_ops); int extent_invalidate_folio(struct extent_io_tree *tree, struct folio *folio, size_t offset); +void btrfs_clear_buffer_dirty(struct btrfs_trans_handle *trans, + struct extent_buffer *buf); int btrfs_alloc_page_array(unsigned int nr_pages, struct page **page_array); From patchwork Thu Jan 26 21:01:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13117770 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4A46C61DA3 for ; Thu, 26 Jan 2023 21:01:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232218AbjAZVBZ (ORCPT ); Thu, 26 Jan 2023 16:01:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232315AbjAZVBX (ORCPT ); Thu, 26 Jan 2023 16:01:23 -0500 Received: from mail-qt1-x833.google.com (mail-qt1-x833.google.com [IPv6:2607:f8b0:4864:20::833]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91BC04C6DE for ; Thu, 26 Jan 2023 13:01:13 -0800 (PST) Received: by mail-qt1-x833.google.com with SMTP id j9so2421476qtv.4 for ; Thu, 26 Jan 2023 13:01:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=X+QTAavJpS9U43VEUJKI5UZJNTE7fRPJLg0dzoOIJ8w=; b=BVkoGkKKVTIczjjjIe1cWQVhYWFCmRWtNTntR6Sil2hjQ/QhediMDz2mOK8mLKXsLt rDyHfgdUVMCaDeSo77zn2eFtWCbIKpv8kj+/6BdKjk1ABv3D2g2Oe3UwelBNL2ZNIEUf u0LMQbWS17Ht5pnNELDDKN7XgWZleN20YfoMqV101tkCh0uJ52IRxh3uOJq11RdMLK3U TJUhADgu4oD3KzXPTA9WLhgaNm2e/aMxCMwbLb+pxwBmQJFb8rz4UOFwKYUMZpd+IHnz hJx4hXUwlOyXIIqtzGrPAbo97+20NVhNF6YQSuxamSmaQWp+aqTGXcVJ4RoOENFgFn4L Gdlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=X+QTAavJpS9U43VEUJKI5UZJNTE7fRPJLg0dzoOIJ8w=; b=U6JY7ms4vT5TVs/a5MW4NUNmIYWnOnmaKW1BwQpGYgSFi8+Xx0lTlqYewjkTACMh0v 8yJ2rwblLvrl+goyQXhs4vjjVBSKxfIxM4LyguJ4Fng7cFkTPf3fMvYrfnfn8+H+pUO2 crozvDr0RKuyQeD6VleELSZuxiCYjoMXpuhEPlp9Vn2b8FoNeFMkRQK0e6ef8s5lWgen QUFYclEbB4ZqJXoQg8Z6tbihHk4Zj8P4mFogCdIcWQEd6AYh0J2MmvNnZFDBRS8p020A 15fUmFQnCnwPQuynnUZBZnA5s2KWEECvwV9cPk1j3SSnJYxn73/b+btEiWp2sMM3SHVS 1/Kw== X-Gm-Message-State: AFqh2kqqiXCZ5qzHqJ2Hsp4H0Slnj3tJjthnjqbbpel+MiFopM4OhqoV HcbA5B5yhR1bKzT66As2OkvgH8Sz0HZ++xoWfq8= X-Google-Smtp-Source: AMrXdXssy+RgYfuMsYTtzFaZRwjIeDVlclXGI0zsLCuNCeZ1+VcrzUNILOjspUOry9y6NUfQvrFStg== X-Received: by 2002:ac8:4b50:0:b0:3b6:8b52:1358 with SMTP id e16-20020ac84b50000000b003b68b521358mr38454593qts.9.1674766872265; Thu, 26 Jan 2023 13:01:12 -0800 (PST) Received: from localhost (cpe-174-109-170-245.nc.res.rr.com. [174.109.170.245]) by smtp.gmail.com with ESMTPSA id s39-20020a05622a1aa700b003a7e38055c9sm1405423qtc.63.2023.01.26.13.01.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Jan 2023 13:01:11 -0800 (PST) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH v3 7/7] btrfs: remove btrfs_wait_tree_block_writeback Date: Thu, 26 Jan 2023 16:01:00 -0500 Message-Id: <5b5da95a6da7abda53004950ab0e293d99fd3a07.1674766637.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org This is used in the tree-log code and is a holdover from previous iterations of extent buffer writeback. We can simply use wait_on_extent_buffer_writeback here, and remove btrfs_wait_tree_block_writeback completely. Signed-off-by: Josef Bacik --- fs/btrfs/tree-log.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index 050ae214fb4f..11141a981533 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -278,12 +278,6 @@ void btrfs_end_log_trans(struct btrfs_root *root) } } -static void btrfs_wait_tree_block_writeback(struct extent_buffer *buf) -{ - filemap_fdatawait_range(buf->pages[0]->mapping, - buf->start, buf->start + buf->len - 1); -} - /* * the walk control struct is used to pass state down the chain when * processing the log tree. The stage field tells us which part @@ -2637,7 +2631,7 @@ static noinline int walk_down_log_tree(struct btrfs_trans_handle *trans, btrfs_tree_lock(next); btrfs_clear_buffer_dirty(trans, next); - btrfs_wait_tree_block_writeback(next); + wait_on_extent_buffer_writeback(next); btrfs_tree_unlock(next); if (trans) { @@ -2706,7 +2700,7 @@ static noinline int walk_up_log_tree(struct btrfs_trans_handle *trans, btrfs_tree_lock(next); btrfs_clear_buffer_dirty(trans, next); - btrfs_wait_tree_block_writeback(next); + wait_on_extent_buffer_writeback(next); btrfs_tree_unlock(next); if (trans) { @@ -2787,7 +2781,7 @@ static int walk_log_tree(struct btrfs_trans_handle *trans, btrfs_tree_lock(next); btrfs_clear_buffer_dirty(trans, next); - btrfs_wait_tree_block_writeback(next); + wait_on_extent_buffer_writeback(next); btrfs_tree_unlock(next); if (trans) {