summaryrefslogtreecommitdiffstats
path: root/xlators/mount/fuse/src/fuse-resolve.c
diff options
context:
space:
mode:
authorRaghavendra G <raghavendra@gluster.com>2012-01-18 10:27:32 +0530
committerAnand Avati <avati@redhat.com>2012-03-18 01:54:50 -0700
commitb7f441dd6c21fd25856ed00d84eced0aca06402e (patch)
tree6aee0cc299bc313d59c3ff27636f204823053237 /xlators/mount/fuse/src/fuse-resolve.c
parenta9511a98194fd3b769a6df4ef7c0477c1bf51e17 (diff)
mount/fuse: Inherit direct-io-mode values from fds alreadyrelease-3.1
opened, for a new fd being opened. When an fd is being opened, it inherits direct-io-mode characterstics (either enabled or disabled) from the fds already opened on inode. If none are opened and user has not specified the mode through cmdline options, default mode is used. Signed-off-by: Raghavendra G <raghavendra@gluster.com> Change-Id: I0c9e959100e9130e46bbd16d63eca278260635b4 BUG: 801 Reviewed-on: http://review.gluster.com/56 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Csaba Henk <csaba@redhat.com>
Diffstat (limited to 'xlators/mount/fuse/src/fuse-resolve.c')
-rw-r--r--xlators/mount/fuse/src/fuse-resolve.c43
1 files changed, 30 insertions, 13 deletions
diff --git a/xlators/mount/fuse/src/fuse-resolve.c b/xlators/mount/fuse/src/fuse-resolve.c
index 0aa6accc4..e83a04b7e 100644
--- a/xlators/mount/fuse/src/fuse-resolve.c
+++ b/xlators/mount/fuse/src/fuse-resolve.c
@@ -125,12 +125,13 @@ static int
fuse_resolve_newfd_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, fd_t *fd)
{
- fuse_state_t *state = NULL;
+ fuse_state_t *state = NULL;
fuse_resolve_t *resolve = NULL;
- fd_t *old_fd = NULL;
- fd_t *tmp_fd = NULL;
- uint64_t tmp_fd_ctx = 0;
- int ret = 0;
+ fd_t *old_fd = NULL;
+ fd_t *tmp_fd = NULL;
+ fuse_fd_ctx_t *tmp_fd_ctx = 0;
+ uint64_t val = 0;
+ int ret = 0;
state = frame->root->state;
resolve = state->resolve_now;
@@ -150,15 +151,31 @@ fuse_resolve_newfd_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
fd_bind (fd);
resolve->fd = NULL;
- ret = fd_ctx_del (old_fd, state->this, &tmp_fd_ctx);
- if (!ret) {
- tmp_fd = (fd_t *)(long)tmp_fd_ctx;
- fd_unref (tmp_fd);
+
+ LOCK (&old_fd->lock);
+ {
+ ret = __fd_ctx_get (old_fd, state->this, &val);
+ if (!ret) {
+ tmp_fd_ctx = (fuse_fd_ctx_t *)(unsigned long)val;
+ tmp_fd = tmp_fd_ctx->fd;
+ if (tmp_fd) {
+ fd_unref (tmp_fd);
+ tmp_fd_ctx->fd = NULL;
+ }
+ } else {
+ tmp_fd_ctx = __fuse_fd_ctx_check_n_create (old_fd,
+ state->this);
+ }
+
+ if (tmp_fd_ctx) {
+ tmp_fd_ctx->fd = fd;
+ } else {
+ gf_log ("resolve", GF_LOG_WARNING,
+ "failed to set the fd ctx with resolved fd");
+ }
}
- ret = fd_ctx_set (old_fd, state->this, (uint64_t)(long)fd);
- if (ret)
- gf_log ("resolve", GF_LOG_WARNING,
- "failed to set the fd ctx with resolved fd");
+ UNLOCK (&old_fd->lock);
+
out:
fuse_resolve_all (state);
return 0;