From 48b027c82322ef8c34c16e3da03a3375de3fe699 Mon Sep 17 00:00:00 2001 From: Shehjar Tikoo Date: Fri, 31 Jul 2009 12:37:40 +0000 Subject: libglusterfsclient: Bind fd on fd creation code paths When an fd_t is fd_create'd, we need to call fd_bind on it to ensure that any fd_lookup on the inode gets us this fd. We're not doing this so translators like write-behind were not able to order path-based requests at all resulting in some fops like stat, which could be issued after a writev, overtaking a previous writev which is still being written-behind. Signed-off-by: Anand V. Avati BUG: 179 (fileop reports miscompares on read tests) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=179 --- libglusterfsclient/src/libglusterfsclient.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'libglusterfsclient/src/libglusterfsclient.c') diff --git a/libglusterfsclient/src/libglusterfsclient.c b/libglusterfsclient/src/libglusterfsclient.c index a680e240f..a9c43dc72 100755 --- a/libglusterfsclient/src/libglusterfsclient.c +++ b/libglusterfsclient/src/libglusterfsclient.c @@ -921,7 +921,7 @@ get_call_frame_for_req (libglusterfs_client_ctx_t *ctx, char d) frame->root->uid = geteuid (); frame->root->gid = getegid (); - frame->root->pid = getpid (); + frame->root->pid = ctx->pid; frame->root->unique = ctx->counter++; return frame; @@ -998,6 +998,7 @@ glusterfs_init (glusterfs_init_params_t *init_ctx, uint32_t fakefsid) ctx->lookup_timeout = init_ctx->lookup_timeout; ctx->stat_timeout = init_ctx->stat_timeout; ctx->fake_fsid = fakefsid; + ctx->pid = getpid (); pthread_mutex_init (&ctx->gf_ctx.lock, NULL); pool = ctx->gf_ctx.pool = CALLOC (1, sizeof (call_pool_t)); @@ -2393,6 +2394,8 @@ libgf_client_open (libglusterfs_client_ctx_t *ctx, op_ret = stub->args.open_cbk.op_ret; errno = stub->args.open_cbk.op_errno; + if (op_ret != -1) + fd_bind (fd); call_stub_destroy (stub); return op_ret; } @@ -2486,6 +2489,8 @@ libgf_client_opendir (libglusterfs_client_ctx_t *ctx, op_ret = stub->args.opendir_cbk.op_ret; errno = stub->args.opendir_cbk.op_errno; + if (op_ret != -1) + fd_bind (fd); call_stub_destroy (stub); out: @@ -2556,7 +2561,7 @@ glusterfs_glh_open (glusterfs_handle_t handle, const char *path, int flags,...) goto out; } - fd = fd_create (loc.inode, 0); + fd = fd_create (loc.inode, ctx->pid); fd->flags = flags; if ((flags & O_CREAT) == O_CREAT) { @@ -5056,7 +5061,7 @@ glusterfs_glh_opendir (glusterfs_handle_t handle, const char *path) goto out; } - dirfd = fd_create (loc.inode, 0); + dirfd = fd_create (loc.inode, ctx->pid); op_ret = libgf_client_opendir (ctx, &loc, dirfd); if (op_ret == -1) { -- cgit