Commit 4b59fb61 authored by Nick Piggin's avatar Nick Piggin Committed by James Toy

Convert simple filesystems: ramfs, configfs, sysfs to new truncate

sequence.
Signed-off-by: default avatarNick Piggin <npiggin@suse.de>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Jan Kara <jack@suse.cz>
Cc: Dave Kleikamp <shaggy@linux.vnet.ibm.com>
Cc: Chris Mason <chris.mason@oracle.com>
Cc: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Cc: Hugh Dickins <hugh.dickins@tiscali.co.uk>
Cc: Miklos Szeredi <miklos@szeredi.hu>
Cc: Trond Myklebust <trond.myklebust@fys.uio.no>
Cc: Steven French <sfrench@us.ibm.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 7d12a880
...@@ -57,6 +57,7 @@ static struct backing_dev_info configfs_backing_dev_info = { ...@@ -57,6 +57,7 @@ static struct backing_dev_info configfs_backing_dev_info = {
}; };
static const struct inode_operations configfs_inode_operations ={ static const struct inode_operations configfs_inode_operations ={
.new_truncate = 1,
.setattr = configfs_setattr, .setattr = configfs_setattr,
}; };
...@@ -77,9 +78,13 @@ int configfs_setattr(struct dentry * dentry, struct iattr * iattr) ...@@ -77,9 +78,13 @@ int configfs_setattr(struct dentry * dentry, struct iattr * iattr)
if (error) if (error)
return error; return error;
error = inode_setattr(inode, iattr); if (iattr->ia_valid & ATTR_SIZE) {
error = simple_setsize(inode, iattr->ia_size);
if (error) if (error)
return error; return error;
}
generic_setattr(inode, iattr);
if (!sd_iattr) { if (!sd_iattr) {
/* setting attributes for the first time, allocate now */ /* setting attributes for the first time, allocate now */
......
...@@ -50,5 +50,7 @@ const struct file_operations ramfs_file_operations = { ...@@ -50,5 +50,7 @@ const struct file_operations ramfs_file_operations = {
}; };
const struct inode_operations ramfs_file_inode_operations = { const struct inode_operations ramfs_file_inode_operations = {
.new_truncate = 1,
.setattr = simple_setattr,
.getattr = simple_getattr, .getattr = simple_getattr,
}; };
...@@ -48,6 +48,7 @@ const struct file_operations ramfs_file_operations = { ...@@ -48,6 +48,7 @@ const struct file_operations ramfs_file_operations = {
}; };
const struct inode_operations ramfs_file_inode_operations = { const struct inode_operations ramfs_file_inode_operations = {
.new_truncate = 1,
.setattr = ramfs_nommu_setattr, .setattr = ramfs_nommu_setattr,
.getattr = simple_getattr, .getattr = simple_getattr,
}; };
...@@ -169,7 +170,7 @@ static int ramfs_nommu_resize(struct inode *inode, loff_t newsize, loff_t size) ...@@ -169,7 +170,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;
} }
...@@ -192,7 +193,8 @@ static int ramfs_nommu_setattr(struct dentry *dentry, struct iattr *ia) ...@@ -192,7 +193,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)
...@@ -205,7 +207,7 @@ static int ramfs_nommu_setattr(struct dentry *dentry, struct iattr *ia) ...@@ -205,7 +207,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;
......
...@@ -35,6 +35,7 @@ static struct backing_dev_info sysfs_backing_dev_info = { ...@@ -35,6 +35,7 @@ static struct backing_dev_info sysfs_backing_dev_info = {
}; };
static const struct inode_operations sysfs_inode_operations ={ static const struct inode_operations sysfs_inode_operations ={
.new_truncate = 1,
.setattr = sysfs_setattr, .setattr = sysfs_setattr,
}; };
...@@ -60,11 +61,7 @@ int sysfs_setattr(struct dentry * dentry, struct iattr * iattr) ...@@ -60,11 +61,7 @@ int sysfs_setattr(struct dentry * dentry, struct iattr * iattr)
if (error) if (error)
return error; return error;
iattr->ia_valid &= ~ATTR_SIZE; /* ignore size changes */ generic_setattr(inode, iattr);
error = inode_setattr(inode, iattr);
if (error)
return error;
if (!sd_iattr) { if (!sd_iattr) {
/* setting attributes for the first time, allocate now */ /* setting attributes for the first time, allocate now */
......
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