From aa1e2fd37ab93b194308f94edd8ab0a342c7830e Mon Sep 17 00:00:00 2001 From: Shehjar Tikoo Date: Mon, 20 Apr 2009 12:31:09 -0700 Subject: libglusterfsclient: Fix stat cache bug The way stat cache gets updated was not consistent across all syscalls. Consequently, I was running into a bug that returned a 0 st_ino. The fix actually resides in the hunk that changes the lines in libgf_client_lookup but similar changes were also required in other users of stat cache. This commit fixes the bug and also cleans up the way stat cache is updated. Signed-off-by: Anand V. Avati --- libglusterfsclient/src/libglusterfsclient.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/libglusterfsclient/src/libglusterfsclient.c b/libglusterfsclient/src/libglusterfsclient.c index 1b444007b8b..449f38d1706 100755 --- a/libglusterfsclient/src/libglusterfsclient.c +++ b/libglusterfsclient/src/libglusterfsclient.c @@ -1178,7 +1178,10 @@ libgf_client_lookup (libglusterfs_client_ctx_t *ctx, inode = stub->args.lookup_cbk.inode; if (!(libgf_get_inode_ctx (inode))) libgf_alloc_inode_ctx (ctx, inode); - libgf_update_iattr_cache (inode, LIBGF_UPDATE_ALL, stbuf); + libgf_update_iattr_cache (inode, LIBGF_UPDATE_ALL, + &stub->args.lookup_cbk.buf); + if (stbuf) + *stbuf = stub->args.lookup_cbk.buf; if (dict) *dict = dict_ref (stub->args.lookup_cbk.dict); @@ -3326,9 +3329,11 @@ libgf_client_stat (libglusterfs_client_ctx_t *ctx, op_ret = stub->args.stat_cbk.op_ret; errno = stub->args.stat_cbk.op_errno; - *stbuf = stub->args.stat_cbk.buf; + if (stbuf) + *stbuf = stub->args.stat_cbk.buf; - libgf_update_iattr_cache (loc->inode, LIBGF_UPDATE_STAT, stbuf); + libgf_update_iattr_cache (loc->inode, LIBGF_UPDATE_STAT, + &stub->args.stat_cbk.buf); call_stub_destroy (stub); out: @@ -3519,9 +3524,11 @@ libgf_client_fstat (libglusterfs_client_ctx_t *ctx, op_ret = stub->args.fstat_cbk.op_ret; errno = stub->args.fstat_cbk.op_errno; - *buf = stub->args.fstat_cbk.buf; + if (buf) + *buf = stub->args.fstat_cbk.buf; - libgf_update_iattr_cache (fd->inode, LIBGF_UPDATE_STAT, buf); + libgf_update_iattr_cache (fd->inode, LIBGF_UPDATE_STAT, + &stub->args.fstat_cbk.buf); call_stub_destroy (stub); out: -- cgit