Skip to content

Commit

Permalink
truncate: drop 'oldsize' truncate_pagecache() parameter
Browse files Browse the repository at this point in the history
truncate_pagecache() doesn't care about old size since commit
cedabed ("vfs: Fix vmtruncate() regression").  Let's drop it.

Signed-off-by: Kirill A. Shutemov <[email protected]>
Cc: OGAWA Hirofumi <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
kiryl authored and torvalds committed Sep 12, 2013
1 parent 5fbc461 commit 7caef26
Show file tree
Hide file tree
Showing 28 changed files with 31 additions and 44 deletions.
2 changes: 1 addition & 1 deletion fs/adfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ static void adfs_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);
truncate_pagecache(inode, inode->i_size);
}

static int adfs_write_begin(struct file *file, struct address_space *mapping,
Expand Down
2 changes: 1 addition & 1 deletion fs/affs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ static void affs_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);
truncate_pagecache(inode, inode->i_size);
affs_truncate(inode);
}
}
Expand Down
2 changes: 1 addition & 1 deletion fs/bfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ static void bfs_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);
truncate_pagecache(inode, inode->i_size);
}

static int bfs_write_begin(struct file *file, struct address_space *mapping,
Expand Down
4 changes: 1 addition & 3 deletions fs/btrfs/free-space-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,10 @@ int btrfs_truncate_free_space_cache(struct btrfs_root *root,
struct btrfs_path *path,
struct inode *inode)
{
loff_t oldsize;
int ret = 0;

oldsize = i_size_read(inode);
btrfs_i_size_write(inode, 0);
truncate_pagecache(inode, oldsize, 0);
truncate_pagecache(inode, 0);

/*
* We don't need an orphan item because truncating the free space cache
Expand Down
2 changes: 1 addition & 1 deletion fs/btrfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -4409,7 +4409,7 @@ static int btrfs_setsize(struct inode *inode, struct iattr *attr)
inode->i_ctime = inode->i_mtime = current_fs_time(inode->i_sb);

if (newsize > oldsize) {
truncate_pagecache(inode, oldsize, newsize);
truncate_pagecache(inode, newsize);
ret = btrfs_cont_expand(inode, oldsize, newsize);
if (ret)
return ret;
Expand Down
5 changes: 1 addition & 4 deletions fs/cifs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1852,14 +1852,11 @@ static int cifs_truncate_page(struct address_space *mapping, loff_t from)

static void cifs_setsize(struct inode *inode, loff_t offset)
{
loff_t oldsize;

spin_lock(&inode->i_lock);
oldsize = inode->i_size;
i_size_write(inode, offset);
spin_unlock(&inode->i_lock);

truncate_pagecache(inode, oldsize, offset);
truncate_pagecache(inode, offset);
}

static int
Expand Down
2 changes: 1 addition & 1 deletion fs/exofs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ static int exofs_writepage(struct page *page, struct writeback_control *wbc)
static void _write_failed(struct inode *inode, loff_t to)
{
if (to > inode->i_size)
truncate_pagecache(inode, to, inode->i_size);
truncate_pagecache(inode, inode->i_size);
}

int exofs_write_begin(struct file *file, struct address_space *mapping,
Expand Down
2 changes: 1 addition & 1 deletion fs/ext2/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ static void ext2_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);
truncate_pagecache(inode, inode->i_size);
ext2_truncate_blocks(inode, inode->i_size);
}
}
Expand Down
3 changes: 1 addition & 2 deletions fs/ext4/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -4587,7 +4587,6 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr)

if (attr->ia_valid & ATTR_SIZE && attr->ia_size != inode->i_size) {
handle_t *handle;
loff_t oldsize = inode->i_size;

if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) {
struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
Expand Down Expand Up @@ -4650,7 +4649,7 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr)
* Truncate pagecache after we've waited for commit
* in data=journal mode to make pages freeable.
*/
truncate_pagecache(inode, oldsize, inode->i_size);
truncate_pagecache(inode, inode->i_size);
}
/*
* We want to call ext4_truncate() even if attr->ia_size ==
Expand Down
2 changes: 1 addition & 1 deletion fs/fat/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ static void fat_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);
truncate_pagecache(inode, inode->i_size);
fat_truncate_blocks(inode, inode->i_size);
}
}
Expand Down
2 changes: 1 addition & 1 deletion fs/fuse/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -1678,7 +1678,7 @@ int fuse_do_setattr(struct inode *inode, struct iattr *attr,
* FUSE_NOWRITE, otherwise fuse_launder_page() would deadlock.
*/
if (S_ISREG(inode->i_mode) && oldsize != outarg.attr.size) {
truncate_pagecache(inode, oldsize, outarg.attr.size);
truncate_pagecache(inode, outarg.attr.size);
invalidate_inode_pages2(inode->i_mapping);
}

Expand Down
2 changes: 1 addition & 1 deletion fs/fuse/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr,
bool inval = false;

if (oldsize != attr->size) {
truncate_pagecache(inode, oldsize, attr->size);
truncate_pagecache(inode, attr->size);
inval = true;
} else if (fc->auto_inval_data) {
struct timespec new_mtime = {
Expand Down
4 changes: 2 additions & 2 deletions fs/gfs2/bmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,7 @@ static int gfs2_journaled_truncate(struct inode *inode, u64 oldsize, u64 newsize
chunk = oldsize - newsize;
if (chunk > max_chunk)
chunk = max_chunk;
truncate_pagecache(inode, oldsize, oldsize - chunk);
truncate_pagecache(inode, oldsize - chunk);
oldsize -= chunk;
gfs2_trans_end(sdp);
error = gfs2_trans_begin(sdp, RES_DINODE, GFS2_JTRUNC_REVOKES);
Expand Down Expand Up @@ -1067,7 +1067,7 @@ static int trunc_start(struct inode *inode, u64 oldsize, u64 newsize)
if (journaled)
error = gfs2_journaled_truncate(inode, oldsize, newsize);
else
truncate_pagecache(inode, oldsize, newsize);
truncate_pagecache(inode, newsize);

if (error) {
brelse(dibh);
Expand Down
2 changes: 1 addition & 1 deletion fs/hfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ 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);
truncate_pagecache(inode, inode->i_size);
hfs_file_truncate(inode);
}
}
Expand Down
2 changes: 1 addition & 1 deletion fs/hfsplus/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ static void hfsplus_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);
truncate_pagecache(inode, inode->i_size);
hfsplus_file_truncate(inode);
}
}
Expand Down
2 changes: 1 addition & 1 deletion fs/hpfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ static void hpfs_write_failed(struct address_space *mapping, loff_t to)
hpfs_lock(inode->i_sb);

