| .. | .. |
|---|
| 94 | 94 | ip->i_d.di_flags &= ~XFS_DIFLAG_PREALLOC; |
|---|
| 95 | 95 | |
|---|
| 96 | 96 | xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); |
|---|
| 97 | | - if (flags & XFS_PREALLOC_SYNC) |
|---|
| 98 | | - xfs_trans_set_sync(tp); |
|---|
| 99 | 97 | return xfs_trans_commit(tp); |
|---|
| 100 | 98 | } |
|---|
| 101 | 99 | |
|---|
| .. | .. |
|---|
| 852 | 850 | struct inode *inode = file_inode(file); |
|---|
| 853 | 851 | struct xfs_inode *ip = XFS_I(inode); |
|---|
| 854 | 852 | long error; |
|---|
| 855 | | - enum xfs_prealloc_flags flags = 0; |
|---|
| 856 | 853 | uint iolock = XFS_IOLOCK_EXCL | XFS_MMAPLOCK_EXCL; |
|---|
| 857 | 854 | loff_t new_size = 0; |
|---|
| 858 | 855 | bool do_file_insert = false; |
|---|
| .. | .. |
|---|
| 896 | 893 | if (error) |
|---|
| 897 | 894 | goto out_unlock; |
|---|
| 898 | 895 | } |
|---|
| 896 | + |
|---|
| 897 | + error = file_modified(file); |
|---|
| 898 | + if (error) |
|---|
| 899 | + goto out_unlock; |
|---|
| 899 | 900 | |
|---|
| 900 | 901 | if (mode & FALLOC_FL_PUNCH_HOLE) { |
|---|
| 901 | 902 | error = xfs_free_file_space(ip, offset, len); |
|---|
| .. | .. |
|---|
| 946 | 947 | } |
|---|
| 947 | 948 | do_file_insert = true; |
|---|
| 948 | 949 | } else { |
|---|
| 949 | | - flags |= XFS_PREALLOC_SET; |
|---|
| 950 | | - |
|---|
| 951 | 950 | if (!(mode & FALLOC_FL_KEEP_SIZE) && |
|---|
| 952 | 951 | offset + len > i_size_read(inode)) { |
|---|
| 953 | 952 | new_size = offset + len; |
|---|
| .. | .. |
|---|
| 1000 | 999 | } |
|---|
| 1001 | 1000 | } |
|---|
| 1002 | 1001 | |
|---|
| 1003 | | - if (file->f_flags & O_DSYNC) |
|---|
| 1004 | | - flags |= XFS_PREALLOC_SYNC; |
|---|
| 1005 | | - |
|---|
| 1006 | | - error = xfs_update_prealloc_flags(ip, flags); |
|---|
| 1007 | | - if (error) |
|---|
| 1008 | | - goto out_unlock; |
|---|
| 1009 | | - |
|---|
| 1010 | 1002 | /* Change file size if needed */ |
|---|
| 1011 | 1003 | if (new_size) { |
|---|
| 1012 | 1004 | struct iattr iattr; |
|---|
| .. | .. |
|---|
| 1024 | 1016 | * leave shifted extents past EOF and hence losing access to |
|---|
| 1025 | 1017 | * the data that is contained within them. |
|---|
| 1026 | 1018 | */ |
|---|
| 1027 | | - if (do_file_insert) |
|---|
| 1019 | + if (do_file_insert) { |
|---|
| 1028 | 1020 | error = xfs_insert_file_space(ip, offset, len); |
|---|
| 1021 | + if (error) |
|---|
| 1022 | + goto out_unlock; |
|---|
| 1023 | + } |
|---|
| 1024 | + |
|---|
| 1025 | + if (file->f_flags & O_DSYNC) |
|---|
| 1026 | + error = xfs_log_force_inode(ip); |
|---|
| 1029 | 1027 | |
|---|
| 1030 | 1028 | out_unlock: |
|---|
| 1031 | 1029 | xfs_iunlock(ip, iolock); |
|---|