[PATCH 1/2] optimize inode_setattr a little

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Only mark the inode dirty if any field was actually changed.  Currently
this can't happen but it will with the next patch.


Signed-off-by: Christoph Hellwig <hch@xxxxxx>

Index: linux-2.6/fs/attr.c
===================================================================
--- linux-2.6.orig/fs/attr.c	2008-05-20 20:37:46.000000000 +0200
+++ linux-2.6/fs/attr.c	2008-05-20 20:39:05.000000000 +0200
@@ -66,36 +66,50 @@ EXPORT_SYMBOL(inode_change_ok);
 int inode_setattr(struct inode * inode, struct iattr * attr)
 {
 	unsigned int ia_valid = attr->ia_valid;
+	int sync_it = 0;
 
 	if (ia_valid & ATTR_SIZE &&
 	    attr->ia_size != i_size_read(inode)) {
 		int error = vmtruncate(inode, attr->ia_size);
 		if (error)
 			return error;
+		sync_it = 1;
 	}
 
-	if (ia_valid & ATTR_UID)
+	if (ia_valid & ATTR_UID) {
 		inode->i_uid = attr->ia_uid;
-	if (ia_valid & ATTR_GID)
+		sync_it = 1;
+	}
+	if (ia_valid & ATTR_GID) {
 		inode->i_gid = attr->ia_gid;
-	if (ia_valid & ATTR_ATIME)
+		sync_it = 1;
+	}
+	if (ia_valid & ATTR_ATIME) {
 		inode->i_atime = timespec_trunc(attr->ia_atime,
 						inode->i_sb->s_time_gran);
-	if (ia_valid & ATTR_MTIME)
+		sync_it = 1;
+	}
+	if (ia_valid & ATTR_MTIME) {
 		inode->i_mtime = timespec_trunc(attr->ia_mtime,
 						inode->i_sb->s_time_gran);
-	if (ia_valid & ATTR_CTIME)
+		sync_it = 1;
+	}
+	if (ia_valid & ATTR_CTIME) {
 		inode->i_ctime = timespec_trunc(attr->ia_ctime,
 						inode->i_sb->s_time_gran);
+		sync_it = 1;
+	}
 	if (ia_valid & ATTR_MODE) {
 		umode_t mode = attr->ia_mode;
 
 		if (!in_group_p(inode->i_gid) && !capable(CAP_FSETID))
 			mode &= ~S_ISGID;
 		inode->i_mode = mode;
+		sync_it = 1;
 	}
-	mark_inode_dirty(inode);
 
+	if (sync_it)
+		mark_inode_dirty(inode);
 	return 0;
 }
 EXPORT_SYMBOL(inode_setattr);
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux