diff options
-rw-r--r-- | fs/btrfs/inode.c | 5 | ||||
-rw-r--r-- | fs/btrfs/ordered-data.c | 7 | ||||
-rw-r--r-- | fs/btrfs/ordered-data.h | 3 |
3 files changed, 10 insertions, 5 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 50ce8840a99..1824dda1d35 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -1698,11 +1698,10 @@ static int btrfs_finish_ordered_io(struct inode *inode, u64 start, u64 end) | |||
1698 | int compressed = 0; | 1698 | int compressed = 0; |
1699 | int ret; | 1699 | int ret; |
1700 | 1700 | ||
1701 | ret = btrfs_dec_test_ordered_pending(inode, start, end - start + 1); | 1701 | ret = btrfs_dec_test_ordered_pending(inode, &ordered_extent, start, |
1702 | end - start + 1); | ||
1702 | if (!ret) | 1703 | if (!ret) |
1703 | return 0; | 1704 | return 0; |
1704 | |||
1705 | ordered_extent = btrfs_lookup_ordered_extent(inode, start); | ||
1706 | BUG_ON(!ordered_extent); | 1705 | BUG_ON(!ordered_extent); |
1707 | 1706 | ||
1708 | if (test_bit(BTRFS_ORDERED_NOCOW, &ordered_extent->flags)) { | 1707 | if (test_bit(BTRFS_ORDERED_NOCOW, &ordered_extent->flags)) { |
diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c index d56f732ba95..a8ffecd0b49 100644 --- a/fs/btrfs/ordered-data.c +++ b/fs/btrfs/ordered-data.c | |||
@@ -232,11 +232,12 @@ int btrfs_add_ordered_sum(struct inode *inode, | |||
232 | * to make sure this function only returns 1 once for a given ordered extent. | 232 | * to make sure this function only returns 1 once for a given ordered extent. |
233 | */ | 233 | */ |
234 | int btrfs_dec_test_ordered_pending(struct inode *inode, | 234 | int btrfs_dec_test_ordered_pending(struct inode *inode, |
235 | struct btrfs_ordered_extent **cached, | ||
235 | u64 file_offset, u64 io_size) | 236 | u64 file_offset, u64 io_size) |
236 | { | 237 | { |
237 | struct btrfs_ordered_inode_tree *tree; | 238 | struct btrfs_ordered_inode_tree *tree; |
238 | struct rb_node *node; | 239 | struct rb_node *node; |
239 | struct btrfs_ordered_extent *entry; | 240 | struct btrfs_ordered_extent *entry = NULL; |
240 | int ret; | 241 | int ret; |
241 | 242 | ||
242 | tree = &BTRFS_I(inode)->ordered_tree; | 243 | tree = &BTRFS_I(inode)->ordered_tree; |
@@ -264,6 +265,10 @@ int btrfs_dec_test_ordered_pending(struct inode *inode, | |||
264 | else | 265 | else |
265 | ret = 1; | 266 | ret = 1; |
266 | out: | 267 | out: |
268 | if (!ret && cached && entry) { | ||
269 | *cached = entry; | ||
270 | atomic_inc(&entry->refs); | ||
271 | } | ||
267 | spin_unlock(&tree->lock); | 272 | spin_unlock(&tree->lock); |
268 | return ret == 0; | 273 | return ret == 0; |
269 | } | 274 | } |
diff --git a/fs/btrfs/ordered-data.h b/fs/btrfs/ordered-data.h index bfbcebbb0ad..c82f76a9f04 100644 --- a/fs/btrfs/ordered-data.h +++ b/fs/btrfs/ordered-data.h | |||
@@ -137,7 +137,8 @@ int btrfs_put_ordered_extent(struct btrfs_ordered_extent *entry); | |||
137 | int btrfs_remove_ordered_extent(struct inode *inode, | 137 | int btrfs_remove_ordered_extent(struct inode *inode, |
138 | struct btrfs_ordered_extent *entry); | 138 | struct btrfs_ordered_extent *entry); |
139 | int btrfs_dec_test_ordered_pending(struct inode *inode, | 139 | int btrfs_dec_test_ordered_pending(struct inode *inode, |
140 | u64 file_offset, u64 io_size); | 140 | struct btrfs_ordered_extent **cached, |
141 | u64 file_offset, u64 io_size); | ||
141 | int btrfs_add_ordered_extent(struct inode *inode, u64 file_offset, | 142 | int btrfs_add_ordered_extent(struct inode *inode, u64 file_offset, |
142 | u64 start, u64 len, u64 disk_len, int tyep); | 143 | u64 start, u64 len, u64 disk_len, int tyep); |
143 | int btrfs_add_ordered_sum(struct inode *inode, | 144 | int btrfs_add_ordered_sum(struct inode *inode, |