Merge branch 'for-linus' of git://oss.sgi.com/xfs/xfs

* 'for-linus' of git://oss.sgi.com/xfs/xfs:
xfs: more swap extent fixes for dynamic fork offsets

+16 -6
+16 -6
fs/xfs/xfs_dfrag.c
··· 177 177 XFS_IFORK_NEXTENTS(ip, XFS_DATA_FORK) > tip->i_df.if_ext_max) 178 178 return EINVAL; 179 179 180 - /* Check root block of temp in btree form to max in target */ 180 + /* 181 + * If we are in a btree format, check that the temp root block will fit 182 + * in the target and that it has enough extents to be in btree format 183 + * in the target. 184 + * 185 + * Note that we have to be careful to allow btree->extent conversions 186 + * (a common defrag case) which will occur when the temp inode is in 187 + * extent format... 188 + */ 181 189 if (tip->i_d.di_format == XFS_DINODE_FMT_BTREE && 182 - XFS_IFORK_BOFF(ip) && 183 - tip->i_df.if_broot_bytes > XFS_IFORK_BOFF(ip)) 190 + ((XFS_IFORK_BOFF(ip) && 191 + tip->i_df.if_broot_bytes > XFS_IFORK_BOFF(ip)) || 192 + XFS_IFORK_NEXTENTS(tip, XFS_DATA_FORK) <= ip->i_df.if_ext_max)) 184 193 return EINVAL; 185 194 186 - /* Check root block of target in btree form to max in temp */ 195 + /* Reciprocal target->temp btree format checks */ 187 196 if (ip->i_d.di_format == XFS_DINODE_FMT_BTREE && 188 - XFS_IFORK_BOFF(tip) && 189 - ip->i_df.if_broot_bytes > XFS_IFORK_BOFF(tip)) 197 + ((XFS_IFORK_BOFF(tip) && 198 + ip->i_df.if_broot_bytes > XFS_IFORK_BOFF(tip)) || 199 + XFS_IFORK_NEXTENTS(ip, XFS_DATA_FORK) <= tip->i_df.if_ext_max)) 190 200 return EINVAL; 191 201 192 202 return 0;