diff options
Diffstat (limited to 'fs/xfs/xfs_dfrag.c')
-rw-r--r-- | fs/xfs/xfs_dfrag.c | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/fs/xfs/xfs_dfrag.c b/fs/xfs/xfs_dfrag.c index 654dc6f05bac..dd974a55c77d 100644 --- a/fs/xfs/xfs_dfrag.c +++ b/fs/xfs/xfs_dfrag.c | |||
@@ -163,12 +163,14 @@ xfs_swap_extents_check_format( | |||
163 | 163 | ||
164 | /* Check temp in extent form to max in target */ | 164 | /* Check temp in extent form to max in target */ |
165 | if (tip->i_d.di_format == XFS_DINODE_FMT_EXTENTS && | 165 | if (tip->i_d.di_format == XFS_DINODE_FMT_EXTENTS && |
166 | XFS_IFORK_NEXTENTS(tip, XFS_DATA_FORK) > ip->i_df.if_ext_max) | 166 | XFS_IFORK_NEXTENTS(tip, XFS_DATA_FORK) > |
167 | XFS_IFORK_MAXEXT(ip, XFS_DATA_FORK)) | ||
167 | return EINVAL; | 168 | return EINVAL; |
168 | 169 | ||
169 | /* Check target in extent form to max in temp */ | 170 | /* Check target in extent form to max in temp */ |
170 | if (ip->i_d.di_format == XFS_DINODE_FMT_EXTENTS && | 171 | if (ip->i_d.di_format == XFS_DINODE_FMT_EXTENTS && |
171 | XFS_IFORK_NEXTENTS(ip, XFS_DATA_FORK) > tip->i_df.if_ext_max) | 172 | XFS_IFORK_NEXTENTS(ip, XFS_DATA_FORK) > |
173 | XFS_IFORK_MAXEXT(tip, XFS_DATA_FORK)) | ||
172 | return EINVAL; | 174 | return EINVAL; |
173 | 175 | ||
174 | /* | 176 | /* |
@@ -180,18 +182,25 @@ xfs_swap_extents_check_format( | |||
180 | * (a common defrag case) which will occur when the temp inode is in | 182 | * (a common defrag case) which will occur when the temp inode is in |
181 | * extent format... | 183 | * extent format... |
182 | */ | 184 | */ |
183 | if (tip->i_d.di_format == XFS_DINODE_FMT_BTREE && | 185 | if (tip->i_d.di_format == XFS_DINODE_FMT_BTREE) { |
184 | ((XFS_IFORK_BOFF(ip) && | 186 | if (XFS_IFORK_BOFF(ip) && |
185 | tip->i_df.if_broot_bytes > XFS_IFORK_BOFF(ip)) || | 187 | tip->i_df.if_broot_bytes > XFS_IFORK_BOFF(ip)) |
186 | XFS_IFORK_NEXTENTS(tip, XFS_DATA_FORK) <= ip->i_df.if_ext_max)) | 188 | return EINVAL; |
187 | return EINVAL; | 189 | if (XFS_IFORK_NEXTENTS(tip, XFS_DATA_FORK) <= |
190 | XFS_IFORK_MAXEXT(ip, XFS_DATA_FORK)) | ||
191 | return EINVAL; | ||
192 | } | ||
188 | 193 | ||
189 | /* Reciprocal target->temp btree format checks */ | 194 | /* Reciprocal target->temp btree format checks */ |
190 | if (ip->i_d.di_format == XFS_DINODE_FMT_BTREE && | 195 | if (ip->i_d.di_format == XFS_DINODE_FMT_BTREE) { |
191 | ((XFS_IFORK_BOFF(tip) && | 196 | if (XFS_IFORK_BOFF(tip) && |
192 | ip->i_df.if_broot_bytes > XFS_IFORK_BOFF(tip)) || | 197 | ip->i_df.if_broot_bytes > XFS_IFORK_BOFF(tip)) |
193 | XFS_IFORK_NEXTENTS(ip, XFS_DATA_FORK) <= tip->i_df.if_ext_max)) | 198 | return EINVAL; |
194 | return EINVAL; | 199 | |
200 | if (XFS_IFORK_NEXTENTS(ip, XFS_DATA_FORK) <= | ||
201 | XFS_IFORK_MAXEXT(tip, XFS_DATA_FORK)) | ||
202 | return EINVAL; | ||
203 | } | ||
195 | 204 | ||
196 | return 0; | 205 | return 0; |
197 | } | 206 | } |
@@ -349,16 +358,6 @@ xfs_swap_extents( | |||
349 | *tifp = *tempifp; /* struct copy */ | 358 | *tifp = *tempifp; /* struct copy */ |
350 | 359 | ||
351 | /* | 360 | /* |
352 | * Fix the in-memory data fork values that are dependent on the fork | ||
353 | * offset in the inode. We can't assume they remain the same as attr2 | ||
354 | * has dynamic fork offsets. | ||
355 | */ | ||
356 | ifp->if_ext_max = XFS_IFORK_SIZE(ip, XFS_DATA_FORK) / | ||
357 | (uint)sizeof(xfs_bmbt_rec_t); | ||
358 | tifp->if_ext_max = XFS_IFORK_SIZE(tip, XFS_DATA_FORK) / | ||
359 | (uint)sizeof(xfs_bmbt_rec_t); | ||
360 | |||
361 | /* | ||
362 | * Fix the on-disk inode values | 361 | * Fix the on-disk inode values |
363 | */ | 362 | */ |
364 | tmp = (__uint64_t)ip->i_d.di_nblocks; | 363 | tmp = (__uint64_t)ip->i_d.di_nblocks; |