# This is a BitKeeper generated diff -Nru style patch. # # ChangeSet # 2004/04/22 09:46:43+10:00 nathans@sgi.com # [XFS] Fix vmtruncate abuse in the XFS setattr ATTR_SIZE operation. # # SGI Modid: xfs-linux:xfs-kern:170344a # # fs/xfs/linux/xfs_linux.h # 2004/04/22 09:46:37+10:00 nathans@sgi.com +3 -6 # [XFS] Fix vmtruncate abuse in the XFS setattr ATTR_SIZE operation. # # fs/xfs/xfs_vnodeops.c # 2004/04/22 09:46:37+10:00 nathans@sgi.com +5 -11 # [XFS] Fix vmtruncate abuse in the XFS setattr ATTR_SIZE operation. # diff -Nru a/fs/xfs/linux/xfs_linux.h b/fs/xfs/linux/xfs_linux.h --- a/fs/xfs/linux/xfs_linux.h Fri Apr 23 01:44:59 2004 +++ b/fs/xfs/linux/xfs_linux.h Fri Apr 23 01:44:59 2004 @@ -262,13 +262,10 @@ #define XFS_DEV_TO_KDEVT(dev) mk_kdev(XFS_DEV_MAJOR(dev),XFS_DEV_MINOR(dev)) +#define xfs_stack_trace() dump_stack() -/* Produce a kernel stack trace */ - -static inline void xfs_stack_trace(void) -{ - dump_stack(); -} +#define xfs_itruncate_data(ip, off) \ + (-vmtruncate(LINVFS_GET_IP(XFS_ITOV(ip)), (off))) /* Move the kernel do_div definition off to one side */ diff -Nru a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c --- a/fs/xfs/xfs_vnodeops.c Fri Apr 23 01:44:59 2004 +++ b/fs/xfs/xfs_vnodeops.c Fri Apr 23 01:44:59 2004 @@ -680,18 +680,12 @@ * once it is a part of the transaction. */ if (mask & XFS_AT_SIZE) { - if (vap->va_size > ip->i_d.di_size) { + code = 0; + if (vap->va_size > ip->i_d.di_size) code = xfs_igrow_start(ip, vap->va_size, credp); - xfs_iunlock(ip, XFS_ILOCK_EXCL); - } else if (vap->va_size <= ip->i_d.di_size) { - xfs_iunlock(ip, XFS_ILOCK_EXCL); - xfs_itruncate_start(ip, XFS_ITRUNC_DEFINITE, - (xfs_fsize_t)vap->va_size); - code = 0; - } else { - xfs_iunlock(ip, XFS_ILOCK_EXCL); - code = 0; - } + xfs_iunlock(ip, XFS_ILOCK_EXCL); + if (!code) + code = xfs_itruncate_data(ip, vap->va_size); if (code) { ASSERT(tp == NULL); lock_flags &= ~XFS_ILOCK_EXCL;