if (to > inode->i_size) {
truncate_pagecache(inode, to, inode->i_size);
truncate_pagecache(inode, inode->i_size);
hpfs_truncate(inode);
}

Expand Down
2 changes: 1 addition & 1 deletion fs/jfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ static void jfs_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);
truncate_pagecache(inode, inode->i_size);
jfs_truncate(inode);
}
}
Expand Down
2 changes: 1 addition & 1 deletion fs/minix/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ static void minix_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);
truncate_pagecache(inode, inode->i_size);
minix_truncate(inode);
}
}
Expand Down
4 changes: 1 addition & 3 deletions fs/nfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -541,19 +541,17 @@ EXPORT_SYMBOL_GPL(nfs_setattr);
*/
static int nfs_vmtruncate(struct inode * inode, loff_t offset)
{
loff_t oldsize;
int err;

err = inode_newsize_ok(inode, offset);
if (err)
goto out;

spin_lock(&inode->i_lock);
oldsize = inode->i_size;
i_size_write(inode, offset);
spin_unlock(&inode->i_lock);

truncate_pagecache(inode, oldsize, offset);
truncate_pagecache(inode, offset);
out:
return err;
}
Expand Down
2 changes: 1 addition & 1 deletion fs/nilfs2/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ void nilfs_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);
truncate_pagecache(inode, inode->i_size);
nilfs_truncate(inode);
}
}
Expand Down
2 changes: 1 addition & 1 deletion fs/ntfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1768,7 +1768,7 @@ static void ntfs_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);
truncate_pagecache(inode, inode->i_size);
ntfs_truncate_vfs(inode);
}
}
Expand Down
2 changes: 1 addition & 1 deletion fs/omfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ static void omfs_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);
truncate_pagecache(inode, inode->i_size);
omfs_truncate(inode);
}
}
Expand Down
2 changes: 1 addition & 1 deletion fs/sysv/itree.c
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ static void sysv_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);
truncate_pagecache(inode, inode->i_size);
sysv_truncate(inode);
}
}
Expand Down
2 changes: 1 addition & 1 deletion fs/udf/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ static void udf_write_failed(struct address_space *mapping, loff_t to)
loff_t isize = inode->i_size;

