Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

xfs: only set extent size hint when asked

Currently the extent size hint is set unconditionally in
xfs_ioctl_setattr() when the FSX_EXTSIZE flag is set. Hence we can
set hints when the inode flags indicating the hint should be used
are not set. Hence only set the extent size hint from userspace
when the inode has the XFS_DIFLAG_EXTSIZE flag set to indicate that
we should have an extent size hint set on the inode.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>

authored by

Dave Chinner and committed by
Dave Chinner
a872703f 9336e3a7

+14 -2
+14 -2
fs/xfs/xfs_ioctl.c
··· 1231 1231 1232 1232 } 1233 1233 1234 - if (mask & FSX_EXTSIZE) 1235 - ip->i_d.di_extsize = fa->fsx_extsize >> mp->m_sb.sb_blocklog; 1236 1234 if (mask & FSX_XFLAGS) { 1237 1235 xfs_set_diflags(ip, fa->fsx_xflags); 1238 1236 xfs_diflags_to_linux(ip); 1237 + } 1238 + 1239 + /* 1240 + * Only set the extent size hint if we've already determined that the 1241 + * extent size hint should be set on the inode. If no extent size flags 1242 + * are set on the inode then unconditionally clear the extent size hint. 1243 + */ 1244 + if (mask & FSX_EXTSIZE) { 1245 + int extsize = 0; 1246 + 1247 + if (ip->i_d.di_flags & 1248 + (XFS_DIFLAG_EXTSIZE | XFS_DIFLAG_EXTSZINHERIT)) 1249 + extsize = fa->fsx_extsize >> mp->m_sb.sb_blocklog; 1250 + ip->i_d.di_extsize = extsize; 1239 1251 } 1240 1252 1241 1253 xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG);