From 972c4a3c347c2581de0e9d0fce6d5c1804eaa974 Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Wed, 13 Jul 2011 00:24:04 +0000 Subject: 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 Signed-off-by: Anand Avati BUG: 3164 (set xattr keys while entry creation) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=3164 --- xlators/storage/posix/src/posix.c | 69 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 67 insertions(+), 2 deletions(-) (limited to 'xlators') 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 @@ -88,6 +88,10 @@ typedef struct { loc_t *loc; } 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) { @@ -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; -- cgit