From 20f42fa658f9ef2791114e2d50cbeec51fc08615 Mon Sep 17 00:00:00 2001 From: Dave Chinner Date: Fri, 21 May 2010 05:47:59 +0000 Subject: [PATCH] --- yaml --- r: 200177 b: refs/heads/master c: 07f1a4f5e89cd4e6c79d67d41e8a18c451214ae2 h: refs/heads/master i: 200175: 48cc87b4cdb18c574e012e9ad4caef1d2da51a0c v: v3 --- [refs] | 2 +- trunk/fs/xfs/linux-2.6/xfs_iops.c | 16 +++++++++++++--- trunk/fs/xfs/xfs_vnodeops.c | 2 +- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/[refs] b/[refs] index 32d0a6068c77..3ea4cf37aee7 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: fdc07f44c891d3fdee7722a03e3881614a293b3c +refs/heads/master: 07f1a4f5e89cd4e6c79d67d41e8a18c451214ae2 diff --git a/trunk/fs/xfs/linux-2.6/xfs_iops.c b/trunk/fs/xfs/linux-2.6/xfs_iops.c index 9c8019c78c92..44f0b2de153e 100644 --- a/trunk/fs/xfs/linux-2.6/xfs_iops.c +++ b/trunk/fs/xfs/linux-2.6/xfs_iops.c @@ -585,11 +585,20 @@ xfs_vn_fallocate( bf.l_len = len; xfs_ilock(ip, XFS_IOLOCK_EXCL); + + /* check the new inode size is valid before allocating */ + if (!(mode & FALLOC_FL_KEEP_SIZE) && + offset + len > i_size_read(inode)) { + new_size = offset + len; + error = inode_newsize_ok(inode, new_size); + if (error) + goto out_unlock; + } + error = -xfs_change_file_space(ip, XFS_IOC_RESVSP, &bf, 0, XFS_ATTR_NOLOCK); - if (!error && !(mode & FALLOC_FL_KEEP_SIZE) && - offset + len > i_size_read(inode)) - new_size = offset + len; + if (error) + goto out_unlock; /* Change file size if needed */ if (new_size) { @@ -600,6 +609,7 @@ xfs_vn_fallocate( error = -xfs_setattr(ip, &iattr, XFS_ATTR_NOLOCK); } +out_unlock: xfs_iunlock(ip, XFS_IOLOCK_EXCL); out_error: return error; diff --git a/trunk/fs/xfs/xfs_vnodeops.c b/trunk/fs/xfs/xfs_vnodeops.c index 9d376be0ea38..a06bd62504fc 100644 --- a/trunk/fs/xfs/xfs_vnodeops.c +++ b/trunk/fs/xfs/xfs_vnodeops.c @@ -267,7 +267,7 @@ xfs_setattr( if (code) { ASSERT(tp == NULL); lock_flags &= ~XFS_ILOCK_EXCL; - ASSERT(lock_flags == XFS_IOLOCK_EXCL); + ASSERT(lock_flags == XFS_IOLOCK_EXCL || !need_iolock); goto error_return; } tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_SIZE);