diff options
author | Peter Watkins <treestem@gmail.com> | 2014-12-03 17:30:51 -0500 |
---|---|---|
committer | Dave Chinner <david@fromorbit.com> | 2014-12-03 17:30:51 -0500 |
commit | 76b57302526ae289e8094a51d6a71031ff3d058b (patch) | |
tree | 2d265a83e3645a8c1fd5d1b41ce42e750b919c88 /fs/xfs/xfs_iomap.c | |
parent | e77b8547ca9c4b87932e9da3db906bc016885d8d (diff) |
xfs: overflow in xfs_iomap_eof_align_last_fsb
If extsize is set and new_last_fsb is larger than 32 bits, the
roundup to extsize will overflow the align variable. Instead,
combine alignments by rounding stripe size up to extsize.
Signed-off-by: Peter Watkins <treestem@gmail.com>
Reviewed-by: Nathaniel W. Turner <nate@houseofnate.net>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Diffstat (limited to 'fs/xfs/xfs_iomap.c')
-rw-r--r-- | fs/xfs/xfs_iomap.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index afcf3c926565..3fad07136c5d 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c | |||
@@ -52,7 +52,6 @@ xfs_iomap_eof_align_last_fsb( | |||
52 | xfs_extlen_t extsize, | 52 | xfs_extlen_t extsize, |
53 | xfs_fileoff_t *last_fsb) | 53 | xfs_fileoff_t *last_fsb) |
54 | { | 54 | { |
55 | xfs_fileoff_t new_last_fsb = 0; | ||
56 | xfs_extlen_t align = 0; | 55 | xfs_extlen_t align = 0; |
57 | int eof, error; | 56 | int eof, error; |
58 | 57 | ||
@@ -70,8 +69,8 @@ xfs_iomap_eof_align_last_fsb( | |||
70 | else if (mp->m_dalign) | 69 | else if (mp->m_dalign) |
71 | align = mp->m_dalign; | 70 | align = mp->m_dalign; |
72 | 71 | ||
73 | if (align && XFS_ISIZE(ip) >= XFS_FSB_TO_B(mp, align)) | 72 | if (align && XFS_ISIZE(ip) < XFS_FSB_TO_B(mp, align)) |
74 | new_last_fsb = roundup_64(*last_fsb, align); | 73 | align = 0; |
75 | } | 74 | } |
76 | 75 | ||
77 | /* | 76 | /* |
@@ -79,14 +78,14 @@ xfs_iomap_eof_align_last_fsb( | |||
79 | * (when file on a real-time subvolume or has di_extsize hint). | 78 | * (when file on a real-time subvolume or has di_extsize hint). |
80 | */ | 79 | */ |
81 | if (extsize) { | 80 | if (extsize) { |
82 | if (new_last_fsb) | 81 | if (align) |
83 | align = roundup_64(new_last_fsb, extsize); | 82 | align = roundup_64(align, extsize); |
84 | else | 83 | else |
85 | align = extsize; | 84 | align = extsize; |
86 | new_last_fsb = roundup_64(*last_fsb, align); | ||
87 | } | 85 | } |
88 | 86 | ||
89 | if (new_last_fsb) { | 87 | if (align) { |
88 | xfs_fileoff_t new_last_fsb = roundup_64(*last_fsb, align); | ||
90 | error = xfs_bmap_eof(ip, new_last_fsb, XFS_DATA_FORK, &eof); | 89 | error = xfs_bmap_eof(ip, new_last_fsb, XFS_DATA_FORK, &eof); |
91 | if (error) | 90 | if (error) |
92 | return error; | 91 | return error; |