if (to > isize) {
truncate_pagecache(inode, to, isize);
truncate_pagecache(inode, isize);
if (iinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB) {
down_write(&iinfo->i_data_sem);
udf_clear_extent_cache(inode);
Expand Down
2 changes: 1 addition & 1 deletion fs/ufs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ static void ufs_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);
truncate_pagecache(inode, inode->i_size);
}

static int ufs_write_begin(struct file *file, struct address_space *mapping,
Expand Down
4 changes: 2 additions & 2 deletions fs/xfs/xfs_aops.c
Original file line number Diff line number Diff line change
Expand Up @@ -1582,7 +1582,7 @@ xfs_vm_write_begin(
unlock_page(page);

if (pos + len > i_size_read(inode))
truncate_pagecache(inode, pos + len, i_size_read(inode));
truncate_pagecache(inode, i_size_read(inode));

page_cache_release(page);
page = NULL;
Expand Down Expand Up @@ -1618,7 +1618,7 @@ xfs_vm_write_end(
loff_t to = pos + len;

if (to > isize) {
truncate_pagecache(inode, to, isize);
truncate_pagecache(inode, isize);
xfs_vm_kill_delalloc_range(inode, isize, to);
}
}
Expand Down
2 changes: 1 addition & 1 deletion include/linux/mm.h
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,7 @@ static inline void unmap_shared_mapping_range(struct address_space *mapping,
unmap_mapping_range(mapping, holebegin, holelen, 0);
}

extern void truncate_pagecache(struct inode *inode, loff_t old, loff_t new);
extern void truncate_pagecache(struct inode *inode, loff_t new);
extern void truncate_setsize(struct inode *inode, loff_t newsize);
void truncate_pagecache_range(struct inode *inode, loff_t offset, loff_t end);
int truncate_inode_page(struct address_space *mapping, struct page *page);
Expand Down
9 changes: 2 additions & 7 deletions mm/truncate.c
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,6 @@ EXPORT_SYMBOL_GPL(invalidate_inode_pages2);
/**
* truncate_pagecache - unmap and remove pagecache that has been truncated
* @inode: inode
* @oldsize: old file size
* @newsize: new file size
*
* inode's new i_size must already be written before truncate_pagecache
Expand All @@ -580,7 +579,7 @@ EXPORT_SYMBOL_GPL(invalidate_inode_pages2);
* situations such as writepage being called for a page that has already
* had its underlying blocks deallocated.
*/
void truncate_pagecache(struct inode *inode, loff_t oldsize, loff_t newsize)
void truncate_pagecache(struct inode *inode, loff_t newsize)
{
struct address_space *mapping = inode->i_mapping;
loff_t holebegin = round_up(newsize, PAGE_SIZE);
Expand Down Expand Up @@ -614,12 +613,8 @@ EXPORT_SYMBOL(truncate_pagecache);
*/
void truncate_setsize(struct inode *inode, loff_t newsize)
{
loff_t oldsize;

oldsize = inode->i_size;
i_size_write(inode, newsize);

truncate_pagecache(inode, oldsize, newsize);
truncate_pagecache(inode, newsize);
}
EXPORT_SYMBOL(truncate_setsize);

Expand Down

0 comments on commit 7caef26

Please sign in to comment.