diff options
author | Marco Stornelli <marco.stornelli@gmail.com> | 2012-12-15 05:53:15 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-12-20 14:00:01 -0500 |
commit | c8cf464bc5cfa689357796db2294c4b2474095fb (patch) | |
tree | 6deda5dfd047b138f7124112724ee267f26f9e48 /fs/hfs | |
parent | 41ddaeeb9d02ca12fee80b4eb23ab388b3ebe69d (diff) |
hfs: drop vmtruncate
Removed vmtruncate
Signed-off-by: Marco Stornelli <marco.stornelli@gmail.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/hfs')
-rw-r--r-- | fs/hfs/inode.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c index 0b35903219bc..d47f11658c17 100644 --- a/fs/hfs/inode.c +++ b/fs/hfs/inode.c | |||
@@ -35,6 +35,16 @@ static int hfs_readpage(struct file *file, struct page *page) | |||
35 | return block_read_full_page(page, hfs_get_block); | 35 | return block_read_full_page(page, hfs_get_block); |
36 | } | 36 | } |
37 | 37 | ||
38 | static void hfs_write_failed(struct address_space *mapping, loff_t to) | ||
39 | { | ||
40 | struct inode *inode = mapping->host; | ||
41 | |||
42 | if (to > inode->i_size) { | ||
43 | truncate_pagecache(inode, to, inode->i_size); | ||
44 | hfs_file_truncate(inode); | ||
45 | } | ||
46 | } | ||
47 | |||
38 | static int hfs_write_begin(struct file *file, struct address_space *mapping, | 48 | static int hfs_write_begin(struct file *file, struct address_space *mapping, |
39 | loff_t pos, unsigned len, unsigned flags, | 49 | loff_t pos, unsigned len, unsigned flags, |
40 | struct page **pagep, void **fsdata) | 50 | struct page **pagep, void **fsdata) |
@@ -45,11 +55,8 @@ static int hfs_write_begin(struct file *file, struct address_space *mapping, | |||
45 | ret = cont_write_begin(file, mapping, pos, len, flags, pagep, fsdata, | 55 | ret = cont_write_begin(file, mapping, pos, len, flags, pagep, fsdata, |
46 | hfs_get_block, | 56 | hfs_get_block, |
47 | &HFS_I(mapping->host)->phys_size); | 57 | &HFS_I(mapping->host)->phys_size); |
48 | if (unlikely(ret)) { | 58 | if (unlikely(ret)) |
49 | loff_t isize = mapping->host->i_size; | 59 | hfs_write_failed(mapping, pos + len); |
50 | if (pos + len > isize) | ||
51 | vmtruncate(mapping->host, isize); | ||
52 | } | ||
53 | 60 | ||
54 | return ret; | 61 | return ret; |
55 | } | 62 | } |
@@ -120,6 +127,7 @@ static ssize_t hfs_direct_IO(int rw, struct kiocb *iocb, | |||
120 | const struct iovec *iov, loff_t offset, unsigned long nr_segs) | 127 | const struct iovec *iov, loff_t offset, unsigned long nr_segs) |
121 | { | 128 | { |
122 | struct file *file = iocb->ki_filp; | 129 | struct file *file = iocb->ki_filp; |
130 | struct address_space *mapping = file->f_mapping; | ||
123 | struct inode *inode = file->f_path.dentry->d_inode->i_mapping->host; | 131 | struct inode *inode = file->f_path.dentry->d_inode->i_mapping->host; |
124 | ssize_t ret; | 132 | ssize_t ret; |
125 | 133 | ||
@@ -135,7 +143,7 @@ static ssize_t hfs_direct_IO(int rw, struct kiocb *iocb, | |||
135 | loff_t end = offset + iov_length(iov, nr_segs); | 143 | loff_t end = offset + iov_length(iov, nr_segs); |
136 | 144 | ||
137 | if (end > isize) | 145 | if (end > isize) |
138 | vmtruncate(inode, isize); | 146 | hfs_write_failed(mapping, end); |
139 | } | 147 | } |
140 | 148 | ||
141 | return ret; | 149 | return ret; |
@@ -617,9 +625,12 @@ int hfs_inode_setattr(struct dentry *dentry, struct iattr * attr) | |||
617 | attr->ia_size != i_size_read(inode)) { | 625 | attr->ia_size != i_size_read(inode)) { |
618 | inode_dio_wait(inode); | 626 | inode_dio_wait(inode); |
619 | 627 | ||
620 | error = vmtruncate(inode, attr->ia_size); | 628 | error = inode_newsize_ok(inode, attr->ia_size); |
621 | if (error) | 629 | if (error) |
622 | return error; | 630 | return error; |
631 | |||
632 | truncate_setsize(inode, attr->ia_size); | ||
633 | hfs_file_truncate(inode); | ||
623 | } | 634 | } |
624 | 635 | ||
625 | setattr_copy(inode, attr); | 636 | setattr_copy(inode, attr); |
@@ -668,7 +679,6 @@ static const struct file_operations hfs_file_operations = { | |||
668 | 679 | ||
669 | static const struct inode_operations hfs_file_inode_operations = { | 680 | static const struct inode_operations hfs_file_inode_operations = { |
670 | .lookup = hfs_file_lookup, | 681 | .lookup = hfs_file_lookup, |
671 | .truncate = hfs_file_truncate, | ||
672 | .setattr = hfs_inode_setattr, | 682 | .setattr = hfs_inode_setattr, |
673 | .setxattr = hfs_setxattr, | 683 | .setxattr = hfs_setxattr, |
674 | .getxattr = hfs_getxattr, | 684 | .getxattr = hfs_getxattr, |