Skip to content

Commit

Permalink
hfs: drop vmtruncate
Browse files Browse the repository at this point in the history
Removed vmtruncate

Signed-off-by: Marco Stornelli <marco.stornelli@gmail.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Marco Stornelli authored and Al Viro committed Dec 20, 2012
1 parent 41ddaee commit c8cf464
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions fs/hfs/inode.c
Expand Up @@ -35,6 +35,16 @@ static int hfs_readpage(struct file *file, struct page *page)
return block_read_full_page(page, hfs_get_block); return block_read_full_page(page, hfs_get_block);
} }


static void hfs_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);
hfs_file_truncate(inode);
}
}

static int hfs_write_begin(struct file *file, struct address_space *mapping, static int hfs_write_begin(struct file *file, struct address_space *mapping,
loff_t pos, unsigned len, unsigned flags, loff_t pos, unsigned len, unsigned flags,
struct page **pagep, void **fsdata) struct page **pagep, void **fsdata)
Expand All @@ -45,11 +55,8 @@ static int hfs_write_begin(struct file *file, struct address_space *mapping,
ret = cont_write_begin(file, mapping, pos, len, flags, pagep, fsdata, ret = cont_write_begin(file, mapping, pos, len, flags, pagep, fsdata,
hfs_get_block, hfs_get_block,
&HFS_I(mapping->host)->phys_size); &HFS_I(mapping->host)->phys_size);
if (unlikely(ret)) { if (unlikely(ret))
loff_t isize = mapping->host->i_size; hfs_write_failed(mapping, pos + len);
if (pos + len > isize)
vmtruncate(mapping->host, isize);
}


return ret; return ret;
} }
Expand Down Expand Up @@ -120,6 +127,7 @@ static ssize_t hfs_direct_IO(int rw, struct kiocb *iocb,
const struct iovec *iov, loff_t offset, unsigned long nr_segs) const struct iovec *iov, loff_t offset, unsigned long nr_segs)
{ {
struct file *file = iocb->ki_filp; struct file *file = iocb->ki_filp;
struct address_space *mapping = file->f_mapping;
struct inode *inode = file->f_path.dentry->d_inode->i_mapping->host; struct inode *inode = file->f_path.dentry->d_inode->i_mapping->host;
ssize_t ret; ssize_t ret;


Expand All @@ -135,7 +143,7 @@ static ssize_t hfs_direct_IO(int rw, struct kiocb *iocb,
loff_t end = offset + iov_length(iov, nr_segs); loff_t end = offset + iov_length(iov, nr_segs);


if (end > isize) if (end > isize)
vmtruncate(inode, isize); hfs_write_failed(mapping, end);
} }


return ret; return ret;
Expand Down Expand Up @@ -617,9 +625,12 @@ int hfs_inode_setattr(struct dentry *dentry, struct iattr * attr)
attr->ia_size != i_size_read(inode)) { attr->ia_size != i_size_read(inode)) {
inode_dio_wait(inode); inode_dio_wait(inode);


error = vmtruncate(inode, attr->ia_size); error = inode_newsize_ok(inode, attr->ia_size);
if (error) if (error)
return error; return error;

truncate_setsize(inode, attr->ia_size);
hfs_file_truncate(inode);
} }


setattr_copy(inode, attr); setattr_copy(inode, attr);
Expand Down Expand Up @@ -668,7 +679,6 @@ static const struct file_operations hfs_file_operations = {


static const struct inode_operations hfs_file_inode_operations = { static const struct inode_operations hfs_file_inode_operations = {
.lookup = hfs_file_lookup, .lookup = hfs_file_lookup,
.truncate = hfs_file_truncate,
.setattr = hfs_inode_setattr, .setattr = hfs_inode_setattr,
.setxattr = hfs_setxattr, .setxattr = hfs_setxattr,
.getxattr = hfs_getxattr, .getxattr = hfs_getxattr,
Expand Down

0 comments on commit c8cf464

Please sign in to comment.