Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 347809
b: refs/heads/master
c: 9014da7
h: refs/heads/master
i:
  347807: d0fe0ec
v: v3
  • Loading branch information
Marco Stornelli authored and Al Viro committed Dec 20, 2012
1 parent 9806182 commit ea254a2
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 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: 2d1b399b22a8042edbaf41b1f2086d4183422ce4
refs/heads/master: 9014da7525dffef69131f717decf262e08ff3d58
16 changes: 13 additions & 3 deletions trunk/fs/ntfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1762,6 +1762,16 @@ static int ntfs_commit_pages_after_write(struct page **pages,
return err;
}

static void ntfs_write_failed(struct address_space *mapping, loff_t to)
{
struct inode *inode = mapping->host;

if (to > inode->i_size) {
truncate_pagecache(inode, to, inode->i_size);
ntfs_truncate_vfs(inode);
}
}

/**
* ntfs_file_buffered_write -
*
Expand Down Expand Up @@ -2022,8 +2032,9 @@ static ssize_t ntfs_file_buffered_write(struct kiocb *iocb,
* allocated space, which is not a disaster.
*/
i_size = i_size_read(vi);
if (pos + bytes > i_size)
vmtruncate(vi, i_size);
if (pos + bytes > i_size) {
ntfs_write_failed(mapping, pos + bytes);
}
break;
}
}
Expand Down Expand Up @@ -2227,7 +2238,6 @@ const struct file_operations ntfs_file_ops = {

const struct inode_operations ntfs_file_inode_ops = {
#ifdef NTFS_RW
.truncate = ntfs_truncate_vfs,
.setattr = ntfs_setattr,
#endif /* NTFS_RW */
};
Expand Down
8 changes: 6 additions & 2 deletions trunk/fs/ntfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -2866,9 +2866,11 @@ int ntfs_truncate(struct inode *vi)
*
* See ntfs_truncate() description above for details.
*/
#ifdef NTFS_RW
void ntfs_truncate_vfs(struct inode *vi) {
ntfs_truncate(vi);
}
#endif

/**
* ntfs_setattr - called from notify_change() when an attribute is being changed
Expand Down Expand Up @@ -2914,8 +2916,10 @@ int ntfs_setattr(struct dentry *dentry, struct iattr *attr)
NInoCompressed(ni) ?
"compressed" : "encrypted");
err = -EOPNOTSUPP;
} else
err = vmtruncate(vi, attr->ia_size);
} else {
truncate_setsize(vi, attr->ia_size);
ntfs_truncate_vfs(vi);
}
if (err || ia_valid == ATTR_SIZE)
goto out;
} else {
Expand Down
4 changes: 4 additions & 0 deletions trunk/fs/ntfs/inode.h
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,10 @@ static inline void ntfs_commit_inode(struct inode *vi)
return;
}

#else

static inline void ntfs_truncate_vfs(struct inode *vi) {}

#endif /* NTFS_RW */

#endif /* _LINUX_NTFS_INODE_H */

0 comments on commit ea254a2

Please sign in to comment.