struct inode *inode;
struct extent_map_tree *em_tree;
struct extent_map *em;
+ struct address_space *mapping;
u64 offset;
+ /* the generic O_DIRECT read code does this */
if (!page) {
__unplug_io_fn(bdi, page);
return;
}
- inode = page->mapping->host;
+ /*
+ * page->mapping may change at any time. Get a consistent copy
+ * and use that for everything below
+ */
+ smp_mb();
+ mapping = page->mapping;
+ if (!mapping)
+ return;
+
+ inode = mapping->host;
offset = page_offset(page);
em_tree = &BTRFS_I(inode)->extent_tree;
u64 total = btrfs_super_total_bytes(&root->fs_info->super_copy);
u64 used = btrfs_super_bytes_used(&root->fs_info->super_copy);
u64 thresh;
+ unsigned long flags;
int ret = 0;
if (for_del)
do_div(thresh, 100);
- spin_lock(&root->fs_info->delalloc_lock);
+ spin_lock_irqsave(&root->fs_info->delalloc_lock, flags);
if (used + root->fs_info->delalloc_bytes + num_required > thresh)
ret = -ENOSPC;
- spin_unlock(&root->fs_info->delalloc_lock);
+ spin_unlock_irqrestore(&root->fs_info->delalloc_lock, flags);
return ret;
}
int btrfs_set_bit_hook(struct inode *inode, u64 start, u64 end,
unsigned long old, unsigned long bits)
{
+ unsigned long flags;
if (!(old & EXTENT_DELALLOC) && (bits & EXTENT_DELALLOC)) {
struct btrfs_root *root = BTRFS_I(inode)->root;
- spin_lock(&root->fs_info->delalloc_lock);
+ spin_lock_irqsave(&root->fs_info->delalloc_lock, flags);
BTRFS_I(inode)->delalloc_bytes += end - start + 1;
root->fs_info->delalloc_bytes += end - start + 1;
- spin_unlock(&root->fs_info->delalloc_lock);
+ spin_unlock_irqrestore(&root->fs_info->delalloc_lock, flags);
}
return 0;
}
{
if ((old & EXTENT_DELALLOC) && (bits & EXTENT_DELALLOC)) {
struct btrfs_root *root = BTRFS_I(inode)->root;
- spin_lock(&root->fs_info->delalloc_lock);
+ unsigned long flags;
+
+ spin_lock_irqsave(&root->fs_info->delalloc_lock, flags);
if (end - start + 1 > root->fs_info->delalloc_bytes) {
printk("warning: delalloc account %Lu %Lu\n",
end - start + 1, root->fs_info->delalloc_bytes);
root->fs_info->delalloc_bytes -= end - start + 1;
BTRFS_I(inode)->delalloc_bytes -= end - start + 1;
}
- spin_unlock(&root->fs_info->delalloc_lock);
+ spin_unlock_irqrestore(&root->fs_info->delalloc_lock, flags);
}
return 0;
}