From 3330c26f199f4a149bf0091259d88534d61f53fa Mon Sep 17 00:00:00 2001 From: Prashanth Pai Date: Thu, 26 May 2016 15:00:13 +0530 Subject: Fix redundant stat in account and container server Multiple stat() calls were made while serving GET requests for container and account. This removes those calls and can be easily verified using strace. There is room for further refactoring of code to simplify it. This will be addressed as a separate change to keep things simple in this patch. Change-Id: Ief457ff869c58519e9dbeb4ef13797185f536673 Signed-off-by: Prashanth Pai Reviewed-on: http://review.gluster.org/14543 Reviewed-by: Thiago da Silva Tested-by: Thiago da Silva --- gluster/swift/common/utils.py | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'gluster/swift/common/utils.py') diff --git a/gluster/swift/common/utils.py b/gluster/swift/common/utils.py index a27aaf0..8f68319 100644 --- a/gluster/swift/common/utils.py +++ b/gluster/swift/common/utils.py @@ -28,9 +28,9 @@ from gluster.swift.common.exceptions import GlusterFileSystemIOError from swift.common.exceptions import DiskFileNoSpace from swift.common.db import utf8encodekeys from gluster.swift.common.fs_utils import do_getctime, do_getmtime, do_stat, \ - do_rmdir, do_log_rl, get_filename_from_fd, do_open, \ - do_isdir, do_getsize, do_getxattr, do_setxattr, do_removexattr, do_read, \ - do_close, do_dup, do_lseek, do_fstat, do_fsync, do_rename + do_rmdir, do_log_rl, get_filename_from_fd, do_open, do_getsize, \ + do_getxattr, do_setxattr, do_removexattr, do_read, do_close, do_dup, \ + do_lseek, do_fstat, do_fsync, do_rename from gluster.swift.common import Glusterfs try: @@ -371,13 +371,12 @@ def get_container_details(cont_path): object_count = 0 obj_list = [] - if do_isdir(cont_path): - for (path, dirs, files) in gf_walk(cont_path): - object_count, bytes_used = update_list(path, cont_path, dirs, - files, object_count, - bytes_used, obj_list) + for (path, dirs, files) in gf_walk(cont_path): + object_count, bytes_used = update_list(path, cont_path, dirs, + files, object_count, + bytes_used, obj_list) - sleep() + sleep() return obj_list, object_count, bytes_used @@ -445,11 +444,10 @@ def get_account_details(acc_path): """ container_list = [] - if os.path.isdir(acc_path): - for entry in gf_listdir(acc_path): - if entry.is_dir() and \ - entry.name not in (TEMP_DIR, ASYNCDIR, TRASHCAN): - container_list.append(entry.name) + for entry in gf_listdir(acc_path): + if entry.is_dir() and \ + entry.name not in (TEMP_DIR, ASYNCDIR, TRASHCAN): + container_list.append(entry.name) return container_list, len(container_list) -- cgit