Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Nick Piggin <npiggin@suse.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

authored by

Nick Piggin and committed by
Al Viro
3322e79a 15c6fd97

+17 -21
+5 -4
fs/block_dev.c
··· 172 172 struct file *file = iocb->ki_filp; 173 173 struct inode *inode = file->f_mapping->host; 174 174 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); 177 178 } 178 179 179 180 int __sync_blockdev(struct block_device *bdev, int wait) ··· 310 309 struct page **pagep, void **fsdata) 311 310 { 312 311 *pagep = NULL; 313 - return block_write_begin(file, mapping, pos, len, flags, pagep, fsdata, 314 - blkdev_get_block); 312 + return block_write_begin_newtrunc(file, mapping, pos, len, flags, 313 + pagep, fsdata, blkdev_get_block); 315 314 } 316 315 317 316 static int blkdev_write_end(struct file *file, struct address_space *mapping,
+4 -9
fs/configfs/inode.c
··· 72 72 if (!sd) 73 73 return -EINVAL; 74 74 75 + error = simple_setattr(dentry, iattr); 76 + if (error) 77 + return error; 78 + 75 79 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); 82 - if (error) 83 - return error; 84 - 85 80 if (!sd_iattr) { 86 81 /* setting attributes for the first time, allocate now */ 87 82 sd_iattr = kzalloc(sizeof(struct iattr), GFP_KERNEL);
+1
fs/ramfs/file-mmu.c
··· 50 50 }; 51 51 52 52 const struct inode_operations ramfs_file_inode_operations = { 53 + .setattr = simple_setattr, 53 54 .getattr = simple_getattr, 54 55 };
+4 -3
fs/ramfs/file-nommu.c
··· 146 146 return ret; 147 147 } 148 148 149 - ret = vmtruncate(inode, newsize); 149 + ret = simple_setsize(inode, newsize); 150 150 151 151 return ret; 152 152 } ··· 169 169 170 170 /* pick out size-changing events */ 171 171 if (ia->ia_valid & ATTR_SIZE) { 172 - loff_t size = i_size_read(inode); 172 + loff_t size = inode->i_size; 173 + 173 174 if (ia->ia_size != size) { 174 175 ret = ramfs_nommu_resize(inode, ia->ia_size, size); 175 176 if (ret < 0 || ia->ia_valid == ATTR_SIZE) ··· 183 182 } 184 183 } 185 184 186 - ret = inode_setattr(inode, ia); 185 + generic_setattr(inode, ia); 187 186 out: 188 187 ia->ia_valid = old_ia_valid; 189 188 return ret;
+3 -5
fs/sysfs/inode.c
··· 117 117 if (error) 118 118 goto out; 119 119 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); 125 122 126 123 error = sysfs_sd_setattr(sd, iattr); 124 + 127 125 out: 128 126 mutex_unlock(&sysfs_mutex); 129 127 return error;