Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 307704
b: refs/heads/master
c: 467f789
h: refs/heads/master
v: v3
  • Loading branch information
Christoph Hellwig authored and Ben Myers committed May 14, 2012
1 parent e9c404d commit e49556a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b4d05e3019692fc5a8c573fbce60de2d48c5b7a1
refs/heads/master: 467f78992a0743e0e71729e4faa20b67b0f25289
23 changes: 9 additions & 14 deletions trunk/fs/xfs/xfs_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -593,35 +593,31 @@ xfs_file_aio_write_checks(
struct xfs_inode *ip = XFS_I(inode);
int error = 0;

xfs_rw_ilock(ip, XFS_ILOCK_EXCL);
restart:
error = generic_write_checks(file, pos, count, S_ISBLK(inode->i_mode));
if (error) {
xfs_rw_iunlock(ip, XFS_ILOCK_EXCL);
if (error)
return error;
}

/*
* If the offset is beyond the size of the file, we need to zero any
* blocks that fall between the existing EOF and the start of this
* write. If zeroing is needed and we are currently holding the
* iolock shared, we need to update it to exclusive which involves
* dropping all locks and relocking to maintain correct locking order.
* If we do this, restart the function to ensure all checks and values
* are still valid.
* iolock shared, we need to update it to exclusive which implies
* having to redo all checks before.
*/
if (*pos > i_size_read(inode)) {
if (*iolock == XFS_IOLOCK_SHARED) {
xfs_rw_iunlock(ip, XFS_ILOCK_EXCL | *iolock);
xfs_rw_iunlock(ip, *iolock);
*iolock = XFS_IOLOCK_EXCL;
xfs_rw_ilock(ip, XFS_ILOCK_EXCL | *iolock);
xfs_rw_ilock(ip, *iolock);
goto restart;
}
xfs_rw_ilock(ip, XFS_ILOCK_EXCL);
error = -xfs_zero_eof(ip, *pos, i_size_read(inode));
xfs_rw_iunlock(ip, XFS_ILOCK_EXCL);
if (error)
return error;
}
xfs_rw_iunlock(ip, XFS_ILOCK_EXCL);
if (error)
return error;

/*
* Updating the timestamps will grab the ilock again from
Expand All @@ -638,7 +634,6 @@ xfs_file_aio_write_checks(
* people from modifying setuid and setgid binaries.
*/
return file_remove_suid(file);

}

/*
Expand Down

0 comments on commit e49556a

Please sign in to comment.