-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid (when possible) calling sys_*getxattr with NULL size #720
Comments
Will send a fix for this. |
https://review.gluster.org/#/c/glusterfs/+/23452/ is an attempt to do that for _posix_xattr_get_set_from_backend() |
The code is simplified to avoid needless copy as well as simplified overall for readability. Such changes are needed elsewhere too (see #720 ) Few other minor changes here and there, nothing functional. Change-Id: Ia1167849f54d9cacbfe32ddd712dc1699760daf5 updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
The code is simplified to avoid needless copy as well as simplified overall for readability. Such changes are needed elsewhere too (see gluster/glusterfs#720 ) Few other minor changes here and there, nothing functional. Change-Id: Ia1167849f54d9cacbfe32ddd712dc1699760daf5 updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
The code is simplified to avoid needless copy as well as simplified overall for readability. Such changes are needed elsewhere too (see #720 ) Few other minor changes here and there, nothing functional. updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com> Change-Id: I14f9dd2c32a8932bfcc80ebe92c9aa77701095ff
The code is simplified to avoid needless copy as well as simplified overall for readability. Such changes are needed elsewhere too (see gluster/glusterfs#720 ) Few other minor changes here and there, nothing functional. updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com> Change-Id: I14f9dd2c32a8932bfcc80ebe92c9aa77701095ff
_get_list_xattr is fixed via https://review.gluster.org/#/c/glusterfs/+/23714/ |
Another location where instead of 2 sys calls we strive to get the xattr in a single call, by guesstimating the required size And avoid (or try to) not to first read the xattr len, then another call to actually fetch. Instead, use a sane size (256 bytes - worth checking if it makes sense or by default use a larger size), and see if we can fetch it. If we fail, we'll read the size and re-fetch. Such changes are needed elsewhere too (see #720 ) Change-Id: I466cea9d8b12fc45f6b37d202b1294ca28cd1fdd updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
@amarts - I hope to complete all of this (or most) for Gluster 8. https://review.gluster.org/#/c/glusterfs/+/23714/ is in the works. |
I'm not going to pursue these for Gluster anymore - patches abandoned . |
Another location where instead of 2 sys calls we strive to get the xattr in a single call, by guesstimating the required size And avoid (or try to) not to first read the xattr len, then another call to actually fetch. Instead, use a sane size (256 bytes - worth checking if it makes sense or by default use a larger size), and see if we can fetch it. If we fail, we'll read the size and re-fetch. Such changes are needed elsewhere too (see gluster/glusterfs#720 ) Change-Id: I466cea9d8b12fc45f6b37d202b1294ca28cd1fdd updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
The code is simplified to avoid needless copy as well as simplified overall for readability. Such changes are needed elsewhere too (see gluster/glusterfs#720 ) Few other minor changes here and there, nothing functional. Change-Id: Ia1167849f54d9cacbfe32ddd712dc1699760daf5 updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
The code is simplified to avoid needless copy as well as simplified overall for readability. Such changes are needed elsewhere too (see gluster/glusterfs#720 ) Few other minor changes here and there, nothing functional. updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com> Change-Id: I14f9dd2c32a8932bfcc80ebe92c9aa77701095ff
Another location where instead of 2 sys calls we strive to get the xattr in a single call, by guesstimating the required size And avoid (or try to) not to first read the xattr len, then another call to actually fetch. Instead, use a sane size (256 bytes - worth checking if it makes sense or by default use a larger size), and see if we can fetch it. If we fail, we'll read the size and re-fetch. Such changes are needed elsewhere too (see gluster/glusterfs#720 ) Change-Id: I466cea9d8b12fc45f6b37d202b1294ca28cd1fdd updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
In several cases in the code [for example, posix_cs_set_state() ], we have this code convention that we do some getxattr without a buffer to get the buffer we need, then we CALLOC (we could MALLOC, btw) the buffer and do another fetch with the size.
In other cases, we are more efficient. We have some buffer, and we either use it, or dynamically realloc if the first getxattr fails. This is better as it removes an xattr in case the value fits the buffer.
Bad example:
Slightly better example: (but still suffers from extra memory copy which can be removed)
The places I found the bad implementation:
The text was updated successfully, but these errors were encountered: