diff options
author | Chris Mason <chris.mason@oracle.com> | 2008-04-22 13:26:47 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2008-09-25 11:04:02 -0400 |
commit | bcbfce8abd5f8d3f84eab60a9df1ec147f81c34f (patch) | |
tree | fe3ce6b6acf66d7cb9278cc47e2d4985e8ca70cf /fs/btrfs/inode.c | |
parent | e1c4b7451e22f5b0a9fbccfa560ee7b80c35b8cd (diff) |
Btrfs: Fix the unplug_io_fn to grab a consistent copy of page->mapping
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r-- | fs/btrfs/inode.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index abfe86df02d2..d58b4d5a1fef 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -80,6 +80,7 @@ int btrfs_check_free_space(struct btrfs_root *root, u64 num_required, | |||
80 | u64 total = btrfs_super_total_bytes(&root->fs_info->super_copy); | 80 | u64 total = btrfs_super_total_bytes(&root->fs_info->super_copy); |
81 | u64 used = btrfs_super_bytes_used(&root->fs_info->super_copy); | 81 | u64 used = btrfs_super_bytes_used(&root->fs_info->super_copy); |
82 | u64 thresh; | 82 | u64 thresh; |
83 | unsigned long flags; | ||
83 | int ret = 0; | 84 | int ret = 0; |
84 | 85 | ||
85 | if (for_del) | 86 | if (for_del) |
@@ -89,10 +90,10 @@ int btrfs_check_free_space(struct btrfs_root *root, u64 num_required, | |||
89 | 90 | ||
90 | do_div(thresh, 100); | 91 | do_div(thresh, 100); |
91 | 92 | ||
92 | spin_lock(&root->fs_info->delalloc_lock); | 93 | spin_lock_irqsave(&root->fs_info->delalloc_lock, flags); |
93 | if (used + root->fs_info->delalloc_bytes + num_required > thresh) | 94 | if (used + root->fs_info->delalloc_bytes + num_required > thresh) |
94 | ret = -ENOSPC; | 95 | ret = -ENOSPC; |
95 | spin_unlock(&root->fs_info->delalloc_lock); | 96 | spin_unlock_irqrestore(&root->fs_info->delalloc_lock, flags); |
96 | return ret; | 97 | return ret; |
97 | } | 98 | } |
98 | 99 | ||
@@ -275,12 +276,13 @@ static int run_delalloc_range(struct inode *inode, u64 start, u64 end) | |||
275 | int btrfs_set_bit_hook(struct inode *inode, u64 start, u64 end, | 276 | int btrfs_set_bit_hook(struct inode *inode, u64 start, u64 end, |
276 | unsigned long old, unsigned long bits) | 277 | unsigned long old, unsigned long bits) |
277 | { | 278 | { |
279 | unsigned long flags; | ||
278 | if (!(old & EXTENT_DELALLOC) && (bits & EXTENT_DELALLOC)) { | 280 | if (!(old & EXTENT_DELALLOC) && (bits & EXTENT_DELALLOC)) { |
279 | struct btrfs_root *root = BTRFS_I(inode)->root; | 281 | struct btrfs_root *root = BTRFS_I(inode)->root; |
280 | spin_lock(&root->fs_info->delalloc_lock); | 282 | spin_lock_irqsave(&root->fs_info->delalloc_lock, flags); |
281 | BTRFS_I(inode)->delalloc_bytes += end - start + 1; | 283 | BTRFS_I(inode)->delalloc_bytes += end - start + 1; |
282 | root->fs_info->delalloc_bytes += end - start + 1; | 284 | root->fs_info->delalloc_bytes += end - start + 1; |
283 | spin_unlock(&root->fs_info->delalloc_lock); | 285 | spin_unlock_irqrestore(&root->fs_info->delalloc_lock, flags); |
284 | } | 286 | } |
285 | return 0; | 287 | return 0; |
286 | } | 288 | } |
@@ -290,7 +292,9 @@ int btrfs_clear_bit_hook(struct inode *inode, u64 start, u64 end, | |||
290 | { | 292 | { |
291 | if ((old & EXTENT_DELALLOC) && (bits & EXTENT_DELALLOC)) { | 293 | if ((old & EXTENT_DELALLOC) && (bits & EXTENT_DELALLOC)) { |
292 | struct btrfs_root *root = BTRFS_I(inode)->root; | 294 | struct btrfs_root *root = BTRFS_I(inode)->root; |
293 | spin_lock(&root->fs_info->delalloc_lock); | 295 | unsigned long flags; |
296 | |||
297 | spin_lock_irqsave(&root->fs_info->delalloc_lock, flags); | ||
294 | if (end - start + 1 > root->fs_info->delalloc_bytes) { | 298 | if (end - start + 1 > root->fs_info->delalloc_bytes) { |
295 | printk("warning: delalloc account %Lu %Lu\n", | 299 | printk("warning: delalloc account %Lu %Lu\n", |
296 | end - start + 1, root->fs_info->delalloc_bytes); | 300 | end - start + 1, root->fs_info->delalloc_bytes); |
@@ -300,7 +304,7 @@ int btrfs_clear_bit_hook(struct inode *inode, u64 start, u64 end, | |||
300 | root->fs_info->delalloc_bytes -= end - start + 1; | 304 | root->fs_info->delalloc_bytes -= end - start + 1; |
301 | BTRFS_I(inode)->delalloc_bytes -= end - start + 1; | 305 | BTRFS_I(inode)->delalloc_bytes -= end - start + 1; |
302 | } | 306 | } |
303 | spin_unlock(&root->fs_info->delalloc_lock); | 307 | spin_unlock_irqrestore(&root->fs_info->delalloc_lock, flags); |
304 | } | 308 | } |
305 | return 0; | 309 | return 0; |
306 | } | 310 | } |