From f2d90013aaa4652dbcc1e6e3d62a0d31ada89d5d Mon Sep 17 00:00:00 2001 From: Mohit Agrawal Date: Thu, 19 Dec 2019 08:32:19 +0530 Subject: Posix: Optimize posix code to improve file creation Problem: Before executing a fop in POSIX xlator it builds an internal path based on GFID.To validate the path it call's (l)stat system call and while .glusterfs is heavily loaded kernel takes time to lookup inode and due to that performance drops Solution: In this patch we followed two ways to improve the performance. 1) Keep open fd specific to first level directory(gfid[0]) in .glusterfs, it would force to kernel keep the inodes from all those files in cache. In case of memory pressure kernel won't uncache first level inodes. We need to open 256 fd's per brick to access the entry faster. 2) Use at based call's to access relative path to reduce path based lookup time. Note: To verify the patch we have executed kernel untar 100 times on 6 different clients after enabling metadata group-cache and some other option.We were getting more than 20 percent improvement in kenel untar after applying the patch. Credits: Xavi Hernandez Change-Id: I1643e6b01ed669b2bb148d02f4e6a8e08da45343 updates: #891 Signed-off-by: Mohit Agrawal --- libglusterfs/src/glusterfs/syscall.h | 9 +++++++++ libglusterfs/src/libglusterfs.sym | 3 +++ libglusterfs/src/syscall.c | 21 +++++++++++++++++++++ 3 files changed, 33 insertions(+) (limited to 'libglusterfs/src') diff --git a/libglusterfs/src/glusterfs/syscall.h b/libglusterfs/src/glusterfs/syscall.h index 6b33c141a5e..91e921aea50 100644 --- a/libglusterfs/src/glusterfs/syscall.h +++ b/libglusterfs/src/glusterfs/syscall.h @@ -95,18 +95,27 @@ sys_mkdirat(int dirfd, const char *pathname, mode_t mode); int sys_unlink(const char *pathname); +int +sys_unlinkat(int dfd, const char *pathname); + int sys_rmdir(const char *pathname); int sys_symlink(const char *oldpath, const char *newpath); +int +sys_symlinkat(const char *oldpath, int dirfd, const char *newpath); + int sys_rename(const char *oldpath, const char *newpath); int sys_link(const char *oldpath, const char *newpath); +int +sys_linkat(int oldfd, const char *oldpath, int newfd, const char *newpath); + int sys_chmod(const char *path, mode_t mode); diff --git a/libglusterfs/src/libglusterfs.sym b/libglusterfs/src/libglusterfs.sym index dc7382ba749..47e0872ca59 100644 --- a/libglusterfs/src/libglusterfs.sym +++ b/libglusterfs/src/libglusterfs.sym @@ -1039,6 +1039,7 @@ sys_futimes sys_lchown sys_lgetxattr sys_link +sys_linkat sys_llistxattr sys_lremovexattr sys_lseek @@ -1062,8 +1063,10 @@ sys_rmdir sys_stat sys_statvfs sys_symlink +sys_symlinkat sys_truncate sys_unlink +sys_unlinkat sys_utimensat sys_write sys_writev diff --git a/libglusterfs/src/syscall.c b/libglusterfs/src/syscall.c index 1d88c8adac1..49f782a837a 100644 --- a/libglusterfs/src/syscall.c +++ b/libglusterfs/src/syscall.c @@ -213,6 +213,15 @@ sys_unlink(const char *pathname) return FS_RET_CHECK0(unlink(pathname), errno); } +int +sys_unlinkat(int dfd, const char *pathname) +{ +#ifdef GF_SOLARIS_HOST_OS + return FS_RET_CHECK0(solaris_unlinkat(dfd, pathname, 0), errno); +#endif + return FS_RET_CHECK0(unlinkat(dfd, pathname, 0), errno); +} + int sys_rmdir(const char *pathname) { @@ -225,6 +234,12 @@ sys_symlink(const char *oldpath, const char *newpath) return FS_RET_CHECK0(symlink(oldpath, newpath), errno); } +int +sys_symlinkat(const char *oldpath, int dirfd, const char *newpath) +{ + return FS_RET_CHECK0(symlinkat(oldpath, dirfd, newpath), errno); +} + int sys_rename(const char *oldpath, const char *newpath) { @@ -252,6 +267,12 @@ sys_link(const char *oldpath, const char *newpath) #endif } +int +sys_linkat(int oldfd, const char *oldpath, int newfd, const char *newpath) +{ + return FS_RET_CHECK0(linkat(oldfd, oldpath, newfd, newpath, 0), errno); +} + int sys_chmod(const char *path, mode_t mode) { -- cgit