diff options
Diffstat (limited to 'fs/hfs/inode.c')
-rw-r--r-- | fs/hfs/inode.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c index 14f5cb1b9fdc..07b2464b5716 100644 --- a/fs/hfs/inode.c +++ b/fs/hfs/inode.c | |||
@@ -112,9 +112,24 @@ static ssize_t hfs_direct_IO(int rw, struct kiocb *iocb, | |||
112 | { | 112 | { |
113 | struct file *file = iocb->ki_filp; | 113 | struct file *file = iocb->ki_filp; |
114 | struct inode *inode = file->f_path.dentry->d_inode->i_mapping->host; | 114 | struct inode *inode = file->f_path.dentry->d_inode->i_mapping->host; |
115 | ssize_t ret; | ||
115 | 116 | ||
116 | return blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov, | 117 | ret = blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov, |
117 | offset, nr_segs, hfs_get_block, NULL); | 118 | offset, nr_segs, hfs_get_block, NULL); |
119 | |||
120 | /* | ||
121 | * In case of error extending write may have instantiated a few | ||
122 | * blocks outside i_size. Trim these off again. | ||
123 | */ | ||
124 | if (unlikely((rw & WRITE) && ret < 0)) { | ||
125 | loff_t isize = i_size_read(inode); | ||
126 | loff_t end = offset + iov_length(iov, nr_segs); | ||
127 | |||
128 | if (end > isize) | ||
129 | vmtruncate(inode, isize); | ||
130 | } | ||
131 | |||
132 | return ret; | ||
118 | } | 133 | } |
119 | 134 | ||
120 | static int hfs_writepages(struct address_space *mapping, | 135 | static int hfs_writepages(struct address_space *mapping, |