[Gluster-devel] Suggestion to optimize posix_getxattr call

Amar Tumballi atumball at redhat.com
Mon May 15 11:33:39 UTC 2017

On Mon, May 15, 2017 at 2:56 PM, Mohit Agrawal <moagrawa at redhat.com> wrote:

> Hi,
>   I was just checking of posix_getxattr code to debug of my one problem.I
> have found scope of improvement in
>   this function to execute system call in better way.As of now
> function(posix_getxattr) is calling system
>   calls (sys_lgetxattr) two times to get the value of xattr or in case of
> list of xattr it calls multiple times
>  1) In first time it get the buffer size required to store the value.
>      call "size = sys_lgetxattr (real_path, key, NULL, 0);"
>  2) In second time it calls the sys_lgetxattr with buffer after allocate
> the buffer size
>      sys_lgetxattr (real_path, key, value, size);
>   In the same way function is calling for listxattr also.I think we can
> optimise it as like below
>   declare buffer buf[8192](size can be double to this also)
>   1) Call size = sys_lgetxattr (real_path,key,buf,8192)
>   2) if size == -1 and errono == ERANGE then we need to call systemcalls
> in old way like above otherwise
>      we don't need to do anything.
>   In the case of failure we need to call systemcall 3 times while buffer
> is more than our declared buffer
>   size otherwise in most of the cases we need to call it only once.

Please add a counter for the number of times the failure happens with
ERANGE, and see if we can log offender keys. Helps to adjust the size later.


    Please share your input on this, appreciate your input.
> Regards
> Mohit Agrawal
> _______________________________________________
> Gluster-devel mailing list
> Gluster-devel at gluster.org
> http://lists.gluster.org/mailman/listinfo/gluster-devel

Amar Tumballi (amarts)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gluster.org/pipermail/gluster-devel/attachments/20170515/3c3b94f1/attachment.html>

More information about the Gluster-devel mailing list