Bug 865858

Summary: Potentially unnecessary file opens/closes performed around xattr read/writes
Product: [Community] Gluster-Swift Reporter: Peter Portante <pportant>
Component: utilsAssignee: Michael Adam <madam>
Status: MODIFIED --- QA Contact:
Severity: low Docs Contact:
Priority: low    
Version: 1.8.0CC: bugs, madam, perfbz, pportant, sankarshan
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Bug Depends On:    
Bug Blocks: 903396, 978061    
Description Flags
Initial patch to remove the use of deprecated pyxattr methods.
Actual fix to remove extra system calls. none

Description Peter Portante 2012-10-12 12:36:18 EDT
Description of problem:

  The Gluster/Swift plugin code provides wrappers for get/set/removexattr
  system calls which perform file open/close systems calls. The open/close
  sequence appears to be unnecessary.

Version-Release number of selected component (if applicable):


Actual results:

  Files are first opened, xattr key read/written/removed, then closed for
  every metadata key stored (could have multiple keys stored, see

Expected results:

  No open or close system call is made around xattr operations.
Comment 1 Peter Portante 2012-10-12 14:34:07 EDT
I created a permanent pastebin link with the output of an strace from a GET on an object.

Lines 222 - 240 are annotated to show where a read_metadata() calls starts and ends, and what do_getxattr() does for a file. Notice that 13 system calls are made. The two calls to fgetxattr in a row are the result of the pyxattr modules' behavior to first find out the size of the xattr value so that it can allocate memory for it and then fetch the full contents of it.

We should be able to remove the extra stat calls as well.
Comment 2 Peter Portante 2012-10-12 14:51:18 EDT
Probably would be helpful to actually include the link to the pastebin ...

Comment 3 Peter Portante 2012-10-12 15:10:11 EDT
Here are the results of the same operation but with a patch applied to remove the extra system calls (from 13 down to 3).

Comment 4 Peter Portante 2012-10-12 15:11:21 EDT
Created attachment 626189 [details]
Initial patch to remove the use of deprecated pyxattr methods.
Comment 5 Peter Portante 2012-10-12 15:12:00 EDT
Created attachment 626190 [details]
Actual fix to remove extra system calls.
Comment 6 Vijay Bellur 2012-10-13 13:40:51 EDT
CHANGE: http://review.gluster.org/4077 (Refactor to use pyxattr's get/set/remove methods) merged in master by Anand Avati (avati@redhat.com)
Comment 7 Vijay Bellur 2012-10-13 13:45:00 EDT
CHANGE: http://review.gluster.org/4078 (Fix BZ 865858: remove unnecessary system calls around xattr ops) merged in master by Anand Avati (avati@redhat.com)