summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2011-07-13 00:37:25 +0000
committerAnand Avati <avati@gluster.com>2011-07-12 23:34:18 -0700
commit7c4ad6d3321cc440590a6132b7dc8d0d0a58ce3b (patch)
tree6ee6b53e9ae46d5bbbe2d4e7a648ce570765ef34 /xlators
parent8b57a5c2fb16f2c85c0f74edbe7b841a6dc4a265 (diff)
storage/posix: set all keys present in 'params' dict while creating an entry
so, there is no need to do a 'setxattr()' after entry creation, which could now fail due to ACL on server side. Signed-off-by: Amar Tumballi <amar@gluster.com> Signed-off-by: Anand Avati <avati@gluster.com> BUG: 3164 (set xattr keys while entry creation) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=3164
Diffstat (limited to 'xlators')
-rw-r--r--xlators/storage/posix/src/posix-helpers.c38
-rw-r--r--xlators/storage/posix/src/posix.c28
-rw-r--r--xlators/storage/posix/src/posix.h8
3 files changed, 68 insertions, 6 deletions
diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c
index 7b130d4b918..5aa09d97769 100644
--- a/xlators/storage/posix/src/posix-helpers.c
+++ b/xlators/storage/posix/src/posix-helpers.c
@@ -394,7 +394,7 @@ out:
int
-posix_set_file_contents (xlator_t *this, char *real_path,
+posix_set_file_contents (xlator_t *this, const char *real_path,
data_pair_t *trav, int flags)
{
char * key = NULL;
@@ -476,7 +476,7 @@ out:
int
-posix_get_file_contents (xlator_t *this, char *real_path,
+posix_get_file_contents (xlator_t *this, const char *real_path,
const char *name, char **contents)
{
char real_filepath[ZR_PATH_MAX] = {0,};
@@ -546,7 +546,7 @@ out:
static int gf_xattr_enotsup_log;
int
-posix_handle_pair (xlator_t *this, char *real_path,
+posix_handle_pair (xlator_t *this, const char *real_path,
data_pair_t *trav, int flags)
{
int sys_ret = -1;
@@ -885,3 +885,35 @@ out:
return ret;
}
+int
+posix_entry_create_xattr_set (xlator_t *this, const char *path,
+ dict_t *dict)
+{
+ data_pair_t *trav = NULL;
+ int ret = -1;
+
+ trav = dict->members_list;
+ while (trav) {
+ if (!strcmp (GFID_XATTR_KEY, trav->key) ||
+ !strcmp ("gfid-req", trav->key) ||
+ !strcmp ("system.posix_acl_default", trav->key) ||
+ !strcmp ("system.posix_acl_access", trav->key) ||
+ ZR_FILE_CONTENT_REQUEST(trav->key)) {
+ trav = trav->next;
+ continue;
+ }
+
+ ret = posix_handle_pair (this, path, trav, XATTR_CREATE);
+ if (ret < 0) {
+ errno = -ret;
+ ret = -1;
+ goto out;
+ }
+ trav = trav->next;
+ }
+
+ ret = 0;
+
+out:
+ return ret;
+}
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
index d2cd79a753c..fd97980072f 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -827,6 +827,13 @@ posix_mknod (call_frame_t *frame, xlator_t *this,
strerror (errno));
}
+ op_ret = posix_entry_create_xattr_set (this, real_path, params);
+ if (op_ret) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "setting xattrs on %s failed (%s)", loc->path,
+ strerror (errno));
+ }
+
op_ret = posix_lstat_with_gfid (this, real_path, &stbuf);
if (op_ret == -1) {
op_errno = errno;
@@ -953,6 +960,13 @@ posix_mkdir (call_frame_t *frame, xlator_t *this,
strerror (errno));
}
+ op_ret = posix_entry_create_xattr_set (this, real_path, params);
+ if (op_ret) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "setting xattrs on %s failed (%s)", loc->path,
+ strerror (errno));
+ }
+
op_ret = posix_lstat_with_gfid (this, real_path, &stbuf);
if (op_ret == -1) {
op_errno = errno;
@@ -1265,6 +1279,13 @@ posix_symlink (call_frame_t *frame, xlator_t *this,
strerror (errno));
}
+ op_ret = posix_entry_create_xattr_set (this, real_path, params);
+ if (op_ret) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "setting xattrs on %s failed (%s)", loc->path,
+ strerror (errno));
+ }
+
op_ret = posix_lstat_with_gfid (this, real_path, &stbuf);
if (op_ret == -1) {
op_errno = errno;
@@ -1718,6 +1739,13 @@ posix_create (call_frame_t *frame, xlator_t *this,
strerror (errno));
}
+ op_ret = posix_entry_create_xattr_set (this, real_path, params);
+ if (op_ret) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "setting xattrs on %s failed (%s)", loc->path,
+ strerror (errno));
+ }
+
op_ret = posix_fstat_with_gfid (this, _fd, &stbuf);
if (op_ret == -1) {
op_errno = errno;
diff --git a/xlators/storage/posix/src/posix.h b/xlators/storage/posix/src/posix.h
index f57bc0d7b68..b49401810a7 100644
--- a/xlators/storage/posix/src/posix.h
+++ b/xlators/storage/posix/src/posix.h
@@ -134,16 +134,18 @@ int posix_fstat_with_gfid (xlator_t *this, int fd, struct iatt *stbuf_p);
int posix_lstat_with_gfid (xlator_t *this, const char *path, struct iatt *buf);
dict_t *posix_lookup_xattr_fill (xlator_t *this, const char *path,
loc_t *loc, dict_t *xattr, struct iatt *buf);
-int posix_handle_pair (xlator_t *this, char *real_path,
+int posix_handle_pair (xlator_t *this, const char *real_path,
data_pair_t *trav, int flags);
int posix_fhandle_pair (xlator_t *this, int fd, data_pair_t *trav, int flags);
void posix_spawn_janitor_thread (xlator_t *this);
-int posix_get_file_contents (xlator_t *this, char *path,
+int posix_get_file_contents (xlator_t *this, const char *path,
const char *name, char **contents);
-int posix_set_file_contents (xlator_t *this, char *path,
+int posix_set_file_contents (xlator_t *this, const char *path,
data_pair_t *trav, int flags);
int posix_acl_xattr_set (xlator_t *this, const char *path, dict_t *xattr_req);
int posix_gfid_heal (xlator_t *this, const char *path, dict_t *xattr_req);
+int posix_entry_create_xattr_set (xlator_t *this, const char *path,
+ dict_t *dict);
#endif /* _POSIX_H */