public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: viro@ZenIV.linux.org.uk
Cc: linux-fsdevel@vger.kernel.org, xfs@oss.sgi.com,
	Artem.Bityutskiy@nokia.com
Subject: [PATCH 1/2] optimize inode_setattr a little
Date: Wed, 21 May 2008 08:58:32 +0200	[thread overview]
Message-ID: <20080521065832.GA27545@lst.de> (raw)

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

                 reply	other threads:[~2008-05-21  6:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080521065832.GA27545@lst.de \
    --to=hch@lst.de \
    --cc=Artem.Bityutskiy@nokia.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=viro@ZenIV.linux.org.uk \
    --cc=xfs@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox