diff options
author | Amar Tumballi <amar@gluster.com> | 2011-07-13 00:24:04 +0000 |
---|---|---|
committer | Anand Avati <avati@gluster.com> | 2011-07-12 23:16:54 -0700 |
commit | 972c4a3c347c2581de0e9d0fce6d5c1804eaa974 (patch) | |
tree | 07928bb50b1b29acd2376c08ddfab74d4692c941 | |
parent | 446e71501b40a5a8f7b53e3086d32404111da37c (diff) |
storage/posix: set all keys present in 'params' dict while creating an entryv3.2.2qa7
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
-rw-r--r-- | xlators/storage/posix/src/posix.c | 69 |
1 files changed, 67 insertions, 2 deletions
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c index f468e3f56be..3cecfca341f 100644 --- a/xlators/storage/posix/src/posix.c +++ b/xlators/storage/posix/src/posix.c @@ -89,6 +89,10 @@ typedef struct { } posix_xattr_filler_t; int +handle_pair (xlator_t *this, const char *real_path, + data_pair_t *trav, int flags); + +int posix_forget (xlator_t *this, inode_t *inode) { uint64_t tmp_cache = 0; @@ -505,6 +509,39 @@ 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 = handle_pair (this, path, trav, XATTR_CREATE); + if (ret < 0) { + errno = -ret; + ret = -1; + goto out; + } + trav = trav->next; + } + + ret = 0; +out: + return ret; +} + + int32_t posix_lookup (call_frame_t *frame, xlator_t *this, @@ -1241,6 +1278,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; @@ -1513,6 +1557,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; @@ -1825,6 +1876,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; @@ -2278,6 +2336,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; @@ -2956,7 +3021,7 @@ out: static int gf_posix_xattr_enotsup_log; int -set_file_contents (xlator_t *this, char *real_path, +set_file_contents (xlator_t *this, const char *real_path, data_pair_t *trav, int flags) { char * key = NULL; @@ -3037,7 +3102,7 @@ out: } int -handle_pair (xlator_t *this, char *real_path, +handle_pair (xlator_t *this, const char *real_path, data_pair_t *trav, int flags) { int sys_ret = -1; |