Skip to content

Commit d506848

Browse files
Marco StornelliAl Viro
authored andcommitted
hfsplus: drop vmtruncate
Removed vmtruncate Signed-off-by: Marco Stornelli <marco.stornelli@gmail.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 86dd07d commit d506848

1 file changed

Lines changed: 16 additions & 11 deletions

File tree

‎fs/hfsplus/inode.c‎

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@ static int hfsplus_writepage(struct page *page, struct writeback_control *wbc)
2828
return block_write_full_page(page, hfsplus_get_block, wbc);
2929
}
3030

31+
static void hfsplus_write_failed(struct address_space *mapping, loff_t to)
32+
{
33+
struct inode *inode = mapping->host;
34+
35+
if (to > inode->i_size) {
36+
truncate_pagecache(inode, to, inode->i_size);
37+
hfsplus_file_truncate(inode);
38+
}
39+
}
40+
3141
static int hfsplus_write_begin(struct file *file, struct address_space *mapping,
3242
loff_t pos, unsigned len, unsigned flags,
3343
struct page **pagep, void **fsdata)
@@ -38,11 +48,8 @@ static int hfsplus_write_begin(struct file *file, struct address_space *mapping,
3848
ret = cont_write_begin(file, mapping, pos, len, flags, pagep, fsdata,
3949
hfsplus_get_block,
4050
&HFSPLUS_I(mapping->host)->phys_size);
41-
if (unlikely(ret)) {
42-
loff_t isize = mapping->host->i_size;
43-
if (pos + len > isize)
44-
vmtruncate(mapping->host, isize);
45-
}
51+
if (unlikely(ret))
52+
hfsplus_write_failed(mapping, pos + len);
4653

4754
return ret;
4855
}
@@ -116,6 +123,7 @@ static ssize_t hfsplus_direct_IO(int rw, struct kiocb *iocb,
116123
const struct iovec *iov, loff_t offset, unsigned long nr_segs)
117124
{
118125
struct file *file = iocb->ki_filp;
126+
struct address_space *mapping = file->f_mapping;
119127
struct inode *inode = file->f_path.dentry->d_inode->i_mapping->host;
120128
ssize_t ret;
121129

@@ -131,7 +139,7 @@ static ssize_t hfsplus_direct_IO(int rw, struct kiocb *iocb,
131139
loff_t end = offset + iov_length(iov, nr_segs);
132140

133141
if (end > isize)
134-
vmtruncate(inode, isize);
142+
hfsplus_write_failed(mapping, end);
135143
}
136144

137145
return ret;
@@ -300,10 +308,8 @@ static int hfsplus_setattr(struct dentry *dentry, struct iattr *attr)
300308
if ((attr->ia_valid & ATTR_SIZE) &&
301309
attr->ia_size != i_size_read(inode)) {
302310
inode_dio_wait(inode);
303-
304-
error = vmtruncate(inode, attr->ia_size);
305-
if (error)
306-
return error;
311+
truncate_setsize(inode, attr->ia_size);
312+
hfsplus_file_truncate(inode);
307313
}
308314

309315
setattr_copy(inode, attr);
@@ -358,7 +364,6 @@ int hfsplus_file_fsync(struct file *file, loff_t start, loff_t end,
358364

359365
static const struct inode_operations hfsplus_file_inode_operations = {
360366
.lookup = hfsplus_file_lookup,
361-
.truncate = hfsplus_file_truncate,
362367
.setattr = hfsplus_setattr,
363368
.setxattr = hfsplus_setxattr,
364369
.getxattr = hfsplus_getxattr,

0 commit comments

Comments
 (0)