linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] optimize inode_setattr a little
@ 2008-05-21  6:58 Christoph Hellwig
  0 siblings, 0 replies; only message in thread
From: Christoph Hellwig @ 2008-05-21  6:58 UTC (permalink / raw)
  To: viro; +Cc: linux-fsdevel, xfs, Artem.Bityutskiy

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@lst.de>

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);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-05-21  6:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-21  6:58 [PATCH 1/2] optimize inode_setattr a little Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).