Skip to content

Commit 41ddaee

Browse files
Marco StornelliAl Viro
authored andcommitted
bfs: 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 1dc1834 commit 41ddaee

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

‎fs/bfs/file.c‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,14 @@ static int bfs_readpage(struct file *file, struct page *page)
161161
return block_read_full_page(page, bfs_get_block);
162162
}
163163

164+
static void bfs_write_failed(struct address_space *mapping, loff_t to)
165+
{
166+
struct inode *inode = mapping->host;
167+
168+
if (to > inode->i_size)
169+
truncate_pagecache(inode, to, inode->i_size);
170+
}
171+
164172
static int bfs_write_begin(struct file *file, struct address_space *mapping,
165173
loff_t pos, unsigned len, unsigned flags,
166174
struct page **pagep, void **fsdata)
@@ -169,11 +177,8 @@ static int bfs_write_begin(struct file *file, struct address_space *mapping,
169177

170178
ret = block_write_begin(mapping, pos, len, flags, pagep,
171179
bfs_get_block);
172-
if (unlikely(ret)) {
173-
loff_t isize = mapping->host->i_size;
174-
if (pos + len > isize)
175-
vmtruncate(mapping->host, isize);
176-
}
180+
if (unlikely(ret))
181+
bfs_write_failed(mapping, pos + len);
177182

178183
return ret;
179184
}

0 commit comments

Comments
 (0)