cluster/dht : Acl fix for distribute directory selfheal
Send acl xattrs, if present in the xattrs returned during lookup, during directory self-heal. Change-Id: I5337bbd3f3963aeed500a8a552e5f6713089b53e BUG: 764787 Signed-off-by: Kaushal M <kaushal@redhat.com> Reviewed-on: http://review.gluster.com/737 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
This commit is contained in:
parent
98b98d6cd7
commit
3184ad0f88
@ -113,6 +113,9 @@
|
||||
#define RB_PUMP_CMD_ABORT "glusterfs.pump.abort"
|
||||
#define RB_PUMP_CMD_STATUS "glusterfs.pump.status"
|
||||
|
||||
#define POSIX_ACL_DEFAULT_XATTR "system.posix_acl_default"
|
||||
#define POSIX_ACL_ACCESS_XATTR "system.posix_acl_access"
|
||||
|
||||
#define GLUSTERFS_RDMA_INLINE_THRESHOLD (2048)
|
||||
#define GLUSTERFS_RDMA_MAX_HEADER_SIZE (228) /* (sizeof (rdma_header_t) \
|
||||
+ RDMA_MAX_SEGMENTS \
|
||||
|
@ -1272,6 +1272,39 @@ err:
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* For directories, check if acl xattrs have been requested (by the acl xlator),
|
||||
* if not, request for them. These xattrs are needed for dht dir self-heal to
|
||||
* perform proper self-healing of dirs
|
||||
*/
|
||||
void
|
||||
dht_check_and_set_acl_xattr_req (inode_t *inode, dict_t *xattr_req)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
GF_ASSERT (inode);
|
||||
GF_ASSERT (xattr_req);
|
||||
|
||||
if (inode->ia_type != IA_IFDIR)
|
||||
return;
|
||||
|
||||
if (!dict_get (xattr_req, POSIX_ACL_ACCESS_XATTR)) {
|
||||
ret = dict_set_int8 (xattr_req, POSIX_ACL_ACCESS_XATTR, 0);
|
||||
if (ret)
|
||||
gf_log (THIS->name, GF_LOG_WARNING,
|
||||
"failed to set key %s",
|
||||
POSIX_ACL_ACCESS_XATTR);
|
||||
}
|
||||
|
||||
if (!dict_get (xattr_req, POSIX_ACL_DEFAULT_XATTR)) {
|
||||
ret = dict_set_int8 (xattr_req, POSIX_ACL_DEFAULT_XATTR, 0);
|
||||
if (ret)
|
||||
gf_log (THIS->name, GF_LOG_WARNING,
|
||||
"failed to set key %s",
|
||||
POSIX_ACL_DEFAULT_XATTR);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int
|
||||
dht_lookup (call_frame_t *frame, xlator_t *this,
|
||||
@ -1395,6 +1428,9 @@ dht_lookup (call_frame_t *frame, xlator_t *this,
|
||||
ret = dict_set_uint32 (local->xattr_req,
|
||||
GLUSTERFS_OPEN_FD_COUNT, 4);
|
||||
|
||||
/* need it for dir self-heal */
|
||||
dht_check_and_set_acl_xattr_req (loc->inode, local->xattr_req);
|
||||
|
||||
for (i = 0; i < call_cnt; i++) {
|
||||
subvol = layout->list[i].xlator;
|
||||
|
||||
@ -1417,6 +1453,9 @@ dht_lookup (call_frame_t *frame, xlator_t *this,
|
||||
ret = dict_set_uint32 (local->xattr_req,
|
||||
GLUSTERFS_OPEN_FD_COUNT, 4);
|
||||
|
||||
/* need it for dir self-heal */
|
||||
dht_check_and_set_acl_xattr_req (loc->inode, local->xattr_req);
|
||||
|
||||
if (!hashed_subvol) {
|
||||
gf_log (this->name, GF_LOG_DEBUG,
|
||||
"no subvolume in layout for path=%s, "
|
||||
|
@ -27,7 +27,6 @@
|
||||
#include "xlator.h"
|
||||
#include "dht-common.h"
|
||||
|
||||
|
||||
#define DHT_SET_LAYOUT_RANGE(layout,i,srt,chunk,cnt,path) do { \
|
||||
layout->list[i].start = srt; \
|
||||
layout->list[i].stop = srt + chunk - 1; \
|
||||
@ -38,7 +37,6 @@
|
||||
layout->list[i].xlator->name, path); \
|
||||
} while (0)
|
||||
|
||||
|
||||
static inline uint32_t
|
||||
dht_find_overlap (int idx, int cnk_idx, uint32_t start, uint32_t stop,
|
||||
uint32_t chunk_size)
|
||||
@ -387,6 +385,46 @@ out:
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
dht_selfheal_dir_mkdir_setacl (dict_t *xattr, dict_t *dict)
|
||||
{
|
||||
data_t *acl_default = NULL;
|
||||
data_t *acl_access = NULL;
|
||||
xlator_t *this = NULL;
|
||||
int ret = -1;
|
||||
|
||||
GF_ASSERT (xattr);
|
||||
GF_ASSERT (dict);
|
||||
|
||||
this = THIS;
|
||||
GF_ASSERT (this);
|
||||
|
||||
acl_default = dict_get (xattr, POSIX_ACL_DEFAULT_XATTR);
|
||||
|
||||
if (!acl_default) {
|
||||
gf_log (this->name, GF_LOG_DEBUG,
|
||||
"ACL_DEFAULT xattr not present");
|
||||
goto cont;
|
||||
}
|
||||
ret = dict_set (dict, POSIX_ACL_DEFAULT_XATTR, acl_default);
|
||||
if (ret)
|
||||
gf_log (this->name, GF_LOG_WARNING,
|
||||
"Could not set ACL_DEFAULT xattr");
|
||||
cont:
|
||||
acl_access = dict_get (xattr, POSIX_ACL_ACCESS_XATTR);
|
||||
if (!acl_access) {
|
||||
gf_log (this->name, GF_LOG_DEBUG,
|
||||
"ACL_ACCESS xattr not present");
|
||||
goto out;
|
||||
}
|
||||
ret = dict_set (dict, POSIX_ACL_ACCESS_XATTR, acl_access);
|
||||
if (ret)
|
||||
gf_log (this->name, GF_LOG_WARNING,
|
||||
"Could not set ACL_ACCESS xattr");
|
||||
|
||||
out:
|
||||
return;
|
||||
}
|
||||
|
||||
int
|
||||
dht_selfheal_dir_mkdir (call_frame_t *frame, loc_t *loc,
|
||||
@ -426,6 +464,9 @@ dht_selfheal_dir_mkdir (call_frame_t *frame, loc_t *loc,
|
||||
/* Send the dictionary from higher layers directly */
|
||||
dict = dict_ref (local->params);
|
||||
}
|
||||
/* Set acls */
|
||||
if (local->xattr && dict)
|
||||
dht_selfheal_dir_mkdir_setacl (local->xattr, dict);
|
||||
|
||||
if (!dict)
|
||||
gf_log (this->name, GF_LOG_WARNING,
|
||||
|
@ -25,11 +25,9 @@
|
||||
|
||||
#include "common-utils.h"
|
||||
#include "posix-acl.h"
|
||||
#include "glusterfs.h"
|
||||
|
||||
#define POSIX_ACL_ACCESS_XATTR "system.posix_acl_access"
|
||||
#define POSIX_ACL_DEFAULT_XATTR "system.posix_acl_default"
|
||||
|
||||
#define POSIX_ACL_VERSION 2
|
||||
#define POSIX_ACL_VERSION 2
|
||||
|
||||
struct posix_acl_xattr_entry {
|
||||
uint16_t tag;
|
||||
|
Loading…
x
Reference in New Issue
Block a user