Skip to content

Commit 3322e79

Browse files
Nick PigginAl Viro
authored andcommitted
fs: convert simple fs to new truncate
Convert simple filesystems: ramfs, configfs, sysfs, block_dev to new truncate sequence. Cc: Christoph Hellwig <[email protected]> Signed-off-by: Nick Piggin <[email protected]> Signed-off-by: Al Viro <[email protected]>
1 parent 15c6fd9 commit 3322e79

File tree

5 files changed

+15
-19
lines changed

5 files changed

+15
-19
lines changed

fs/block_dev.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,9 @@ blkdev_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
172172
struct file *file = iocb->ki_filp;
173173
struct inode *inode = file->f_mapping->host;
174174

175-
return blockdev_direct_IO_no_locking(rw, iocb, inode, I_BDEV(inode),
176-
iov, offset, nr_segs, blkdev_get_blocks, NULL);
175+
return blockdev_direct_IO_no_locking_newtrunc(rw, iocb, inode,
176+
I_BDEV(inode), iov, offset, nr_segs,
177+
blkdev_get_blocks, NULL);
177178
}
178179

179180
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,
309310
struct page **pagep, void **fsdata)
310311
{
311312
*pagep = NULL;
312-
return block_write_begin(file, mapping, pos, len, flags, pagep, fsdata,
313-
blkdev_get_block);
313+
return block_write_begin_newtrunc(file, mapping, pos, len, flags,
314+
pagep, fsdata, blkdev_get_block);
314315
}
315316

316317
static int blkdev_write_end(struct file *file, struct address_space *mapping,

fs/configfs/inode.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,11 @@ int configfs_setattr(struct dentry * dentry, struct iattr * iattr)
7272
if (!sd)
7373
return -EINVAL;
7474

75-
sd_iattr = sd->s_iattr;
76-
77-
error = inode_change_ok(inode, iattr);
78-
if (error)
79-
return error;
80-
81-
error = inode_setattr(inode, iattr);
75+
error = simple_setattr(dentry, iattr);
8276
if (error)
8377
return error;
8478

79+
sd_iattr = sd->s_iattr;
8580
if (!sd_iattr) {
8681
/* setting attributes for the first time, allocate now */
8782
sd_iattr = kzalloc(sizeof(struct iattr), GFP_KERNEL);

fs/ramfs/file-mmu.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,6 @@ const struct file_operations ramfs_file_operations = {
5050
};
5151

5252
const struct inode_operations ramfs_file_inode_operations = {
53+
.setattr = simple_setattr,
5354
.getattr = simple_getattr,
5455
};

fs/ramfs/file-nommu.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ static int ramfs_nommu_resize(struct inode *inode, loff_t newsize, loff_t size)
146146
return ret;
147147
}
148148

149-
ret = vmtruncate(inode, newsize);
149+
ret = simple_setsize(inode, newsize);
150150

151151
return ret;
152152
}
@@ -169,7 +169,8 @@ static int ramfs_nommu_setattr(struct dentry *dentry, struct iattr *ia)
169169

170170
/* pick out size-changing events */
171171
if (ia->ia_valid & ATTR_SIZE) {
172-
loff_t size = i_size_read(inode);
172+
loff_t size = inode->i_size;
173+
173174
if (ia->ia_size != size) {
174175
ret = ramfs_nommu_resize(inode, ia->ia_size, size);
175176
if (ret < 0 || ia->ia_valid == ATTR_SIZE)
@@ -182,7 +183,7 @@ static int ramfs_nommu_setattr(struct dentry *dentry, struct iattr *ia)
182183
}
183184
}
184185

185-
ret = inode_setattr(inode, ia);
186+
generic_setattr(inode, ia);
186187
out:
187188
ia->ia_valid = old_ia_valid;
188189
return ret;

fs/sysfs/inode.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,11 @@ int sysfs_setattr(struct dentry *dentry, struct iattr *iattr)
117117
if (error)
118118
goto out;
119119

120-
iattr->ia_valid &= ~ATTR_SIZE; /* ignore size changes */
121-
122-
error = inode_setattr(inode, iattr);
123-
if (error)
124-
goto out;
120+
/* this ignores size changes */
121+
generic_setattr(inode, iattr);
125122

126123
error = sysfs_sd_setattr(sd, iattr);
124+
127125
out:
128126
mutex_unlock(&sysfs_mutex);
129127
return error;

0 commit comments

Comments
 (0)