From mboxrd@z Thu Jan 1 00:00:00 1970 From: npiggin@suse.de Subject: [patch 04/11] fs: convert simple fs to new truncate Date: Fri, 21 Aug 2009 02:35:08 +1000 Message-ID: <20090820164050.891792656@suse.de> References: <20090820163504.131529718@suse.de> Cc: linux-fsdevel@vger.kernel.org, Christoph Hellwig To: Andrew Morton Return-path: Received: from cantor.suse.de ([195.135.220.2]:38015 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754477AbZHTQmw (ORCPT ); Thu, 20 Aug 2009 12:42:52 -0400 Content-Disposition: inline; filename=fs-simple-new-truncate.patch Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Convert simple filesystems: ramfs, configfs, sysfs to new truncate sequence. Signed-off-by: Nick Piggin --- fs/configfs/inode.c | 11 ++++++++--- fs/ramfs/file-mmu.c | 2 ++ fs/ramfs/file-nommu.c | 8 +++++--- fs/sysfs/inode.c | 7 ++----- 4 files changed, 17 insertions(+), 11 deletions(-) Index: linux-2.6/fs/ramfs/file-mmu.c =================================================================== --- linux-2.6.orig/fs/ramfs/file-mmu.c +++ linux-2.6/fs/ramfs/file-mmu.c @@ -50,5 +50,7 @@ const struct file_operations ramfs_file_ }; const struct inode_operations ramfs_file_inode_operations = { + .new_truncate = 1, + .setattr = simple_setattr, .getattr = simple_getattr, }; Index: linux-2.6/fs/ramfs/file-nommu.c =================================================================== --- linux-2.6.orig/fs/ramfs/file-nommu.c +++ linux-2.6/fs/ramfs/file-nommu.c @@ -48,6 +48,7 @@ const struct file_operations ramfs_file_ }; const struct inode_operations ramfs_file_inode_operations = { + .new_truncate = 1, .setattr = ramfs_nommu_setattr, .getattr = simple_getattr, }; @@ -169,7 +170,7 @@ static int ramfs_nommu_resize(struct ino return ret; } - ret = vmtruncate(inode, newsize); + ret = simple_setsize(inode, newsize); return ret; } @@ -192,7 +193,8 @@ static int ramfs_nommu_setattr(struct de /* pick out size-changing events */ if (ia->ia_valid & ATTR_SIZE) { - loff_t size = i_size_read(inode); + loff_t size = inode->i_size; + if (ia->ia_size != size) { ret = ramfs_nommu_resize(inode, ia->ia_size, size); if (ret < 0 || ia->ia_valid == ATTR_SIZE) @@ -205,7 +207,7 @@ static int ramfs_nommu_setattr(struct de } } - ret = inode_setattr(inode, ia); + generic_setattr(inode, ia); out: ia->ia_valid = old_ia_valid; return ret; Index: linux-2.6/fs/configfs/inode.c =================================================================== --- linux-2.6.orig/fs/configfs/inode.c +++ linux-2.6/fs/configfs/inode.c @@ -56,6 +56,7 @@ static struct backing_dev_info configfs_ }; static const struct inode_operations configfs_inode_operations ={ + .new_truncate = 1, .setattr = configfs_setattr, }; @@ -76,9 +77,13 @@ int configfs_setattr(struct dentry * den if (error) return error; - error = inode_setattr(inode, iattr); - if (error) - return error; + if (iattr->ia_valid & ATTR_SIZE) { + error = simple_setsize(inode, iattr->ia_size); + if (error) + return error; + } + + generic_setattr(inode, iattr); if (!sd_iattr) { /* setting attributes for the first time, allocate now */ Index: linux-2.6/fs/sysfs/inode.c =================================================================== --- linux-2.6.orig/fs/sysfs/inode.c +++ linux-2.6/fs/sysfs/inode.c @@ -34,6 +34,7 @@ static struct backing_dev_info sysfs_bac }; static const struct inode_operations sysfs_inode_operations ={ + .new_truncate = 1, .setattr = sysfs_setattr, }; @@ -59,11 +60,7 @@ int sysfs_setattr(struct dentry * dentry if (error) return error; - iattr->ia_valid &= ~ATTR_SIZE; /* ignore size changes */ - - error = inode_setattr(inode, iattr); - if (error) - return error; + generic_setattr(inode, iattr); if (!sd_iattr) { /* setting attributes for the first time, allocate now */