Commit 3322e79a authored by Nick Piggin's avatar Nick Piggin Committed by Al Viro

fs: convert simple fs to new truncate

Convert simple filesystems: ramfs, configfs, sysfs, block_dev to new truncate
sequence.

Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: default avatarNick Piggin <npiggin@suse.de>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 15c6fd97
...@@ -172,8 +172,9 @@ blkdev_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov, ...@@ -172,8 +172,9 @@ blkdev_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
struct file *file = iocb->ki_filp; struct file *file = iocb->ki_filp;
struct inode *inode = file->f_mapping->host; struct inode *inode = file->f_mapping->host;
return blockdev_direct_IO_no_locking(rw, iocb, inode, I_BDEV(inode), return blockdev_direct_IO_no_locking_newtrunc(rw, iocb, inode,
iov, offset, nr_segs, blkdev_get_blocks, NULL); I_BDEV(inode), iov, offset, nr_segs,
blkdev_get_blocks, NULL);
} }
int __sync_blockdev(struct block_device *bdev, int wait) int __sync_blockdev(struct block_device *bdev, int wait)
...@@ -309,8 +310,8 @@ static int blkdev_write_begin(struct file *file, struct address_space *mapping, ...@@ -309,8 +310,8 @@ static int blkdev_write_begin(struct file *file, struct address_space *mapping,
struct page **pagep, void **fsdata) struct page **pagep, void **fsdata)
{ {
*pagep = NULL; *pagep = NULL;
return block_write_begin(file, mapping, pos, len, flags, pagep, fsdata, return block_write_begin_newtrunc(file, mapping, pos, len, flags,
blkdev_get_block); pagep, fsdata, blkdev_get_block);
} }
static int blkdev_write_end(struct file *file, struct address_space *mapping, static int blkdev_write_end(struct file *file, struct address_space *mapping,
......
...@@ -72,16 +72,11 @@ int configfs_setattr(struct dentry * dentry, struct iattr * iattr) ...@@ -72,16 +72,11 @@ int configfs_setattr(struct dentry * dentry, struct iattr * iattr)
if (!sd) if (!sd)
return -EINVAL; return -EINVAL;
sd_iattr = sd->s_iattr; error = simple_setattr(dentry, iattr);
error = inode_change_ok(inode, iattr);
if (error)
return error;
error = inode_setattr(inode, iattr);
if (error) if (error)
return error; return error;
sd_iattr = sd->s_iattr;
if (!sd_iattr) { if (!sd_iattr) {
/* setting attributes for the first time, allocate now */ /* setting attributes for the first time, allocate now */
sd_iattr = kzalloc(sizeof(struct iattr), GFP_KERNEL); sd_iattr = kzalloc(sizeof(struct iattr), GFP_KERNEL);
......
...@@ -50,5 +50,6 @@ const struct file_operations ramfs_file_operations = { ...@@ -50,5 +50,6 @@ const struct file_operations ramfs_file_operations = {
}; };
const struct inode_operations ramfs_file_inode_operations = { const struct inode_operations ramfs_file_inode_operations = {
.setattr = simple_setattr,
.getattr = simple_getattr, .getattr = simple_getattr,
}; };
...@@ -146,7 +146,7 @@ static int ramfs_nommu_resize(struct inode *inode, loff_t newsize, loff_t size) ...@@ -146,7 +146,7 @@ static int ramfs_nommu_resize(struct inode *inode, loff_t newsize, loff_t size)
return ret; return ret;
} }
ret = vmtruncate(inode, newsize); ret = simple_setsize(inode, newsize);
return ret; return ret;
} }
...@@ -169,7 +169,8 @@ static int ramfs_nommu_setattr(struct dentry *dentry, struct iattr *ia) ...@@ -169,7 +169,8 @@ static int ramfs_nommu_setattr(struct dentry *dentry, struct iattr *ia)
/* pick out size-changing events */ /* pick out size-changing events */
if (ia->ia_valid & ATTR_SIZE) { if (ia->ia_valid & ATTR_SIZE) {
loff_t size = i_size_read(inode); loff_t size = inode->i_size;
if (ia->ia_size != size) { if (ia->ia_size != size) {
ret = ramfs_nommu_resize(inode, ia->ia_size, size); ret = ramfs_nommu_resize(inode, ia->ia_size, size);
if (ret < 0 || ia->ia_valid == ATTR_SIZE) if (ret < 0 || ia->ia_valid == ATTR_SIZE)
...@@ -182,7 +183,7 @@ static int ramfs_nommu_setattr(struct dentry *dentry, struct iattr *ia) ...@@ -182,7 +183,7 @@ static int ramfs_nommu_setattr(struct dentry *dentry, struct iattr *ia)
} }
} }
ret = inode_setattr(inode, ia); generic_setattr(inode, ia);
out: out:
ia->ia_valid = old_ia_valid; ia->ia_valid = old_ia_valid;
return ret; return ret;
......
...@@ -117,13 +117,11 @@ int sysfs_setattr(struct dentry *dentry, struct iattr *iattr) ...@@ -117,13 +117,11 @@ int sysfs_setattr(struct dentry *dentry, struct iattr *iattr)
if (error) if (error)
goto out; goto out;
iattr->ia_valid &= ~ATTR_SIZE; /* ignore size changes */ /* this ignores size changes */
generic_setattr(inode, iattr);
error = inode_setattr(inode, iattr);
if (error)
goto out;
error = sysfs_sd_setattr(sd, iattr); error = sysfs_sd_setattr(sd, iattr);
out: out:
mutex_unlock(&sysfs_mutex); mutex_unlock(&sysfs_mutex);
return error; return error;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment