mirror of
https://github.com/samba-team/samba.git
synced 2025-01-14 19:24:43 +03:00
vfs_glusterfs: In vfs_gluster_sys_acl_get_file/fd, reduce the number of getxattr calls.
Signed-off-by: Poornima G <pgurusid@redhat.com> Reviewed-by: Ira Cooper <ira@samba.org> Reviewed-by: Guenther Deschner <gd@samba.org>
This commit is contained in:
parent
8c56989325
commit
a4fa9ca5a7
@ -1006,6 +1006,8 @@ static int vfs_gluster_set_offline(struct vfs_handle_struct *handle,
|
|||||||
#define GLUSTER_ACL_HEADER_SIZE 4
|
#define GLUSTER_ACL_HEADER_SIZE 4
|
||||||
#define GLUSTER_ACL_ENTRY_SIZE 8
|
#define GLUSTER_ACL_ENTRY_SIZE 8
|
||||||
|
|
||||||
|
#define GLUSTER_ACL_SIZE(n) (GLUSTER_ACL_HEADER_SIZE + (n * GLUSTER_ACL_ENTRY_SIZE))
|
||||||
|
|
||||||
static SMB_ACL_T gluster_to_smb_acl(const char *buf, size_t xattr_size,
|
static SMB_ACL_T gluster_to_smb_acl(const char *buf, size_t xattr_size,
|
||||||
TALLOC_CTX *mem_ctx)
|
TALLOC_CTX *mem_ctx)
|
||||||
{
|
{
|
||||||
@ -1275,7 +1277,7 @@ static SMB_ACL_T vfs_gluster_sys_acl_get_file(struct vfs_handle_struct *handle,
|
|||||||
struct smb_acl_t *result;
|
struct smb_acl_t *result;
|
||||||
char *buf;
|
char *buf;
|
||||||
const char *key;
|
const char *key;
|
||||||
ssize_t ret;
|
ssize_t ret, size = GLUSTER_ACL_SIZE(20);
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case SMB_ACL_TYPE_ACCESS:
|
case SMB_ACL_TYPE_ACCESS:
|
||||||
@ -1289,13 +1291,22 @@ static SMB_ACL_T vfs_gluster_sys_acl_get_file(struct vfs_handle_struct *handle,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = glfs_getxattr(handle->data, path_p, key, 0, 0);
|
buf = alloca(size);
|
||||||
if (ret <= 0) {
|
if (!buf) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = glfs_getxattr(handle->data, path_p, key, buf, size);
|
||||||
|
if (ret == -1 && errno == ERANGE) {
|
||||||
|
ret = glfs_getxattr(handle->data, path_p, key, 0, 0);
|
||||||
|
if (ret > 0) {
|
||||||
buf = alloca(ret);
|
buf = alloca(ret);
|
||||||
|
if (!buf) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
ret = glfs_getxattr(handle->data, path_p, key, buf, ret);
|
ret = glfs_getxattr(handle->data, path_p, key, buf, ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (ret <= 0) {
|
if (ret <= 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -1310,18 +1321,29 @@ static SMB_ACL_T vfs_gluster_sys_acl_get_fd(struct vfs_handle_struct *handle,
|
|||||||
TALLOC_CTX *mem_ctx)
|
TALLOC_CTX *mem_ctx)
|
||||||
{
|
{
|
||||||
struct smb_acl_t *result;
|
struct smb_acl_t *result;
|
||||||
int ret;
|
ssize_t ret, size = GLUSTER_ACL_SIZE(20);
|
||||||
char *buf;
|
char *buf;
|
||||||
glfs_fd_t *glfd;
|
glfs_fd_t *glfd;
|
||||||
|
|
||||||
glfd = *(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp);
|
glfd = *(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp);
|
||||||
ret = glfs_fgetxattr(glfd, "system.posix_acl_access", 0, 0);
|
|
||||||
if (ret <= 0) {
|
buf = alloca(size);
|
||||||
|
if (!buf) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = glfs_fgetxattr(glfd, "system.posix_acl_access", buf, size);
|
||||||
|
if (ret == -1 && errno == ERANGE) {
|
||||||
|
ret = glfs_fgetxattr(glfd, "system.posix_acl_access", 0, 0);
|
||||||
|
if (ret > 0) {
|
||||||
buf = alloca(ret);
|
buf = alloca(ret);
|
||||||
ret = glfs_fgetxattr(glfd, "system.posix_acl_access", buf, ret);
|
if (!buf) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
ret = glfs_fgetxattr(glfd, "system.posix_acl_access",
|
||||||
|
buf, ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (ret <= 0) {
|
if (ret <= 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user