From: Qu Wenruo <quwenruo@cn.fujitsu.com>
To: <linux-btrfs@vger.kernel.org>
Cc: <dsterba@suse.cz>, <miaoxie@huawei.com>
Subject: [PATCH RFC v3 4/5] btrfs: Use btrfs_test_trans_opt() to handle SPACE_CACHE if it's under transaction protect.
Date: Fri, 23 Jan 2015 17:31:44 +0800 [thread overview]
Message-ID: <1422005505-9472-5-git-send-email-quwenruo@cn.fujitsu.com> (raw)
In-Reply-To: <1422005505-9472-1-git-send-email-quwenruo@cn.fujitsu.com>
Convert btrfs_test_opt() to btrfs_test_trans_opt() if it's called under
transaction protection.
This will ensure SPACE_CACHE bit is consistent during transaction.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
---
fs/btrfs/extent-tree.c | 2 +-
fs/btrfs/transaction.c | 7 ++++---
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 1511658..c968d12 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -3260,7 +3260,7 @@ again:
spin_lock(&block_group->lock);
if (block_group->cached != BTRFS_CACHE_FINISHED ||
- !btrfs_test_opt(root, SPACE_CACHE) ||
+ !btrfs_test_trans_opt(trans, SPACE_CACHE) ||
block_group->delalloc_bytes) {
/*
* don't bother trying to write stuff out _if_
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 846e1b8..aec5a5a 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -1507,7 +1507,8 @@ static noinline int create_pending_snapshots(struct btrfs_trans_handle *trans,
return ret;
}
-static void update_super_roots(struct btrfs_root *root)
+static void update_super_roots(struct btrfs_trans_handle *trans,
+ struct btrfs_root *root)
{
struct btrfs_root_item *root_item;
struct btrfs_super_block *super;
@@ -1523,7 +1524,7 @@ static void update_super_roots(struct btrfs_root *root)
super->root = root_item->bytenr;
super->generation = root_item->generation;
super->root_level = root_item->level;
- if (btrfs_test_opt(root, SPACE_CACHE))
+ if (btrfs_test_trans_opt(trans, SPACE_CACHE))
super->cache_generation = root_item->generation;
if (root->fs_info->update_uuid_tree_gen)
super->uuid_tree_generation = root_item->generation;
@@ -1987,7 +1988,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
switch_commit_roots(cur_trans, root->fs_info);
assert_qgroups_uptodate(trans);
- update_super_roots(root);
+ update_super_roots(trans, root);
btrfs_set_super_log_root(root->fs_info->super_copy, 0);
btrfs_set_super_log_root_level(root->fs_info->super_copy, 0);
--
2.2.2
next prev parent reply other threads:[~2015-01-23 9:33 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-23 9:31 [PATCH RFC v3 0/5] mount options consistent enhancement Qu Wenruo
2015-01-23 9:31 ` [PATCH RFC v3 1/5] Revert "btrfs: add support for processing pending changes" related commits Qu Wenruo
2015-01-23 14:57 ` David Sterba
2015-01-26 0:37 ` Qu Wenruo
2015-01-26 6:05 ` Qu Wenruo
2015-01-28 13:25 ` David Sterba
2015-01-29 1:15 ` Qu Wenruo
2015-01-30 17:30 ` David Sterba
2015-01-23 9:31 ` [PATCH RFC v3 2/5] btrfs: Make btrfs_parse_options() parse mount option in a atomic way Qu Wenruo
2015-01-23 9:31 ` [PATCH RFC v3 3/5] btrfs: Introduce per-transaction mount_opt to keep mount option consistent during transaction Qu Wenruo
2015-01-23 9:31 ` Qu Wenruo [this message]
2015-01-23 9:31 ` [PATCH RFC v3 5/5] btrfs: Use btrfs_test_trans_opt() to handle INODE_CACHE if it's under transaction protect Qu Wenruo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1422005505-9472-5-git-send-email-quwenruo@cn.fujitsu.com \
--to=quwenruo@cn.fujitsu.com \
--cc=dsterba@suse.cz \
--cc=linux-btrfs@vger.kernel.org \
--cc=miaoxie@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).