diff options
Diffstat (limited to 'fs/ntfs')
-rw-r--r-- | fs/ntfs/file.c | 16 | ||||
-rw-r--r-- | fs/ntfs/inode.c | 8 | ||||
-rw-r--r-- | fs/ntfs/inode.h | 4 |
3 files changed, 23 insertions, 5 deletions
diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c index 1ecf46448f85..5b2d4f0853ac 100644 --- a/fs/ntfs/file.c +++ b/fs/ntfs/file.c | |||
@@ -1762,6 +1762,16 @@ err_out: | |||
1762 | return err; | 1762 | return err; |
1763 | } | 1763 | } |
1764 | 1764 | ||
1765 | static void ntfs_write_failed(struct address_space *mapping, loff_t to) | ||
1766 | { | ||
1767 | struct inode *inode = mapping->host; | ||
1768 | |||
1769 | if (to > inode->i_size) { | ||
1770 | truncate_pagecache(inode, to, inode->i_size); | ||
1771 | ntfs_truncate_vfs(inode); | ||
1772 | } | ||
1773 | } | ||
1774 | |||
1765 | /** | 1775 | /** |
1766 | * ntfs_file_buffered_write - | 1776 | * ntfs_file_buffered_write - |
1767 | * | 1777 | * |
@@ -2022,8 +2032,9 @@ static ssize_t ntfs_file_buffered_write(struct kiocb *iocb, | |||
2022 | * allocated space, which is not a disaster. | 2032 | * allocated space, which is not a disaster. |
2023 | */ | 2033 | */ |
2024 | i_size = i_size_read(vi); | 2034 | i_size = i_size_read(vi); |
2025 | if (pos + bytes > i_size) | 2035 | if (pos + bytes > i_size) { |
2026 | vmtruncate(vi, i_size); | 2036 | ntfs_write_failed(mapping, pos + bytes); |
2037 | } | ||
2027 | break; | 2038 | break; |
2028 | } | 2039 | } |
2029 | } | 2040 | } |
@@ -2227,7 +2238,6 @@ const struct file_operations ntfs_file_ops = { | |||
2227 | 2238 | ||
2228 | const struct inode_operations ntfs_file_inode_ops = { | 2239 | const struct inode_operations ntfs_file_inode_ops = { |
2229 | #ifdef NTFS_RW | 2240 | #ifdef NTFS_RW |
2230 | .truncate = ntfs_truncate_vfs, | ||
2231 | .setattr = ntfs_setattr, | 2241 | .setattr = ntfs_setattr, |
2232 | #endif /* NTFS_RW */ | 2242 | #endif /* NTFS_RW */ |
2233 | }; | 2243 | }; |
diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c index 1d27331e6fc9..d3e118cc6ffa 100644 --- a/fs/ntfs/inode.c +++ b/fs/ntfs/inode.c | |||
@@ -2866,9 +2866,11 @@ conv_err_out: | |||
2866 | * | 2866 | * |
2867 | * See ntfs_truncate() description above for details. | 2867 | * See ntfs_truncate() description above for details. |
2868 | */ | 2868 | */ |
2869 | #ifdef NTFS_RW | ||
2869 | void ntfs_truncate_vfs(struct inode *vi) { | 2870 | void ntfs_truncate_vfs(struct inode *vi) { |
2870 | ntfs_truncate(vi); | 2871 | ntfs_truncate(vi); |
2871 | } | 2872 | } |
2873 | #endif | ||
2872 | 2874 | ||
2873 | /** | 2875 | /** |
2874 | * ntfs_setattr - called from notify_change() when an attribute is being changed | 2876 | * ntfs_setattr - called from notify_change() when an attribute is being changed |
@@ -2914,8 +2916,10 @@ int ntfs_setattr(struct dentry *dentry, struct iattr *attr) | |||
2914 | NInoCompressed(ni) ? | 2916 | NInoCompressed(ni) ? |
2915 | "compressed" : "encrypted"); | 2917 | "compressed" : "encrypted"); |
2916 | err = -EOPNOTSUPP; | 2918 | err = -EOPNOTSUPP; |
2917 | } else | 2919 | } else { |
2918 | err = vmtruncate(vi, attr->ia_size); | 2920 | truncate_setsize(vi, attr->ia_size); |
2921 | ntfs_truncate_vfs(vi); | ||
2922 | } | ||
2919 | if (err || ia_valid == ATTR_SIZE) | 2923 | if (err || ia_valid == ATTR_SIZE) |
2920 | goto out; | 2924 | goto out; |
2921 | } else { | 2925 | } else { |
diff --git a/fs/ntfs/inode.h b/fs/ntfs/inode.h index db29695f845c..76b6cfb579d7 100644 --- a/fs/ntfs/inode.h +++ b/fs/ntfs/inode.h | |||
@@ -316,6 +316,10 @@ static inline void ntfs_commit_inode(struct inode *vi) | |||
316 | return; | 316 | return; |
317 | } | 317 | } |
318 | 318 | ||
319 | #else | ||
320 | |||
321 | static inline void ntfs_truncate_vfs(struct inode *vi) {} | ||
322 | |||
319 | #endif /* NTFS_RW */ | 323 | #endif /* NTFS_RW */ |
320 | 324 | ||
321 | #endif /* _LINUX_NTFS_INODE_H */ | 325 | #endif /* _LINUX_NTFS_INODE_H */ |