aboutsummaryrefslogtreecommitdiffstats
path: root/fs/inode.c
diff options
context:
space:
mode:
authorAndi Kleen <andi@firstfloor.org>2009-09-18 16:05:47 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2009-09-24 07:47:26 -0400
commitb12536c27043f1c21195e587eb59950428326e22 (patch)
tree6b498fc08174b16b9fa1f44cce5d08d884eec49b /fs/inode.c
parent22fe404218156328a27e66349b1175cd0baa4990 (diff)
vfs: optimization for touch_atime()
Some benchmark testing shows touch_atime to be high up in profile logs for IO intensive workloads. Most likely that's due to the lock in mnt_want_write(). Unfortunately touch_atime first takes the lock, and then does all the other tests that could avoid atime updates (like noatime or relatime). Do it the other way round -- first try to avoid the update and only then if that didn't succeed take the lock. That works because none of the atime avoidance tests rely on locking. This also eliminates a goto. Signed-off-by: Andi Kleen <ak@linux.intel.com> Cc: Christoph Hellwig <hch@infradead.org> Reviewed-by: Valerie Aurora <vaurora@redhat.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Dave Hansen <haveblue@us.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/inode.c')
-rw-r--r--fs/inode.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/fs/inode.c b/fs/inode.c
index fa506d539653..31168fd45bdc 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -1416,31 +1416,31 @@ void touch_atime(struct vfsmount *mnt, struct dentry *dentry)
1416 struct inode *inode = dentry->d_inode; 1416 struct inode *inode = dentry->d_inode;
1417 struct timespec now; 1417 struct timespec now;
1418 1418
1419 if (mnt_want_write(mnt))
1420 return;
1421 if (inode->i_flags & S_NOATIME) 1419 if (inode->i_flags & S_NOATIME)
1422 goto out; 1420 return;
1423 if (IS_NOATIME(inode)) 1421 if (IS_NOATIME(inode))
1424 goto out; 1422 return;
1425 if ((inode->i_sb->s_flags & MS_NODIRATIME) && S_ISDIR(inode->i_mode)) 1423 if ((inode->i_sb->s_flags & MS_NODIRATIME) && S_ISDIR(inode->i_mode))
1426 goto out; 1424 return;
1427 1425
1428 if (mnt->mnt_flags & MNT_NOATIME) 1426 if (mnt->mnt_flags & MNT_NOATIME)
1429 goto out; 1427 return;
1430 if ((mnt->mnt_flags & MNT_NODIRATIME) && S_ISDIR(inode->i_mode)) 1428 if ((mnt->mnt_flags & MNT_NODIRATIME) && S_ISDIR(inode->i_mode))
1431 goto out; 1429 return;
1432 1430
1433 now = current_fs_time(inode->i_sb); 1431 now = current_fs_time(inode->i_sb);
1434 1432
1435 if (!relatime_need_update(mnt, inode, now)) 1433 if (!relatime_need_update(mnt, inode, now))
1436 goto out; 1434 return;
1437 1435
1438 if (timespec_equal(&inode->i_atime, &now)) 1436 if (timespec_equal(&inode->i_atime, &now))
1439 goto out; 1437 return;
1438
1439 if (mnt_want_write(mnt))
1440 return;
1440 1441
1441 inode->i_atime = now; 1442 inode->i_atime = now;
1442 mark_inode_dirty_sync(inode); 1443 mark_inode_dirty_sync(inode);
1443out:
1444 mnt_drop_write(mnt); 1444 mnt_drop_write(mnt);
1445} 1445}
1446EXPORT_SYMBOL(touch_atime); 1446EXPORT_SYMBOL(touch_atime);