diff options
Diffstat (limited to 'fs/xfs/xfs_vnodeops.c')
-rw-r--r-- | fs/xfs/xfs_vnodeops.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c index 70bc82f65311..6420ca8df5ec 100644 --- a/fs/xfs/xfs_vnodeops.c +++ b/fs/xfs/xfs_vnodeops.c | |||
@@ -1201,13 +1201,15 @@ xfs_fsync( | |||
1201 | } | 1201 | } |
1202 | 1202 | ||
1203 | /* | 1203 | /* |
1204 | * This is called by xfs_inactive to free any blocks beyond eof, | 1204 | * This is called by xfs_inactive to free any blocks beyond eof |
1205 | * when the link count isn't zero. | 1205 | * when the link count isn't zero and by xfs_dm_punch_hole() when |
1206 | * punching a hole to EOF. | ||
1206 | */ | 1207 | */ |
1207 | STATIC int | 1208 | int |
1208 | xfs_inactive_free_eofblocks( | 1209 | xfs_free_eofblocks( |
1209 | xfs_mount_t *mp, | 1210 | xfs_mount_t *mp, |
1210 | xfs_inode_t *ip) | 1211 | xfs_inode_t *ip, |
1212 | int flags) | ||
1211 | { | 1213 | { |
1212 | xfs_trans_t *tp; | 1214 | xfs_trans_t *tp; |
1213 | int error; | 1215 | int error; |
@@ -1216,6 +1218,7 @@ xfs_inactive_free_eofblocks( | |||
1216 | xfs_filblks_t map_len; | 1218 | xfs_filblks_t map_len; |
1217 | int nimaps; | 1219 | int nimaps; |
1218 | xfs_bmbt_irec_t imap; | 1220 | xfs_bmbt_irec_t imap; |
1221 | int use_iolock = (flags & XFS_FREE_EOF_LOCK); | ||
1219 | 1222 | ||
1220 | /* | 1223 | /* |
1221 | * Figure out if there are any blocks beyond the end | 1224 | * Figure out if there are any blocks beyond the end |
@@ -1256,11 +1259,13 @@ xfs_inactive_free_eofblocks( | |||
1256 | * cache and we can't | 1259 | * cache and we can't |
1257 | * do that within a transaction. | 1260 | * do that within a transaction. |
1258 | */ | 1261 | */ |
1259 | xfs_ilock(ip, XFS_IOLOCK_EXCL); | 1262 | if (use_iolock) |
1263 | xfs_ilock(ip, XFS_IOLOCK_EXCL); | ||
1260 | error = xfs_itruncate_start(ip, XFS_ITRUNC_DEFINITE, | 1264 | error = xfs_itruncate_start(ip, XFS_ITRUNC_DEFINITE, |
1261 | ip->i_size); | 1265 | ip->i_size); |
1262 | if (error) { | 1266 | if (error) { |
1263 | xfs_iunlock(ip, XFS_IOLOCK_EXCL); | 1267 | if (use_iolock) |
1268 | xfs_iunlock(ip, XFS_IOLOCK_EXCL); | ||
1264 | return error; | 1269 | return error; |
1265 | } | 1270 | } |
1266 | 1271 | ||
@@ -1297,7 +1302,8 @@ xfs_inactive_free_eofblocks( | |||
1297 | error = xfs_trans_commit(tp, | 1302 | error = xfs_trans_commit(tp, |
1298 | XFS_TRANS_RELEASE_LOG_RES); | 1303 | XFS_TRANS_RELEASE_LOG_RES); |
1299 | } | 1304 | } |
1300 | xfs_iunlock(ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL); | 1305 | xfs_iunlock(ip, (use_iolock ? (XFS_IOLOCK_EXCL|XFS_ILOCK_EXCL) |
1306 | : XFS_ILOCK_EXCL)); | ||
1301 | } | 1307 | } |
1302 | return error; | 1308 | return error; |
1303 | } | 1309 | } |
@@ -1573,7 +1579,8 @@ xfs_release( | |||
1573 | (ip->i_df.if_flags & XFS_IFEXTENTS)) && | 1579 | (ip->i_df.if_flags & XFS_IFEXTENTS)) && |
1574 | (!(ip->i_d.di_flags & | 1580 | (!(ip->i_d.di_flags & |
1575 | (XFS_DIFLAG_PREALLOC | XFS_DIFLAG_APPEND)))) { | 1581 | (XFS_DIFLAG_PREALLOC | XFS_DIFLAG_APPEND)))) { |
1576 | if ((error = xfs_inactive_free_eofblocks(mp, ip))) | 1582 | error = xfs_free_eofblocks(mp, ip, XFS_FREE_EOF_LOCK); |
1583 | if (error) | ||
1577 | return error; | 1584 | return error; |
1578 | /* Update linux inode block count after free above */ | 1585 | /* Update linux inode block count after free above */ |
1579 | vn_to_inode(vp)->i_blocks = XFS_FSB_TO_BB(mp, | 1586 | vn_to_inode(vp)->i_blocks = XFS_FSB_TO_BB(mp, |
@@ -1654,7 +1661,8 @@ xfs_inactive( | |||
1654 | (!(ip->i_d.di_flags & | 1661 | (!(ip->i_d.di_flags & |
1655 | (XFS_DIFLAG_PREALLOC | XFS_DIFLAG_APPEND)) || | 1662 | (XFS_DIFLAG_PREALLOC | XFS_DIFLAG_APPEND)) || |
1656 | (ip->i_delayed_blks != 0)))) { | 1663 | (ip->i_delayed_blks != 0)))) { |
1657 | if ((error = xfs_inactive_free_eofblocks(mp, ip))) | 1664 | error = xfs_free_eofblocks(mp, ip, XFS_FREE_EOF_LOCK); |
1665 | if (error) | ||
1658 | return VN_INACTIVE_CACHE; | 1666 | return VN_INACTIVE_CACHE; |
1659 | /* Update linux inode block count after free above */ | 1667 | /* Update linux inode block count after free above */ |
1660 | vn_to_inode(vp)->i_blocks = XFS_FSB_TO_BB(mp, | 1668 | vn_to_inode(vp)->i_blocks = XFS_FSB_TO_BB(mp, |