]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.4.13/xfs-don-t-wrap-growfs-agfl-indexes.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.4.13 / xfs-don-t-wrap-growfs-agfl-indexes.patch
1 From ad747e3b299671e1a53db74963cc6c5f6cdb9f6d Mon Sep 17 00:00:00 2001
2 From: Dave Chinner <dchinner@redhat.com>
3 Date: Wed, 6 Apr 2016 07:06:20 +1000
4 Subject: xfs: Don't wrap growfs AGFL indexes
5
6 From: Dave Chinner <dchinner@redhat.com>
7
8 commit ad747e3b299671e1a53db74963cc6c5f6cdb9f6d upstream.
9
10 Commit 96f859d ("libxfs: pack the agfl header structure so
11 XFS_AGFL_SIZE is correct") allowed the freelist to use the empty
12 slot at the end of the freelist on 64 bit systems that was not
13 being used due to sizeof() rounding up the structure size.
14
15 This has caused versions of xfs_repair prior to 4.5.0 (which also
16 has the fix) to report this as a corruption once the filesystem has
17 been grown. Older kernels can also have problems (seen from a whacky
18 container/vm management environment) mounting filesystems grown on a
19 system with a newer kernel than the vm/container it is deployed on.
20
21 To avoid this problem, change the initial free list indexes not to
22 wrap across the end of the AGFL, hence avoiding the initialisation
23 of agf_fllast to the last index in the AGFL.
24
25 Signed-off-by: Dave Chinner <dchinner@redhat.com>
26 Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
27 Signed-off-by: Dave Chinner <david@fromorbit.com>
28 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
29
30 ---
31 fs/xfs/xfs_fsops.c | 4 ++--
32 1 file changed, 2 insertions(+), 2 deletions(-)
33
34 --- a/fs/xfs/xfs_fsops.c
35 +++ b/fs/xfs/xfs_fsops.c
36 @@ -243,8 +243,8 @@ xfs_growfs_data_private(
37 agf->agf_roots[XFS_BTNUM_CNTi] = cpu_to_be32(XFS_CNT_BLOCK(mp));
38 agf->agf_levels[XFS_BTNUM_BNOi] = cpu_to_be32(1);
39 agf->agf_levels[XFS_BTNUM_CNTi] = cpu_to_be32(1);
40 - agf->agf_flfirst = 0;
41 - agf->agf_fllast = cpu_to_be32(XFS_AGFL_SIZE(mp) - 1);
42 + agf->agf_flfirst = cpu_to_be32(1);
43 + agf->agf_fllast = 0;
44 agf->agf_flcount = 0;
45 tmpsize = agsize - XFS_PREALLOC_BLOCKS(mp);
46 agf->agf_freeblks = cpu_to_be32(tmpsize);