Sync ext4 encryption as of commit dffd334e4d7134
[ext4-patch-queue.git] / dont-release-reserved-space-for-previously-allocated-cluster
blobf0f09b37453b6de79c6e46bd73c234524f8c3bf9
1 ext4: don't release reserved space for previously allocated cluster
3 From: Eric Whitney <enwlinux@gmail.com>
5 When xfstests' auto group is run on a bigalloc filesystem with a
6 4.0-rc3 kernel, e2fsck failures and kernel warnings occur for some
7 tests. e2fsck reports incorrect iblocks values, and the warnings
8 indicate that the space reserved for delayed allocation is being
9 overdrawn at allocation time.
11 Some of these errors occur because the reserved space is incorrectly
12 decreased by one cluster when ext4_ext_map_blocks satisfies an
13 allocation request by mapping an unused portion of a previously
14 allocated cluster.  Because a cluster's worth of reserved space was
15 already released when it was first allocated, it should not be released
16 again.
18 This patch appears to correct the e2fsck failure reported for
19 generic/232 and the kernel warnings produced by ext4/001, generic/009,
20 and generic/033.  Failures and warnings for some other tests remain to
21 be addressed.
23 Signed-off-by: Eric Whitney <enwlinux@gmail.com>
24 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
25 ---
26  fs/ext4/extents.c | 14 +-------------
27  1 file changed, 1 insertion(+), 13 deletions(-)
29 diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
30 index bed4308..554190e 100644
31 --- a/fs/ext4/extents.c
32 +++ b/fs/ext4/extents.c
33 @@ -4535,19 +4535,7 @@ got_allocated_blocks:
34                  */
35                 reserved_clusters = get_reserved_cluster_alloc(inode,
36                                                 map->m_lblk, allocated);
37 -               if (map_from_cluster) {
38 -                       if (reserved_clusters) {
39 -                               /*
40 -                                * We have clusters reserved for this range.
41 -                                * But since we are not doing actual allocation
42 -                                * and are simply using blocks from previously
43 -                                * allocated cluster, we should release the
44 -                                * reservation and not claim quota.
45 -                                */
46 -                               ext4_da_update_reserve_space(inode,
47 -                                               reserved_clusters, 0);
48 -                       }
49 -               } else {
50 +               if (!map_from_cluster) {
51                         BUG_ON(allocated_clusters < reserved_clusters);
52                         if (reserved_clusters < allocated_clusters) {
53                                 struct ext4_inode_info *ei = EXT4_I(inode);
54 -- 
55 2.1.0