summaryrefslogtreecommitdiffstats
path: root/libglusterfsclient
diff options
context:
space:
mode:
authorShehjar Tikoo <shehjart@gluster.com>2009-07-02 06:20:21 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-07-07 16:24:51 -0700
commitc8ef6e541f4dacd58258b0448046d4fae2c511be (patch)
tree74c77dbc2b1514504302e86e8fdfad6752fa334e /libglusterfsclient
parent41027a22054af821caeb2b47a7b93ff028ecaedf (diff)
libglusterfsclient: Update attr cache on read/write
We werent updating the attr AKA stat cache on read and write on files so every stat on the file before the timeout was returning stale attr from the cache. Yuck! This fixes it. Turns out there is a good aspect of unfs3's notoriety when it comes to doing stat()s for every operation. Signed-off-by: Anand V. Avati <avati@dev.gluster.com>
Diffstat (limited to 'libglusterfsclient')
-rwxr-xr-xlibglusterfsclient/src/libglusterfsclient-internals.h4
-rwxr-xr-xlibglusterfsclient/src/libglusterfsclient.c17
2 files changed, 16 insertions, 5 deletions
diff --git a/libglusterfsclient/src/libglusterfsclient-internals.h b/libglusterfsclient/src/libglusterfsclient-internals.h
index 9b14dcb..951843e 100755
--- a/libglusterfsclient/src/libglusterfsclient-internals.h
+++ b/libglusterfsclient/src/libglusterfsclient-internals.h
@@ -64,10 +64,12 @@ typedef struct {
int32_t size;
} lookup;
}fop;
- fd_t *dirfd; /* Needed here because we need a ref to the dir
+ fd_t *fd; /* Needed here because we need a ref to the dir
fd in the libgf_client_readdir_cbk in order
to process the dirents received, without
having them added to the reply stub.
+ Also used in updating iattr cache. See
+ readv_cbk for eg.
*/
}libgf_client_local_t;
diff --git a/libglusterfsclient/src/libglusterfsclient.c b/libglusterfsclient/src/libglusterfsclient.c
index 7246c91..1cb66ab 100755
--- a/libglusterfsclient/src/libglusterfsclient.c
+++ b/libglusterfsclient/src/libglusterfsclient.c
@@ -3105,7 +3105,7 @@ libgf_client_readv_cbk (call_frame_t *frame,
local->reply_stub = fop_readv_cbk_stub (frame, NULL, op_ret, op_errno,
vector, count, stbuf, iobref);
-
+ libgf_update_iattr_cache (local->fd->inode, LIBGF_UPDATE_STAT, stbuf);
LIBGF_REPLY_NOTIFY (local);
return 0;
}
@@ -3123,6 +3123,9 @@ libgf_client_read (libglusterfs_client_ctx_t *ctx,
int count = 0;
libgf_client_local_t *local = NULL;
+ local = CALLOC (1, sizeof (*local));
+ ERR_ABORT (local);
+ local->fd = fd;
LIBGF_CLIENT_FOP (ctx, stub, readv, local, fd, size, offset);
op_ret = stub->args.readv_cbk.op_ret;
@@ -3220,6 +3223,9 @@ libgf_client_readv (libglusterfs_client_ctx_t *ctx,
size += dst_vector[i].iov_len;
}
+ local = CALLOC (1, sizeof (*local));
+ ERR_ABORT (local);
+ local->fd = fd;
LIBGF_CLIENT_FOP (ctx, stub, readv, local, fd, size, offset);
op_ret = stub->args.readv_cbk.op_ret;
@@ -3369,7 +3375,7 @@ libgf_client_writev_cbk (call_frame_t *frame,
local->reply_stub = fop_writev_cbk_stub (frame, NULL, op_ret, op_errno,
stbuf);
-
+ libgf_update_iattr_cache (local->fd->inode, LIBGF_UPDATE_STAT, stbuf);
LIBGF_REPLY_NOTIFY (local);
return 0;
}
@@ -3387,6 +3393,9 @@ libgf_client_writev (libglusterfs_client_ctx_t *ctx,
struct iobref *iobref = NULL;
iobref = iobref_new ();
+ local = CALLOC (1, sizeof (*local));
+ ERR_ABORT (local);
+ local->fd = fd;
LIBGF_CLIENT_FOP (ctx, stub, writev, local, fd, vector, count, offset,
iobref);
@@ -3587,7 +3596,7 @@ libgf_client_readdir_cbk (call_frame_t *frame,
local->reply_stub = fop_readdir_cbk_stub (frame, NULL, op_ret, op_errno,
NULL);
if (op_ret > 0)
- libgf_dcache_update (frame->root->state, local->dirfd, entries);
+ libgf_dcache_update (frame->root->state, local->fd, entries);
LIBGF_REPLY_NOTIFY (local);
return 0;
}
@@ -3604,7 +3613,7 @@ libgf_client_readdir (libglusterfs_client_ctx_t *ctx, fd_t *fd,
return 1;
local = CALLOC (1, sizeof (*local));
ERR_ABORT (local);
- local->dirfd = fd;
+ local->fd = fd;
LIBGF_CLIENT_FOP (ctx, stub, readdir, local, fd,
LIBGF_READDIR_BLOCK, *offset);