diff options
author | Josef Bacik <josef@redhat.com> | 2012-05-23 14:13:11 -0400 |
---|---|---|
committer | Josef Bacik <josef@redhat.com> | 2012-05-30 10:23:36 -0400 |
commit | 72ac3c0d7921f943d92d1ef42a549fb52e56817d (patch) | |
tree | c8825a2b3848f201a2b67b3a2ec0aaf9669f9ed3 /fs/btrfs/file.c | |
parent | cd023e7b17fe86c530475da210b3348421c40e5f (diff) |
Btrfs: convert the inode bit field to use the actual bit operations
Miao pointed this out while I was working on an orphan problem that messing
with a bitfield where different ranges are protected by different locks
doesn't work out right. Turns out we've been doing this forever where we
have different parts of the bit field protected by either no lock at all or
different locks which could cause all sorts of weird problems including the
issue I was hitting. So instead make a runtime_flags thing that we use the
normal bit operations on that are all atomic so we can keep having our
no/different locking for the different flags and then make force_compress
it's own thing so it can be treated normally. Thanks,
Signed-off-by: Josef Bacik <josef@redhat.com>
Diffstat (limited to 'fs/btrfs/file.c')
-rw-r--r-- | fs/btrfs/file.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index cfc0ab915d03..c9005f216975 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c | |||
@@ -103,7 +103,7 @@ static void __btrfs_add_inode_defrag(struct inode *inode, | |||
103 | goto exists; | 103 | goto exists; |
104 | } | 104 | } |
105 | } | 105 | } |
106 | BTRFS_I(inode)->in_defrag = 1; | 106 | set_bit(BTRFS_INODE_IN_DEFRAG, &BTRFS_I(inode)->runtime_flags); |
107 | rb_link_node(&defrag->rb_node, parent, p); | 107 | rb_link_node(&defrag->rb_node, parent, p); |
108 | rb_insert_color(&defrag->rb_node, &root->fs_info->defrag_inodes); | 108 | rb_insert_color(&defrag->rb_node, &root->fs_info->defrag_inodes); |
109 | return; | 109 | return; |
@@ -131,7 +131,7 @@ int btrfs_add_inode_defrag(struct btrfs_trans_handle *trans, | |||
131 | if (btrfs_fs_closing(root->fs_info)) | 131 | if (btrfs_fs_closing(root->fs_info)) |
132 | return 0; | 132 | return 0; |
133 | 133 | ||
134 | if (BTRFS_I(inode)->in_defrag) | 134 | if (test_bit(BTRFS_INODE_IN_DEFRAG, &BTRFS_I(inode)->runtime_flags)) |
135 | return 0; | 135 | return 0; |
136 | 136 | ||
137 | if (trans) | 137 | if (trans) |
@@ -148,7 +148,7 @@ int btrfs_add_inode_defrag(struct btrfs_trans_handle *trans, | |||
148 | defrag->root = root->root_key.objectid; | 148 | defrag->root = root->root_key.objectid; |
149 | 149 | ||
150 | spin_lock(&root->fs_info->defrag_inodes_lock); | 150 | spin_lock(&root->fs_info->defrag_inodes_lock); |
151 | if (!BTRFS_I(inode)->in_defrag) | 151 | if (!test_bit(BTRFS_INODE_IN_DEFRAG, &BTRFS_I(inode)->runtime_flags)) |
152 | __btrfs_add_inode_defrag(inode, defrag); | 152 | __btrfs_add_inode_defrag(inode, defrag); |
153 | else | 153 | else |
154 | kfree(defrag); | 154 | kfree(defrag); |
@@ -252,7 +252,7 @@ int btrfs_run_defrag_inodes(struct btrfs_fs_info *fs_info) | |||
252 | goto next; | 252 | goto next; |
253 | 253 | ||
254 | /* do a chunk of defrag */ | 254 | /* do a chunk of defrag */ |
255 | BTRFS_I(inode)->in_defrag = 0; | 255 | clear_bit(BTRFS_INODE_IN_DEFRAG, &BTRFS_I(inode)->runtime_flags); |
256 | range.start = defrag->last_offset; | 256 | range.start = defrag->last_offset; |
257 | num_defrag = btrfs_defrag_file(inode, NULL, &range, defrag->transid, | 257 | num_defrag = btrfs_defrag_file(inode, NULL, &range, defrag->transid, |
258 | defrag_batch); | 258 | defrag_batch); |
@@ -1465,8 +1465,8 @@ int btrfs_release_file(struct inode *inode, struct file *filp) | |||
1465 | * flush down new bytes that may have been written if the | 1465 | * flush down new bytes that may have been written if the |
1466 | * application were using truncate to replace a file in place. | 1466 | * application were using truncate to replace a file in place. |
1467 | */ | 1467 | */ |
1468 | if (BTRFS_I(inode)->ordered_data_close) { | 1468 | if (test_and_clear_bit(BTRFS_INODE_ORDERED_DATA_CLOSE, |
1469 | BTRFS_I(inode)->ordered_data_close = 0; | 1469 | &BTRFS_I(inode)->runtime_flags)) { |
1470 | btrfs_add_ordered_operation(NULL, BTRFS_I(inode)->root, inode); | 1470 | btrfs_add_ordered_operation(NULL, BTRFS_I(inode)->root, inode); |
1471 | if (inode->i_size > BTRFS_ORDERED_OPERATIONS_FLUSH_LIMIT) | 1471 | if (inode->i_size > BTRFS_ORDERED_OPERATIONS_FLUSH_LIMIT) |
1472 | filemap_flush(inode->i_mapping); | 1472 | filemap_flush(inode->i_mapping); |