xfs
[Top] [All Lists]

[PATCH 1/2] optimize inode_setattr a little

To: viro@xxxxxxxxxxxxxxxxxx
Subject: [PATCH 1/2] optimize inode_setattr a little
From: Christoph Hellwig <hch@xxxxxx>
Date: Wed, 21 May 2008 08:58:32 +0200
Cc: linux-fsdevel@xxxxxxxxxxxxxxx, xfs@xxxxxxxxxxx, Artem.Bityutskiy@xxxxxxxxx
Sender: xfs-bounce@xxxxxxxxxxx
User-agent: Mutt/1.3.28i
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);


<Prev in Thread] Current Thread [Next in Thread>
  • [PATCH 1/2] optimize inode_setattr a little, Christoph Hellwig <=