diff options
author | Krutika Dhananjay <kdhananj@redhat.com> | 2015-08-10 19:10:21 +0530 |
---|---|---|
committer | Pranith Kumar Karampuri <pkarampu@redhat.com> | 2015-08-19 02:15:04 -0700 |
commit | 470a50b1d5017f015a1f3f3ea65a33902a02ffea (patch) | |
tree | 4627307c0ce2c5d15da3d6655b5d2ead48166dc1 /xlators/features/shard/src | |
parent | a4bbb71e91744ed387606dd4eb5bee55cf86b079 (diff) |
features/shard: Ensure shards are owned by the same owner/group as the original file
Change-Id: Id759af8f3ff5fd8bfa9f8121bab25722709d42b7
BUG: 1251824
Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com>
Reviewed-on: http://review.gluster.org/11874
Tested-by: NetBSD Build System <jenkins@build.gluster.org>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Diffstat (limited to 'xlators/features/shard/src')
-rw-r--r-- | xlators/features/shard/src/shard.c | 73 | ||||
-rw-r--r-- | xlators/features/shard/src/shard.h | 3 |
2 files changed, 45 insertions, 31 deletions
diff --git a/xlators/features/shard/src/shard.c b/xlators/features/shard/src/shard.c index 52b95472ba7..ba1579f1170 100644 --- a/xlators/features/shard/src/shard.c +++ b/xlators/features/shard/src/shard.c @@ -2551,8 +2551,11 @@ shard_common_mknod_cbk (call_frame_t *frame, void *cookie, xlator_t *this, done: call_count = shard_call_count_return (frame); - if (call_count == 0) + if (call_count == 0) { + frame->root->uid = local->uid; + frame->root->gid = local->gid; local->post_mknod_handler (frame, this); + } return 0; } @@ -2581,9 +2584,14 @@ shard_common_resume_mknod (call_frame_t *frame, xlator_t *this, fd = local->fd; shard_idx_iter = local->first_block; last_block = local->last_block; - call_count = local->call_count; + call_count = local->call_count = local->create_count; local->post_mknod_handler = post_mknod_handler; + local->uid = frame->root->uid; + local->gid = frame->root->gid; + frame->root->uid = local->prebuf.ia_uid; + frame->root->gid = local->prebuf.ia_gid; + ret = shard_inode_ctx_get_all (fd->inode, this, &ctx_tmp); if (ret) { gf_log (this->name, GF_LOG_ERROR, "Failed to get inode ctx for" @@ -2697,11 +2705,13 @@ shard_post_resolve_readv_handler (call_frame_t *frame, xlator_t *this) } } - if (local->call_count) + if (local->call_count) { + local->create_count = local->call_count; shard_common_resume_mknod (frame, this, shard_post_mknod_readv_handler); - else + } else { shard_readv_do (frame, this); + } return 0; } @@ -3033,7 +3043,7 @@ next: } int -shard_post_lookup_writev_handler (call_frame_t *frame, xlator_t *this) +shard_post_lookup_shards_writev_handler (call_frame_t *frame, xlator_t *this) { shard_local_t *local = NULL; @@ -3045,21 +3055,13 @@ shard_post_lookup_writev_handler (call_frame_t *frame, xlator_t *this) return 0; } - local->postbuf = local->prebuf; - - /* At this point, calculate the size of the hole if it is going to be - * created as part of this write. - */ - if (local->offset > local->prebuf.ia_size) - local->hole_size = local->offset - local->prebuf.ia_size; - shard_writev_do (frame, this); return 0; } int -shard_post_lookup_shards_writev_handler (call_frame_t *frame, xlator_t *this) +shard_post_mknod_writev_handler (call_frame_t *frame, xlator_t *this) { shard_local_t *local = NULL; @@ -3071,13 +3073,19 @@ shard_post_lookup_shards_writev_handler (call_frame_t *frame, xlator_t *this) return 0; } - shard_lookup_base_file (frame, this, &local->loc, - shard_post_lookup_writev_handler); + if (!local->eexist_count) { + shard_writev_do (frame, this); + } else { + local->call_count = local->eexist_count; + shard_common_lookup_shards (frame, this, local->loc.inode, + shard_post_lookup_shards_writev_handler); + } + return 0; } int -shard_post_mknod_writev_handler (call_frame_t *frame, xlator_t *this) +shard_post_lookup_writev_handler (call_frame_t *frame, xlator_t *this) { shard_local_t *local = NULL; @@ -3089,14 +3097,19 @@ shard_post_mknod_writev_handler (call_frame_t *frame, xlator_t *this) return 0; } - if (!local->eexist_count) { - shard_lookup_base_file (frame, this, &local->loc, - shard_post_lookup_writev_handler); - } else { - local->call_count = local->eexist_count; - shard_common_lookup_shards (frame, this, local->loc.inode, - shard_post_lookup_shards_writev_handler); - } + local->postbuf = local->prebuf; + + /* At this point, calculate the size of the hole if it is going to be + * created as part of this write. + */ + if (local->offset > local->prebuf.ia_size) + local->hole_size = local->offset - local->prebuf.ia_size; + + if (local->create_count) + shard_common_resume_mknod (frame, this, + shard_post_mknod_writev_handler); + else + shard_writev_do (frame, this); return 0; } @@ -3114,12 +3127,10 @@ shard_post_resolve_writev_handler (call_frame_t *frame, xlator_t *this) return 0; } - if (local->call_count) - shard_common_resume_mknod (frame, this, - shard_post_mknod_writev_handler); - else - shard_lookup_base_file (frame, this, &local->loc, - shard_post_lookup_writev_handler); + local->create_count = local->call_count; + + shard_lookup_base_file (frame, this, &local->loc, + shard_post_lookup_writev_handler); return 0; } diff --git a/xlators/features/shard/src/shard.h b/xlators/features/shard/src/shard.h index 2e2b3abd593..61255cd4936 100644 --- a/xlators/features/shard/src/shard.h +++ b/xlators/features/shard/src/shard.h @@ -144,9 +144,12 @@ typedef struct shard_local { int num_blocks; int call_count; int eexist_count; + int create_count; int xflag; int count; uint32_t flags; + uint32_t uid; + uint32_t gid; uint64_t block_size; uint64_t dst_block_size; off_t offset; |