X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;ds=sidebyside;f=fs%2Fbtrfs%2Ffile.c;h=ade03e6f7bd2706bbaac3406f1bcc31cf70cb578;hb=9d2da7af909e1cf529f3cac582aaae05b107aa1e;hp=5b4ea5f55b8f47d0bf9a90992dd9da2d33880e14;hpb=9217cbb8df31c10efc96362227b2ebdbb9fe996c;p=~andy%2Flinux diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 5b4ea5f55b8..ade03e6f7bd 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -2142,6 +2142,7 @@ static long btrfs_fallocate(struct file *file, int mode, { struct inode *inode = file_inode(file); struct extent_state *cached_state = NULL; + struct btrfs_root *root = BTRFS_I(inode)->root; u64 cur_offset; u64 last_byte; u64 alloc_start; @@ -2169,6 +2170,11 @@ static long btrfs_fallocate(struct file *file, int mode, ret = btrfs_check_data_free_space(inode, alloc_end - alloc_start); if (ret) return ret; + if (root->fs_info->quota_enabled) { + ret = btrfs_qgroup_reserve(root, alloc_end - alloc_start); + if (ret) + goto out_reserve_fail; + } /* * wait for ordered IO before we have any locks. We'll loop again @@ -2272,6 +2278,9 @@ static long btrfs_fallocate(struct file *file, int mode, &cached_state, GFP_NOFS); out: mutex_unlock(&inode->i_mutex); + if (root->fs_info->quota_enabled) + btrfs_qgroup_free(root, alloc_end - alloc_start); +out_reserve_fail: /* Let go of our reservation. */ btrfs_free_reserved_data_space(inode, alloc_end - alloc_start); return ret;